source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SDPMHLS.m@ 1078

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

initial load of WorldVistAEHR

File size: 6.4 KB
Line 
1SDPMHLS ;BPFO/JRC -Build ROU-R01 HL7 message for 'SD ENC PERF MON' application ; 4/2/04 7:12am [5/12/04 10:29am]
2 ;;5.3;Scheduling;**313,371,416**;AUG 13, 1993
3 ;
4QUE ;Queue retroactive XMIT job
5 ;Declare variables
6 S (STDT,EDT,Y,X)=""
7 ;Prompt user for month and year
8 S %DT("A")="Please select MONTH and YEAR for TIU's National Rollup to transmit: "
9 S %DT="AEMX"
10 ;Set %DT not to allow current and future months
11 S %DT(0)=-($$FMADD^XLFDT($$NOW^XLFDT(),-32))
12 D ^%DT
13 ;Check date input if (-1) quit else continue
14 I Y<0 Q
15 ;Set STDT = user selected month and year and add 1 day
16 S STDT=Y+01
17 ;Add 32 days to STDT
18 S X=$$FMADD^XLFDT(STDT,32)
19 ;Subtract number of days that overlap into the following month
20 S EDT=$$FMADD^XLFDT(X,-($E(X,6,7)))
21 ;Set task variables
22 S ZTIO=""
23 S ZTDESC="Performance Indicator National Rollup"
24 S ZTRTN="EN^SDPMHLS"
25 S ZTSAVE("STDT")=""
26 S ZTSAVE("EDT")=""
27 D ^%ZTLOAD W:$D(ZTSK) " (Task: ",ZTSK,")"
28 K STDT,EDT,X,Y,%DT,%DT("A"),%DT(0)
29 Q
30EN ;Entry point
31 ;Note: Retroactive reports use variables STDT and EDT to pass dates
32 ; STDT - start date, first day of the month for selected month
33 ; EDT - ending date, last day of the month for selected month
34 ;Declare variables
35 N STDATE,ENDDATE
36 N XMTARRY,SCRNARR,SORTARR,OUTARR,X,RDATE
37 S SCRNARR="^TMP(""SCRPW"",$J,""SCRNARR"")"
38 S SORTARR="^TMP(""SCRPW"",$J,""SORTARR"")"
39 S OUTARR="^TMP(""SCRPW"",$J,""OUTARR"")"
40 S XMTARRY="^TMP(""HLS"","_$J_")"
41 S (STDATE,ENDDATE)=""
42 ;Set national screen/sort
43 D ROLLUP^SCRPW303(SCRNARR,SORTARR)
44 ;Call module to build scratch global
45 D GETINFO
46 ;Build HL7 Message
47 D BLDMSG(OUTARR,XMTARRY)
48 ;Send HL7 Message
49 I +$O(@XMTARRY@(""))>0 D
50 .S J=$$SENDMSG(.XMTARRY)
51 ;Send XMIT notifications
52 D MSG
53 ;Cleanup an quit
54 D EXIT
55 Q
56BLDMSG(OUTARR,XMTARRY) ;Build OBR segment
57 ;Input : OUTARR - Ouptut array
58 ;Output: XMTARRY - HL7 temporary array
59 ;Declare variables
60 N HL,HLFS,HLECH,HLQ,SNODE,PNODE,DIVHL,TYPE,COUNT
61 D INIT^HLFNC2("SD ENC PERF MON ORU-R01 SERVER",.HL)
62 Q:$O(HL(""))=""
63 N VAFEVN,VAFSTR,CNT,MAKE,VAFOBR,VAFOBX,I,XCNT,INFO,DIV,DIVHL
64 S CNT=1,XCNT=0
65 S MAKE(1)="1"
66 S MAKE(4,1,1)="01"
67 S MAKE(4,1,2)="VA ENC PERF MONITOR"
68 S MAKE(7)=$$HLDATE^HLFNC(RDATE)
69 S MAKE(25)="F"
70 S MAKE(27,1,4)=$$HLDATE^HLFNC(STDATE,"DT")
71 S MAKE(27,1,5)=$$HLDATE^HLFNC(ENDDATE,"DT")
72 K VAFOBR
73 D MAKEIT^VAFHLU("OBR",.MAKE,.VAFOBR,.VAFOBR)
74 M @XMTARRY@(CNT)=VAFOBR
75 S XCNT=XCNT+1,CNT=CNT+1
76 ;Build OBX segment for facility
77 S SNODE=$G(@OUTARR@("SUMMARY"))
78 S PNODE=$G(@OUTARR@("SUMMARY","PI"))
79 S DIVHL=$P($$SITE^VASITE,"^",3)
80 D MAKEOBX
81 ;Build OBX segment for division(s)
82 S DIV="" F S DIV=$O(@OUTARR@("SUBTOTAL",DIV)) Q:DIV="" D
83 .N SNODE,PNODE
84 .S SNODE=$G(@OUTARR@("SUBTOTAL",DIV))
85 .S PNODE=$G(@OUTARR@("SUBTOTAL",DIV,"PI"))
86 .S DIVHL=$P(DIV,"^",2)
87 .D MAKEOBX
88 .Q
89 Q
90MAKEOBX ;Set type and count for total encounters to bld OBX
91 ;Input : SNODE - Temporary counter node for summary
92 ; PNODE - Temporary counter node for PI
93 ; DIVHL - Division and Suffix
94 ; CNT - Temporary array subscript count
95 ; XCNT - OBX segment counter
96 ; XMTARRY - Temporary HL array ^TMP("HLS",$J)
97 S TYPE="CD",COUNT=$P($G(SNODE),U,1),OBID=1 D BLDOBX
98 ;Set type and count for counters for ET in days F0 - F10 to bld OBX
99 F M4=0:1:10 D
100 .S OBID=2
101 .S TYPE="F"_M4
102 .S COUNT=$P($G(PNODE),U,(M4+1))
103 .D BLDOBX
104 ;Set type and count for scanned notes and Uniques to bld OBX
105 S TYPE="FSPN",OBID=2,COUNT=$P($G(SNODE),U,7) D BLDOBX
106 S TYPE="FEP",OBID=2,COUNT=$P($G(SNODE),U,4) D BLDOBX
107 S TYPE="FDSS",OBID=2,COUNT=$P($G(SNODE),U,5) D BLDOBX
108 ;Set types and count for encounters w/o progress notes and
109 ;encounters w/progress notes pending signatures
110 S TYPE="FNPN",OBID=2,COUNT=+$P(SNODE,U,1)-(+($P(SNODE,U,2)))-(+($P(SNODE,U,9)))-(+($P(SNODE,U,7)))-(+($P(PNODE,U,11))) D BLDOBX
111 S TYPE="FNPS",OBID=2,COUNT=$P($G(SNODE),U,9) D BLDOBX
112 Q
113BLDOBX ;Build OBX
114 ;Ouput : @XMTARRY = Temporary HL array
115 ;Set variables
116 N MAKE,VAFOBX
117 S MAKE(1)=XCNT
118 S MAKE(2)="NM"
119 S MAKE(3,1,1)=OBID
120 S MAKE(3,1,4)=TYPE
121 S MAKE(5)=COUNT
122 S MAKE(11)="F"
123 S MAKE(15)=DIVHL
124 K VAFOBX
125 D MAKEIT^VAFHLU("OBX",.MAKE,.VAFOBX,.VAFOBX)
126 M @XMTARRY@(CNT)=VAFOBX
127 S XCNT=XCNT+1,CNT=CNT+1
128 Q
129SENDMSG(XMTARRY) ;Send HL7 message
130 ;Input - @XMTARRY
131 ;Output - ARRY4HL7
132 N ARRY4HL7,KILLARRY,HL,HLRESLT,HLFS,HLECH,HLQ,HLP
133 S XMTARRY=$G(XMTARRY)
134 S:'(XMTARRY]"") XMTARRY="^TMP(""HLS"","_$J_")"
135 Q:($O(@XMTARRY@(""))="") "-1^Can not send empty message"
136 S ARRY4HL7="TMP(""HLS"","_$J_")"
137 ;Initialize HL7 variables
138 D INIT^HLFNC2("SD ENC PERF MON ORU-R01 SERVER",.HL)
139 Q:($O(HL(""))="") "-1^Unable to initialize HL7 variables"
140 ;Check if XMTARRY is ^TMP("HLS",$J)
141 S KILLARRY=0
142 I $NA(@XMTARRY)'=$NA(@ARRY4HL7) D
143 .K @ARRY4HL7
144 .M @ARRY4HL7=@XMTARRY
145 .S KILLARRY=1
146 ;Broadcast message
147 D GENERATE^HLMA("SD ENC PERF MON ORU-R01 SERVER","GM",1,.HLRESLT,"",.HLP)
148 S:('HLRESLT) HLRESLT=$P(HLRESLT,"^",2,3)
149 ;Delete ^TMP("HLS",$J) if XMTARRY was different
150 K:(KILLARRY) @ARRY4HL7
151 Q $G(HLRESLT)
152GETINFO ;Get performance monitor data
153 ;Input:
154 ; @SCRNARR - Screen array full global reference
155 ; @SORTARR - Sort array full global reference
156 ;Output:
157 ; @OUTARR - Ouput array full global reference
158 ;Remember starting time
159 S RDATE=$$NOW^XLFDT()
160 ;Check STDT and EDT, if 1 set STDATE and ENDDATE
161 I $D(STDT)&$D(EDT) S STDATE=STDT,ENDDATE=EDT
162 I STDATE="" D
163 .;Set start date = 1st day of previous month
164 .N X,X1,X2
165 .S X1=$$DT^XLFDT(),X2=-30 S:$E(X1,6,7)=31 X2=-31
166 .D C^%DTC
167 .S STDATE=$E(X,1,5)_"01"
168 .;Set end date = start date + 32 minus number of days into next month
169 .S X=$$FMADD^XLFDT(STDATE,32)
170 .S ENDDATE=$$FMADD^XLFDT(X,-($E(X,6,7)))
171 .Q
172 ;Set date range in screen array
173 S @SCRNARR@("RANGE")=STDATE_"^"_ENDDATE
174 ;Get data
175 D GETDATA^SDPMUT1(SCRNARR,SORTARR,OUTARR)
176 Q
177MSG ;Build bulletin and send
178 ;Input:
179 ; RDATE - report starting time
180 ;Output:
181 ; Notificaion bulletin to SD ENC PERF MON mail group
182 N MSGTEXT,XMTEXT,XMSUB,XMY,XMCHAN,XMZ,XMDUZ
183 S MSGTEXT(1)=" "
184 S MSGTEXT(2)="Performance Indicator National Rollup was started on "_$$FMTE^XLFDT(RDATE,1)
185 S MSGTEXT(3)="Encounter date range: "_$$FMTE^XLFDT(STDATE,1)_" to "_$$FMTE^XLFDT(ENDDATE,1)
186 S MSGTEXT(3)="Extraction of data and sending of data completed "_$$FMTE^XLFDT($$NOW^XLFDT(),1)
187 S MSGTEXT(4)=" "
188 ;Send completion bulletin to current user
189 S XMSUB="Performance Indicator National Rollup"
190 S XMTEXT="MSGTEXT("
191 S XMY("G.SD PM NOTIFICATION TIU")=""
192 S XMCHAN=1
193 S XMDUZ="Performance Indicator"
194 D ^XMD
195 Q
196EXIT ;Done
197 K @SCRNARR,@SORTARR,@OUTARR,@XMTARRY
198 Q
Note: See TracBrowser for help on using the repository browser.