SDESEDITAPPT ;ALB/BLB,JAS - SDES EDIT APPT ; Oct 04, 2024@12:53
;;5.3;Scheduling;**846,893**;Aug 13, 1993;Build 6
;;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) S ERRORS("Appointment",1)="" 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")
; 409.84 NOTE AUDIT multiple
S FDA(409.847,"+1,"_APPTIEN_",",.01)=$$NOW^XLFDT
S FDA(409.847,"+1,"_APPTIEN_",",1)=DUZ
S FDA(409.847,"+1,"_APPTIEN_",",2)=NOTE
D UPDATE^DIE("","FDA") K FDA
; 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 1679 printed Dec 13, 2024@02:56:30 Page 2
SDESEDITAPPT ;ALB/BLB,JAS - SDES EDIT APPT ; Oct 04, 2024@12:53
+1 ;;5.3;Scheduling;**846,893**;Aug 13, 1993;Build 6
+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)
SET ERRORS("Appointment",1)=""
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 ; 409.84 NOTE AUDIT multiple
+6 SET FDA(409.847,"+1,"_APPTIEN_",",.01)=$$NOW^XLFDT
+7 SET FDA(409.847,"+1,"_APPTIEN_",",1)=DUZ
+8 SET FDA(409.847,"+1,"_APPTIEN_",",2)=NOTE
+9 DO UPDATE^DIE("","FDA")
KILL FDA
+10 ; 44 free text field
+11 SET SUBIEN=0
SET EDITED=0
+12 FOR
SET SUBIEN=$ORDER(^SC(CLINICIEN,"S",STARTDATETIME,1,SUBIEN))
if 'SUBIEN!(EDITED=1)
QUIT
Begin DoDot:1
+13 IF DFN=$$GET1^DIQ(44.003,SUBIEN_","_STARTDATETIME_","_CLINICIEN_",",.01,"I")
Begin DoDot:2
+14 SET FDA(44.003,SUBIEN_","_STARTDATETIME_","_CLINICIEN_",",3)=NOTE
+15 DO FILE^DIE(,"FDA")
KILL FDA
+16 SET EDITED=1
End DoDot:2
End DoDot:1
+17 QUIT
+18 ;
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 ;