Skip to content

Commit

Permalink
feat: series create person names when creation
Browse files Browse the repository at this point in the history
- create Operators' Name
- create Performing Physician's Name
  • Loading branch information
Chinlinlee committed Aug 4, 2023
1 parent b454036 commit e567951
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion models/sql/po/series.po.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SeriesPersistentObject {
this.x00200011 = _.get(dicomJson, "00200011.Value.0", "");
this.x00400244 = _.get(dicomJson, "00400244.Value.0", undefined);
this.x00400245 = _.get(dicomJson, "00400245.Value.0", "");
this.x00400275 = _.get(dicomJson, "00400275.Value", "");
this.x00400275 = _.get(dicomJson, "00400275.Value.0", "");
this.x00080031 = _.get(dicomJson, "00080031.Value.0", "");
}

Expand All @@ -48,6 +48,35 @@ class SeriesPersistentObject {
return undefined;
}

async createPersonNames(field) {
let personNames = [];
if (this[field]) {
for (let personName of this[field]) {
let personNameSequelize = await PersonNameModel.create({
alphabetic: _.get(personName, "Alphabetic", undefined),
ideographic: _.get(personName, "Ideographic", undefined),
phonetic: _.get(personName, "Phonetic", undefined)
});
personNames.push(personNameSequelize);
}
}
return personNames;
}

async addPerformingPhysicianNames(series) {
let performingPhysicianNames = await this.createPersonNames("x00081050");
for (let performingPhysicianName of performingPhysicianNames) {
await series.addPerformingPhysicianName(performingPhysicianName);
}
}

async addOperatorsNames(series) {
let operationsNames = await this.createPersonNames("x00081070");
for (let operationsName of operationsNames) {
await series.addOperatorsName(operationsName);
}
}

async createSeries() {
let [series, created] = await SeriesModel.findOrCreate({
where: {
Expand Down Expand Up @@ -76,6 +105,12 @@ class SeriesPersistentObject {
}
});

if (created) {
await this.addPerformingPhysicianNames(series);
await this.addOperatorsNames(series);
await series.save();
}

return series;
}

Expand Down

0 comments on commit e567951

Please sign in to comment.