SDESGETAPPTSIEN2 ;ALB/DJS - SDES GET APPTS BY IEN2 RPC ; May 24, 2023
;;5.3;SCHEDULING;**846**;AUG 13, 1993;Build 12
;;Per VHA Directive 6402, this routine should not be modified
;
; Copy of SDESGETAPPTSIEN
;
Q
;
APPTSLISTBYIEN(APPTSLISTJSON,EASAUDITID,APPTIENS,SDEASARRAY) ;
N APPTDATA,NODE,SEQ,IEN,RETURNDATA,APPTLIST,ERRORS,SDEAS,SDESCNT,VALAPPT,MAX
S (APPTDATA,NODE,IEN,RETURNDATA,APPTLIST,SDEAS,SDESCNT)=""
S (SEQ,MAX)=0
;
F S NODE=$O(APPTIENS(NODE)) Q:NODE=""!(MAX) D
. S SEQ=SEQ+1
. I SEQ>50 D ERRLOG^SDESJSON(.ERRORS,429) S MAX=1 Q
. ;
. S IEN=$G(APPTIENS(NODE))
. S VALAPPT=$$VALAPPTIEN(.ERRORS,IEN) Q:'VALAPPT
. ;
. S SDEAS=$G(SDEASARRAY(NODE),"")
. N APPTDATA,RETURNDATA
. D GETAPPTBYIEN^SDESGETAPPTWRAP4(.RETURNDATA,IEN,SDEAS)
. D DECODE^XLFJSON("RETURNDATA","APPTDATA")
. M APPTLIST("Appointment",SEQ)=APPTDATA("Appointment","1")
. K APPTDATA,RETURNDATA
. Q
M APPTLIST=ERRORS
I '$D(APPTLIST) S APPTLIST("Appointment",1)=""
D BUILDJSON(.APPTSLISTJSON,.APPTLIST)
Q
BUILDJSON(APPTSLISTJSON,APPTLIST) ;Convert data to JSON
N JSONERR
S JSONERR=""
D BUILDJSON^SDESBUILDJSON(.APPTSLISTJSON,.APPTLIST)
Q
; validate appointment ID/IEN
VALAPPTIEN(ERRORS,APPTIEN) ;
I '$L(APPTIEN) D ERRLOG^SDESJSON(.ERRORS,14) Q 0
I 'APPTIEN D ERRLOG^SDESJSON(.ERRORS,15,APPTIEN) Q 0
I APPTIEN,'$D(^SDEC(409.84,APPTIEN)) D ERRLOG^SDESJSON(.ERRORS,15,APPTIEN) Q 0
Q 1
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESGETAPPTSIEN2 1435 printed Nov 22, 2024@18:06:31 Page 2
SDESGETAPPTSIEN2 ;ALB/DJS - SDES GET APPTS BY IEN2 RPC ; May 24, 2023
+1 ;;5.3;SCHEDULING;**846**;AUG 13, 1993;Build 12
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 ; Copy of SDESGETAPPTSIEN
+5 ;
+6 QUIT
+7 ;
APPTSLISTBYIEN(APPTSLISTJSON,EASAUDITID,APPTIENS,SDEASARRAY) ;
+1 NEW APPTDATA,NODE,SEQ,IEN,RETURNDATA,APPTLIST,ERRORS,SDEAS,SDESCNT,VALAPPT,MAX
+2 SET (APPTDATA,NODE,IEN,RETURNDATA,APPTLIST,SDEAS,SDESCNT)=""
+3 SET (SEQ,MAX)=0
+4 ;
+5 FOR
SET NODE=$ORDER(APPTIENS(NODE))
if NODE=""!(MAX)
QUIT
Begin DoDot:1
+6 SET SEQ=SEQ+1
+7 IF SEQ>50
DO ERRLOG^SDESJSON(.ERRORS,429)
SET MAX=1
QUIT
+8 ;
+9 SET IEN=$GET(APPTIENS(NODE))
+10 SET VALAPPT=$$VALAPPTIEN(.ERRORS,IEN)
if 'VALAPPT
QUIT
+11 ;
+12 SET SDEAS=$GET(SDEASARRAY(NODE),"")
+13 NEW APPTDATA,RETURNDATA
+14 DO GETAPPTBYIEN^SDESGETAPPTWRAP4(.RETURNDATA,IEN,SDEAS)
+15 DO DECODE^XLFJSON("RETURNDATA","APPTDATA")
+16 MERGE APPTLIST("Appointment",SEQ)=APPTDATA("Appointment","1")
+17 KILL APPTDATA,RETURNDATA
+18 QUIT
End DoDot:1
+19 MERGE APPTLIST=ERRORS
+20 IF '$DATA(APPTLIST)
SET APPTLIST("Appointment",1)=""
+21 DO BUILDJSON(.APPTSLISTJSON,.APPTLIST)
+22 QUIT
BUILDJSON(APPTSLISTJSON,APPTLIST) ;Convert data to JSON
+1 NEW JSONERR
+2 SET JSONERR=""
+3 DO BUILDJSON^SDESBUILDJSON(.APPTSLISTJSON,.APPTLIST)
+4 QUIT
+5 ; validate appointment ID/IEN
VALAPPTIEN(ERRORS,APPTIEN) ;
+1 IF '$LENGTH(APPTIEN)
DO ERRLOG^SDESJSON(.ERRORS,14)
QUIT 0
+2 IF 'APPTIEN
DO ERRLOG^SDESJSON(.ERRORS,15,APPTIEN)
QUIT 0
+3 IF APPTIEN
IF '$DATA(^SDEC(409.84,APPTIEN))
DO ERRLOG^SDESJSON(.ERRORS,15,APPTIEN)
QUIT 0
+4 QUIT 1