source: FOIAVistA/trunk/r/HEALTH_SUMMARY-GMTS/GMTSPNJ.m@ 811

Last change on this file since 811 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 3.6 KB
Line 
1GMTSPNJ ;SLC/JER - Nightly Job to Queue HS Batch Print-by-Loc ; 08/27/2002
2 ;;2.7;Health Summary;**5,56**;Oct 20, 1995
3 ;
4 ; External References
5 ; DBIA 10000 C^%DTC
6 ; DBIA 10000 NOW^%DTC
7 ; DBIA 10063 ^%ZTLOAD
8 ; DBIA 10006 ^DIC
9 ; DBIA 2051 FIND^DIC
10 ; DBIA 10103 $$DOW^XLFDT
11 ;
12 ; Sets GMTSSC=location pointer
13 ; If clinic, sets GMTSCDT=desired appt day
14 ;
15 ; Summaries are considered ready Today if GMTSPNJ
16 ; run time is today between 24:00 and 12:00, ready
17 ; Tomorrow if run time is today between 12:00 and
18 ; 24:00.
19 ;
20MAIN ; Controls branching
21 N GMTSTYP,GMTSCL,GMW,X
22 S GMTSTYP=0 F S GMTSTYP=$O(^GMT(142,GMTSTYP)) Q:+GMTSTYP'>0 D
23 . S GMTSCL=0 F S GMTSCL=$O(^GMT(142,GMTSTYP,20,GMTSCL)) Q:+GMTSCL'>0 D QUEUE
24 Q
25QUEUE ; Queues HS batch print for HS Type and Location
26 N DIC,GMPSAP,GMTSLOC,GMTSSC,GMTSIO,GMTSDYS,GMV,QUEQIT,X,Y,DAY,NEWDAY
27 N GMTSQ,BEGDT,ENDDT,PDATE
28 S QUEQIT=0
29 S GMTSLOC=$G(^GMT(142,GMTSTYP,20,GMTSCL,0))
30 S X=+GMTSLOC,DIC=44,DIC(0)="NXZ" D ^DIC
31 I $S(+Y'>0:1,"WCOR"'[$P($G(Y(0)),U,3):1,1:0) Q
32 S GMTSSC=Y_U_$P(Y(0),U,3)
33 I "COR"[$P(GMTSSC,U,3) D Q
34 . S DAY=+$P(GMTSLOC,U,4)
35 . ; Don't print in advance
36 . I DAY'>0 S $P(GMTSSC,U,4)=$$GETDATE(DAY) D QCONT Q
37 . S BEGDT=$$GETDATE(0),ENDDT=$$GETDATE(DAY)
38 . Q:$$NONWDAY(BEGDT)
39 . S NEWDAY=$$WKEND(DAY,BEGDT,ENDDT)
40 . ; Get last date to be printed
41 . S PDATE=$$GETDATE(+NEWDAY)
42 . F D Q:+$G(GMTSQ)
43 . . ; Set variable before doing QCONT
44 . . S $P(GMTSSC,U,4)=PDATE
45 . . D QCONT
46 . . ; Decrement to get previous day
47 . . S NEWDAY=NEWDAY-1
48 . . ; Quit For Loop when non-workdays data has been printed
49 . . I DAY>NEWDAY S GMTSQ=1 Q
50 . . ; Get date
51 . . S PDATE=$$GETDATE(+NEWDAY)
52 . . ; Quit For Loop if there's a work
53 . . ; day between Holiday and Weekend.
54 . . ; Don't print weekend data twice.
55 . . I +$$NONWDAY(PDATE)'>0 S GMTSQ=1 Q
56 ;
57QCONT ; Used so following can be done for
58 ; multiple dates for Clinics and ORs.
59 I $$CKPAT^GMTSPD(GMTSSC)'>0 Q
60 S GMPSAP=$S($P(GMTSLOC,U,3)="Y":1,1:0)
61 S ZTIO=$$GETIO($P(GMTSLOC,U,2)) Q:'$L(ZTIO)
62 S ZTDTH=$H,ZTRTN="MAIN^GMTSPL",ZTDESC="Health Summary"
63 F GMV="GMTSTYP","GMTSSC","GMPSAP" S ZTSAVE(GMV)=""
64 D ^%ZTLOAD
65 Q
66 ;
67GETDATE(DAYS) ; Gets desired Visit/Surgery date
68 ; Receives: DAYS=Print Days ahead
69 ; Returns: FileMan Date/time
70 N %,%H,%I,%T,GMTSDT,GMTSPM,X1,X2,X
71 D NOW^%DTC S GMTSDT=$P(%,"."),GMTSPM=$S(+$E($P(%,".",2),1,2)>12:1,1:0)
72 S X1=GMTSDT,X2=DAYS+GMTSPM D C^%DTC
73 Q X
74 ;
75NONWDAY(GMTSDT) ; Determines if non work day (i.e. Sat., Sun., or Holiday)
76 ; Returns 1 if print day is weekend or holiday
77 N DAYNAME
78 S DAYNAME=$$DOW^XLFDT(GMTSDT)
79 Q $S(DAYNAME="Saturday":1,DAYNAME="Sunday":1,$$HOLIDAY(GMTSDT):1,1:0)
80 ;
81WKEND(DAY,BEGDT,ENDDT) ; Updates days in advance for weekend and holiday dates
82 N GMI,X1,X2,X,%H,DAYNAME
83 F GMI=1:1 S X1=BEGDT,X2=GMI D C^%DTC Q:X>ENDDT D
84 . S DAYNAME=$$DOW^XLFDT(X)
85 . I DAYNAME="Saturday"!(DAYNAME="Sunday")!($$HOLIDAY(X)) S DAY=DAY+1,ENDDT=$$GETDATE(DAY)
86 . ; If one of days is Saturday, Sunday, or holiday,
87 . ; up days by one and recalculate ending date
88 Q DAY
89 ;
90HOLIDAY(GMDT) ; Determines if a date is a Holiday.
91 ; Requires that the Holiday (#40.5) file is updated
92 ; to determine if a date is a holiday.
93 N GMDATE
94 D FIND^DIC(40.5,"",.01,"QX",GMDT,1,"","","","GMDATE")
95 Q +$G(GMDATE("DILIST",0))
96 ;
97GETIO(X) ; Get device for queueing
98 N %,%Y,C,DIC,Y
99 S DIC=3.5,DIC(0)="NXZ" D ^DIC S Y=$S(+Y'>0:"",1:$P(Y(0),U))
100 Q Y
Note: See TracBrowser for help on using the repository browser.