SDESEDITAPPT ;ALB/BLB - SDES EDIT APPT; Jun 01, 2023@09:49
;;5.3;Scheduling;**846**;Aug 13, 1993;Build 12
;;Per VHA Directive 6402, this routine should not be modified
;
Q
;
EDIT(JSON,APPTIEN,NOTE) ;
N RETURN,ERRORS
;
I $G(NOTE)="" D ERRLOG^SDESJSON(.ERRORS,444)
D VALIDATEAPPTIEN(.ERRORS,$G(APPTIEN))
I $D(ERRORS) M RETURN=ERRORS D BUILDJSON(.JSON,.RETURN) Q
;
D EDITNOTE(APPTIEN,$TR($E(NOTE,1,150),"^",""),$$GET1^DIQ(409.84,APPTIEN,.01,"I"),$$GET1^DIQ(409.831,$$GET1^DIQ(409.84,APPTIEN,.07,"I"),.04,"I"),$$GET1^DIQ(409.84,APPTIEN,.05,"I"))
;
S RETURN("Appointment","IEN")=APPTIEN
D BUILDJSON^SDESBUILDJSON(.JSON,.RETURN)
Q
;
EDITNOTE(APPTIEN,NOTE,STARTDATETIME,CLINICIEN,DFN) ;
N FDA,SUBIEN,EDITED,EDITEDNOTE
; 409.84 WP field
S EDITEDNOTE(1)=NOTE
D WP^DIE(409.84,APPTIEN_",",1,"","EDITEDNOTE")
; 44 free text field
S SUBIEN=0,EDITED=0
F S SUBIEN=$O(^SC(CLINICIEN,"S",STARTDATETIME,1,SUBIEN)) Q:'SUBIEN!(EDITED=1) D
.I DFN=$$GET1^DIQ(44.003,SUBIEN_","_STARTDATETIME_","_CLINICIEN_",",.01,"I") D
..S FDA(44.003,SUBIEN_","_STARTDATETIME_","_CLINICIEN_",",3)=NOTE
..D FILE^DIE(,"FDA") K FDA
..S EDITED=1
Q
;
VALIDATEAPPTIEN(ERRORS,APPTIEN) ;
I APPTIEN="" D ERRLOG^SDESJSON(.ERRORS,14) Q
I APPTIEN'="",'$D(^SDEC(409.84,APPTIEN,0)) D ERRLOG^SDESJSON(.ERRORS,15) Q
Q
;
BUILDJSON(JSONRETURN,RETURN) ;
N JSONERROR
D ENCODE^XLFJSON("RETURN","JSONRETURN","JSONERR")
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESEDITAPPT 1446 printed Oct 16, 2024@18:56:54 Page 2
SDESEDITAPPT ;ALB/BLB - SDES EDIT APPT; Jun 01, 2023@09:49
+1 ;;5.3;Scheduling;**846**;Aug 13, 1993;Build 12
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 QUIT
+5 ;
EDIT(JSON,APPTIEN,NOTE) ;
+1 NEW RETURN,ERRORS
+2 ;
+3 IF $GET(NOTE)=""
DO ERRLOG^SDESJSON(.ERRORS,444)
+4 DO VALIDATEAPPTIEN(.ERRORS,$GET(APPTIEN))
+5 IF $DATA(ERRORS)
MERGE RETURN=ERRORS
DO BUILDJSON(.JSON,.RETURN)
QUIT
+6 ;
+7 DO EDITNOTE(APPTIEN,$TRANSLATE($EXTRACT(NOTE,1,150),"^",""),$$GET1^DIQ(409.84,APPTIEN,.01,"I"),$$GET1^DIQ(409.831,$$GET1^DIQ(409.84,APPTIEN,.07,"I"),.04,"I"),$$GET1^DIQ(409.84,APPTIEN,.05,"I"))
+8 ;
+9 SET RETURN("Appointment","IEN")=APPTIEN
+10 DO BUILDJSON^SDESBUILDJSON(.JSON,.RETURN)
+11 QUIT
+12 ;
EDITNOTE(APPTIEN,NOTE,STARTDATETIME,CLINICIEN,DFN) ;
+1 NEW FDA,SUBIEN,EDITED,EDITEDNOTE
+2 ; 409.84 WP field
+3 SET EDITEDNOTE(1)=NOTE
+4 DO WP^DIE(409.84,APPTIEN_",",1,"","EDITEDNOTE")
+5 ; 44 free text field
+6 SET SUBIEN=0
SET EDITED=0
+7 FOR
SET SUBIEN=$ORDER(^SC(CLINICIEN,"S",STARTDATETIME,1,SUBIEN))
if 'SUBIEN!(EDITED=1)
QUIT
Begin DoDot:1
+8 IF DFN=$$GET1^DIQ(44.003,SUBIEN_","_STARTDATETIME_","_CLINICIEN_",",.01,"I")
Begin DoDot:2
+9 SET FDA(44.003,SUBIEN_","_STARTDATETIME_","_CLINICIEN_",",3)=NOTE
+10 DO FILE^DIE(,"FDA")
KILL FDA
+11 SET EDITED=1
End DoDot:2
End DoDot:1
+12 QUIT
+13 ;
VALIDATEAPPTIEN(ERRORS,APPTIEN) ;
+1 IF APPTIEN=""
DO ERRLOG^SDESJSON(.ERRORS,14)
QUIT
+2 IF APPTIEN'=""
IF '$DATA(^SDEC(409.84,APPTIEN,0))
DO ERRLOG^SDESJSON(.ERRORS,15)
QUIT
+3 QUIT
+4 ;
BUILDJSON(JSONRETURN,RETURN) ;
+1 NEW JSONERROR
+2 DO ENCODE^XLFJSON("RETURN","JSONRETURN","JSONERR")
+3 QUIT
+4 ;