Skip to content

Commit

Permalink
fix: study level of exist imagingStudy not update
Browse files Browse the repository at this point in the history
- Claim exists imagingStudy document,
then merge with local converted imagingStudy
  • Loading branch information
Chinlinlee committed Nov 18, 2022
1 parent 7532628 commit 0cebc85
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions models/FHIR/DICOM/DICOMToFHIR.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,13 @@ class DICOMFHIRConverter {
}

/**
* POST the imagingStudy resource to FHIR server
* Create the imagingStudy resource on FHIR server
*/
async createImagingStudy() {
try {
fhirLogger.info(
`[FHIR] [ImagingStudy not exists, identifier: ${this.dicomFHIR.imagingStudy.identifier[0].value}, create it]`
);
let postUrl = urlJoin(`/ImagingStudy`, this.fhir.baseUrl);
let { data } = await axios.post(
postUrl,
Expand All @@ -137,6 +140,7 @@ class DICOMFHIRConverter {
fhirLogger.info(
`[FHIR] [ImagingStudy exists, identifier: ${identifier.value}, update it]`
);
this.updateExistStudy(existImagingStudy);
this.updateExistSeries(existImagingStudy);
let putUrl = urlJoin(
`/ImagingStudy/${existImagingStudy.id}`,
Expand All @@ -154,6 +158,14 @@ class DICOMFHIRConverter {
}
}

updateExistStudy(existImagingStudy) {
let cloneImagingStudy = _.cloneDeep(this.dicomFHIR.imagingStudy);
delete cloneImagingStudy.series;
let id = _.cloneDeep(existImagingStudy.id);
existImagingStudy = _.merge(existImagingStudy, cloneImagingStudy);
existImagingStudy.id = id;
}

updateExistSeries(existImagingStudy) {
let seriesUID = this.dicomFHIR.imagingStudy.series[0].uid;
let existSeriesIndex = existImagingStudy.series.findIndex(
Expand All @@ -165,7 +177,7 @@ class DICOMFHIRConverter {
this.dicomFHIR.imagingStudy.series[0]
);
delete seriesClone.instance;
existSeries = {
existImagingStudy.series[existSeriesIndex] = {
...existSeries,
...seriesClone
};
Expand Down Expand Up @@ -194,7 +206,7 @@ class DICOMFHIRConverter {
);
if (existInstanceIndex !== -1) {
let existInstance = existSeries.instance[existInstanceIndex];
existInstance = {
existSeries.instance[existInstanceIndex] = {
...existInstance,
...series.instance[0]
};
Expand Down

0 comments on commit 0cebc85

Please sign in to comment.