Skip to content

Commit

Permalink
feat: add Human Performer's Name for UPS model
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinlinlee committed Nov 24, 2023
1 parent 4cb8ecd commit 2810f96
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
7 changes: 6 additions & 1 deletion models/sql/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,15 @@ async function init() {
});
WorkItemModel.belongsToMany(DicomCodeModel, {
through: `rel_${dictionary.tag["00404018"]}`,
sourceKey: "id",
sourceKey: "upsInstanceUID",
foreignKey: "upsInstanceUID",
as: dictionary.tag["00404018"]
});
WorkItemModel.belongsToMany(PersonNameModel, {
through: "rel_human_performer_s_name",
sourceKey: "upsInstanceUID",
as: dictionary.tag["00404037"]
});

//TODO: 設計完畢後要將 force 刪除
await sequelizeInstance.sync({
Expand Down
7 changes: 2 additions & 5 deletions models/sql/models/workitems.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class WorkItemModel extends Model {
const WorkItemSchema = {
upsInstanceUID: {
type: DataTypes.STRING,
allowNull: false
allowNull: false,
unique: true
},
patientID: {
type: DataTypes.STRING,
Expand Down Expand Up @@ -95,10 +96,6 @@ const WorkItemSchema = {
// DICOM Code
type: DataTypes.INTEGER
},
"x00404037": {
// Person Name
type: DataTypes.INTEGER
},
"x00404036": {
type: vrTypeMapping.LO
},
Expand Down
18 changes: 13 additions & 5 deletions models/sql/po/upsWorkItem.po.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ class UpsWorkItemPersistentObject {
this.x00404026 = dicomJsonObj.getValue("00404026");
this.x00404027 = dicomJsonObj.getValue("00404027");
this.x00404005 = dicomJsonObj.getValue("00404005");
this.x00404009 = dicomJsonObj.getValue("00404009");
this.x00404037 = dicomJsonObj.getValue("00404037");
this.x00404036 = dicomJsonObj.getValue("00404036");
let scheduledHumanPerformerSequence = new BaseDicomJson(dicomJsonObj.getValue("00404034"));
this.x00404009 = scheduledHumanPerformerSequence.getValue("00404009");
this.x00404037 = scheduledHumanPerformerSequence.getValue("00404037");
this.x00404036 = scheduledHumanPerformerSequence.getValue("00404036");
this.x00404011 = dicomJsonObj.getValue("00404011");
this.x00400418 = dicomJsonObj.getValue("00400418");
this.x00380010 = dicomJsonObj.getValue("00380010");
Expand Down Expand Up @@ -62,7 +63,7 @@ class UpsWorkItemPersistentObject {
x00404010: vrValueTransform.DT(this.x00404010),
x00741204: this.x00741204,
x00741202: this.x00741202,
x00404009: this.x00404009,
x00404036: this.x00404036,
x00404005: vrValueTransform.DT(this.x00404005),
x00404011: vrValueTransform.DT(this.x00404011),
x00380010: this.x00380010,
Expand All @@ -83,6 +84,7 @@ class UpsWorkItemPersistentObject {
await this.setGeneralCode(upsWorkItem, dictionary.keyword.HumanPerformerCodeSequence);
await this.setGeneralCode(upsWorkItem, dictionary.keyword.ScheduledWorkitemCodeSequence);
await this.setGeneralCode(upsWorkItem, dictionary.keyword.InstitutionCodeSequence);
await this.setHumanPerformerName(upsWorkItem);


if (created) {
Expand All @@ -98,7 +100,6 @@ class UpsWorkItemPersistentObject {
return upsWorkItem;
}


async setGeneralCode(item, tag) {
if (this[`x${tag}`]) {
let code = await DicomCodeModel.create({
Expand All @@ -111,6 +112,13 @@ class UpsWorkItemPersistentObject {
await item[`set${keyword}`](code);
}
}

async setHumanPerformerName(upsWorkItem) {
if (this.x00404037) {
let nameOfHumanPerformer = await PersonNameModel.createPersonName(this.x00404037);
await upsWorkItem[`set${dictionary.tag["00404037"]}`](nameOfHumanPerformer);
}
}
}

module.exports.UpsWorkItemPersistentObject = UpsWorkItemPersistentObject;

0 comments on commit 2810f96

Please sign in to comment.