SDESGETCLNSCHEDS ;ALB/BLB - SDES GET AVAIL BY CLIN LIST; Oct 17, 2022@20:49
;;5.3;Scheduling;**838**;Aug 13, 1993;Build 7
;;Per VHA Directive 6402, this routine should not be modified
;
GETSCHEDULES(JSONRETURN,AUDITIEN,CLINICS,STARTDATETIME,ENDDATETIME) ;
N ERRORS,RETURN,SCHEDULES
;
D VALIDATECLINICS(.ERRORS,.CLINICS)
D VALIDATESTART(.ERRORS,STARTDATETIME)
D VALIDATEEND(.ERRORS,ENDDATETIME)
I $D(ERRORS) M RETURN=ERRORS D BUILDJSON(.JSONRETURN,.RETURN) Q
;
D BUILDSCHEDULES(.CLINICS,.SCHEDULES,STARTDATETIME,ENDDATETIME)
;
I '$D(SCHEDULES) S SCHEDULES("ClinicSchedules",1)=""
M RETURN=SCHEDULES D BUILDJSON^SDESBUILDJSON(.JSONRETURN,.RETURN)
Q
;
BUILDSCHEDULES(CLINICS,SCHEDULES,STARTDATETIME,ENDDATETIME) ;
N CLINICCOUNT,CLINICIEN,RESOURCEIEN,SLOTS,SLOTIEN,RET,COUNT
;
S CLINICCOUNT=0,COUNT=0
F S CLINICCOUNT=$O(CLINICS(CLINICCOUNT)) Q:'CLINICCOUNT D
.N SLOTS,RET
.S CLINICIEN=$G(CLINICS(CLINICCOUNT))
.D GETCLAVAILABLTY^SDESCLINICAVAIL(.RET,CLINICIEN,STARTDATETIME,ENDDATETIME),DECODE^XLFJSON("RET","SLOTS")
.;
.;I '$L($G(SLOTS("ClinAvail",1,"BeginTime"))) Q
.S SLOTIEN=0
.S COUNT="",COUNT=$O(SCHEDULES("ClinicSchedules",COUNT),-1)+1
.F S SLOTIEN=$O(SLOTS("ClinAvail",SLOTIEN)) Q:'SLOTIEN D
..S SCHEDULES("ClinicSchedules",COUNT,"ClinicIEN")=CLINICIEN
..S SCHEDULES("ClinicSchedules",COUNT,"ClinicName")=$$GET1^DIQ(44,CLINICIEN,.01,"E")
..S SCHEDULES("ClinicSchedules",COUNT,"Slot",SLOTIEN,"StartTime")=$G(SLOTS("ClinAvail",SLOTIEN,"BeginTime"))
..S SCHEDULES("ClinicSchedules",COUNT,"Slot",SLOTIEN,"EndTime")=$G(SLOTS("ClinAvail",SLOTIEN,"EndTime"))
..S SCHEDULES("ClinicSchedules",COUNT,"Slot",SLOTIEN,"AvailableSlots")=$G(SLOTS("ClinAvail",SLOTIEN,"SlotsAvail"))
Q
;
VALIDATECLINICS(ERRORS,CLINICS) ;
N CLINICIEN,ERRORFOUND,CLINICIEN,CLINICCOUNT
;
I '$D(CLINICS) D ERRLOG^SDESJSON(.ERRORS,18) Q
;
S CLINICCOUNT=0,ERRORFOUND=0
F S CLINICCOUNT=$O(CLINICS(CLINICCOUNT)) Q:'CLINICCOUNT!(ERRORFOUND) D
.S CLINICIEN=$G(CLINICS(CLINICCOUNT))
.I '$D(^SC(CLINICIEN,0)) S ERRORFOUND=1 D ERRLOG^SDESJSON(.ERRORS,19)
;
I CLINICCOUNT>50 D ERRLOG^SDESJSON(.ERRORS,430)
Q
;
VALIDATESTART(ERRORS,STARTDATETIME) ;
N ERRORFLAG
I STARTDATETIME="" D ERRLOG^SDESJSON(.ERRORS,25) Q
I STARTDATETIME'="" D
.S STARTDATETIME=$$ISOTFM^SDAMUTDT(STARTDATETIME)
.I STARTDATETIME=-1!(STARTDATETIME="") D ERRLOG^SDESJSON(.ERRORS,27)
Q
;
VALIDATEEND(ERRORS,ENDDATETIME) ;
N ERRORFLAG
I ENDDATETIME="" D ERRLOG^SDESJSON(.ERRORS,26) Q
I ENDDATETIME'="" D
.S ENDDATETIME=$$ISOTFM^SDAMUTDT(ENDDATETIME)
.I ENDDATETIME=-1!(ENDDATETIME="") D ERRLOG^SDESJSON(.ERRORS,28)
Q
;
BUILDJSON(JSONRETURN,RETURN) ;
D ENCODE^XLFJSON("RETURN","JSONRETURN")
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESGETCLNSCHEDS 2759 printed Dec 13, 2024@02:56:51 Page 2
SDESGETCLNSCHEDS ;ALB/BLB - SDES GET AVAIL BY CLIN LIST; Oct 17, 2022@20:49
+1 ;;5.3;Scheduling;**838**;Aug 13, 1993;Build 7
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
GETSCHEDULES(JSONRETURN,AUDITIEN,CLINICS,STARTDATETIME,ENDDATETIME) ;
+1 NEW ERRORS,RETURN,SCHEDULES
+2 ;
+3 DO VALIDATECLINICS(.ERRORS,.CLINICS)
+4 DO VALIDATESTART(.ERRORS,STARTDATETIME)
+5 DO VALIDATEEND(.ERRORS,ENDDATETIME)
+6 IF $DATA(ERRORS)
MERGE RETURN=ERRORS
DO BUILDJSON(.JSONRETURN,.RETURN)
QUIT
+7 ;
+8 DO BUILDSCHEDULES(.CLINICS,.SCHEDULES,STARTDATETIME,ENDDATETIME)
+9 ;
+10 IF '$DATA(SCHEDULES)
SET SCHEDULES("ClinicSchedules",1)=""
+11 MERGE RETURN=SCHEDULES
DO BUILDJSON^SDESBUILDJSON(.JSONRETURN,.RETURN)
+12 QUIT
+13 ;
BUILDSCHEDULES(CLINICS,SCHEDULES,STARTDATETIME,ENDDATETIME) ;
+1 NEW CLINICCOUNT,CLINICIEN,RESOURCEIEN,SLOTS,SLOTIEN,RET,COUNT
+2 ;
+3 SET CLINICCOUNT=0
SET COUNT=0
+4 FOR
SET CLINICCOUNT=$ORDER(CLINICS(CLINICCOUNT))
if 'CLINICCOUNT
QUIT
Begin DoDot:1
+5 NEW SLOTS,RET
+6 SET CLINICIEN=$GET(CLINICS(CLINICCOUNT))
+7 DO GETCLAVAILABLTY^SDESCLINICAVAIL(.RET,CLINICIEN,STARTDATETIME,ENDDATETIME)
DO DECODE^XLFJSON("RET","SLOTS")
+8 ;
+9 ;I '$L($G(SLOTS("ClinAvail",1,"BeginTime"))) Q
+10 SET SLOTIEN=0
+11 SET COUNT=""
SET COUNT=$ORDER(SCHEDULES("ClinicSchedules",COUNT),-1)+1
+12 FOR
SET SLOTIEN=$ORDER(SLOTS("ClinAvail",SLOTIEN))
if 'SLOTIEN
QUIT
Begin DoDot:2
+13 SET SCHEDULES("ClinicSchedules",COUNT,"ClinicIEN")=CLINICIEN
+14 SET SCHEDULES("ClinicSchedules",COUNT,"ClinicName")=$$GET1^DIQ(44,CLINICIEN,.01,"E")
+15 SET SCHEDULES("ClinicSchedules",COUNT,"Slot",SLOTIEN,"StartTime")=$GET(SLOTS("ClinAvail",SLOTIEN,"BeginTime"))
+16 SET SCHEDULES("ClinicSchedules",COUNT,"Slot",SLOTIEN,"EndTime")=$GET(SLOTS("ClinAvail",SLOTIEN,"EndTime"))
+17 SET SCHEDULES("ClinicSchedules",COUNT,"Slot",SLOTIEN,"AvailableSlots")=$GET(SLOTS("ClinAvail",SLOTIEN,"SlotsAvail"))
End DoDot:2
End DoDot:1
+18 QUIT
+19 ;
VALIDATECLINICS(ERRORS,CLINICS) ;
+1 NEW CLINICIEN,ERRORFOUND,CLINICIEN,CLINICCOUNT
+2 ;
+3 IF '$DATA(CLINICS)
DO ERRLOG^SDESJSON(.ERRORS,18)
QUIT
+4 ;
+5 SET CLINICCOUNT=0
SET ERRORFOUND=0
+6 FOR
SET CLINICCOUNT=$ORDER(CLINICS(CLINICCOUNT))
if 'CLINICCOUNT!(ERRORFOUND)
QUIT
Begin DoDot:1
+7 SET CLINICIEN=$GET(CLINICS(CLINICCOUNT))
+8 IF '$DATA(^SC(CLINICIEN,0))
SET ERRORFOUND=1
DO ERRLOG^SDESJSON(.ERRORS,19)
End DoDot:1
+9 ;
+10 IF CLINICCOUNT>50
DO ERRLOG^SDESJSON(.ERRORS,430)
+11 QUIT
+12 ;
VALIDATESTART(ERRORS,STARTDATETIME) ;
+1 NEW ERRORFLAG
+2 IF STARTDATETIME=""
DO ERRLOG^SDESJSON(.ERRORS,25)
QUIT
+3 IF STARTDATETIME'=""
Begin DoDot:1
+4 SET STARTDATETIME=$$ISOTFM^SDAMUTDT(STARTDATETIME)
+5 IF STARTDATETIME=-1!(STARTDATETIME="")
DO ERRLOG^SDESJSON(.ERRORS,27)
End DoDot:1
+6 QUIT
+7 ;
VALIDATEEND(ERRORS,ENDDATETIME) ;
+1 NEW ERRORFLAG
+2 IF ENDDATETIME=""
DO ERRLOG^SDESJSON(.ERRORS,26)
QUIT
+3 IF ENDDATETIME'=""
Begin DoDot:1
+4 SET ENDDATETIME=$$ISOTFM^SDAMUTDT(ENDDATETIME)
+5 IF ENDDATETIME=-1!(ENDDATETIME="")
DO ERRLOG^SDESJSON(.ERRORS,28)
End DoDot:1
+6 QUIT
+7 ;
BUILDJSON(JSONRETURN,RETURN) ;
+1 DO ENCODE^XLFJSON("RETURN","JSONRETURN")
+2 QUIT
+3 ;