Kristoffer Hundvin opened merge request !695: OSLO-1950 NIPT - Matching of files to the correct bacth at GenomeDx / labautomation / sapio-webhooks

Kristoffer Hundvin
2026-04-01T12:39:40Z

https://sapio-sciences.atlassian.net/browse/OSLO-1950

Refactor NIPT file handling: folder-based batch identification and attachment upsert

Batch ID is now extracted from the SDMS source folder path (.../{batchname}/) instead of filename regex. The NIPT results folder is configurable via two new fields on ClientConfigurations: NIPTResultFolder and NIPTSampleSheetFolder.

File type detection uses substring matching on the filename (e.g. "batch_initiation_report" in name) instead of regex with capture groups. All RE_BATCH_* constants removed from Constants.

Re-uploaded files now replace the existing attachment on the batch instead of creating duplicates, via NIPTUtils.replace_or_add_nipt_batch_attachment(). Record-level data (QC results, reagents, instruments, samples) was already upserted by key and is unaffected.

NIPTInstrumentFileHandler split into NIPTProcessLogHandler (operator + instrument from process log) and NIPTQCSequencingReportHandler.check_instruments() (instrument from sequencing report). The contains_hamilton flag is removed.

Files changed

nipt_utils.py — added get_nipt_results_folder, get_nipt_sample_sheet_folder, get_batch_id_from_path, replace_or_add_nipt_batch_attachment

sdms_file_handler.py — NIPT routing via folder path check and route_nipt_file()

nipt_file_handlers.py — all handlers use attachment upsert, added NIPTProcessLogHandler, removed NIPTInstrumentFileHandler

check_samples_for_nipt.py — substring matching, separate methods for process log and sequencing report checks

constants.py — removed NIPT batch regex constants

generate_nipt_report.py — fixed bug that blocked report generation