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

SDESGETCLNSCHEDS.m

Go to the documentation of this file.
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
 ;