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

BSDX05.m

Go to the documentation of this file.
BSDX05 ; IHS/OIT/HMW/MSC/SAT - WINDOWS SCHEDULING RPCS ;
 ;;3.0;IHS WINDOWS SCHEDULING;;DEC 09, 2010
 ;
 ;
APBLKOV(BSDXY,BSDXSTART,BSDXEND,BSDXRES,BSDXWI)  ;EP
 ;Called by BSDX APPT BLOCKS OVERLAP
 ;(Duplicates old qryAppointmentBlocksOverlapB)
 ;BSDXRES is resource name
 ;BSDXWI is for walk-in appointments. 1 - Include walkins, otherwise do not include them.
 ;
 ;Test lines:
 ;D APBLKOV^BSDX05(.RES,"11-8-2000","11-8-2004","WHITT") ZW RES
 ;BSDX APPT BLOCKS OVERLAP^11-8-2000^11-8-2004^WHITT
 ;S ^HW("BSDXD05")=BSDXSTART_U_BSDXEND_U_BSDXRES
 ;
 N BSDXERR,BSDXIEN,BSDXDEP,BSDXBS,BSDXI,BSDXNEND,BSDXNSTART,BSDXPEND,BSDXRESD,BSDXRESN,BSDXS,BSDXAD,BSDXNOD,BSDXPAT
 K ^BSDXTMP($J)
 S BSDXERR=""
 S BSDXY="^BSDXTMP("_$J_")"
 S ^BSDXTMP($J,0)="D00030START_TIME^D00030END_TIME^I00010PAT_ID"_$C(30)
 D
 . S BSDXBS=0
 . S:BSDXSTART["@0000" BSDXSTART=$P(BSDXSTART,"@")
 . S:BSDXEND["@0000" BSDXEND=$P(BSDXEND,"@")
 . S %DT="T",X=BSDXSTART D ^%DT S BSDXSTART=Y
 . I BSDXSTART=-1 S ^BSDXTMP($J,1)=$C(31) Q
 . S %DT="T",X=BSDXEND D ^%DT S BSDXEND=Y
 . I BSDXEND=-1 S ^BSDXTMP($J,1)=$C(31) Q
 . I $L(BSDXEND,".")=1 S BSDXEND=BSDXEND+.9999 ;Go to end of day
 . S BSDXRESN=BSDXRES
 . Q:BSDXRESN=""
 . Q:'$D(^BSDXRES("B",BSDXRESN))
 . S BSDXRESD=$O(^BSDXRES("B",BSDXRESN,0))
 . Q:'+BSDXRESD
 . Q:'$D(^BSDXAPPT("ARSRC",BSDXRESD))
 . D STRES(BSDXRESD,BSDXSTART,BSDXEND,$G(BSDXWI))
 . Q
 ;
 S BSDXI=$G(BSDXI)+1
 S ^BSDXTMP($J,BSDXI)=$C(31)
 Q
 ;
APBLKALL(BSDXY,BSDXSTART,BSDXEND) ;EP
 ; List of all appointments for all resources. - BWF/MSC, added 3-1-2010
 ; Called by BSDX ALL APPOINTMENTS
 ;
 ; Input:  BSDXSTART - Start Date
 ;         BSDXEND   - End Date
 ;         
 ;Test Lines:
 ;D APBLKALL^BSDX05(.RES,"11-8-2000","11-8-2004") ZW RES
 ;BSDX ALL APPOINTMENTS^11-8-2000^11-8-2004
 ;
 N BSDXRIEN,BSDXRESN,BSDXI
 S BSDXRIEN=0 F  S BSDXRIEN=$O(^BSDXRES(BSDXRIEN)) Q:'BSDXRIEN  D
 .S BSDXRESN=$$GET1^DIQ(9002018.1,BSDXRIEN,.01,"E")
 .Q:BSDXRESN=""
 .; Call existing API to gather appointments for each resource found
 .D APBLKOV(.BSDXDATA,BSDXSTART,BSDXEND,BSDXRESN,1)
 .D GATHER(BSDXDATA,BSDXRESN)
 .K ^BSDXTMP($J)
 M ^BSDXTMP($J)=^BSDXTMP("BSDX05",$J)
 K ^BSDXTMP("BSDX05",$J)
 S BSDXY="^BSDXTMP("_$J_")"
 S ^BSDXTMP($J,0)="D00030START_TIME^D00030END_TIME^I00010PAT_ID^T00030RES_NAME"_$C(30)
 S BSDXI=$O(^BSDXTMP($J,""),-1),BSDXI=$G(BSDXI)+1
 S ^BSDXTMP($J,BSDXI)=$C(31)
 Q
 ;
GATHER(BSDXDAT,BSDXRESN) ;
 ; Called by APBLKBR to retrieve data gathered for each resource.
 N X,BSDXADAT,BSDXI
 S X=0 F  S X=$O(@BSDXDAT@(X)) Q:'X  D
 .S BSDXADAT=$G(@BSDXDAT@(X)) Q:BSDXADAT=$C(31)
 .S BSDXI=$O(^BSDXTMP("BSDX05",$J,""),-1) S BSDXI=$G(BSDXI)+1
 .S ^BSDXTMP("BSDX05",$J,BSDXI)=$P(BSDXADAT,$C(30))_U_BSDXRESN_$C(30)
 Q
 ;
STRES(BSDXRESD,BSDXSTART,BSDXEND,BSDXWI) ;
 ;$O THRU "ARSRC" XREF OF ^BSDXAPPT
 ;Start at the beginning of the day -- appts can't overlap days
 S BSDXS=$P(BSDXSTART,"."),BSDXS=BSDXS-.0001
 S BSDXI=0
 F  S BSDXS=$O(^BSDXAPPT("ARSRC",BSDXRESD,BSDXS)) Q:'+BSDXS  Q:BSDXS>BSDXEND  D
 . S BSDXAD=0 F  S BSDXAD=$O(^BSDXAPPT("ARSRC",BSDXRESD,BSDXS,BSDXAD)) Q:'+BSDXAD  D STCOMM(BSDXAD,$G(BSDXWI)) ;BSDXAD Is the AppointmentID
 . Q
 Q
 ;
STCOMM(BSDXAD,BSDXWI) ;
 S BSDXNEND=0,BSDXNSTART=0,BSDXPEND=0
 Q:'$D(^BSDXAPPT(BSDXAD,0))
 S BSDXNOD=^BSDXAPPT(BSDXAD,0)
 S BSDXPAT=$P(BSDXNOD,U,5)
 Q:$P(BSDXNOD,U,10)=1  ;NO-SHOW Flag
 Q:$P(BSDXNOD,U,12)]""  ;CANCELLED APPT
 I '$G(BSDXWI) Q:$P(BSDXNOD,U,13)="y"  ;WALKIN
 S BSDXNSTART=$P(BSDXNOD,U)
 S BSDXNEND=$P(BSDXNOD,U,2)
 I BSDXNEND'>BSDXSTART Q  ;End is less than start
 S Y=BSDXNSTART X ^DD("DD") S BSDXNSTART=$TR(Y,"@"," ")
 S Y=BSDXNEND X ^DD("DD") S BSDXNEND=$TR(Y,"@"," ")
 S BSDXI=BSDXI+1
 S ^BSDXTMP($J,BSDXI)=BSDXNSTART_U_BSDXNEND_U_BSDXPAT_$C(30)
 Q