SDESGETAPPTWRAP4 ;ALB/RRM,MGD/RRM - RPC WRAPPER FOR VIEWING AN APPOINTMENT ;JULY 5, 2022
;;5.3;Scheduling;**823**;Aug 13, 1993;Build 9
;;Per VHA Directive 6402, this routine should not be modified
;
;External References
;-------------------
; Reference to $$GETS^DIQ is supported by IA #2056
; Reference to GETS^DIQ is supported by IA #2056
; Reference to $$FIND1^DIC is supported by IA #2051
; Reference to ENCODE^XLFJSON is supported by IA #6682
;
;Global References
;-----------------
; Reference to ^DPT( is supported by IAs #7030,7029,1476,10035
;
Q ;No Direct Call
;
; 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.
;
; Copy of SDESGETAPPTWRAP2
;
GETAPPTBYPATDFN(RETURNJSON,DFN,SDBEGDATE,SDENDDATE,SDEAS) ;Called from the RPC: SDES GET APPTS BY PATIENT DFN
;Based on Patient DFN, retrieve and return all appointments associated with a patient from SDEC APPOINTMENT File #409.84,
;HOSPITAL LOCATION File #44, and the Appointment Multiple Patient File #2
;
; Input:
; DFN [Required] = This the patient's DFN from PATIENT File #2
; SDBEGDATE [Required] = The beginning date/time in ISO8601 Time Format for the search.
; SDENDDATE [Required] = The ending date/time in ISO8601 Time Format for the search.
; SDEAS [Optional] = The Enterprise Appointment Scheduling (EAS) Tracking Number associated to an appointment.
;
; Output:
; RETURNJSON = Returns fields from the (not in particular order) HOSPITAL LOCATION File #44, PATIENT File #2, and SDEC APPOINTMENT File #409.84
; in JSON format. JSON Errors will be returned for any invalid/missing parameters.
;
N ERRORS,RETURNERROR ;temp data storage for input validation error
N SDALLAPPTARY ;temp data storage for all records found in the HOSPITAL LOCATION File #44, PATIENT File #2, and SDEC APPOINTMENT File #409.84
N SDVIEWAPPTBY ;the driver of which process to perform in retrieving appointment
N HASDFNERRORS,HASBEGDATEERRORS,HASENDDATEERRORS,HASEASERRORS,SDAPPTNO
;
D INITVARBYDFN
S HASDFNERRORS=$$VALIDATEPTDFN(.ERRORS,$G(DFN)) ;DFN input parameter validation
I HASDFNERRORS M RETURNERROR=ERRORS
;
S:$G(SDBEGDATE)'="" SDBEGDATE=$$ISOTFM^SDAMUTDT(SDBEGDATE)
S:$G(SDENDDATE)'="" SDENDDATE=$$ISOTFM^SDAMUTDT(SDENDDATE)
D INPUTDATEVAL($G(SDBEGDATE),$G(SDENDDATE)) ;beginning and ending date input parameter validation
;
S HASEASERRORS=$$VALIDATEEAS(.ERRORS,$G(SDEAS))
I HASEASERRORS M RETURNERROR=ERRORS
;
I $O(RETURNERROR("Error",""))'="" S RETURNERROR("Appointment",1)="" D BUILDJSON(.RETURNERROR,.RETURNJSON) Q ;do not continue, errors detected
;
S (SDVIEWAPPTBY,SDAPPTNO)=0 ;view appointment using DFN of the patient from Patient File #2
D GETAPPOINTMENTS(.SDALLAPPTARY,DFN,SDBEGDATE,SDENDDATE,SDVIEWAPPTBY)
D BUILDJSON(.SDALLAPPTARY,.RETURNJSON)
D CLEANUP
Q
;
GETAPPTBYCLNIEN(RETURNJSON,CLINICIEN,SDBEGDATE,SDENDDATE,SDEAS) ;Called from the RPC: SDES GET APPTS BY CLIN IEN
;Based on CLINIC IEN, retrieve and return all appointments associated with a clinic from SDEC APPOINTMENT File #409.84,
;HOSPITAL LOCATION File #44, and the Appointment Multiple Patient File #2
;
; Input:
; CLINICIEN [Required] = This the CLINIC IEN from HOSPITAL LOCATION File #44
; SDBEGDATE [Required] = The beginning date/time in ISO8601 Time Format for the search.
; SDENDDATE [Required] = The ending date/time in ISO8601 Time Format for the search.
; SDEAS [Optional] = The Enterprise Appointment Scheduling (EAS) Tracking Number associated to an appointment.
;
; Output:
; RETURNJSON = Returns fields from the (not in particular order) HOSPITAL LOCATION File #44, PATIENT File #2, and SDEC APPOINTMENT File #409.84
; in JSON format. JSON Errors will be returned for any invalid/missing parameters.
;
N ERRORS,RETURNERROR ;temp data storage for input validation error
N SDALLAPPTARY ;temp data storage for all records found in the HOSPITAL LOCATION File #44, PATIENT File #2, and SDEC APPOINTMENT File #409.84
N SDVIEWAPPTBY ;the driver of which process to perform in retrieving appointment
N HASCLINIENERRORS,HASBEGDATEERRORS,HASENDDATEERRORS,HASEASERRORS,SDAPPTNO
;
D INITVARBYCLNIEN
S HASCLINIENERRORS=$$VALIDATECLINIC(.ERRORS,$G(CLINICIEN)) ;CLINICIEN input parameter validation
I HASCLINIENERRORS M RETURNERROR=ERRORS
;
S:$G(SDBEGDATE)'="" SDBEGDATE=$$ISOTFM^SDAMUTDT(SDBEGDATE)
S:$G(SDENDDATE)'="" SDENDDATE=$$ISOTFM^SDAMUTDT(SDENDDATE)
D INPUTDATEVAL($G(SDBEGDATE),$G(SDENDDATE)) ;beginning and ending date input parameter validation
;
S HASEASERRORS=$$VALIDATEEAS(.ERRORS,$G(SDEAS))
I HASEASERRORS M RETURNERROR=ERRORS
;
I $O(RETURNERROR("Error",""))'="" S RETURNERROR("Appointment",1)="" D BUILDJSON(.RETURNERROR,.RETURNJSON) Q ;do not continue, errors detected
;
S SDVIEWAPPTBY=1 ;view appointment using CLINIC IEN from Hospital Location File #44
D GETAPPOINTMENTS(.SDALLAPPTARY,CLINICIEN,SDBEGDATE,SDENDDATE,SDVIEWAPPTBY)
D BUILDJSON(.SDALLAPPTARY,.RETURNJSON)
D CLEANUP
Q
;
GETAPPTBYIEN(RETURNJSON,SDAPPTIEN,SDEAS) ;Called from the RPC: SDES GET APPTS BY IEN
;Based on APPOINTMENT IEN, retrieve and return all appointments associated with a clinic from SDEC APPOINTMENT File #409.84,
;HOSPITAL LOCATION File #44, and the Appointment Multiple Patient File #2
;
; Input:
; DFN [Required] = This the patient's DFN from PATIENT File #2
; SDEAS [Optional] = The Enterprise Appointment Scheduling (EAS) Tracking Number associated to an appointment.
;
; Output:
; RETURNJSON = Returns fields from the (not in particular order) HOSPITAL LOCATION File #44, PATIENT File #2, and SDEC APPOINTMENT File #409.84
; in JSON format. JSON Errors will be returned for any invalid/missing parameters.
;
N ERRORS,RETURNERROR ;temp data storage for input validation error
N SDALLAPPTARY ;temp data storage for all records found in the HOSPITAL LOCATION File #44, PATIENT File #2, and SDEC APPOINTMENT File #409.84
N SDVIEWAPPTBY ;the driver of which process to perform in retrieving appointment
N HASAPPTIENERRORS,HASEASERRORS,DFN,APPTIEN,SDAPPTNO,SDBEGDATE,SDENDDATE,SDAPPTNO,FOUND
;
D INITVARBYCLNIEN
S HASAPPTIENERRORS=$$VALIDATEAPPTIEN(.ERRORS,$G(SDAPPTIEN)) ;CLINICIEN input parameter validation
I HASAPPTIENERRORS M RETURNERROR=ERRORS
;
S HASEASERRORS=$$VALIDATEEAS(.ERRORS,$G(SDEAS))
I HASEASERRORS M RETURNERROR=ERRORS
;
I $O(RETURNERROR("Error",""))'="" S RETURNERROR("Appointment",1)="" D BUILDJSON(.RETURNERROR,.RETURNJSON) Q ;do not continue,errors detected
;
S SDVIEWAPPTBY=2 ;view appointment using APPOINTMENT IEN from SDEC APPOINTMENT File #409.84
S DFN=$$GET1^DIQ(409.84,SDAPPTIEN,.05,"I")
S SDBEGDATE=$$GET1^DIQ(409.84,SDAPPTIEN,.01,"I")
S SDENDDATE=$$GET1^DIQ(409.84,SDAPPTIEN,.02,"I")
D GETAPPOINTMENTS(.SDALLAPPTARY,DFN,SDBEGDATE,SDENDDATE,SDVIEWAPPTBY,SDAPPTIEN)
D BUILDJSON(.SDALLAPPTARY,.RETURNJSON)
D CLEANUP
Q
;
GETAPPOINTMENTS(SDALLAPPTARY,SDPOINTERIEN,SDBEGDATE,SDENDDATE,SDVIEWAPPTBY,SDAPPTIEN) ;
; Input:
; SDPOINTERIEN [Required] = This can be a patient's DFN from PATIENT File #2 or the Internal Entry Number (IEN) from HOSPITAL LOCATION FILE #44.
; SDBEGDATE [Required] = The beginning date/time in FileMan Format for the search.
; SDENDDATE [Required] = The ending date/time in FileMan Time Format for the search.
; SDVIEWAPPTBY [Optional] = The driver of which process to perform when retrieving appointments (By DFN, Clinic IEN, or Appointment IEN)
; = If NULL, this will be defaulted to by DFN
; SDAPPTIEN [Optional] = Only send this parameter if you want to retrieve appointments using APPOINTMENT IEN from SDEC APPOINTMENT File #409.84
;
; Output:
; SDALLAPPTARY = Returns fields from the (not in particular order) HOSPITAL LOCATION File #44, PATIENT File #2, and SDEC APPOINTMENT File #409.84
; in array format. Errors will be returned for any invalid/missing parameters.
N RECNUM
S RECNUM=0
I $G(SDVIEWAPPTBY)="" S SDVIEWAPPTBY=0
S SDAPPTIEN=$G(SDAPPTIEN)
I $G(SDVIEWAPPTBY)=0!($G(SDVIEWAPPTBY)=2) D GETAPPT40984^SDESGETAPPTWRAP5(.SDALLAPPTARY,SDPOINTERIEN,SDBEGDATE,SDENDDATE,SDAPPTIEN,RECNUM,SDVIEWAPPTBY) ;view appointment using DFN of the patient OR using Appointment IEN
I $G(SDVIEWAPPTBY)=1 D GETAPPT44^SDESGETAPPTWRAP5(.SDALLAPPTARY,SDPOINTERIEN,SDBEGDATE,SDENDDATE,RECNUM,SDVIEWAPPTBY) ;view appointment using Clinic IEN
Q
;
VALIDATEPTDFN(ERRORS,SDDFN) ;Validate patient DFN
N ERRORFLAG
S ERRORFLAG=$$VALIDATEPTDFN^SDESGETPATAPPT(.ERRORS,SDDFN)
Q $G(ERRORFLAG)
;
VALIDATECLINIC(ERRORS,SDCLINICIEN) ;Validate Clinic
N ERRORFLAG
S ERRORFLAG=$$VALIDATECLINIC^SDESGETPATAPPT(.ERRORS,SDCLINICIEN)
Q $G(ERRORFLAG)
;
VALIDATEAPPTIEN(ERRORS,SDAPPTIEN) ;Validate Appointment IEN
N ERRORFLAG
I SDAPPTIEN="" D ERRLOG^SDESJSON(.ERRORS,14) S ERRORFLAG=1
I SDAPPTIEN'="",'$D(^SDEC(409.84,SDAPPTIEN,0)) D ERRLOG^SDESJSON(.ERRORS,15) S ERRORFLAG=1
Q $G(ERRORFLAG)
;
INPUTDATEVAL(SDBEGDATE,SDENDDATE) ;beginning and ending date input parameter validation
S HASBEGDATEERRORS=$$VALIDATEBEGDATE(.ERRORS,SDBEGDATE) ;SDBEGDATE input parameter validation
I HASBEGDATEERRORS M RETURNERROR=ERRORS
;
S HASENDDATEERRORS=$$VALIDATEENDDATE(.ERRORS,SDENDDATE) ;SDENDDATE input parameter validation
I HASENDDATEERRORS M RETURNERROR=ERRORS
Q
;
VALIDATEBEGDATE(ERRORS,SDBEGDATE) ;Validate Beginning Date
N ERRORFLAG
I $G(SDBEGDATE)="" D ERRLOG^SDESJSON(.ERRORS,25) S ERRORFLAG=1 Q $G(ERRORFLAG)
S ERRORFLAG=$$VALIDATEBEGDT^SDESPRINTPATAPPT(.ERRORS,SDBEGDATE)
Q $G(ERRORFLAG)
;
VALIDATEENDDATE(ERRORS,SDENDDATE) ;Validate Ending Date
N ERRORFLAG
I SDENDDATE="" D ERRLOG^SDESJSON(.ERRORS,26) S ERRORFLAG=1 Q $G(ERRORFLAG)
S ERRORFLAG=$$VALIDATEENDDT^SDESPRINTPATAPPT(.ERRORS,SDENDDATE)
Q $G(ERRORFLAG)
;
VALIDATEEAS(ERRORS,EAS) ;
I $L(EAS) S EAS=$$EASVALIDATE^SDESUTIL($G(EAS))
I $P($G(EAS),U)=-1 D ERRLOG^SDESJSON(.ERRORS,142) Q 1
Q 0
;
BUILDJSON(RETURNJSON,INPUT) ; Build JSON format
N JSONERROR
S JSONERROR=""
D ENCODE^XLFJSON("RETURNJSON","INPUT","JSONERROR")
Q
;
CLEANUP ;
K RETURNERROR,SDALLAPPTARY,SDBEG,SDEND,ERRORFLAG,HASDFNERRORS,HASCLINIENERRORS,ERRORS
K SDMSG,FOUND,ERR,SDCLINICIEN,SDDFN,SDVIEWAPPTBY,HASBEGDATEERRORS,HASENDDATEERRORS,STARTTIME
Q
;
INITVARBYDFN ;initialized input parameter for SDES GET APPTS BY PATIENT DFN3 RPC
S DFN=$G(DFN)
S SDBEGDATE=$G(SDBEGDATE)
S SDENDDATE=$G(SDENDDATE)
S SDEAS=$G(SDEAS)
Q
;
INITVARBYCLNIEN ;initialized input parameter for SDES GET APPTS BY CLIN IEN 3 RPC
S CLINICIEN=$G(CLINICIEN)
S SDBEGDATE=$G(SDBEGDATE)
S SDENDDATE=$G(SDENDDATE)
S SDEAS=$G(SDEAS)
Q
;
INITVARBYIEN ;initialized input parameter for SDES GET APPTS BY IEN 2 RPC
S SDAPPTIEN=$G(SDAPPTIEN)
S SDEAS=$G(SDEAS)
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESGETAPPTWRAP4 11180 printed Oct 16, 2024@18:57:08 Page 2
SDESGETAPPTWRAP4 ;ALB/RRM,MGD/RRM - RPC WRAPPER FOR VIEWING AN APPOINTMENT ;JULY 5, 2022
+1 ;;5.3;Scheduling;**823**;Aug 13, 1993;Build 9
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 ;External References
+5 ;-------------------
+6 ; Reference to $$GETS^DIQ is supported by IA #2056
+7 ; Reference to GETS^DIQ is supported by IA #2056
+8 ; Reference to $$FIND1^DIC is supported by IA #2051
+9 ; Reference to ENCODE^XLFJSON is supported by IA #6682
+10 ;
+11 ;Global References
+12 ;-----------------
+13 ; Reference to ^DPT( is supported by IAs #7030,7029,1476,10035
+14 ;
+15 ;No Direct Call
QUIT
+16 ;
+17 ; The parameter list for this RPC must be kept in sync.
+18 ; If you need to add or remove a parameter, ensure that the Remote Procedure File #8994 definition is also updated.
+19 ;
+20 ; Copy of SDESGETAPPTWRAP2
+21 ;
GETAPPTBYPATDFN(RETURNJSON,DFN,SDBEGDATE,SDENDDATE,SDEAS) ;Called from the RPC: SDES GET APPTS BY PATIENT DFN
+1 ;Based on Patient DFN, retrieve and return all appointments associated with a patient from SDEC APPOINTMENT File #409.84,
+2 ;HOSPITAL LOCATION File #44, and the Appointment Multiple Patient File #2
+3 ;
+4 ; Input:
+5 ; DFN [Required] = This the patient's DFN from PATIENT File #2
+6 ; SDBEGDATE [Required] = The beginning date/time in ISO8601 Time Format for the search.
+7 ; SDENDDATE [Required] = The ending date/time in ISO8601 Time Format for the search.
+8 ; SDEAS [Optional] = The Enterprise Appointment Scheduling (EAS) Tracking Number associated to an appointment.
+9 ;
+10 ; Output:
+11 ; RETURNJSON = Returns fields from the (not in particular order) HOSPITAL LOCATION File #44, PATIENT File #2, and SDEC APPOINTMENT File #409.84
+12 ; in JSON format. JSON Errors will be returned for any invalid/missing parameters.
+13 ;
+14 ;temp data storage for input validation error
NEW ERRORS,RETURNERROR
+15 ;temp data storage for all records found in the HOSPITAL LOCATION File #44, PATIENT File #2, and SDEC APPOINTMENT File #409.84
NEW SDALLAPPTARY
+16 ;the driver of which process to perform in retrieving appointment
NEW SDVIEWAPPTBY
+17 NEW HASDFNERRORS,HASBEGDATEERRORS,HASENDDATEERRORS,HASEASERRORS,SDAPPTNO
+18 ;
+19 DO INITVARBYDFN
+20 ;DFN input parameter validation
SET HASDFNERRORS=$$VALIDATEPTDFN(.ERRORS,$GET(DFN))
+21 IF HASDFNERRORS
MERGE RETURNERROR=ERRORS
+22 ;
+23 if $GET(SDBEGDATE)'=""
SET SDBEGDATE=$$ISOTFM^SDAMUTDT(SDBEGDATE)
+24 if $GET(SDENDDATE)'=""
SET SDENDDATE=$$ISOTFM^SDAMUTDT(SDENDDATE)
+25 ;beginning and ending date input parameter validation
DO INPUTDATEVAL($GET(SDBEGDATE),$GET(SDENDDATE))
+26 ;
+27 SET HASEASERRORS=$$VALIDATEEAS(.ERRORS,$GET(SDEAS))
+28 IF HASEASERRORS
MERGE RETURNERROR=ERRORS
+29 ;
+30 ;do not continue, errors detected
IF $ORDER(RETURNERROR("Error",""))'=""
SET RETURNERROR("Appointment",1)=""
DO BUILDJSON(.RETURNERROR,.RETURNJSON)
QUIT
+31 ;
+32 ;view appointment using DFN of the patient from Patient File #2
SET (SDVIEWAPPTBY,SDAPPTNO)=0
+33 DO GETAPPOINTMENTS(.SDALLAPPTARY,DFN,SDBEGDATE,SDENDDATE,SDVIEWAPPTBY)
+34 DO BUILDJSON(.SDALLAPPTARY,.RETURNJSON)
+35 DO CLEANUP
+36 QUIT
+37 ;
GETAPPTBYCLNIEN(RETURNJSON,CLINICIEN,SDBEGDATE,SDENDDATE,SDEAS) ;Called from the RPC: SDES GET APPTS BY CLIN IEN
+1 ;Based on CLINIC IEN, retrieve and return all appointments associated with a clinic from SDEC APPOINTMENT File #409.84,
+2 ;HOSPITAL LOCATION File #44, and the Appointment Multiple Patient File #2
+3 ;
+4 ; Input:
+5 ; CLINICIEN [Required] = This the CLINIC IEN from HOSPITAL LOCATION File #44
+6 ; SDBEGDATE [Required] = The beginning date/time in ISO8601 Time Format for the search.
+7 ; SDENDDATE [Required] = The ending date/time in ISO8601 Time Format for the search.
+8 ; SDEAS [Optional] = The Enterprise Appointment Scheduling (EAS) Tracking Number associated to an appointment.
+9 ;
+10 ; Output:
+11 ; RETURNJSON = Returns fields from the (not in particular order) HOSPITAL LOCATION File #44, PATIENT File #2, and SDEC APPOINTMENT File #409.84
+12 ; in JSON format. JSON Errors will be returned for any invalid/missing parameters.
+13 ;
+14 ;temp data storage for input validation error
NEW ERRORS,RETURNERROR
+15 ;temp data storage for all records found in the HOSPITAL LOCATION File #44, PATIENT File #2, and SDEC APPOINTMENT File #409.84
NEW SDALLAPPTARY
+16 ;the driver of which process to perform in retrieving appointment
NEW SDVIEWAPPTBY
+17 NEW HASCLINIENERRORS,HASBEGDATEERRORS,HASENDDATEERRORS,HASEASERRORS,SDAPPTNO
+18 ;
+19 DO INITVARBYCLNIEN
+20 ;CLINICIEN input parameter validation
SET HASCLINIENERRORS=$$VALIDATECLINIC(.ERRORS,$GET(CLINICIEN))
+21 IF HASCLINIENERRORS
MERGE RETURNERROR=ERRORS
+22 ;
+23 if $GET(SDBEGDATE)'=""
SET SDBEGDATE=$$ISOTFM^SDAMUTDT(SDBEGDATE)
+24 if $GET(SDENDDATE)'=""
SET SDENDDATE=$$ISOTFM^SDAMUTDT(SDENDDATE)
+25 ;beginning and ending date input parameter validation
DO INPUTDATEVAL($GET(SDBEGDATE),$GET(SDENDDATE))
+26 ;
+27 SET HASEASERRORS=$$VALIDATEEAS(.ERRORS,$GET(SDEAS))
+28 IF HASEASERRORS
MERGE RETURNERROR=ERRORS
+29 ;
+30 ;do not continue, errors detected
IF $ORDER(RETURNERROR("Error",""))'=""
SET RETURNERROR("Appointment",1)=""
DO BUILDJSON(.RETURNERROR,.RETURNJSON)
QUIT
+31 ;
+32 ;view appointment using CLINIC IEN from Hospital Location File #44
SET SDVIEWAPPTBY=1
+33 DO GETAPPOINTMENTS(.SDALLAPPTARY,CLINICIEN,SDBEGDATE,SDENDDATE,SDVIEWAPPTBY)
+34 DO BUILDJSON(.SDALLAPPTARY,.RETURNJSON)
+35 DO CLEANUP
+36 QUIT
+37 ;
GETAPPTBYIEN(RETURNJSON,SDAPPTIEN,SDEAS) ;Called from the RPC: SDES GET APPTS BY IEN
+1 ;Based on APPOINTMENT IEN, retrieve and return all appointments associated with a clinic from SDEC APPOINTMENT File #409.84,
+2 ;HOSPITAL LOCATION File #44, and the Appointment Multiple Patient File #2
+3 ;
+4 ; Input:
+5 ; DFN [Required] = This the patient's DFN from PATIENT File #2
+6 ; SDEAS [Optional] = The Enterprise Appointment Scheduling (EAS) Tracking Number associated to an appointment.
+7 ;
+8 ; Output:
+9 ; RETURNJSON = Returns fields from the (not in particular order) HOSPITAL LOCATION File #44, PATIENT File #2, and SDEC APPOINTMENT File #409.84
+10 ; in JSON format. JSON Errors will be returned for any invalid/missing parameters.
+11 ;
+12 ;temp data storage for input validation error
NEW ERRORS,RETURNERROR
+13 ;temp data storage for all records found in the HOSPITAL LOCATION File #44, PATIENT File #2, and SDEC APPOINTMENT File #409.84
NEW SDALLAPPTARY
+14 ;the driver of which process to perform in retrieving appointment
NEW SDVIEWAPPTBY
+15 NEW HASAPPTIENERRORS,HASEASERRORS,DFN,APPTIEN,SDAPPTNO,SDBEGDATE,SDENDDATE,SDAPPTNO,FOUND
+16 ;
+17 DO INITVARBYCLNIEN
+18 ;CLINICIEN input parameter validation
SET HASAPPTIENERRORS=$$VALIDATEAPPTIEN(.ERRORS,$GET(SDAPPTIEN))
+19 IF HASAPPTIENERRORS
MERGE RETURNERROR=ERRORS
+20 ;
+21 SET HASEASERRORS=$$VALIDATEEAS(.ERRORS,$GET(SDEAS))
+22 IF HASEASERRORS
MERGE RETURNERROR=ERRORS
+23 ;
+24 ;do not continue,errors detected
IF $ORDER(RETURNERROR("Error",""))'=""
SET RETURNERROR("Appointment",1)=""
DO BUILDJSON(.RETURNERROR,.RETURNJSON)
QUIT
+25 ;
+26 ;view appointment using APPOINTMENT IEN from SDEC APPOINTMENT File #409.84
SET SDVIEWAPPTBY=2
+27 SET DFN=$$GET1^DIQ(409.84,SDAPPTIEN,.05,"I")
+28 SET SDBEGDATE=$$GET1^DIQ(409.84,SDAPPTIEN,.01,"I")
+29 SET SDENDDATE=$$GET1^DIQ(409.84,SDAPPTIEN,.02,"I")
+30 DO GETAPPOINTMENTS(.SDALLAPPTARY,DFN,SDBEGDATE,SDENDDATE,SDVIEWAPPTBY,SDAPPTIEN)
+31 DO BUILDJSON(.SDALLAPPTARY,.RETURNJSON)
+32 DO CLEANUP
+33 QUIT
+34 ;
GETAPPOINTMENTS(SDALLAPPTARY,SDPOINTERIEN,SDBEGDATE,SDENDDATE,SDVIEWAPPTBY,SDAPPTIEN) ;
+1 ; Input:
+2 ; SDPOINTERIEN [Required] = This can be a patient's DFN from PATIENT File #2 or the Internal Entry Number (IEN) from HOSPITAL LOCATION FILE #44.
+3 ; SDBEGDATE [Required] = The beginning date/time in FileMan Format for the search.
+4 ; SDENDDATE [Required] = The ending date/time in FileMan Time Format for the search.
+5 ; SDVIEWAPPTBY [Optional] = The driver of which process to perform when retrieving appointments (By DFN, Clinic IEN, or Appointment IEN)
+6 ; = If NULL, this will be defaulted to by DFN
+7 ; SDAPPTIEN [Optional] = Only send this parameter if you want to retrieve appointments using APPOINTMENT IEN from SDEC APPOINTMENT File #409.84
+8 ;
+9 ; Output:
+10 ; SDALLAPPTARY = Returns fields from the (not in particular order) HOSPITAL LOCATION File #44, PATIENT File #2, and SDEC APPOINTMENT File #409.84
+11 ; in array format. Errors will be returned for any invalid/missing parameters.
+12 NEW RECNUM
+13 SET RECNUM=0
+14 IF $GET(SDVIEWAPPTBY)=""
SET SDVIEWAPPTBY=0
+15 SET SDAPPTIEN=$GET(SDAPPTIEN)
+16 ;view appointment using DFN of the patient OR using Appointment IEN
IF $GET(SDVIEWAPPTBY)=0!($GET(SDVIEWAPPTBY)=2)
DO GETAPPT40984^SDESGETAPPTWRAP5(.SDALLAPPTARY,SDPOINTERIEN,SDBEGDATE,SDENDDATE,SDAPPTIEN,RECNUM,SDVIEWAPPTBY)
+17 ;view appointment using Clinic IEN
IF $GET(SDVIEWAPPTBY)=1
DO GETAPPT44^SDESGETAPPTWRAP5(.SDALLAPPTARY,SDPOINTERIEN,SDBEGDATE,SDENDDATE,RECNUM,SDVIEWAPPTBY)
+18 QUIT
+19 ;
VALIDATEPTDFN(ERRORS,SDDFN) ;Validate patient DFN
+1 NEW ERRORFLAG
+2 SET ERRORFLAG=$$VALIDATEPTDFN^SDESGETPATAPPT(.ERRORS,SDDFN)
+3 QUIT $GET(ERRORFLAG)
+4 ;
VALIDATECLINIC(ERRORS,SDCLINICIEN) ;Validate Clinic
+1 NEW ERRORFLAG
+2 SET ERRORFLAG=$$VALIDATECLINIC^SDESGETPATAPPT(.ERRORS,SDCLINICIEN)
+3 QUIT $GET(ERRORFLAG)
+4 ;
VALIDATEAPPTIEN(ERRORS,SDAPPTIEN) ;Validate Appointment IEN
+1 NEW ERRORFLAG
+2 IF SDAPPTIEN=""
DO ERRLOG^SDESJSON(.ERRORS,14)
SET ERRORFLAG=1
+3 IF SDAPPTIEN'=""
IF '$DATA(^SDEC(409.84,SDAPPTIEN,0))
DO ERRLOG^SDESJSON(.ERRORS,15)
SET ERRORFLAG=1
+4 QUIT $GET(ERRORFLAG)
+5 ;
INPUTDATEVAL(SDBEGDATE,SDENDDATE) ;beginning and ending date input parameter validation
+1 ;SDBEGDATE input parameter validation
SET HASBEGDATEERRORS=$$VALIDATEBEGDATE(.ERRORS,SDBEGDATE)
+2 IF HASBEGDATEERRORS
MERGE RETURNERROR=ERRORS
+3 ;
+4 ;SDENDDATE input parameter validation
SET HASENDDATEERRORS=$$VALIDATEENDDATE(.ERRORS,SDENDDATE)
+5 IF HASENDDATEERRORS
MERGE RETURNERROR=ERRORS
+6 QUIT
+7 ;
VALIDATEBEGDATE(ERRORS,SDBEGDATE) ;Validate Beginning Date
+1 NEW ERRORFLAG
+2 IF $GET(SDBEGDATE)=""
DO ERRLOG^SDESJSON(.ERRORS,25)
SET ERRORFLAG=1
QUIT $GET(ERRORFLAG)
+3 SET ERRORFLAG=$$VALIDATEBEGDT^SDESPRINTPATAPPT(.ERRORS,SDBEGDATE)
+4 QUIT $GET(ERRORFLAG)
+5 ;
VALIDATEENDDATE(ERRORS,SDENDDATE) ;Validate Ending Date
+1 NEW ERRORFLAG
+2 IF SDENDDATE=""
DO ERRLOG^SDESJSON(.ERRORS,26)
SET ERRORFLAG=1
QUIT $GET(ERRORFLAG)
+3 SET ERRORFLAG=$$VALIDATEENDDT^SDESPRINTPATAPPT(.ERRORS,SDENDDATE)
+4 QUIT $GET(ERRORFLAG)
+5 ;
VALIDATEEAS(ERRORS,EAS) ;
+1 IF $LENGTH(EAS)
SET EAS=$$EASVALIDATE^SDESUTIL($GET(EAS))
+2 IF $PIECE($GET(EAS),U)=-1
DO ERRLOG^SDESJSON(.ERRORS,142)
QUIT 1
+3 QUIT 0
+4 ;
BUILDJSON(RETURNJSON,INPUT) ; Build JSON format
+1 NEW JSONERROR
+2 SET JSONERROR=""
+3 DO ENCODE^XLFJSON("RETURNJSON","INPUT","JSONERROR")
+4 QUIT
+5 ;
CLEANUP ;
+1 KILL RETURNERROR,SDALLAPPTARY,SDBEG,SDEND,ERRORFLAG,HASDFNERRORS,HASCLINIENERRORS,ERRORS
+2 KILL SDMSG,FOUND,ERR,SDCLINICIEN,SDDFN,SDVIEWAPPTBY,HASBEGDATEERRORS,HASENDDATEERRORS,STARTTIME
+3 QUIT
+4 ;
INITVARBYDFN ;initialized input parameter for SDES GET APPTS BY PATIENT DFN3 RPC
+1 SET DFN=$GET(DFN)
+2 SET SDBEGDATE=$GET(SDBEGDATE)
+3 SET SDENDDATE=$GET(SDENDDATE)
+4 SET SDEAS=$GET(SDEAS)
+5 QUIT
+6 ;
INITVARBYCLNIEN ;initialized input parameter for SDES GET APPTS BY CLIN IEN 3 RPC
+1 SET CLINICIEN=$GET(CLINICIEN)
+2 SET SDBEGDATE=$GET(SDBEGDATE)
+3 SET SDENDDATE=$GET(SDENDDATE)
+4 SET SDEAS=$GET(SDEAS)
+5 QUIT
+6 ;
INITVARBYIEN ;initialized input parameter for SDES GET APPTS BY IEN 2 RPC
+1 SET SDAPPTIEN=$GET(SDAPPTIEN)
+2 SET SDEAS=$GET(SDEAS)
+3 QUIT
+4 ;