From ea0c7b2ba87bd843deea3c186d02b4f01a976d32 Mon Sep 17 00:00:00 2001 From: vsoch Date: Fri, 16 Jun 2017 18:46:21 -0400 Subject: [PATCH] updating api to use deid --- README.md | 7 ++++++- sendit/apps/main/tasks.py | 15 +++++++++++++-- sendit/settings/config.py | 5 +++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0fb316a..50078a3 100644 --- a/README.md +++ b/README.md @@ -64,9 +64,14 @@ DEIDENTIFY_RESTFUL=True # The default study to use SOM_STUDY="test" + +# PatientID and SOPInstanceUID: +# These are default for deid, but we can change that here +ENTITY_ID="PatientID" +ITEM_ID="SOPInstanceUID" ``` -If `DEIDENTIFY_RESTFUL` is False, we skip this task, and the batch is sent to the next task (or tasks) to send to different storage. If True, the batch is first put in the queue to be de-identified, and then upon receival of the identifiers, the batch is put into the same queues to be sent to storage. The `SOM_STUDY` is part of the Stanford DASHER API to specify a study, and the default should be set before you start the application. If the study needs to vary between calls, please [post an issue](https://www.github.com/pydicom/sendit) and it can be added to be done at runtime. These functions can be modified to use different endpoints, or do different replacements in the data. For more details about the deidentify functions, see [docs/deidentify.md](docs/deidentify.md) +Note that the fields for `ENTITY_ID` and `ITEM_ID` are set to the default of [deid](https://pydicom.github.io/deid), but I've added them here in case it ever needs to be changed. If `DEIDENTIFY_RESTFUL` is False, we skip this task, and the batch is sent to the next task (or tasks) to send to different storage. If True, the batch is first put in the queue to be de-identified, and then upon receival of the identifiers, the batch is put into the same queues to be sent to storage. The `SOM_STUDY` is part of the Stanford DASHER API to specify a study, and the default should be set before you start the application. If the study needs to vary between calls, please [post an issue](https://www.github.com/pydicom/sendit) and it can be added to be done at runtime. These functions can be modified to use different endpoints, or do different replacements in the data. For more details about the deidentify functions, see [docs/deidentify.md](docs/deidentify.md) The next set of variables are specific to [storage](docs/storage.md), which is the final step in the pipeline. diff --git a/sendit/apps/main/tasks.py b/sendit/apps/main/tasks.py index c927b23..6cff981 100644 --- a/sendit/apps/main/tasks.py +++ b/sendit/apps/main/tasks.py @@ -169,8 +169,11 @@ def get_identifiers(bid,study=None): # Returns dictionary with {"identifiers": [ E1,E2 ]} ids = get_ids(dicom_files=dicom_files) - + bot.debug("som.client making request to deidentify batch %s" %(bid)) + #:param save_records: if True, will use mrn endpoint and and save data. + # if False, will use uid endpoint and not save data. + # Right now save_records is set to False, not sure if it should be result = cli.deidentify(ids=ids,study=study) # should return a list batch_ids = BatchIdentifiers.objects.create(batch=batch, @@ -199,11 +202,19 @@ def replace_identifiers(bid): # replace ids to update the dicom_files (same paths) dicom_files = batch.get_image_paths() + + # We are going to overwrite, they have same base + output_folder = os.path.dirname(dicom_files[0]) + updated_files = replace_ids(dicom_files=dicom_files, - response=batch_ids.response) + response=batch_ids.response, + overwrite=True, + output_folder=output_folder) + change_status(batch,"DONEPROCESSING") batch.change_images_status('DONEPROCESSING') + except: bot.error("In replace_identifiers: Batch %s or identifiers does not exist." %(bid)) return None diff --git a/sendit/settings/config.py b/sendit/settings/config.py index 00f6bbd..9a41150 100644 --- a/sendit/settings/config.py +++ b/sendit/settings/config.py @@ -10,6 +10,11 @@ # The default study to use SOM_STUDY="test" +# PatientID and SOPInstanceUID: +# These are default for deid, but we can change that here +ENTITY_ID="PatientID" +ITEM_ID="SOPInstanceUID" + ##################################################### # STORAGE #####################################################