diff --git a/modules/cold-extraction/ColdDataRetriever.py b/modules/cold-extraction/ColdDataRetriever.py index 3f0c6b0..24c863c 100644 --- a/modules/cold-extraction/ColdDataRetriever.py +++ b/modules/cold-extraction/ColdDataRetriever.py @@ -138,6 +138,9 @@ def initialize(): date_str = dt_stamp.strftime('%Y%m%d') dates.append(date_str) length = len(patients) + elif (extraction_type == 'empi'): + patients.append(row[patient_index]) + length = len(patients) elif (extraction_type == 'accession'): accessions.append(row[accession_index]) length = len(accessions) @@ -177,6 +180,22 @@ def retrieve(): subprocess.call("{0}/movescu -c {1} -b {2} -M PatientRoot -m PatientID={3} -m AccessionNumber={4} --dest {5}".format(DCM4CHE_BIN, SRC_AET, QUERY_AET, PatientID, Accession, DEST_AET), shell=True) extracted_ones.append(temp_id) + # For the cases that have the EMPI. + elif (extraction_type == 'empi'): + # Create our Identifier (query) dataset + for pid in range(0, len(patients)): + PatientID = patients[pid] + if NIGHTLY_ONLY: + if (datetime.datetime.now().hour >= END_HOUR and datetime.datetime.now().hour < START_HOUR): + # log once while sleeping + logging.info("Nightly mode. Niffler schedules the extraction to resume at start hour {0} and start within 30 minutes after that. It will then pause at the end hour {1}".format(START_HOUR, END_HOUR)) + while (datetime.datetime.now().hour >= END_HOUR and datetime.datetime.now().hour < START_HOUR): + # sleep for 5 minutes + time.sleep(300) + if ((not resume) or (resume and (PatientID not in extracted_ones))): + subprocess.call("{0}/movescu -c {1} -b {2} -M PatientRoot -m PatientID={3} --dest {4}".format(DCM4CHE_BIN, SRC_AET, QUERY_AET, PatientID, DEST_AET), shell=True) + extracted_ones.append(PatientID) + # For the cases that does not have the typical EMPI and Accession values together. elif (extraction_type == 'empi_date' or extraction_type == 'accession'): # Create our Identifier (query) dataset diff --git a/modules/cold-extraction/README.md b/modules/cold-extraction/README.md index e296927..45678b9 100644 --- a/modules/cold-extraction/README.md +++ b/modules/cold-extraction/README.md @@ -45,28 +45,20 @@ First, place the csv file adhering to the correct formats in a folder (by defaul * Please include a header for the csv, such as "EMPI,Accession", as otherwise the first line will be ignored. -* Usual fields that Niffler supports by default: AccessionNumber, AccessionNumber and EMPI, EMPI and a date (indicate whether StudyDate or AcquisitionDate). +* Usual fields that Niffler supports by default: EMPI, AccessionNumber, AccessionNumber and EMPI, EMPI and a date (indicate whether StudyDate or AcquisitionDate). The format examples: - +``` [1] - EMPI,Accession - AAAAA,BBBBBYYBBBBB - AAAAA,BBBBBYYBBBBB - AAAAA,BBBBBYYBBBBB [2] - EMPI, Study Date - AAAAA,20180723 - AAAAA,20180724 - AAAAA,20180725 Make sure the accession's year is in the YY format. @@ -74,14 +66,18 @@ Make sure the accession's year is in the YY format. [3] Accession - BBBBBYYBBBBB - BBBBBYYBBBBB - BBBBBYYBBBBB +[4] +EMPI +AAAAA +AAAAA +AAAAA +``` + ## Configuring Extraction Profile with config.json. Find the config.json file in the folder and modify accordingly. @@ -96,7 +92,7 @@ config.json entries are to be set *for each* Niffler on-demand DICOM extractions * *CsvFile*: Enter the correct csv file name with a relative path to the current folder or a full path. The default value given assumes the CSV file to be in a "csv" folder in the current folder. -* *ExtractionType*: Currently supported options, empi_accession (extractions based on EMPI and AccessionNumber), accession (extractions based solely on AccessionNumber), empi_date (extractions based on EMPI and a date such as StudyDate or AcquisitionDate). +* *ExtractionType*: Currently supported options, empi (extractions based on EMPI), empi_accession (extractions based on EMPI and AccessionNumber), accession (extractions based solely on AccessionNumber), empi_date (extractions based on EMPI and a date such as StudyDate or AcquisitionDate). * *AccessionIndex*: Set the CSV column index of AccessionNumber for extractions with Accessions (with or without EMPI provided). Entry count starts with 0. For extractions other than types of accession and empi_accession, leave this entry unmodified.