source: WorldVistAEHR/trunk/r/LAB_SERVICE-LR-LS/LRPXAPI.m@ 861

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

initial load of WorldVistAEHR

File size: 6.1 KB
Line 
1LRPXAPI ;SLC/STAFF Lab Extract APIs ;2/26/04 13:34
2 ;;5.2;LAB SERVICE;**295**;Sep 27, 1994
3 ;
4 ; lab extract API routines
5 ; dbia 4245
6 ; no need to namespace local variables when calling these APIs
7 ; the LRPXAPP routine shows examples of calling these APIs
8 ; parameters: (.parameter is a call by reference)
9 ; .TESTS array(ien)=ien^test name
10 ; .VALUES array(seq of recent first)=col date/time^TEST^comment flag^RESULT
11 ; .PATS array(dfn)=dfn^patient name
12 ; .DATES array(-date)=date
13 ; DFN is patient ien
14 ; MAX is optional, # of tests,values,pts to return/call, default is 100
15 ; .NEXT is optional, if NEXT'=0 then not finished
16 ; COND is optional, condition for value (example I V>30), default is ""
17 ; TYPE is [C M A] and is optional, default is C
18 ; DATE1 is optional, earliest date, default is 0 (oldest)
19 ; DATE2 is optional, latest date, default is 9999999 (most recent)
20 ; .DATA is lab result or array(STYPE,#)= specimen, comments, datanumbers
21 ; DATE is collection date/time
22 ; ITEM is test number in file 60 for Chem data
23 ; ITEM is "M;[S T O A M];[S T O A M] ien" for Micro data
24 ; ITEM is "A;[S T O D M E F P I];[S T O D M E F P I] ien" for AP data
25 ; SOURCE is optional, array reference used as alternate list of patients
26 ; .RESULT is patient's test result (result^flag^...)
27 ; NODE is data reference in ^PXRMINDX( indexes "lrdfn;CH;lridt;lrdn"
28 ; LRDFN is lab patient ien
29 ; LRIDT is lab collection time (inverted)
30 ; LRDN is lab datanumbers for test values
31 ; STYPE is "S" specimen node, "C" comments, "V" data nodes, "A" all
32 ; .ERR is -1 when data cannot be found
33 ;
34 ; -- TESTS returns tests (items) on patient; dfn required --
35 ;
36TESTS(TESTS,DFN,TYPE,MAX,NEXT,COND,DATE1,DATE2) ; API
37 I $G(TESTS)?1U1UN1.14UNP,'$G(MAX) S MAX=1000000000 ; default for ^TMP is all, else 100 tests
38 E S MAX=+$G(MAX,100)
39 S TYPE=$G(TYPE,"C") ; default is CH data
40 I TYPE="C" D TESTS^LRPXAPI1(.TESTS,+$G(DFN),MAX,.NEXT,$G(COND),$G(DATE1),$G(DATE2)) Q
41 D TESTS^LRPXAPI3(.TESTS,+$G(DFN),TYPE,MAX,.NEXT,$G(COND),$G(DATE1),$G(DATE2)) Q
42 Q
43 ;
44 ; -- RESULTS returns results on patient; dfn required --
45 ;
46RESULTS(VALUES,DFN,ITEM,MAX,NEXT,COND,DATE1,DATE2) ; API
47 N TYPE
48 I $G(VALUES)?1U1UN1.14UNP,'$G(MAX) S MAX=1000000000 ; default for ^TMP is all, else 100 results
49 E S MAX=+$G(MAX,100)
50 S ITEM=$G(ITEM)
51 I ITEM'=+ITEM,$L(ITEM)<5 D Q ; results for all of type or partial item
52 . S MAX=+$G(MAX,10)
53 . S TYPE=$E(ITEM)
54 . I TYPE="C"!'$L(TYPE) D RESULTS^LRPXAPI1(.VALUES,+$G(DFN),MAX,.NEXT,$G(COND),$G(DATE1),$G(DATE2)) Q
55 . D RESULTS^LRPXAPI3(.VALUES,+$G(DFN),ITEM,MAX,.NEXT,$G(COND),$G(DATE1),$G(DATE2)) Q
56 I ITEM=+ITEM D TRESULTS^LRPXAPI1(.VALUES,+$G(DFN),ITEM,MAX,.NEXT,$G(COND),$G(DATE1),$G(DATE2)) Q
57 S TYPE=$E(ITEM)
58 D TRESULTS^LRPXAPI3(.VALUES,+$G(DFN),TYPE,ITEM,MAX,.NEXT,$G(COND),$G(DATE1),$G(DATE2)) Q
59 Q
60 ;
61 ; -- PATIENTS returns patients with a specific item; item required --
62 ;
63PATIENTS(PATS,ITEM,SOURCE,MAX,NEXT,COND,DATE1,DATE2) ; API
64 N TYPE
65 I $G(PATS)?1U1UN1.14UNP,'$G(MAX) S MAX=1000000000 ; default for ^TMP is all, else 100 patients
66 E S MAX=+$G(MAX,100)
67 S ITEM=$G(ITEM,0)
68 I ITEM=0!'$L($G(ITEM)) D ALLPATS^LRPXAPI3(.PATS,$G(SOURCE),MAX,.NEXT,$G(COND),$G(DATE1),$G(DATE2)) Q
69 I ITEM'=+ITEM,$L(ITEM)<5 D Q ; patients for all of type or partial item
70 . S TYPE=$E(ITEM)
71 . I TYPE="C" D PTS^LRPXAPI1(.PATS,$G(SOURCE),MAX,.NEXT,$G(COND),$G(DATE1),$G(DATE2)) Q
72 . D PTS^LRPXAPI3(.PATS,TYPE,ITEM,$G(SOURCE),MAX,.NEXT,$G(COND),$G(DATE1),$G(DATE2)) Q
73 I ITEM=+ITEM D PATIENTS^LRPXAPI1(.PATS,ITEM,$G(SOURCE),MAX,.NEXT,$G(COND),$G(DATE1),$G(DATE2)) Q
74 S TYPE=$E(ITEM)
75 D PATIENTS^LRPXAPI3(.PATS,TYPE,ITEM,$G(SOURCE),MAX,.NEXT,$G(COND),$G(DATE1),$G(DATE2)) Q
76 Q
77 ;
78 ; -- DATES returns col date/times as (date) or (type,date); dfn required --
79 ;
80DATES(DATES,DFN,TYPE,MAX,NEXT,DATE1,DATE2) ; API
81 I $G(DATES)?1U1UN1.14UNP,'$G(MAX) S MAX=1000000000 ; default for ^TMP is all, else 100 date/times
82 E S MAX=+$G(MAX,100)
83 S TYPE=$G(TYPE,"C") ; default is CH data
84 D DATES^LRPXAPI1(.DATES,+$G(DFN),TYPE,MAX,.NEXT,$G(DATE1),$G(DATE2))
85 Q
86 ;
87 ; ------------ other extract APIs --------------------
88 ;
89VALUE(RESULT,DFN,DATE,TEST,COND,ERR) ; API
90 ; returns result node as RESULT; dfn, date, test required
91 D VALUE^LRPXAPI2(.RESULT,+$G(DFN),+$G(DATE),+$G(TEST),$G(COND),.ERR)
92 Q
93 ;
94LRVALUE(RESULT,LRDFN,LRIDT,LRDN,COND,ERR) ; API
95 ; returns result node as RESULT; lrdfn, lridt, lrdn required
96 D LRVALUE^LRPXAPI2(.RESULT,+$G(LRDFN),+$G(LRIDT),+$G(LRDN),$G(COND),.ERR)
97 Q
98 ;
99LRPXRM(RESULT,NODE,ITEM,TYPES) ; API
100 ; returns lab data using ^PXRMINDX indexes; node, item required
101 ; types of data: V value, S specimen, C comments, or combinations
102 D LRPXRM^LRPXAPI2(.RESULT,$G(NODE),$G(ITEM),$G(TYPES,"VS"))
103 Q
104 ;
105SPEC(DATA,DFN,DATE,STYPE,ERR) ; API
106 ; returns specimen node, comments, data nodes
107 ; returned in array DATA; dfn, date required
108 D SPEC^LRPXAPI2(.DATA,+$G(DFN),+$G(DATE),$G(STYPE),.ERR)
109 Q
110 ;
111LRSPEC(DATA,LRDFN,LRIDT,STYPE,ERR) ; API
112 ; returns specimen node, comments, data nodes
113 ; returned in array DATA; lrdfn, lridt required
114 D LRSPEC^LRPXAPI2(.DATA,+$G(LRDFN),+$G(LRIDT),$G(STYPE),.ERR)
115 Q
116 ;
117VERIFIED(LRDFN,LRIDT) ; API $$(lrdfn,lridt) -> 1 if verified, else 0
118 Q $$VERIFIED^LRPXAPI2(+$G(LRDFN),+$G(LRIDT))
119 ;
120MIVERIFY(LRDFN,LRIDT,SUB) ; $$(lrdfn,lridt,sub) -> 1 if verified, else 0
121 Q $$MIVERIFY^LRPXAPI2(+$G(LRDFN),+$G(LRIDT),$G(SUB,"MI"))
122 ;
123APVERIFY(LRDFN,LRIDT,SUB) ; $$(lrdfn,lridt,sub) -> 1 if verified, else 0
124 Q $$APVERIFY^LRPXAPI2(+$G(LRDFN),+$G(LRIDT),$G(SUB))
125 ;
126VAL(LRDFN,LRIDT,LRDN) ; API $$(lrdfn,lridt,lrdn) -> result node
127 Q $$VAL^LRPXAPI2(+$G(LRDFN),+$G(LRIDT),+$G(LRDN))
128 ;
129REFVAL(NODE) ; API $$(reference node) -> data node
130 Q $$REFVAL^LRPXAPI2($G(NODE))
131 ;
132COMMENT(LRDFN,LRIDT) ; API $$(lrdfn,lridt) --> 1 if comment exists, else 0
133 Q $$COMMENT^LRPXAPI2(+$G(LRDFN),+$G(LRIDT))
134 ;
135ACCY(TESTS,ACC,BDN) ; API
136 ; returns TESTS from yearly accession, ACC, BDN required
137 ; BDN is beginning date number
138 D ACCY^LRPXAPI2(.TESTS,ACC,BDN)
139 Q
140 ;
141CHNODE(ARRAY,NODE) ; API
142 ; returns ARRAY of values on CH result node
143 D CHNODE^LRPXAPI2(.ARRAY,$G(NODE))
144 Q
145 ;
146HASITEM(DFN,ITEM) ; API $$(dfn,item) -> 1 if patient has item, else 0
147 I $D(^PXRMINDX(63,"PI",+$G(DFN),$G(ITEM,0))) Q 1
148 Q 0
149 ;
Note: See TracBrowser for help on using the repository browser.