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

SDESGETAPPTRPCS.m

Go to the documentation of this file.
SDESGETAPPTRPCS ;ALB/LAB - VISTA SCHEDULING RPCS TO GET APPOINTMENTS ;MAY 10,2024
 ;;5.3;Scheduling;**880**;Aug 13, 1993;Build 5
 ;;Per VHA Directive 6402, this routine should not be modified
 ;
 Q
 ;
BYPATDFN(RESULT,DFN,SDBEGDATE,SDENDDATE,SDEAS) ;RPC: SDES GET APPTS BY PATIENT DFN3
 N RECCNT,APPTDATE,APPTIEN,ERRORS,APPTOBJ
 D VALIDATEBYDFN(.ERRORS,DFN,.SDBEGDATE,.SDENDDATE,.SDEAS)
 I $D(ERRORS) S ERRORS("Appointment",1)="" D BUILDJSON^SDES2JSON(.RESULT,.ERRORS) Q
 S APPTDATE=SDBEGDATE-.0001
 S RECCNT=0
 F  S APPTDATE=$O(^SDEC(409.84,"APTDT",DFN,APPTDATE)) Q:(APPTDATE>SDENDDATE)!(APPTDATE="")   D
 . S APPTIEN=""
 . F  S APPTIEN=$O(^SDEC(409.84,"APTDT",DFN,APPTDATE,APPTIEN)) Q:APPTIEN=""  D
 . . S RECCNT=RECCNT+1
 . . D BUILDAPPTOBJ^SDES2BLDAPPTOBJ(.APPTOBJ,APPTIEN,RECCNT,.ERRORS,DUZ)
 I $D(ERRORS) M ERRORS=APPTOBJ D BUILDJSON^SDES2JSON(.RESULT,.ERRORS) Q
 S:'$D(APPTOBJ) APPTOBJ("Appointment",1)=""
 D BUILDJSON^SDES2JSON(.RESULT,.APPTOBJ)
 Q
 ;
VALIDATEBYDFN(ERRORS,DFN,SDBEGDATE,SDENDDATE,SDEAS) ;
 D VALFILEIEN^SDES2VALUTIL(,.ERRORS,2,$G(DFN),1,,1,2)
 S SDBEGDATE=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,SDBEGDATE,,1,9,11)
 S SDENDDATE=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,SDENDDATE,,1,10,12)
 S SDEAS=$G(SDEAS)
 I $L(SDEAS) S SDEAS=$$EASVALIDATE^SDESUTIL($G(SDEAS))
 I $P($G(SDEAS),U)=-1 D ERRLOG^SDESJSON(.ERRORS,142)
 Q
 ;
BYCLINIEN(RESULT,CLINICIEN,SDBEGDATE,SDENDDATE,SDEAS) ;Called from the RPC: SDES GET APPTS BY CLIN IEN
 N ERRORS,RESOURCEIEN,APPTIEN,APPTOBJ,RECCNT,APPTDATE
 D VALIDATEBYCLIN(.ERRORS,.CLINICIEN,.SDBEGDATE,.SDENDDATE)
 I $D(ERRORS) S ERRORS("Appointment",1)="" D BUILDJSON^SDES2JSON(.RESULT,.ERRORS) Q
 S RESOURCEIEN=$$GETRES^SDES2UTIL1(CLINICIEN,1)
 I RESOURCEIEN="" D ERRLOG^SDES2JSON(.ERRORS,52,"Clinic is missing a resourceIEN")
 I $D(ERRORS) S ERRORS("Appointment",1)="" D BUILDJSON^SDES2JSON(.RESULT,.ERRORS) Q
 ;add error if resource not found
 S APPTDATE=SDBEGDATE-.0001
 S RECCNT=0
 F  S APPTDATE=$O(^SDEC(409.84,"ARSRC",RESOURCEIEN,APPTDATE)) Q:(APPTDATE>SDENDDATE)!(APPTDATE="")   D
 . S APPTIEN=""
 . F  S APPTIEN=$O(^SDEC(409.84,"ARSRC",RESOURCEIEN,APPTDATE,APPTIEN)) Q:APPTIEN=""  D
 . . S RECCNT=RECCNT+1
 . . D BUILDAPPTOBJ^SDES2BLDAPPTOBJ(.APPTOBJ,APPTIEN,RECCNT,.ERRORS,DUZ)
 I $D(ERRORS) M ERRORS=APPTOBJ D BUILDJSON^SDES2JSON(.RESULT,.ERRORS) Q
 S:'$D(APPTOBJ) APPTOBJ("Appointment",1)=""
 D BUILDJSON^SDES2JSON(.RESULT,.APPTOBJ)
 Q
 ;
VALIDATEBYCLIN(ERRORS,CLINICIEN,SDBEGDATE,SDENDDATE) ;
 ; Validate Clinic IEN
 D VALFILEIEN^SDES2VALUTIL(,.ERRORS,44,$G(CLINICIEN),1,0,18,19)
 S SDBEGDATE=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,$G(SDBEGDATE),$G(CLINICIEN),1,9,11)
 S SDENDDATE=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,$G(SDENDDATE),$G(CLINICIEN),1,10,12)
 Q:$D(ERRORS)
 I SDBEGDATE>SDENDDATE D ERRLOG^SDESJSON(.ERRORS,13)
 Q
 ;