GMTSPNJ ;SLC/JER - Nightly Job to Queue HS Batch Print-by-Loc ; 08/27/2002
;;2.7;Health Summary;**5,56**;Oct 20, 1995
;
; External References
; DBIA 10000 C^%DTC
; DBIA 10000 NOW^%DTC
; DBIA 10063 ^%ZTLOAD
; DBIA 10006 ^DIC
; DBIA 2051 FIND^DIC
; DBIA 10103 $$DOW^XLFDT
;
; Sets GMTSSC=location pointer
; If clinic, sets GMTSCDT=desired appt day
;
; Summaries are considered ready Today if GMTSPNJ
; run time is today between 24:00 and 12:00, ready
; Tomorrow if run time is today between 12:00 and
; 24:00.
;
MAIN ; Controls branching
N GMTSTYP,GMTSCL,GMW,X
S GMTSTYP=0 F S GMTSTYP=$O(^GMT(142,GMTSTYP)) Q:+GMTSTYP'>0 D
. S GMTSCL=0 F S GMTSCL=$O(^GMT(142,GMTSTYP,20,GMTSCL)) Q:+GMTSCL'>0 D QUEUE
Q
QUEUE ; Queues HS batch print for HS Type and Location
N DIC,GMPSAP,GMTSLOC,GMTSSC,GMTSIO,GMTSDYS,GMV,QUEQIT,X,Y,DAY,NEWDAY
N GMTSQ,BEGDT,ENDDT,PDATE
S QUEQIT=0
S GMTSLOC=$G(^GMT(142,GMTSTYP,20,GMTSCL,0))
S X=+GMTSLOC,DIC=44,DIC(0)="NXZ" D ^DIC
I $S(+Y'>0:1,"WCOR"'[$P($G(Y(0)),U,3):1,1:0) Q
S GMTSSC=Y_U_$P(Y(0),U,3)
I "COR"[$P(GMTSSC,U,3) D Q
. S DAY=+$P(GMTSLOC,U,4)
. ; Don't print in advance
. I DAY'>0 S $P(GMTSSC,U,4)=$$GETDATE(DAY) D QCONT Q
. S BEGDT=$$GETDATE(0),ENDDT=$$GETDATE(DAY)
. Q:$$NONWDAY(BEGDT)
. S NEWDAY=$$WKEND(DAY,BEGDT,ENDDT)
. ; Get last date to be printed
. S PDATE=$$GETDATE(+NEWDAY)
. F D Q:+$G(GMTSQ)
. . ; Set variable before doing QCONT
. . S $P(GMTSSC,U,4)=PDATE
. . D QCONT
. . ; Decrement to get previous day
. . S NEWDAY=NEWDAY-1
. . ; Quit For Loop when non-workdays data has been printed
. . I DAY>NEWDAY S GMTSQ=1 Q
. . ; Get date
. . S PDATE=$$GETDATE(+NEWDAY)
. . ; Quit For Loop if there's a work
. . ; day between Holiday and Weekend.
. . ; Don't print weekend data twice.
. . I +$$NONWDAY(PDATE)'>0 S GMTSQ=1 Q
;
QCONT ; Used so following can be done for
; multiple dates for Clinics and ORs.
I $$CKPAT^GMTSPD(GMTSSC)'>0 Q
S GMPSAP=$S($P(GMTSLOC,U,3)="Y":1,1:0)
S ZTIO=$$GETIO($P(GMTSLOC,U,2)) Q:'$L(ZTIO)
S ZTDTH=$H,ZTRTN="MAIN^GMTSPL",ZTDESC="Health Summary"
F GMV="GMTSTYP","GMTSSC","GMPSAP" S ZTSAVE(GMV)=""
D ^%ZTLOAD
Q
;
GETDATE(DAYS) ; Gets desired Visit/Surgery date
; Receives: DAYS=Print Days ahead
; Returns: FileMan Date/time
N %,%H,%I,%T,GMTSDT,GMTSPM,X1,X2,X
D NOW^%DTC S GMTSDT=$P(%,"."),GMTSPM=$S(+$E($P(%,".",2),1,2)>12:1,1:0)
S X1=GMTSDT,X2=DAYS+GMTSPM D C^%DTC
Q X
;
NONWDAY(GMTSDT) ; Determines if non work day (i.e. Sat., Sun., or Holiday)
; Returns 1 if print day is weekend or holiday
N DAYNAME
S DAYNAME=$$DOW^XLFDT(GMTSDT)
Q $S(DAYNAME="Saturday":1,DAYNAME="Sunday":1,$$HOLIDAY(GMTSDT):1,1:0)
;
WKEND(DAY,BEGDT,ENDDT) ; Updates days in advance for weekend and holiday dates
N GMI,X1,X2,X,%H,DAYNAME
F GMI=1:1 S X1=BEGDT,X2=GMI D C^%DTC Q:X>ENDDT D
. S DAYNAME=$$DOW^XLFDT(X)
. I DAYNAME="Saturday"!(DAYNAME="Sunday")!($$HOLIDAY(X)) S DAY=DAY+1,ENDDT=$$GETDATE(DAY)
. ; If one of days is Saturday, Sunday, or holiday,
. ; up days by one and recalculate ending date
Q DAY
;
HOLIDAY(GMDT) ; Determines if a date is a Holiday.
; Requires that the Holiday (#40.5) file is updated
; to determine if a date is a holiday.
N GMDATE
D FIND^DIC(40.5,"",.01,"QX",GMDT,1,"","","","GMDATE")
Q +$G(GMDATE("DILIST",0))
;
GETIO(X) ; Get device for queueing
N %,%Y,C,DIC,Y
S DIC=3.5,DIC(0)="NXZ" D ^DIC S Y=$S(+Y'>0:"",1:$P(Y(0),U))
Q Y
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HGMTSPNJ 3749 printed Nov 22, 2024@17:09:30 Page 2
GMTSPNJ ;SLC/JER - Nightly Job to Queue HS Batch Print-by-Loc ; 08/27/2002
+1 ;;2.7;Health Summary;**5,56**;Oct 20, 1995
+2 ;
+3 ; External References
+4 ; DBIA 10000 C^%DTC
+5 ; DBIA 10000 NOW^%DTC
+6 ; DBIA 10063 ^%ZTLOAD
+7 ; DBIA 10006 ^DIC
+8 ; DBIA 2051 FIND^DIC
+9 ; DBIA 10103 $$DOW^XLFDT
+10 ;
+11 ; Sets GMTSSC=location pointer
+12 ; If clinic, sets GMTSCDT=desired appt day
+13 ;
+14 ; Summaries are considered ready Today if GMTSPNJ
+15 ; run time is today between 24:00 and 12:00, ready
+16 ; Tomorrow if run time is today between 12:00 and
+17 ; 24:00.
+18 ;
MAIN ; Controls branching
+1 NEW GMTSTYP,GMTSCL,GMW,X
+2 SET GMTSTYP=0
FOR
SET GMTSTYP=$ORDER(^GMT(142,GMTSTYP))
if +GMTSTYP'>0
QUIT
Begin DoDot:1
+3 SET GMTSCL=0
FOR
SET GMTSCL=$ORDER(^GMT(142,GMTSTYP,20,GMTSCL))
if +GMTSCL'>0
QUIT
DO QUEUE
End DoDot:1
+4 QUIT
QUEUE ; Queues HS batch print for HS Type and Location
+1 NEW DIC,GMPSAP,GMTSLOC,GMTSSC,GMTSIO,GMTSDYS,GMV,QUEQIT,X,Y,DAY,NEWDAY
+2 NEW GMTSQ,BEGDT,ENDDT,PDATE
+3 SET QUEQIT=0
+4 SET GMTSLOC=$GET(^GMT(142,GMTSTYP,20,GMTSCL,0))
+5 SET X=+GMTSLOC
SET DIC=44
SET DIC(0)="NXZ"
DO ^DIC
+6 IF $SELECT(+Y'>0:1,"WCOR"'[$PIECE($GET(Y(0)),U,3):1,1:0)
QUIT
+7 SET GMTSSC=Y_U_$PIECE(Y(0),U,3)
+8 IF "COR"[$PIECE(GMTSSC,U,3)
Begin DoDot:1
+9 SET DAY=+$PIECE(GMTSLOC,U,4)
+10 ; Don't print in advance
+11 IF DAY'>0
SET $PIECE(GMTSSC,U,4)=$$GETDATE(DAY)
DO QCONT
QUIT
+12 SET BEGDT=$$GETDATE(0)
SET ENDDT=$$GETDATE(DAY)
+13 if $$NONWDAY(BEGDT)
QUIT
+14 SET NEWDAY=$$WKEND(DAY,BEGDT,ENDDT)
+15 ; Get last date to be printed
+16 SET PDATE=$$GETDATE(+NEWDAY)
+17 FOR
Begin DoDot:2
+18 ; Set variable before doing QCONT
+19 SET $PIECE(GMTSSC,U,4)=PDATE
+20 DO QCONT
+21 ; Decrement to get previous day
+22 SET NEWDAY=NEWDAY-1
+23 ; Quit For Loop when non-workdays data has been printed
+24 IF DAY>NEWDAY
SET GMTSQ=1
QUIT
+25 ; Get date
+26 SET PDATE=$$GETDATE(+NEWDAY)
+27 ; Quit For Loop if there's a work
+28 ; day between Holiday and Weekend.
+29 ; Don't print weekend data twice.
+30 IF +$$NONWDAY(PDATE)'>0
SET GMTSQ=1
QUIT
End DoDot:2
if +$GET(GMTSQ)
QUIT
End DoDot:1
QUIT
+31 ;
QCONT ; Used so following can be done for
+1 ; multiple dates for Clinics and ORs.
+2 IF $$CKPAT^GMTSPD(GMTSSC)'>0
QUIT
+3 SET GMPSAP=$SELECT($PIECE(GMTSLOC,U,3)="Y":1,1:0)
+4 SET ZTIO=$$GETIO($PIECE(GMTSLOC,U,2))
if '$LENGTH(ZTIO)
QUIT
+5 SET ZTDTH=$HOROLOG
SET ZTRTN="MAIN^GMTSPL"
SET ZTDESC="Health Summary"
+6 FOR GMV="GMTSTYP","GMTSSC","GMPSAP"
SET ZTSAVE(GMV)=""
+7 DO ^%ZTLOAD
+8 QUIT
+9 ;
GETDATE(DAYS) ; Gets desired Visit/Surgery date
+1 ; Receives: DAYS=Print Days ahead
+2 ; Returns: FileMan Date/time
+3 NEW %,%H,%I,%T,GMTSDT,GMTSPM,X1,X2,X
+4 DO NOW^%DTC
SET GMTSDT=$PIECE(%,".")
SET GMTSPM=$SELECT(+$EXTRACT($PIECE(%,".",2),1,2)>12:1,1:0)
+5 SET X1=GMTSDT
SET X2=DAYS+GMTSPM
DO C^%DTC
+6 QUIT X
+7 ;
NONWDAY(GMTSDT) ; Determines if non work day (i.e. Sat., Sun., or Holiday)
+1 ; Returns 1 if print day is weekend or holiday
+2 NEW DAYNAME
+3 SET DAYNAME=$$DOW^XLFDT(GMTSDT)
+4 QUIT $SELECT(DAYNAME="Saturday":1,DAYNAME="Sunday":1,$$HOLIDAY(GMTSDT):1,1:0)
+5 ;
WKEND(DAY,BEGDT,ENDDT) ; Updates days in advance for weekend and holiday dates
+1 NEW GMI,X1,X2,X,%H,DAYNAME
+2 FOR GMI=1:1
SET X1=BEGDT
SET X2=GMI
DO C^%DTC
if X>ENDDT
QUIT
Begin DoDot:1
+3 SET DAYNAME=$$DOW^XLFDT(X)
+4 IF DAYNAME="Saturday"!(DAYNAME="Sunday")!($$HOLIDAY(X))
SET DAY=DAY+1
SET ENDDT=$$GETDATE(DAY)
+5 ; If one of days is Saturday, Sunday, or holiday,
+6 ; up days by one and recalculate ending date
End DoDot:1
+7 QUIT DAY
+8 ;
HOLIDAY(GMDT) ; Determines if a date is a Holiday.
+1 ; Requires that the Holiday (#40.5) file is updated
+2 ; to determine if a date is a holiday.
+3 NEW GMDATE
+4 DO FIND^DIC(40.5,"",.01,"QX",GMDT,1,"","","","GMDATE")
+5 QUIT +$GET(GMDATE("DILIST",0))
+6 ;
GETIO(X) ; Get device for queueing
+1 NEW %,%Y,C,DIC,Y
+2 SET DIC=3.5
SET DIC(0)="NXZ"
DO ^DIC
SET Y=$SELECT(+Y'>0:"",1:$PIECE(Y(0),U))
+3 QUIT Y