Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: SDESPRINTPATAPPT

SDESPRINTPATAPPT.m

Go to the documentation of this file.
SDESPRINTPATAPPT ;ALB/LAB,MGD - SDES Print basic appointments ;July 5, 2022
 ;;5.3;Scheduling;**813,820**;Aug 13, 1993;Build 10
 ;;Per VHA Directive 6402, this routine should not be modified
 ;
 ; SDDFN (REQUIRED) = DFN OF THE PATIENT
 Q
 ;
PRINTPATAPPTS(SDPATIENTAPPTS,SDDFN,SDBEG,SDEND,EAS) ; PRINT PATIENT APPOINTMENTS
 N HASDFNERRORS,HASBEGDTERRORS,HASENDDTERRORS,HASERRORS,HASEASERRORS,ERRORS,SDAPPOINTARRAY,PRINTFIELDS,RETURN
 S (RETURN,HASERRORS,PRINTFIELDS)=""
 ;
 S HASDFNERRORS=$$VALIDATEPTDFN(.ERRORS,SDDFN)
 I HASDFNERRORS M RETURN=ERRORS
 ;
 S HASBEGDTERRORS=$$VALIDATEBEGDT(.ERRORS,SDBEG)
 I HASBEGDTERRORS M RETURN=ERRORS
 ;
 S HASENDDTERRORS=$$VALIDATEENDDT(.ERRORS,SDEND)
 I HASENDDTERRORS M RETURN=ERRORS
 ;
 S HASEASERRORS=$$VALIDATEEAS(.ERRORS,EAS)
 I HASEASERRORS M RETURN=ERRORS
 ;
 I '$D(ERRORS) D
 . S PRINTFIELDS=$$GETAPPOINTMENTS(.SDAPPOINTARRAY,SDDFN,SDBEG,SDEND)
 . I PRINTFIELDS M RETURN=SDAPPOINTARRAY
 ;
 D BUILDJSON(.SDPATIENTAPPTS,.RETURN)
 Q
 ;
VALIDATEPTDFN(ERRORS,SDDFN) ;Validate Patient DFN
 N ERRORFLAG
 I SDDFN="" D
 .S ERRORFLAG=1 D ERRLOG^SDESJSON(.ERRORS,1)
 .S RETURN("PatientAppointments",1)=""
 I SDDFN'="",('$D(^DPT(SDDFN,0))) D
 .S ERRORFLAG=1 D ERRLOG^SDESJSON(.ERRORS,2)
 .S RETURN("PatientAppointments",1)=""
 Q $D(ERRORFLAG)
 ;
VALIDATEBEGDT(ERRORS,SDBEG) ;Validate Begin date - converted in SDES so -1 if invalid
 N ERRORFLAG
 I SDBEG=-1 D
 .S ERRORFLAG=1 D ERRLOG^SDESJSON(.ERRORS,11)
 .S RETURN("PatientAppointments",1)=""
 Q $D(ERRORFLAG)
 ;
VALIDATEENDDT(ERRORS,SDEND) ;validate End date - converted in SDES so -1 if invalid
 N ERRORFLAG
 I SDEND=-1 D
 .S ERRORFLAG=1 D ERRLOG^SDESJSON(.ERRORS,12)
 .S RETURN("PatientAppointments",1)=""
 Q $D(ERRORFLAG)
 ;
VALIDATEEAS(ERRORS,EAS) ;Validate EAS Tracking number
 N ERRORFLAG
 S EAS=$G(EAS,"")
 I $L(EAS) S EAS=$$EASVALIDATE^SDESUTIL(EAS)
 I EAS=-1 D
 .S ERRORFLAG=1 D ERRLOG^SDESJSON(.ERRORS,142)
 .S RETURN("PatientAppointments",1)=""
 Q $D(ERRORFLAG)
 ;
GETAPPOINTMENTS(SDPATIENTAPPTS,SDDFN,SDBEGIN,SDEND) ;select appointments
 N SDAPPTIEN,DISPLAY,SDCANCELDT,COUNT,SDRESOURCE,SDAPPTDTTIM,SDAPPTDTTIME,SDTIMEZONE,SDCLINIC,SDRESOURCENAME
 N SDNOSHOWDT
 S SDAPPTIEN=0,DISPLAY=1,SDCANCELDT="",COUNT=0
 F  S SDAPPTIEN=$O(^SDEC(409.84,"CPAT",SDDFN,SDAPPTIEN)) Q:SDAPPTIEN=""  D
 . S SDAPPTDTTIM=$$GET1^DIQ(409.84,SDAPPTIEN,.01,"I")
 . Q:(SDBEGIN>SDAPPTDTTIM)!(SDAPPTDTTIM>SDEND)
 . ;
 . S SDCANCELDT=$$GET1^DIQ(409.84,SDAPPTIEN,.12,"I")
 . S SDNOSHOWDT=$$GET1^DIQ(409.84,SDAPPTIEN,.101,"I")
 . Q:(+SDCANCELDT)!(+SDNOSHOWDT)
 . ;
 . S SDRESOURCE=$$GET1^DIQ(409.84,SDAPPTIEN,.07,"I")
 . S SDCLINIC=$$GET1^DIQ(409.831,SDRESOURCE,.04,"I")
 . S DISPLAY=$$GET1^DIQ(44,SDCLINIC,62,"I")
 . Q:(DISPLAY'="Y")
 . ;
 . S SDTIMEZONE=$$TIMEZONEDATA^SDESUTIL($G(SDCLINIC)),SDTIMEZONE=$P($G(SDTIMEZONE),U)
 . S SDRESOURCENAME=$$GET1^DIQ(409.84,SDAPPTIEN,.07,"E")
 . S SDAPPTDTTIME=$$FMTISO^SDAMUTDT(SDAPPTDTTIM,SDCLINIC)
 . ;
 . S COUNT=COUNT+1
 . S SDPATIENTAPPTS("PatientAppointments",COUNT,"AppointDateTime")=SDAPPTDTTIME
 . S SDPATIENTAPPTS("PatientAppointments",COUNT,"TimeZone")=SDTIMEZONE
 . S SDPATIENTAPPTS("PatientAppointments",COUNT,"Clinic")=SDRESOURCENAME
 I COUNT=0 D
 . S SDPATIENTAPPTS("PatientAppointments",1)=""
 . S COUNT=1
 Q COUNT
 ;
BUILDJSON(JSONRETURN,INPUT) ;
 N JSONERROR
 S JSONERROR=""
 D ENCODE^XLFJSON("INPUT","JSONRETURN","JSONERROR")
 Q
 ;