Skip to content

Commit

Permalink
UI Navigation -> UWL: Add new workitems #2768, UI Navigation -> UWL: …
Browse files Browse the repository at this point in the history
…Edit existing workitems #2767
  • Loading branch information
shral committed Sep 24, 2020
1 parent 02a5121 commit 3cae0b3
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 1 deletion.
69 changes: 69 additions & 0 deletions dcm4chee-arc-ui2/src/app/study/study/study.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export class StudyComponent implements OnInit, OnDestroy, AfterContentChecked{
placeholder: $localize `:@@more_functions:More functions`,
options:[
new SelectDropdown("create_patient",$localize `:@@study.create_patient:Create patient`),
// new SelectDropdown("create_ups",$localize `:@@study.create_ups:Add new Workitem`),
new SelectDropdown("upload_dicom",$localize`:@@study.upload_dicom_object:Upload DICOM Object`),
new SelectDropdown("permanent_delete",$localize `:@@study.short_permanent_delete:Permanent delete`, $localize `:@@study.permanent_delete:Delete rejected Instances permanently`),
new SelectDropdown("export_multiple",$localize `:@@study.export_multiple:Export matching studies`),
Expand Down Expand Up @@ -395,6 +396,9 @@ export class StudyComponent implements OnInit, OnDestroy, AfterContentChecked{
case "create_patient":
this.createPatient();
break;
case "create_ups":
this.createUPS();
break;
case "permanent_delete":
this.deleteRejectedInstances();
break;
Expand Down Expand Up @@ -2546,6 +2550,71 @@ export class StudyComponent implements OnInit, OnDestroy, AfterContentChecked{
this.modifyPatient(newPatient, 'create', config);
};

createUPS(){
this.modifyUPS(undefined, "create",{
saveLabel: $localize `:@@CREATE:CREATE`,
titleLabel: $localize `:@@create_new_ups:Create new Workitem`
})
}

modifyUPS(workitem, mode:("edit"|"create"),config?:{saveLabel:string,titleLabel:string}){
let originalWorkitemObject;
if(mode === "edit"){
originalWorkitemObject = _.cloneDeep(workitem);
}
this.service.getUPSIod(mode).subscribe(ups=>{
console.log("ups",ups);
if(mode === "create" && !workitem){
workitem = {
"attrs":{}
};
Object.keys(ups).forEach(dicomAttr=>{
if((ups[dicomAttr].required && ups[dicomAttr].required === 1) || dicomAttr === "00741202"){
workitem["attrs"][dicomAttr] = ups[dicomAttr];
}
});
}else{
let config = {
saveLabel: $localize `:@@SAVE:SAVE`,

}
}
this.service.initEmptyValue(workitem.attrs);
this.dialogRef = this.dialog.open(EditPatientComponent, {
height: 'auto',
width: '90%'
});

this.dialogRef.componentInstance.mode = "create";
this.dialogRef.componentInstance.object = workitem;
this.dialogRef.componentInstance.dropdown = this.service.getArrayFromIod(ups);
this.dialogRef.componentInstance.iod = this.service.replaceKeyInJson(ups, 'items', 'Value');
this.dialogRef.componentInstance.saveLabel = config.saveLabel;
this.dialogRef.componentInstance.titleLabel = config.titleLabel;
this.dialogRef.afterClosed().subscribe(ok => {
if (ok){
if(mode === "create"){
/* this.service.createUPS(undefined,workitem.attrs,this.studyWebService).subscribe(res=>{
this.appService.showMsg($localize `:@@study.patient_created_successfully:Workitem created successfully`);
},err=>{
this.httpErrorHandler.handleError(err);
});*/
}else{
/* this.service.modifyUPS(this.service.getPatientId(originalWorkitemObject.attrs),workitem.attrs,this.studyWebService).subscribe(res=>{
this.appService.showMsg($localize `:@@study.workitem_updated_successfully:Workitem updated successfully`);
},err=>{
_.assign(workitem, originalWorkitemObject);
this.httpErrorHandler.handleError(err);
});*/
}
}else{
_.assign(workitem, originalWorkitemObject);
}
this.dialogRef = null;
});
})
}

editPatient(patient){
let config:{saveLabel:string,titleLabel:string} = {
saveLabel:$localize `:@@SAVE:SAVE`,
Expand Down
28 changes: 27 additions & 1 deletion dcm4chee-arc-ui2/src/app/study/study/study.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3205,6 +3205,26 @@ export class StudyService {
}
};

modifyUPS(workitemUID: string, object, deviceWebservice: StudyWebService) {
// const url = this.getModifyPatientUrl(deviceWebservice);
return this.getModifyPatientUrl(deviceWebservice)
.pipe(switchMap((url:string)=>{
if (url) {
if (workitemUID) {
//Change ups;
return this.$http.put(`${url}/${workitemUID}`, object);
} else {
//Create new patient
return this.$http.post(url, object);
}
}
return throwError({error: $localize `:@@error_on_getting_needed_webapp:Error on getting the needed WebApp (with one of the web service classes "DCM4CHEE_ARC_AET" or "PAM")`});
}))
}

getModifyUPSUrl(deviceWebService: StudyWebService) {
return this.getDicomURLFromWebService(deviceWebService, "uwl");
}
modifyPatient(patientId: string, patientObject, deviceWebservice: StudyWebService, queued?, batchID?) {
// const url = this.getModifyPatientUrl(deviceWebservice);
return this.getModifyPatientUrl(deviceWebservice)
Expand All @@ -3230,7 +3250,7 @@ export class StudyService {
return this.getWebAppFromWebServiceClassAndSelectedWebApp(deviceWebService, "DCM4CHEE_ARC_AET", "PAM");
}

getDicomURLFromWebService(deviceWebService: StudyWebService, mode: ("patient" | "study")) {
getDicomURLFromWebService(deviceWebService: StudyWebService, mode:DicomMode) {
return this.getModifyPatientWebApp(deviceWebService).pipe(map((webApp:DcmWebApp)=>{
return this.getDicomURL(mode, webApp);
}));
Expand Down Expand Up @@ -3357,6 +3377,12 @@ export class StudyService {
}));
}

getUPSIod(mode:("create"|"edit")) {
if(mode && mode === "create"){
return this.getIod("upsCreate");
}
return this.getIod("upsUpdate");
};
getPatientIod() {
return this.getIod("patient");
};
Expand Down

0 comments on commit 3cae0b3

Please sign in to comment.