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

SDES2BLOCKPBSP.m

Go to the documentation of this file.
SDES2BLOCKPBSP ;ALB/BLB - SDES2 BLOCK PBSP CLINIC AVAIL; FEB 27 2024  11:30 AM
 ;;5.3;Scheduling;**875**;Aug 13, 1993;Build 25
 ;;Per VHA Directive 6402, this routine should not be modified
 ;
 Q
 ;
BLOCK(JSON,SDCONTEXT,BLOCK) ;
 N ERRORS,PBSPID,STARTDATETIME,ENDDATETIME,CLINICIENTOSKIP,RETURN
 ;
 D POPULATE(.BLOCK,.PBSPID,.STARTDATETIME,.ENDDATETIME,.CLINICIENTOSKIP)
 D VALIDATE(.ERRORS,.SDCONTEXT,$G(PBSPID),$G(STARTDATETIME),$G(ENDDATETIME),$G(CLINICIENTOSKIP))
 I $D(ERRORS) S ERRORS("BlockPBSPID")="" D BUILDJSON^SDES2JSON(.JSON,.ERRORS) Q
 ;
 D BLOCKSLOTS(PBSPID,STARTDATETIME,ENDDATETIME,CLINICIENTOSKIP,.SDCONTEXT)
 S RETURN("BlockPBSPID")=1
 D BUILDJSON^SDES2JSON(.JSON,.RETURN)
 Q
 ;
BLOCKSLOTS(PBSPID,STARTDATETIME,ENDDATETIME,CLINICIENTOSKIP,SDCONTEXT) ;
 N CLINICIEN,CANCEL,CANCELJSON
 ;
 S CLINICIEN=0
 F  S CLINICIEN=$O(^SC("PBSP",PBSPID,CLINICIEN)) Q:'CLINICIEN  D
 .I CLINICIEN=CLINICIENTOSKIP Q
 .S CANCEL("CLINIC IEN")=CLINICIEN
 .S CANCEL("FULL PARTIAL FLAG")="P"
 .S CANCEL("START DATE TIME")=STARTDATETIME
 .S CANCEL("END DATE TIME")=ENDDATETIME
 .D CANCEL^SDES2CANCLNAVAIL(.CANCELJSON,.SDCONTEXT,.CANCEL)
 Q
 ;
APPTEXISTSINSLOT(PBSPID,STARTDATETIME,ENDDATETIME,CLINICIENTOSKIP) ;
 N DATETIME,FOUND,SUBIEN,CLINICIEN
 ;
 S CLINICIEN=0,FOUND=0
 F  S CLINICIEN=$O(^SC("PBSP",PBSPID,CLINICIEN)) Q:'CLINICIEN  D
 .I CLINICIEN=CLINICIENTOSKIP Q
 .S DATETIME=STARTDATETIME-.0001
 .F  S DATETIME=$O(^SC(CLINICIEN,"S",DATETIME)) Q:'DATETIME!(FOUND)!(DATETIME>ENDDATETIME)  D
 ..S SUBIEN=0
 ..F  S SUBIEN=$O(^SC(CLINICIEN,"S",DATETIME,1,SUBIEN)) Q:'SUBIEN!(FOUND)  D
 ...I $$GET1^DIQ(44.003,SUBIEN_","_STARTDATETIME_","_CLINICIEN_",",310,"E")'="CANCELLED" D
 ....S FOUND=1
 Q FOUND
 ;
VALIDATE(ERRORS,SDCONTEXT,PBSPID,STARTDATETIME,ENDDATETIME,CLINICIENTOSKIP) ;
 D VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
 I $D(ERRORS) Q
 ;
 D VALFILEIEN^SDES2VALUTIL(,.ERRORS,44,CLINICIENTOSKIP,1,,18,19)
 ;
 S STARTDATETIME=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,STARTDATETIME,CLINICIENTOSKIP,1,165,166)
 S ENDDATETIME=$$VALISODTTM^SDES2VALISODTTM(.ERRORS,ENDDATETIME,CLINICIENTOSKIP,1,167,168)
 ;
 I '$L($G(PBSPID)) D ERRLOG^SDESJSON(.ERRORS,557) Q
 I '$D(^SC("PBSP",PBSPID)) D ERRLOG^SDESJSON(.ERRORS,556) Q
 I $L(PBSPID)>100 D ERRLOG^SDESJSON(.ERRORS,556)
 I $D(ERRORS) Q
 ;
 I $$APPTEXISTSINSLOT(PBSPID,STARTDATETIME,ENDDATETIME,CLINICIENTOSKIP) D ERRLOG^SDESJSON(.ERRORS,558)
 Q
 ;
POPULATE(BLOCK,PBSPID,STARTDATETIME,ENDDATETIME,CLINICIENTOSKIP) ;
 S PBSPID=$G(BLOCK("PBSPID"))
 S STARTDATETIME=$G(BLOCK("START DATE TIME"))
 S ENDDATETIME=$G(BLOCK("END DATE TIME"))
 S CLINICIENTOSKIP=$G(BLOCK("APPOINTMENT IN CLINIC"))
 Q
 ;