SDESGETAPPTWRAP2 ;ALB/RRM,MGD - RPC WRAPPER FOR VIEWING AN APPOINTMENT ;JULY 5, 2022
;;5.3;Scheduling;**815,820**;Aug 13, 1993;Build 10
;;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.
;
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
;
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
;
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
;
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^SDESGETAPPTWRAP3(.SDALLAPPTARY,SDPOINTERIEN,SDBEGDATE,SDENDDATE,SDAPPTIEN,RECNUM,SDVIEWAPPTBY) ;view appointment using DFN of the patient OR using Appointment IEN
I $G(SDVIEWAPPTBY)=1 D GETAPPT44^SDESGETAPPTWRAP3(.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
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESGETAPPTWRAP2 10582 printed Oct 16, 2024@18:57:06 Page 2
SDESGETAPPTWRAP2 ;ALB/RRM,MGD - RPC WRAPPER FOR VIEWING AN APPOINTMENT ;JULY 5, 2022
+1 ;;5.3;Scheduling;**815,820**;Aug 13, 1993;Build 10
+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 ;
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 ;DFN input parameter validation
SET HASDFNERRORS=$$VALIDATEPTDFN(.ERRORS,$GET(DFN))
+20 IF HASDFNERRORS
MERGE RETURNERROR=ERRORS
+21 ;
+22 if $GET(SDBEGDATE)'=""
SET SDBEGDATE=$$ISOTFM^SDAMUTDT(SDBEGDATE)
+23 if $GET(SDENDDATE)'=""
SET SDENDDATE=$$ISOTFM^SDAMUTDT(SDENDDATE)
+24 ;beginning and ending date input parameter validation
DO INPUTDATEVAL($GET(SDBEGDATE),$GET(SDENDDATE))
+25 ;
+26 SET HASEASERRORS=$$VALIDATEEAS(.ERRORS,$GET(SDEAS))
+27 IF HASEASERRORS
MERGE RETURNERROR=ERRORS
+28 ;
+29 ;do not continue, errors detected
IF $ORDER(RETURNERROR("Error",""))'=""
SET RETURNERROR("Appointment",1)=""
DO BUILDJSON(.RETURNERROR,.RETURNJSON)
QUIT
+30 ;
+31 ;view appointment using DFN of the patient from Patient File #2
SET (SDVIEWAPPTBY,SDAPPTNO)=0
+32 DO GETAPPOINTMENTS(.SDALLAPPTARY,DFN,SDBEGDATE,SDENDDATE,SDVIEWAPPTBY)
+33 DO BUILDJSON(.SDALLAPPTARY,.RETURNJSON)
+34 DO CLEANUP
+35 QUIT
+36 ;
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 ;CLINICIEN input parameter validation
SET HASCLINIENERRORS=$$VALIDATECLINIC(.ERRORS,$GET(CLINICIEN))
+20 IF HASCLINIENERRORS
MERGE RETURNERROR=ERRORS
+21 ;
+22 if $GET(SDBEGDATE)'=""
SET SDBEGDATE=$$ISOTFM^SDAMUTDT(SDBEGDATE)
+23 if $GET(SDENDDATE)'=""
SET SDENDDATE=$$ISOTFM^SDAMUTDT(SDENDDATE)
+24 ;beginning and ending date input parameter validation
DO INPUTDATEVAL($GET(SDBEGDATE),$GET(SDENDDATE))
+25 ;
+26 SET HASEASERRORS=$$VALIDATEEAS(.ERRORS,$GET(SDEAS))
+27 IF HASEASERRORS
MERGE RETURNERROR=ERRORS
+28 ;
+29 ;do not continue, errors detected
IF $ORDER(RETURNERROR("Error",""))'=""
SET RETURNERROR("Appointment",1)=""
DO BUILDJSON(.RETURNERROR,.RETURNJSON)
QUIT
+30 ;
+31 ;view appointment using CLINIC IEN from Hospital Location File #44
SET SDVIEWAPPTBY=1
+32 DO GETAPPOINTMENTS(.SDALLAPPTARY,CLINICIEN,SDBEGDATE,SDENDDATE,SDVIEWAPPTBY)
+33 DO BUILDJSON(.SDALLAPPTARY,.RETURNJSON)
+34 DO CLEANUP
+35 QUIT
+36 ;
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 ;CLINICIEN input parameter validation
SET HASAPPTIENERRORS=$$VALIDATEAPPTIEN(.ERRORS,$GET(SDAPPTIEN))
+18 IF HASAPPTIENERRORS
MERGE RETURNERROR=ERRORS
+19 ;
+20 SET HASEASERRORS=$$VALIDATEEAS(.ERRORS,$GET(SDEAS))
+21 IF HASEASERRORS
MERGE RETURNERROR=ERRORS
+22 ;
+23 ;do not continue,errors detected
IF $ORDER(RETURNERROR("Error",""))'=""
SET RETURNERROR("Appointment",1)=""
DO BUILDJSON(.RETURNERROR,.RETURNJSON)
QUIT
+24 ;
+25 ;view appointment using APPOINTMENT IEN from SDEC APPOINTMENT File #409.84
SET SDVIEWAPPTBY=2
+26 SET DFN=$$GET1^DIQ(409.84,SDAPPTIEN,.05,"I")
+27 SET SDBEGDATE=$$GET1^DIQ(409.84,SDAPPTIEN,.01,"I")
+28 SET SDENDDATE=$$GET1^DIQ(409.84,SDAPPTIEN,.02,"I")
+29 DO GETAPPOINTMENTS(.SDALLAPPTARY,DFN,SDBEGDATE,SDENDDATE,SDVIEWAPPTBY,SDAPPTIEN)
+30 DO BUILDJSON(.SDALLAPPTARY,.RETURNJSON)
+31 DO CLEANUP
+32 QUIT
+33 ;
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^SDESGETAPPTWRAP3(.SDALLAPPTARY,SDPOINTERIEN,SDBEGDATE,SDENDDATE,SDAPPTIEN,RECNUM,SDVIEWAPPTBY)
+17 ;view appointment using Clinic IEN
IF $GET(SDVIEWAPPTBY)=1
DO GETAPPT44^SDESGETAPPTWRAP3(.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 ;