Skip to content

Commit

Permalink
refactor: wrap updateStatus for mwl work item instance
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinlinlee committed Jan 19, 2024
1 parent 094e8a3 commit b519dd3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ class ChangeMwlItemStatusService {
throw new DicomWebServiceError(DicomWebStatusCodes.NoSuchObjectInstance, "No such object instance", 404);
}

_.set(mwlItem, `${dictionary.keyword.ScheduledProcedureStepSequence}.Value.0.${dictionary.keyword.ScheduledProcedureStepStatus}.Value.0`, status);
await mwlItem.save();
await mwlItem.updateStatus(status);

return mwlItem.toGeneralDicomJson();
}
Expand Down
8 changes: 8 additions & 0 deletions models/mongodb/models/mwlitems.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ let mwlItemSchema = new mongoose.Schema(
getAttributes: async function () {
let jsonStr = JSON.stringify(this.toDicomJson());
return await Common.getAttributesFromJsonString(jsonStr);
},
/**
*
* @param {"SCHEDULED" | "ARRIVED" | "READY" | "STARTED" | "DEPARTED" | "CANCELED" | "DISCONTINUED" | "COMPLETED"} status
*/
updateStatus: async function (status) {
this.$set(`${dictionary.keyword.ScheduledProcedureStepSequence}.Value.0.${dictionary.keyword.ScheduledProcedureStepStatus}.Value.0`, status);
await this.save();
}
}
}
Expand Down

0 comments on commit b519dd3

Please sign in to comment.