SDESAPPTEDIT ;ALB/RRM - EDIT SDEC APPOINTMENT FILE #409.84 ;March 21, 2022
;;5.3;Scheduling;**813**;Aug 13, 1993;Build 6
;;Per VHA Directive 6402, this routine should not be modified
;
;Global References Supported by ICR# Type
;----------------- ----------------- ----------
; ^SDEC(409.84 SD is the owner. ICR not needed
;
;External References
;-------------------
; FILE^DIE 2053 Supported
;
Q ;No Direct Call
;
; Called from RPC: SDES EDIT APPT #409.84
; The parameter list for this RPC must be kept in sync.
; If you need to add or remove a parameter, ensure that the Remote Procedure File #8994 definition is also updated.
;
EDITAPPT(SDRETJSONFRMT,SDECAPTID,SDECNOTE,SDECLEN) ;Edit Appointment in File #409.84 (only 'note text' and appointment length can be edited)
;EDITAPPT(.SDRETJSONFRMT,SDECAPTID,SDECNOTE,SDECLEN) external parameter tag is in SDES routine
; SDECAPTID - Appointment IEN - Pointer to SDEC APPOINTMENT File #409.84
; SDECNOTE - Note
; SDECLEN - If there is a change in the length of appointment, this is the new value (in minutes) for length
;
N SDERROR,SDEDITAPPTRET
K SDRETJSONFRMT,SDEDITAPPTRET ;always clear returned data array to ensure a new array of data are returned
I $$VALAPTIEN($G(SDECAPTID,"")) Q ;validate Appointment IEN
I $$VALAPTLEN(SDECLEN) Q ;validate Appointment Length
;update begins when all input parameters pass all validations
D UPDATEAPT($G(SDECAPTID,""),$G(SDECNOTE),$G(SDECLEN))
D BUILDJSON(.SDEDITAPPTRET,.SDRETJSONFRMT)
D CLEANUP
Q
;
VALAPTIEN(SDECAPTID) ;validate Appointment IEN in File #409.84
N SDERRFLG
S SDERRFLG=0
I SDECAPTID="" D ERRLOG^SDESJSON(.SDEDITAPPTRET,14,SDECAPTID) S SDERRFLG=1
I SDECAPTID'="",'$D(^SDEC(409.84,SDECAPTID,0)) D ERRLOG^SDESJSON(.SDEDITAPPTRET,15,SDECAPTID) S SDERRFLG=1
I SDERRFLG D BUILDJSON(.SDEDITAPPTRET,.SDRETJSONFRMT),CLEANUP
Q SDERRFLG
;
VALAPTLEN(SDECLEN) ;validate Appointment Length
N SDERRFLG
S SDERRFLG=0
I SDECLEN'?.N D ERRLOG^SDESJSON(.SDEDITAPPTRET,116) S SDERRFLG=1
E D
. I $G(SDECLEN)&($G(SDECLEN)>0) D
. . I $G(SDECLEN)?.E1"."1N.N D ERRLOG^SDESJSON(.SDEDITAPPTRET,116,"Length of Appointment must be 0 decimal digits.") S SDERRFLG=1
. . I +$G(SDECLEN)>120!(+$G(SDECLEN)<5) D ERRLOG^SDESJSON(.SDEDITAPPTRET,116,"Length of Appointment must be between 5 and 120.") S SDERRFLG=1
I SDERRFLG D BUILDJSON(.SDEDITAPPTRET,.SDRETJSONFRMT),CLEANUP
Q SDERRFLG
;
UPDATEAPT(SDECAPTID,SDECNOTE,SDECLEN) ;update Field .18 LENGTH OF APPT and Field 1 Note Multiple in File #409.84
N SDECAPTFDA,SDECAPTERR,SDECMSG
I $G(SDECLEN),$G(SDECLEN)>0 D ;Edit Field .18 LENGTH OF APPT in File #409.84
. S SDECAPTFDA(409.84,SDECAPTID_",",.18)=SDECLEN
. D FILE^DIE("","SDECAPTFDA","SDECAPTERR")
. I $D(SDECAPTERR) D ERRLOG^SDESJSON(.SDEDITAPPTRET,52,"Appt Length update not Successful.Error occurred during Filing.")
Q:$D(SDECAPTERR) ;do not continue editing if Appointment Length errored out
;
;update NOTE begins here
S SDECNOTE=$$STRIP^SDEC07($E(SDECNOTE,1,150)),SDECNOTE=$TR(SDECNOTE,"^"," ") ;only use 1st 150 characters
S SDECNOTE(.5)=SDECNOTE,SDECNOTE=""
D WP^DIE(409.84,SDECAPTID_",",1,"","SDECNOTE","SDECMSG") ;edit Field 1 Note Multiple in File #409.84
I $D(SDECMSG("DIERR")) D ERRLOG^SDESJSON(.SDEDITAPPTRET,52,"NOTE update not Successful.Error occurred during Filing.")
E S SDEDITAPPTRET("Success")="Appointment is successfully updated."
K SDECAPTFDA,SDECAPTERR,SDECMSG
Q
;
BUILDJSON(SDEDITAPPTRET,SDRETJSONFRMT) ;Convert data to JSON
N JSONERR
S JSONERR=""
D ENCODE^SDESJSON(.SDEDITAPPTRET,.SDRETJSONFRMT,.JSONERR)
Q
;
CLEANUP ;cleanup variables
K SDERROR,SDEDITAPPTRET,SDTMPARY
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESAPPTEDIT 3821 printed Nov 22, 2024@18:05:32 Page 2
SDESAPPTEDIT ;ALB/RRM - EDIT SDEC APPOINTMENT FILE #409.84 ;March 21, 2022
+1 ;;5.3;Scheduling;**813**;Aug 13, 1993;Build 6
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 ;Global References Supported by ICR# Type
+5 ;----------------- ----------------- ----------
+6 ; ^SDEC(409.84 SD is the owner. ICR not needed
+7 ;
+8 ;External References
+9 ;-------------------
+10 ; FILE^DIE 2053 Supported
+11 ;
+12 ;No Direct Call
QUIT
+13 ;
+14 ; Called from RPC: SDES EDIT APPT #409.84
+15 ; The parameter list for this RPC must be kept in sync.
+16 ; If you need to add or remove a parameter, ensure that the Remote Procedure File #8994 definition is also updated.
+17 ;
EDITAPPT(SDRETJSONFRMT,SDECAPTID,SDECNOTE,SDECLEN) ;Edit Appointment in File #409.84 (only 'note text' and appointment length can be edited)
+1 ;EDITAPPT(.SDRETJSONFRMT,SDECAPTID,SDECNOTE,SDECLEN) external parameter tag is in SDES routine
+2 ; SDECAPTID - Appointment IEN - Pointer to SDEC APPOINTMENT File #409.84
+3 ; SDECNOTE - Note
+4 ; SDECLEN - If there is a change in the length of appointment, this is the new value (in minutes) for length
+5 ;
+6 NEW SDERROR,SDEDITAPPTRET
+7 ;always clear returned data array to ensure a new array of data are returned
KILL SDRETJSONFRMT,SDEDITAPPTRET
+8 ;validate Appointment IEN
IF $$VALAPTIEN($GET(SDECAPTID,""))
QUIT
+9 ;validate Appointment Length
IF $$VALAPTLEN(SDECLEN)
QUIT
+10 ;update begins when all input parameters pass all validations
+11 DO UPDATEAPT($GET(SDECAPTID,""),$GET(SDECNOTE),$GET(SDECLEN))
+12 DO BUILDJSON(.SDEDITAPPTRET,.SDRETJSONFRMT)
+13 DO CLEANUP
+14 QUIT
+15 ;
VALAPTIEN(SDECAPTID) ;validate Appointment IEN in File #409.84
+1 NEW SDERRFLG
+2 SET SDERRFLG=0
+3 IF SDECAPTID=""
DO ERRLOG^SDESJSON(.SDEDITAPPTRET,14,SDECAPTID)
SET SDERRFLG=1
+4 IF SDECAPTID'=""
IF '$DATA(^SDEC(409.84,SDECAPTID,0))
DO ERRLOG^SDESJSON(.SDEDITAPPTRET,15,SDECAPTID)
SET SDERRFLG=1
+5 IF SDERRFLG
DO BUILDJSON(.SDEDITAPPTRET,.SDRETJSONFRMT)
DO CLEANUP
+6 QUIT SDERRFLG
+7 ;
VALAPTLEN(SDECLEN) ;validate Appointment Length
+1 NEW SDERRFLG
+2 SET SDERRFLG=0
+3 IF SDECLEN'?.N
DO ERRLOG^SDESJSON(.SDEDITAPPTRET,116)
SET SDERRFLG=1
+4 IF '$TEST
Begin DoDot:1
+5 IF $GET(SDECLEN)&($GET(SDECLEN)>0)
Begin DoDot:2
+6 IF $GET(SDECLEN)?.E1"."1N.N
DO ERRLOG^SDESJSON(.SDEDITAPPTRET,116,"Length of Appointment must be 0 decimal digits.")
SET SDERRFLG=1
+7 IF +$GET(SDECLEN)>120!(+$GET(SDECLEN)<5)
DO ERRLOG^SDESJSON(.SDEDITAPPTRET,116,"Length of Appointment must be between 5 and 120.")
SET SDERRFLG=1
End DoDot:2
End DoDot:1
+8 IF SDERRFLG
DO BUILDJSON(.SDEDITAPPTRET,.SDRETJSONFRMT)
DO CLEANUP
+9 QUIT SDERRFLG
+10 ;
UPDATEAPT(SDECAPTID,SDECNOTE,SDECLEN) ;update Field .18 LENGTH OF APPT and Field 1 Note Multiple in File #409.84
+1 NEW SDECAPTFDA,SDECAPTERR,SDECMSG
+2 ;Edit Field .18 LENGTH OF APPT in File #409.84
IF $GET(SDECLEN)
IF $GET(SDECLEN)>0
Begin DoDot:1
+3 SET SDECAPTFDA(409.84,SDECAPTID_",",.18)=SDECLEN
+4 DO FILE^DIE("","SDECAPTFDA","SDECAPTERR")
+5 IF $DATA(SDECAPTERR)
DO ERRLOG^SDESJSON(.SDEDITAPPTRET,52,"Appt Length update not Successful.Error occurred during Filing.")
End DoDot:1
+6 ;do not continue editing if Appointment Length errored out
if $DATA(SDECAPTERR)
QUIT
+7 ;
+8 ;update NOTE begins here
+9 ;only use 1st 150 characters
SET SDECNOTE=$$STRIP^SDEC07($EXTRACT(SDECNOTE,1,150))
SET SDECNOTE=$TRANSLATE(SDECNOTE,"^"," ")
+10 SET SDECNOTE(.5)=SDECNOTE
SET SDECNOTE=""
+11 ;edit Field 1 Note Multiple in File #409.84
DO WP^DIE(409.84,SDECAPTID_",",1,"","SDECNOTE","SDECMSG")
+12 IF $DATA(SDECMSG("DIERR"))
DO ERRLOG^SDESJSON(.SDEDITAPPTRET,52,"NOTE update not Successful.Error occurred during Filing.")
+13 IF '$TEST
SET SDEDITAPPTRET("Success")="Appointment is successfully updated."
+14 KILL SDECAPTFDA,SDECAPTERR,SDECMSG
+15 QUIT
+16 ;
BUILDJSON(SDEDITAPPTRET,SDRETJSONFRMT) ;Convert data to JSON
+1 NEW JSONERR
+2 SET JSONERR=""
+3 DO ENCODE^SDESJSON(.SDEDITAPPTRET,.SDRETJSONFRMT,.JSONERR)
+4 QUIT
+5 ;
CLEANUP ;cleanup variables
+1 KILL SDERROR,SDEDITAPPTRET,SDTMPARY
+2 QUIT
+3 ;