source: FOIAVistA/trunk/r/HEALTH_LEVEL_SEVEN-HL/HLUCM.m@ 1310

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

initial load of FOIAVistA 6/30/08 version

File size: 8.4 KB
Line 
1HLUCM ;CIOFO-O/LJA - HL7/Capacity Mgt API ;09/13/04 14:01
2 ;;1.6;HEALTH LEVEL SEVEN;**79,88,103,114**;Oct 13, 1995
3 ;
4 QUIT
5 ;
6CM(START,END,PNMSP,IEN101,TOTALS,COND,ERRINFO) ; Capacity management totals
7 N NMSPTYPE,PROTYPE,RESULTS,SITENM
8 I '$D(HLAPI) N HLAPI S HLAPI="CM"
9 QUIT:'$$PREPARE^HLUCM001 "" ;->
10 D KILLS^HLUCM009("START")
11 S RESULTS=$P($$LOOP,U,1,3)
12 D XTMP
13 D KILLS^HLUCM009("END")
14 KILL HLAPI
15 Q RESULTS
16 ;
17CMF(START,END,PNMSP,IEN101,TOTALS,COND,ERRINFO) ; Collect Remote Facility data - SYNC
18 N HLAPI
19 S HLAPI="CMF"
20 Q $$CM(START,END,.PNMSP,.IEN101,TOTALS,COND,.ERRINFO)
21 ;
22CM2(START,END,PNMSP,IEN101,TOTALS,COND,ERRINFO) ; Capacity management totals
23 N NMSPTYPE,PROTYPE,RESULTS,SITENM
24 I '$D(HLAPI) N HLAPI S HLAPI="CM2"
25 QUIT:'$$PREPARE^HLUCM001 "" ;->
26 D KILLS^HLUCM009("START")
27 S RESULTS=$P($$LOOP,U,1,3) ; Counts are aggregate
28 D XTMP
29 D KILLS^HLUCM009("END")
30 KILL HLAPI
31 QUIT RESULTS
32 ;
33CM2F(START,END,PNMSP,IEN101,TOTALS,COND,ERRINFO) ; Collect Remote Facility data - SYNC
34 N HLAPI
35 S HLAPI="CM2F"
36 Q $$CM2(START,END,.PNMSP,.IEN101,TOTALS,COND,.ERRINFO)
37 ;
38LOOP() ; Loop thru 772's .01... (Called from LOOP^HLUCM)
39 N ANS,API,CHAR,COUNTED,CTDBG,CTPCKG,D0,DATA,DEF,ERR,FAC,FAIL,HL,HLASTNM
40 N HLUCMADD,IEN772,IEN773,LEN,LOOP772,LOOPDT,NMSP,NUM,OK
41 N ORIGETM,ORIGSTM,PCKG,PROT,PROTOCOL,QUES,SEC
42 N SP,SUB,SVNO,TIMEP,TM772,TOT,V1,V2,VAL,VALUE,X,Y
43 ;
44 D LOAD
45 D ADJTIME^HLUCM003
46 D CMDBD
47 D TOTALCM ; Already stored in X (no counted) or C (counted) subscripts...
48 S RESULTS=$G(^TMP(TOTALS,$J))
49 ;
50 QUIT RESULTS
51 ;
52CMDBD ; Create $$CM debug data...
53 ; HLAPI,START,END -- req
54 N DATA,IENPAR,IEN772,OKPP,S1,S2,S3,SUB,TOT,VALNMSP,VALPROT
55 ;
56 S API=$S($G(API)["CM2":1,1:0) ; Async=1, Sync=0
57 ;
58 S IENPAR=0
59 F S IENPAR=$O(^TMP($J,"HLPARENT",IENPAR)) Q:'IENPAR D
60 . S DATA=$G(^TMP($J,"HLPARENT",+IENPAR)) QUIT:DATA']"" ;->
61 . S VALPROT=$P(DATA,U,7),VALNMSP=$P(DATA,U,9)
62 . F S1="C","X" F S2="C","X" F S3="C","X" S TOT(S1_S2_S3)=0
63 . S ^TMP($J,"HLUCMSTORE","U",+IENPAR)=DATA
64 . S IEN772=0
65 . F S IEN772=$O(^TMP($J,"HLPARENT",+IENPAR,IEN772)) Q:'IEN772 D
66 . . S ^TMP($J,"HLUCMSTORE","X",+IEN772)=+IENPAR
67 . . S (OKPP,OKPP(1))=$$PP(+IEN772)
68 . . S OKPP=$S(OKPP=U:"X",1:"C")
69 . . S OK=$$COLLSYNC(+IEN772,START,END) ; Outside time range?
70 . . S SUB=$S(OK:"C",1:"X")
71 . . S DATA=$P($G(^TMP($J,"HLCHILD",+IEN772)),"~",2,999) Q:DATA']"" ;->
72 . . ; If # seconds exceeds 1799...
73 . . S SUB=SUB_$S($P(DATA,U,3)>1799:"X",1:"C")_OKPP
74 . . S:$P(DATA,U,7)']"" $P(DATA,U,7)=VALPROT
75 . . S:$P(DATA,U,9)']"" $P(DATA,U,9)=VALNMSP
76 . . S ^TMP($J,"HLUCMSTORE","U",+IENPAR,+IEN772,SUB)=DATA
77 . . F I=1:1:3 S $P(TOT(SUB),U,I)=$P(TOT(SUB),U,I)+$P(DATA,U,I)
78 . . S DATA=$G(^TMP($J,"HLPARENT",+IENPAR,+IEN772))
79 . . S X=OKPP(1),$P(DATA,U,5)=$P(X,U),$P(DATA,U,6)=$P(X,U,2)
80 . . S ^TMP($J,"HLUCMSTORE","U",+IENPAR,+IEN772,SUB,772)=DATA
81 .
82 . ; Position #1 C=Count (Message BEGIN is not before START)
83 . ; X=Outside (Msg BEGIN is before START)
84 . ; #2 C=Count (#Seconds<1800)
85 . ; X=Greater (#Seconds>1799)
86 . ; #3 C=Count (Protocol/Namespace match)
87 . ; X=Mismatch (Protocol/Namespace mismatch)
88 . F S1="C","X" F S2="C","X" F S3="C","X" S SUB=S1_S2_S3 D
89 . . QUIT:$TR(TOT(SUB),"0^","")']"" ;->
90 . . S ^TMP($J,"HLUCMSTORE","U",+IENPAR,SUB)=TOT(SUB)
91 . .
92 . . S TOT=$G(^TMP($J,"HLUCMSTORE","T",SUB))
93 . . D UPTOT
94 . . S ^TMP($J,"HLUCMSTORE","T",SUB)=TOT
95 . .
96 . . S ^TMP($J,"HLUCMSTORE","T",SUB,IENPAR)=TOT(SUB)
97 . .
98 . . S TOT=$G(^TMP($J,"HLUCMSTORE","T"))
99 . . D UPTOT
100 . . S ^TMP($J,"HLUCMSTORE","T")=TOT
101 ;
102 KILL ^TMP($J,"HLCHILD"),^TMP($J,"HLPARENT")
103 ;
104 Q
105 ;
106UPTOT ; Up the totals...
107 ; TOT,TOT(SUB) -- req
108 S $P(TOT,U)=$P(TOT,U)+$P(TOT(SUB),U)
109 S $P(TOT,U,2)=$P(TOT,U,2)+$P(TOT(SUB),U,2)
110 S $P(TOT,U,3)=$P(TOT,U,3)+$P(TOT(SUB),U,3)
111 Q
112 ;
113PP(IEN772) ; Get store value for NMSP and PROT...
114 N PCKG,PP,PROT,X
115 S PP=$$PROTNMSP^HLUCM002(+IEN772)
116 I $P(PP,U)']""!($P(PP,U,2)']"") QUIT U ;->
117 S X=$P(PP,U),PROT=$S(X]"":X,1:"ZZZ")
118 S X=$P(PP,U,2),PCKG=$S(X]"":X,1:"ZZZ")
119 Q PROT_U_PCKG
120 ;
121LOAD ; Load data (Called by $$CM, $$CM2, and all other APIs)
122 ; START,END -- req
123 N IEN772,LOOPDT,X
124 S LOOPDT=START-.000001
125 F S LOOPDT=$O(^HL(772,"B",LOOPDT)) Q:LOOPDT'>0!(LOOPDT>END) D
126 . S IEN772=0
127 . F S IEN772=$O(^HL(772,"B",LOOPDT,IEN772)) Q:IEN772'>0 D
128 . . QUIT:'$$OK772(+IEN772) ;->
129 . . S X=$$LOAD772S^HLUCM009(IEN772)
130 Q
131 ;
132TOTALCM ; Loop, total for $$CM...
133 ; HLAPI -- req
134 N IEN772,IENPAR
135 S IENPAR=0
136 F S IENPAR=$O(^TMP($J,"HLUCMSTORE","U",IENPAR)) Q:'IENPAR D
137 . ; Don't count anything unless the entire unit is OK...
138 . QUIT:$O(^TMP($J,"HLUCMSTORE","U",+IENPAR,"CCC"))]"" ;->
139 . S IEN772=0,HLUCMADD=""
140 . F S IEN772=$O(^TMP($J,"HLUCMSTORE","U",IENPAR,IEN772)) Q:'IEN772 D
141 . . ;QUIT:'$D(^TMP($J,"HLUCMSTORE","U",+IENPAR,+IEN772,"CCC")) ;->
142 . . D COLLECT(+IENPAR,+IEN772)
143 . . I HLAPI["CM2" S HLUCMADD="DON'T ADD. COLLECT3~HLUCM003"
144 Q
145 ;
146COLLSYNC(IEN772,START,END) ; Does entry fall in START/END range?
147 N DATA,X
148 S DATA=$G(^TMP($J,"HLCHILD",+IEN772)) QUIT:DATA']"" "" ;->
149 S X=$P($P(DATA,"~",2,999),U,4) Q:X'?7N.E!(X<START)!(X>END) "" ;->
150 Q 1
151 ;
152OK772(IEN772) ; Valid entry?
153 N D
154 S D=$G(^HL(772,+IEN772,0))
155 QUIT:$P(D,U)'?7N.E "" ;->
156 I $P(D,U,2)']"",$P(D,U,3)']"",$P(D,U,4)']"",$P(D,U,5)']"" QUIT ""
157 Q 1
158 ;
159COLLECT(PAR,IEN772) ; Collect 772 data and associated 773 data...
160 N CT,CTPCKG,DATA,DBGBL,IEN773,PP,TOT772,TOT772T,TYPEHR,TYPEIO,TYPELR
161 ;
162 ; ^("U",PARENT-IEN,CHILD-IEN,"CCC")
163 S DATA=$G(^TMP($J,"HLUCMSTORE","U",+PAR,+IEN772,"CCC"))
164 S DATA("CHAR")=$P(DATA,U),DATA("DIFF")=$P(DATA,U,3)
165 S DATA("START")=$P(DATA,U,4),DATA("END")=$P(DATA,U,5)
166 S DATA("FAC")=$P(DATA,U,11)
167 ;
168 ; ^("U",PARENT-IEN,CHILD-IEN,"CCC",772)
169 S DATA=$G(^TMP($J,"HLUCMSTORE","U",+PAR,+IEN772,"CCC",772))
170 S DATA("HR")=$P(DATA,U),DATA("IO")=$P(DATA,U,2),DATA("LR")=$P(DATA,U,3)
171 S (DATA("PROT"),PROT)=$P(DATA,U,5)
172 S (DATA("PCKG"),PCKG)=$P(DATA,U,6)
173 ;
174 S DBGBL=1
175 ;
176 ; Store DATA() info in ^TMP(TOTALS,$J,...)
177 D ADDTMP^HLUCM001
178 ;
179 QUIT
180 ;
181TOT772C(IEN772) ; Total number of characters in message...
182 N LEN,LNO,TXT
183 ;
184 ; Use field if present. (Not present about 25% of time)
185 S LEN=$P($G(^HL(772,IEN772,"S")),U)
186 I LEN D QUIT ;->
187 . S DATA("CHAR",772)=$G(DATA("CHAR",772))+LEN
188 . S DATA("CHAR")=$G(DATA("CHAR"))+LEN
189 ;
190 ; Total manually...
191 S LNO=0
192 F S LNO=$O(^HL(772,IEN772,"IN",LNO)) Q:LNO'>0 D
193 . S TXT=$G(^HL(772,IEN772,"IN",+LNO,0)) QUIT:TXT']"" ;->
194 . S DATA("CHAR",772)=$G(DATA("CHAR",772))+$L(TXT)
195 . S DATA("CHAR")=$G(DATA("CHAR"))+$L(TXT)
196 ;
197 QUIT
198 ;
199TOT772T(IEN772) ; Processing time...
200 ; No totals here. Just set times in DATA() array for later use...
201 N TIME
202 ;
203 ; Time of entry...
204 S TIME=+$G(^HL(772,+IEN772,0))
205 I TIME?7N.E S DATA("TIME",TIME,772,.01)=""
206 ;
207 ; Time processed...
208 S TIME=$P($G(^HL(772,+IEN772,"P")),U,2)
209 I TIME?7N.E S DATA("TIME",TIME,772,21)=""
210 ;
211 QUIT
212 ;
213TOT773C(IEN773) ; Total number of characters...
214 ; DATA() -- passed in (See COLLECT)
215 N CHAR
216 S CHAR=$$MSGSIZE(+IEN773) QUIT:CHAR'>0 ;->
217 S DATA("CHAR",773,IEN773)=CHAR
218 S DATA("CHAR")=$G(DATA("CHAR"))+CHAR
219 S TOT773(IEN773)=CHAR
220 QUIT
221 ;
222MSGSIZE(IEN773) ; Number characters in 773 entry...
223 N NCH,NO
224 S NCH=0,NO=0
225 F S NO=$O(^HLMA(+IEN773,"MSH",NO)) Q:NO'>0 D
226 . S NCH=NCH+$L($G(^HLMA(+IEN773,"MSH",+NO,0)))
227 QUIT NCH
228 ;
229TOT773T(IEN773) ; Set TIMEs...
230 ; DATA() -- passed in (See COLLECT)
231 N TIME
232 ;
233 ; Creation time already taken from 772...
234 ;
235 ; Processed time...
236 S TIME=+$G(^HLMA(+IEN773,"S")) QUIT:TIME'>0 ;->
237 S DATA("TIME",TIME,773,100)=""
238 ;
239 QUIT
240 ;
241ERR(REA) ; Record error...
242 S NOERR=NOERR+1
243 S REA=$S($G(REA)]"":REA,1:"?")
244 S ERRINFO(REA)=""
245 QUIT
246 ;
247SEC(FMDT) ;
248 S FMDT=$$FMTH^XLFDT(FMDT)
249 QUIT $$SEC^XLFDT(FMDT)
250 ;
251TMDIFF ; DATA("TIME",...) -- req --> DATA("DIFF")
252 S (DATA("DIFF"),DATA("END"),DATA("START"))="" ; Default... HL*1.6*114
253 S DATA("START")=$O(DATA("TIME",0)) QUIT:DATA("START")'>0 ;->
254 S DATA("END")=$O(DATA("TIME",":"),-1)
255 S DATA("DIFF")=$$SEC(DATA("END"))-$$SEC(DATA("START"))
256 QUIT
257 ;
258XTMP ; Store in ^XTMP...
259 ; API Parameters -- req
260 N XTMP
261 ;
262 QUIT:PNMSP'=1!(IEN101'=1) ;-> Must be ALL,ALL
263 ;
264 S XTMP="HLUCM "_$$DT^XLFDT
265 S:'$D(^XTMP(XTMP,0)) ^XTMP(XTMP,0)=$$FMADD^XLFDT($$DT^XLFDT,7)_U_$$NOW^XLFDT_U_"HLUCM Data"
266 ;
267 S SVNO=$G(^XTMP(XTMP,"P",+START,+END,COND))
268 I SVNO'>0 S SVNO=$O(^XTMP(XTMP,"N",":"),-1)+1
269 S ^XTMP(XTMP,"P",+START,+END,COND)=SVNO_U_$$NOW^XLFDT
270 S ^XTMP(XTMP,"N",+SVNO)=START_U_END_U_COND_U_HLAPI
271 KILL ^XTMP(XTMP,"D",+SVNO)
272 ;
273 MERGE ^XTMP(XTMP,"D",+SVNO)=^TMP(TOTALS,$J)
274 ;
275 Q
276 ;
277EOR ; HLUCM - HL7/Capacity Mgt API ;2/27/01 10:15
Note: See TracBrowser for help on using the repository browser.