Closed ebrahimebrahim closed 1 year ago
On the EHR side, our data tables have a column called ID
. This goes into the local fhir server server (via this and this) as a FHIR business identifier for the Patient resource.
On the imaging side, the anonymized CXR data are in a folder hierarchy like this:
filestore_annon/
├── 1
│ └── anon
│ ├── 102_0.dcm
│ ├── 12_0.dcm
│ ├── 14_0.dcm
│ ├── 15_0.dcm
│ ├── 17_0.dcm
│ ├── 18_0.dcm
...
There are many folders like the one named 1
shown here, one for each patient. That top level folder name like 1
is what corresponds to the ID
column from the data table.
The folder name is not a good way to communicate patient ID to LungAIR web app, because really LungAIR ought to get everything via the DICOMWeb protocol. The DICOM headers in the individual dcm
files do have a patient ID element (tag (0010, 0020)) but it is just a garbled (anonymized) version of the original hospital medical record numbers and no longer corresponds to anything.
I think that it makes sense for the link to ultimately be (0010, 0020) from DICOM and a FHIR Patient identifier from EHR, with some identifier system that perhaps ought to be configurable by the user of LungAIR web app.
So in order to use our own imaging data here, I think that before uploading our imaging data to the local orthanc server we should go through each dcm file and replace the value in the patient id tag (0010, 0020) by the top level folder name for that patient. Here is a python snippet that does that:
from pathlib import Path
import pydicom
cxr_dir = Path("/path/to/filestore_annon/")
for dcm_path in cxr_dir.glob('*'):
patient_id = dcm_path.stem
for dcm_file in dcm_path.glob('*/*.dcm'):
ds = pydicom.dcmread(dcm_file)
ds.PatientID = patient_id
ds.save_as(dcm_file)
To close this issue here is the plan:
.env
configurable identifier system string so that the application can extract the patient ID from the patient fhir object
Make the app understand the link between our imaging and our EHR data. Our data tables have a patient ID column that links the entries to our images. In the app, if we are using data and images from our research group, we should be able to select a patient and have the app both load the EHR data for that patient and the images for that patient.
This relies on #9 being completed so that the app has access to EHR data that contains references to image data.