source: BMXNET_RPMS_dotNET_UTILITIES-BMX/trunk/m/BMXADOX1.m@ 1582

Last change on this file since 1582 was 1209, checked in by Sam Habiel, 13 years ago

BMXMON fix; updated all routines to v 2.31

File size: 11.8 KB
RevLine 
[645]1BMXADOX1 ; IHS/CIHA/GIS - RPC CALL: GENERATE AN ADO SCHEMA STRING AND DATA SET ;
[1209]2 ;;2.31;BMX;;Jul 25, 2011
[645]3 ; EXMAPLES OF FILEMAN SCHEMA GENERATION
4 ;
5 ;
6 ; N OUT,DAX,% S DAX=0 D SS^BMXADO(.OUT,1,DAX,"^^^5^I^^^^3,XSUB,2160010.03") D DISP(OUT) Q ; TEST EXTENDED SUBJOIN
7 ;
8DISP(OUT) ;
9 D DISP^BMXADOX(OUT)
10 Q
11 ;
12SCHEMA(NAME) ; GIVEN SCHEMA NAME, RETURN THE IEN
13 N IEN
14 S IEN=$O(^BMXADO("B",NAME,0))
15 Q IEN
16 ;
17NUM ; ITERATE BY IEN
18 ; IX="",START WITH IEN=1, STOP AFTER IEN=20, MAX # RECORDS RETURNED = 5
19 ; TO VIEW INTERNAL VALUES SET VSTG="~1~20~5~I"
20 N OUT,%,SIEN
21 S SIEN=$$SCHEMA("IHS PATIENT")
22 D SS^BMXADO(.OUT,SIEN,"","~1~20~5")
23 D DISP(OUT) R %:$G(DTIME,60)
24 K ^TMP("BMX ADO",$J)
25 Q
26 ;
27IX ; ITERATE BY INDEX
28 ; ITERATE USING THE "B" INDEX
29 ; START WITH PT NAME "C", STOP AFTER PATIENT NAME = "D", MAX # RECORDS RETURNED = 5
30 N OUT,%,SIEN
31 S SIEN=$$SCHEMA("IHS PATIENT")
32 D SS^BMXADO(.OUT,SIEN,"","B~C~D~5")
33 D DISP(OUT) R %:$G(DTIME,60)
34 K ^TMP("BMX ADO",$J)
35 Q
36 ;
37VCN ; SHOW VALUES FOR A SINGLE VISIT THAT AS A DEFINED VCN
38 N OUT,%,SIEN
39 S SIEN=$$SCHEMA("BMXADO DATA ENTRY IDENTIFIERS")
40 D SS^BMXADO(.OUT,SIEN,"","VCN~1.242A~1.242A~")
41 D DISP(OUT) R %:$G(DTIME,60)
42 K ^TMP("BMX ADO",$J)
43 Q
44 ;
45MT ; MEASUREMNT TYPES
46 N OUT,%,SIEN
47 S SIEN=$$SCHEMA("BMXADO MEASUREMENT TYPES")
48 D SS^BMXADO(.OUT,SIEN,"","B~~")
49 D DISP(OUT) R %:$G(DTIME,60)
50 K ^TMP("BMX ADO",$J)
51 Q
52 ;
53PROB ; PATIENT PROBLEMS
54 N OUT,%,SIEN
55 S SIEN=$$SCHEMA("BMXADO PROBLEMS")
56 D SS^BMXADO(.OUT,SIEN,"","AA~53~53")
57 D DISP(OUT) R %:$G(DTIME,60)
58 K ^TMP("BMX ADO",$J)
59 Q
60 ;
61PB1 ; ALT PROB RETRIEVAL TEST
62 N OUT,%,SIEN
63 S SIEN=$$SCHEMA("BMXADO PROBLEMS")
64 D SS^BMXADO(.OUT,SIEN,"","~221~221~")
65 D DISP(OUT) R %:$G(DTIME,60)
66 K ^TMP("BMX ADO",$J)
67 Q
68 ;
69POV ; RETURN THE POV SCHEMA
70 N OUT,%,SIEN
71 S SIEN=$$SCHEMA("BMXADO ADD POV")
72 D SS^BMXADO(.OUT,SIEN,"","")
73 D DISP(OUT) R %:$G(DTIME,60)
74 K ^TMP("BMX ADO",$J)
75 Q
76 ;
77NOTES ; RETURN NOTES FOR A SPECIFIC PATIENT PROBLEMS
78 N OUT,%,SIEN
79 S SIEN=$$SCHEMA("BMXADO NOTES")
80 D SS^BMXADO(.OUT,SIEN,"","~~~~~NOTES~BMXADOFD~53")
81 D DISP(OUT) R %:$G(DTIME,60)
82 K ^TMP("BMX ADO",$J)
83 Q
84 ;
85RENT ; ITERATE IN CHUNKS
86 ; RE-ITERATE USING THE "B" INDEX
87 ; START WITH PT IEN 5 AS THE "SEED", STOP AFTER PATIENT NAME = "D", MAX # RECORDS RETURNED = 5
88 N OUT,%,SIEN,SEED,LSEED,X,Y
89 S SEED=0,LSEED=""
90 S SIEN=$$SCHEMA("IHS PATIENT")
91RIT F D I '$G(SEED) Q
92 . ; D SS^BMXADO(.OUT,SIEN,SEED,"B~CA~CB~5")
93 . D SS^BMXADO(.OUT,SIEN,SEED,"~~~5")
94 . D DISP(OUT) R %:$G(DTIME,60) E S SEED="" Q
95 . I %?1"^" S SEED="" Q
96 . S X=$P(@OUT@(1),U,1)
97 . S SEED=$P(X,"|",3)
98 . I SEED=LSEED S SEED="" Q
99 . S LSEED=SEED
100 . K ^TMP("BMX ADO",$J)
101 . Q
102 Q
103 ;
104SUB ; SUBFILE ITERATION
105 ; THE SCHEMA IS ATTACHED TO THE MEDICARE ELIGIBILITY FILE/ELIG DATE SUBFILE
106 ; THE DA STRING HAS A VALUE OF '1,',: THE IEN IN THE PARENT FILE.
107 ; NOTE THE COMMA IN THE DA STRING. THIS INDICATES THAT THE FILE IEN IS 1 BUT THE SUBFILE IEN IS UNSPECIFIED
108 N OUT,%,SIEN
109 S SIEN=$$SCHEMA("UPDATE MEDICARE DATES")
110 D SS^BMXADO(.OUT,SIEN,"1,","~~~")
111 D DISP(OUT) R %:$G(DTIME,60)
112 K ^TMP("BMX ADO",$J)
113 Q
114 ;
115DINUM ; DINUMED POINTER ITERATION
116 ; THE SCHEMA IS ATTACHED TO THE IHS PATIENT FILE (9000001)
117 ; THE IHS PATIENT FILE IS DINUM'D AND ITS .01 FIELD POINTS TO THE VA PATIENT FILE (2)
118 ; BECAUSE OF THE SPECIAL RELATIONSHIP BETWEEN THE FILES, WE CAN USE THE B INDEX OF FILE 2 TO ITERATE FILE 9000001.
119 N OUT,%,SIEN
120 S SIEN=$$SCHEMA("IHS PATIENT")
121 D SS^BMXADO(.OUT,SIEN,"","B~A~B~5")
122 D DISP(OUT) R %:$G(DTIME,60)
123 K ^TMP("BMX ADO",$J)
124 Q
125 ;
126IXP ; INDEXED POINTER ITERATION
127 ; THE SCHEMA IS ATTACHED TO THE V POV FILE
128 ; THE AC CROSS REFERENCE INDEXES THE PATIENT FIELD
129 ; BY STARTING AND STOPING WITH PATIENT 1 (MAX=5) WE COLLECT THE FIRST 5 POVS FOR PATIENT 1 IN THE FILE
130 N OUT,%,SIEN
131 S SIEN=$$SCHEMA("VIEW POVS")
132 D SS^BMXADO(.OUT,SIEN,"","AC~1~1~5")
133 D DISP(OUT) R %:$G(DTIME,60)
134 K ^TMP("BMX ADO",$J)
135 Q
136 ;
137AA ; ITERATE USING AA INDEX
138 ; INDEX IS 'AA" THE START AND STOP DATES ARE SPECIFIED IN EXTERNAL FORMAT. MAX=10
139 ; THE FOLLOWING FILTERS ARE SPECIFIED IN THE LAST PARAMETER ("1|WT|C"):
140 ; 1=PATIENT DFN #1
141 ; WT=RETURN ONLY WEIGHTS. MEASUREMENT TYPE MUST BE SPECIFIED WITH A VALID, UNAMBIGUOUS LOOKUP VALUE.
142 ; C=RETRUN VALUES IN CHRONOLOGICAL ORDER USE 'R' INSTEAD OF 'C' FOR REVERSE CHRONOLOGICAL ORDER. DEFAULT=C
143 ; THE SEED PARAMTER IS SET AND CAN BE USED TO RETURN DATA IN CHUNKS
144 N OUT,%,SIEN
145 S SIEN=$$SCHEMA("VIEW MEASUREMENTS")
146 D SS^BMXADO(.OUT,SIEN,"","AA~3/21/1985~6/4/1986~5~~~~1|WT|C")
147 D DISP(OUT) R %:$G(DTIME,60)
148 K ^TMP("BMX ADO",$J)
149 Q
150 ;
151AA2 ; ITERATE USING AA INDEX
152 ; THIS SCHEMA IS ATTACHED TO THE VISIT FILE (9000010)
153 ; IN THIS CASE THERE IS NO ATTRIBUTE TYPE SO THE FILTER PARAM HAS ONLY 2 PIECES "1|R"
154 ; 1=PATIENT DFN
155 ; R=RETURN DATA IN REVERSE CHRONOLOGICAL ORDER
156 N OUT,%,SIEN
157 S SIEN=$$SCHEMA("VISITS")
158 D SS^BMXADO(.OUT,SIEN,"","AA~3/21/1985~6/4/1986~5~~~~1|R")
159 D DISP(OUT) R %:$G(DTIME,60)
160 K ^TMP("BMX ADO",$J)
161 Q
162 ;
163CIT ; CUSTOM ITERATOR
164 ; IF COMPLEX OR UNUSUAL SORTING/FILTERING IS REQUITED, USE A CUSTOM ITERATOR
165 ; THE CUSTOM ITERATOR IS DEFINED BY 6TH, 7TH AND 8TH PIECES IN THE VSTG
166 ; PIECE 8=TAG, PIECE 9=ROUTINE, PIECE 8=A PARAMETER PASSED TO THE ENTRY POINT
167 ; THE 9TH PIECE CONTAINS PT DFN, TIMESTAMP, VISIT TYPE, LOC IEN, AND SERVICE CATEGORY IN A "|" DELIMTED STRING
168 ; THE ITERATOR CALL TAG^ROUTINE(PARAM) TO GENERATE IENS
169 ; IN THIS CASE THE SCHEMA IS ATTACHED TO THE VISIT FILE.
170 ; GIVEN THE INFORMATION IN THE PARAMETER, THE CUSTOM ITERATOR RETURNS POSSIBLE DUPLICATE VISITS
171 N OUT,%,SIEN
172 S SIEN=$$SCHEMA("VISITS")
173 D SS^BMXADO(.OUT,SIEN,"","~~~~~DUPV~BMXADOV2~1|4/19/04@1PM|I|4585|A~")
174 D DISP(OUT) R %:$G(DTIME,60)
175 K ^TMP("BMX ADO",$J)
176 Q
177 ;
178TRIGGER ; TEXT TRIGGER FUNCTION
179 N OUT,%,SIEN
180 S SIEN=$$SCHEMA("PATIENT DEMOGRAPHICS")
181 D SS^BMXADO(.OUT,SIEN,"","~1~5")
182 D DISP(OUT) R %:$G(DTIME,60)
183 K ^TMP("BMX ADO",$J)
184 Q
185 ;
186ID ; IDENTIFIER FIELD
187 ; THE SCHEMA IS ATTACHED TO THE VA PATIENT FILE (2)
188 ; THE SCHEMA HAS A BUILT IN FIELD (.01ID) THAT RETURNS THE IDENTIFIERS
189 ; THE ENTRY POINT THAT GENERATES THE IDETIFIERS IS STORED IN THE BMX ADO SCHEMA FILE
190 N OUT,%,SIEN
191 S SIEN=$$SCHEMA("UPDATE PATIENT DEMOGRAPHICS")
192 D SS^BMXADO(.OUT,SIEN,"","~1~1~")
193 D DISP(OUT) R %:$G(DTIME,60)
194 K ^TMP("BMX ADO",$J)
195 Q
196 ;
197JMD ; JOIN MASTER TO DETAIL
198 N OUT,%,SIEN1,SIEN2,VSTG,SIEN3,JSTG
199 S SIEN1=$$SCHEMA("PATIENT DEMOGRAPHICS")
200 S SIEN2=$$SCHEMA("VIEW MEASUREMENTS")
201 S SIEN3=$$SCHEMA("VIEW MEDS")
202 S VSTG="~1~5" ; INSTRUCTIONS FOR GATHERING DATA SET FOR PTS 1-5 FROM THE MASTER FILE
203 S JSTG=SIEN3_",.001,.02IEN,AA~1/1/1960~6/30/2004~~~~~|C" ; + INSTRUCTIONS FOR 1ST JOIN TO GET MEDS
204 S JSTG=JSTG_"@JOIN@"_SIEN2_",.001,.02IEN,AA~1/1/1988~12/31/1988~~~~~|WT|R" ; + INSTRUCTIONS FOR 2ND JOIN TO GET MSRMNTS
205 D SS^BMXADO(.OUT,SIEN1,"",VSTG,JSTG)
206 D DISP(OUT) R %:$G(DTIME,60)
207 K ^TMP("BMX ADO",$J)
208 Q
209 ;
210JVPT ; JOIN PT DEMOG TO VISIT
211 N OUT,%,SIEN1,SIEN2,VSTG,JSTG
212 S SIEN1=$$SCHEMA("PATIENT DEMOGRAPHICS")
213 S SIEN2=$$SCHEMA("VISITS")
214 S VSTG="~1~1" ; INSTRUCTIONS FOR GATHERING DATA SET FOR PT 5 FROM THE MASTER FILE
215 S JSTG=SIEN2_",.05IEN,.001,AC" ; + INSTRUCTIONS FOR 1ST JOIN TO GET VISIT INFO
216 D SS^BMXADO(.OUT,SIEN1,"",VSTG,JSTG)
217 D DISP(OUT) R %:$G(DTIME,60)
218 K ^TMP("BMX ADO",$J)
219 Q
220 ;
221JAC ; TEST AC INDEX
222 N OUT,%,SIEN1,SIEN2
223 S SIEN1=$$SCHEMA("PATIENT DEMOGRAPHICS")
224 S SIEN2=$$SCHEMA("VIEW LABS")
225 S SIEN3=$$SCHEMA("VIEW MEASUREMENTS")
226 D SS^BMXADO(.OUT,SIEN1,"","~3~5~~~~~~"_SIEN2_",.001,.02IEN,AC@JOIN@"_SIEN3_",.001,.02IEN,AC")
227 D DISP(OUT) R %:$G(DTIME,60)
228 K ^TMP("BMX ADO",$J)
229 Q
230 ;
231JPB ; TEST AA INDEX JOINS FOR PROBLEM LIST
232 N OUT,%,SIEN1,SIEN2
233 S SIEN1=$$SCHEMA("PATIENT DEMOGRAPHICS")
234 S SIEN2=$$SCHEMA("VIEW PROBLEMS")
235 D SS^BMXADO(.OUT,SIEN1,"","~1~5~~~~~~"_SIEN2_",.001,.02IEN,AA")
236 D DISP(OUT) R %:$G(DTIME,60)
237 K ^TMP("BMX ADO",$J)
238 Q
239 ;
240JSUB ; SUBFILE JOIN
241 ; IN THIS CASE THE RECORDS IN A PARENT FILE ARE "JOINED" TO THE RECORDS IN ONE OF ITS SUB FILES
242 ; THE SCHEMA IS ATTACHED TO THE "MEDICARE ELIGIBLE" FILE
243 ; IT IS JOINED TO ITS SUBFILE, "ELIG DATES", VIA THE UPDATE MEDICARE DATES SCHEMA
244 N OUT,%,SIEN1,SIEN2
245 S SIEN1=$$SCHEMA("UPDATE MEDICARE INFO")
246 S SIEN2=$$SCHEMA("UPDATE MEDICARE DATES")
247 D SS^BMXADO(.OUT,SIEN1,"","~1~5~~~~~~"_SIEN2_",SUB")
248 D DISP(OUT) R %:$G(DTIME,60)
249 K ^TMP("BMX ADO",$J)
250 Q
251 ;
252ADD ; ADD A NEW ENTRY
253 ; THIS IS A 2 STEP PROCESS:
254 ; FIRST GET THE SCHEMA FOR THE FILE YOU WISH TO UPDATE
255 ; THIS SCHEMA TYPICALLY BEGINS WITH THE WORD "UPDATE"
256 ; IT CONTAINS NO ID IR IEN FIELDS
257 ; SECOND ADD THE DATA NODE TO THE ARRAY
258 ; IT HAS THE SAME FORMAT AS A DATA STRING ASSOCIATED WITH THE SCHEMA EXCEPT THE FIRST "^" PIECE IS NULL
259 ; THIS PIECE CORRESPONDS TO THE IEN OF THE RECORD. SINCE THE RECORD HASNOT BEEN ADDED YET, IT IS NULL.
260 ; IN THE DATA STRING, ALL POINTER VALUES ARE PRECEDED BY THE '`' CHARACTER AND EA. STRING ENDS IN $C(30)
261 ; MULTIPLE DATA STRINGS CAN BE APPENDED AS NEW NODES AT THE BOTTOM OF THE ARRAY
262 ; IN THIS CASE WE ARE ADDING A RECORD TO THE V MEASUREMENT FILE
263 ; DATA STRING="^MEASUREMENT TYPE IEN^PATIENT DFN^VISIT IEN^RESULT"_$C(30)
264 ; THERE ARE 2 INPUT PARAMS:
265 ; THE CLOSED REF WHERE THE INPUT ARRAY IS STORED
266 ; SINCE IT IS PASSED BY REFERENCE "OUT" CAN BE NULL OR UNDEFIEND.
267 ; OUT WILL BE DEFINED AT THE CONCLUSION OF THE TRANSACTION.
268 ; THE OUTPUT IS IN THE OUT ARRAY
269 ; OUT(1)="OK|ien" WHERE ien IS THE IEN OF THE RECORD THAT HAS BEE ADDED.
270 ; IF THE TRANSACTION FAILED, AN ERROR MSG WILL BE IN THE OUT ARRAY
271 ;
272 N OUT,%,SIEN,NODE
273 S SIEN=$$SCHEMA("UPDATE MEASUREMENTS")
274 D SS^BMXADO(.OUT,SIEN,"","") ; GET SCHEMA
275 S NODE=$O(^TMP("BMX ADO",$J,999999),-1)+1
276 S ^TMP("BMX ADO",$J,NODE)="^`2^`1^`71164^175.75"_$C(30)
277 D DISP(OUT) R %:$G(DTIME,60) ; DISPLAY THE INPUT ARRAY BEFORE UPDATING THE RECORD
278 D BAFM^BMXADOF1(.OUT,$NA(^TMP("BMX ADO",$J))) ; EP FOR UPDAING THE RECORD
279 K ^TMP("BMX ADO",$J)
280 W !!,OUT S %=0 F S %=$O(OUT(%)) Q:'% W !,OUT(%) ; SEND BACK AN ACKNOWLEDGEMENT OR ERROR MSG
281 Q
282 ;
283DELREC ; DELETE AN ENTRY
284 ; THE SIMPLEST WAY TO DELETE AN ENTRY IS TO PUT THE RECORD IEN IN THE DA STRING PRECEDED BY A MINUS SIGN
285 ; YOU CAN ALSO SET THE VALUE OF THE .01 FIELD TO "@"
286 ; IF THE VALUE OF THE .01 FIELD IS NULL AND THE DA STRING IS NOT PRECEDED BY A MINUS SIGN, THE TRANSACTION WILL BE CANCELLED
287 ; IF THE DA STRING IS NULL, THE TRANSACTION WILL BE CANCELLED
288 N OUT,%,SIEN,NODE,DEL
289 S DEL=51385
290 S SIEN=$$SCHEMA("UPDATE MEASUREMENTS")
291 D SS^BMXADO(.OUT,SIEN,"","") ; GET SCHEMA
292 S NODE=$O(^TMP("BMX ADO",$J,999999),-1)+1
293 S ^TMP("BMX ADO",$J,NODE)="-"_DEL_$C(30)
294 D DISP(OUT) R %:$G(DTIME,60) ; DISPLAY THE INPUT ARRAY BEFORE UPDATING THE RECORD
295 D BAFM^BMXADOF1(.OUT,$NA(^TMP("BMX ADO",$J))) ; EP FOR UPDAING THE RECORD
296 K ^TMP("BMX ADO",$J)
297 W !!,OUT S %=0 F S %=$O(OUT(%)) Q:'% W !,OUT(%) ; SEND BACK AN ACKNOWLEDGEMENT OR ERROR MSG
298 Q
299 ;
300EDIT ; EDIT AN EXISTING ENTRY
301 ; SIMILAR TO ABOVE EXCEPT THAT THE FIRST "^" PIECE OF THE DATA NODE IS THE IEN OF THE RECORD TO BE EDITIED
302 ; NOTE THAT THERE IS NO '`' IN FRONT OF THE FIRST PIECE. IT IS A PURE INTEGER
303 N OUT,%,SIEN,NODE
304 S SIEN=$$SCHEMA("UPDATE MEASUREMENTS")
305 D SS^BMXADO(.OUT,SIEN,"","") ; GET SCHEMA
306 S NODE=$O(^TMP("BMX ADO",$J,999999),-1)+1
307 S ^TMP("BMX ADO",$J,NODE)="51385^^^^176^`6"_$C(30)
308 D DISP(OUT) R %:$G(DTIME,60) ; DISPLAY THE INPUT ARRAY BEFORE UPDATING THE RECORD
309 D BAFM^BMXADOF1(.OUT,$NA(^TMP("BMX ADO",$J))) ; EP FOR UPDAING THE RECORD
310 K ^TMP("BMX ADO",$J)
311 W !!,OUT S %=0 F S %=$O(OUT(%)) Q:'% W !,OUT(%) ; SEND BACK AN ACKNOWLEDGEMENT OR ERROR MSG
312 Q
313 ;
314DELVAL ; DELETE A VALUE IN A FIELD
315 ; SIMILAR TO EDIT EXCEPT THE VALUE IS "@"
316 N OUT,%,SIEN,NODE
317 S SIEN=$$SCHEMA("UPDATE MEASUREMENTS")
318 D SS^BMXADO(.OUT,SIEN,"","") ; GET SCHEMA
319 S NODE=$O(^TMP("BMX ADO",$J,999999),-1)+1
320 S ^TMP("BMX ADO",$J,NODE)="51385^^^^^@"_$C(30)
321 D DISP(OUT) R %:$G(DTIME,60) ; DISPLAY THE INPUT ARRAY BEFORE UPDATING THE RECORD
322 D BAFM^BMXADOF1(.OUT,$NA(^TMP("BMX ADO",$J))) ; EP FOR UPDAING THE RECORD
323 K ^TMP("BMX ADO",$J)
324 W !!,OUT S %=0 F S %=$O(OUT(%)) Q:'% W !,OUT(%) ; SEND BACK AN ACKNOWLEDGEMENT OR ERROR MSG
325 Q
Note: See TracBrowser for help on using the repository browser.