Skip to content

Commit

Permalink
Merge pull request #113 from Emory-HITI/dev
Browse files Browse the repository at this point in the history
Query by EMPI
  • Loading branch information
pradeeban authored Mar 19, 2021
2 parents 7186745 + 97a1e47 commit 9fcc433
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
19 changes: 19 additions & 0 deletions modules/cold-extraction/ColdDataRetriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
24 changes: 10 additions & 14 deletions modules/cold-extraction/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,43 +45,39 @@ 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.
[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.
Expand All @@ -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.

Expand Down

0 comments on commit 9fcc433

Please sign in to comment.