source: WorldVistAEHR/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORWGAPIC.m@ 1375

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

initial load of WorldVistAEHR

File size: 5.5 KB
Line 
1ORWGAPIC ; SLC/STAFF - Graph Application Calls - Labs, Meds ;11/1/06 12:49
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**243**;Dec 17, 1997;Build 242
3 ;
4AA(IEN) ; $$(ien) -> external display of accession area
5 Q $P($G(^LRO(68,IEN,0)),U)
6 ;
7AALAB(TEST) ; $$(lab test) -> accession ien^acc name^acc abbrev
8 N AA,DIV
9 S TEST=+$G(TEST)
10 S DIV=+$G(DUZ(2))
11 S AA=+$P($G(^LAB(60,+TEST,8,DIV,0)),U,2)
12 I AA Q AA_U_$$ACCLAB(AA)
13 S AA=+$P($G(^LAB(60,+TEST,8,+$O(^LAB(60,+TEST,8,0)),0)),U,2)
14 I AA Q AA_U_$$ACCLAB(AA)
15 Q ""
16 ;
17ACC(DATA) ; API - get accession areas - from ORWGAPI
18 N CNT,IEN,TMP,RESULT,ZERO
19 D RETURN^ORWGAPIW(.TMP,.DATA)
20 S CNT=0
21 S IEN=0
22 F S IEN=$O(^LRO(68,IEN)) Q:IEN<1 D
23 . S ZERO=$G(^LRO(68,IEN,0)) I '$L(ZERO) Q
24 . S RESULT="68^"_IEN_U_$P(ZERO,U)_U_$P(ZERO,U,11)
25 . D SETUP^ORWGAPIW(.DATA,RESULT,TMP,.CNT)
26 Q
27 ;
28ACCLAB(AA) ; $$(accession ien) -> acc name^acc abbrev
29 N ZERO
30 S ZERO=$G(^LRO(68,AA,0)) I '$L(ZERO) Q ""
31 Q "lab - "_$P(ZERO,U)_U_$P(ZERO,U,11)
32 ;
33ADDDRUG(IEN) ; $$(additive) -> drug in 50 else ""
34 N RESULT K ^TMP($J,"RX")
35 I '$G(IEN) Q ""
36 D ZERO^PSS52P6(IEN,,,"RX")
37 S RESULT=$P($G(^TMP($J,"RX",IEN,1)),U)
38 K ^TMP($J,"RX")
39 Q RESULT
40 ;
41BCMAX(DFN) ; $$(dfn) -> 1 if patient has data else 0
42 Q $O(^PSB(53.79,"B",+$G(DFN),0))>0
43 ;
44DC(IEN) ; $$(ien) -> external display of drug class
45 N RESULT K ^TMP($J,"RX")
46 I '$G(IEN) Q ""
47 D IEN^PSN50P65(IEN,,"RX")
48 S RESULT=$G(^TMP($J,"RX",IEN,1))
49 K ^TMP($J,"RX")
50 Q RESULT
51 ;
52DRGCLASS(DRUG) ; $$(drug) -> drug class^classification
53 N RESULT K ^TMP($J,"RX")
54 I '$G(DRUG) Q ""
55 D DATA^PSS50(DRUG,,,,,"RX")
56 S RESULT=+$G(^TMP($J,"RX",DRUG,25))
57 K ^TMP($J,"RX")
58 Q RESULT_U_"drug - "_$$DC(RESULT)
59 ;
60DRUG(NUM) ; $$(bcma entry) -> drug in 50 else ""
61 N DONE,DRUG,NUM1
62 S DONE=0,NUM=+$G(NUM)
63 S NUM1=0
64 F S NUM1=$O(^PSB(53.79,NUM,.5,"B",NUM1)) Q:NUM1<1 S DONE=1 Q
65 I DONE Q NUM1
66 S DRUG=0
67 S NUM1=0
68 F S NUM1=$O(^PSB(53.79,NUM,.6,"B",NUM1)) Q:NUM1<1 D I DONE Q
69 . S DRUG=$$ADDDRUG(NUM1)
70 . I DRUG S DONE=1
71 I DONE Q DRUG
72 S DRUG=0
73 S NUM1=0
74 F S NUM1=$O(^PSB(53.79,NUM,.7,"B",NUM1)) Q:NUM1<1 D I DONE Q
75 . S DRUG=$$SOLDRUG(NUM1)
76 . I DRUG S DONE=1
77 I DONE Q DRUG
78 Q ""
79 ;
80DRUGC(VALUES) ; API - get drug classes - from ORWGAPI
81 N CLASS,IEN,NUM,ROOT K VALUES
82 S NUM=0
83 S ROOT=$$ROOT^PSN50P65(1)
84 S CLASS=""
85 F S CLASS=$O(@ROOT@(CLASS)) Q:CLASS="" D
86 . S IEN=0
87 . F S IEN=$O(@ROOT@(CLASS,IEN)) Q:IEN="" D
88 .. S NUM=NUM+1
89 .. S VALUES(NUM)="50.605^"_IEN_U_CLASS
90 M ^TMP("ORWGRPC",$J)=VALUES K VALUES
91 Q
92 ;
93INSIG(NODE) ; $$(node) -> sig
94 N SIG,SUB,VALUES K VALUES
95 S SUB=$P($G(NODE),";",2)
96 D RXIN(NODE,.VALUES)
97 S SIG=""
98 I SUB=5 D
99 . S SIG=" Give: "_$G(VALUES("MR"))
100 . S SIG=SIG_" "_$P($G(VALUES("SCH",1,0)),U)
101 . S SIG=SIG_" "_$P($G(VALUES("SCH",1,0)),U,2)
102 I SUB="IV" D
103 . S SIG=" Give: "_$G(VALUES("DO"))
104 . S SIG=SIG_" "_$$EXT^ORWGAPIX($G(VALUES("START")),55.01,.02)
105 . S SIG=SIG_" "_$G(VALUES("SCH",1,0))
106 Q SIG
107 ;
108LAB(ORVALUE,NODE,ITEM) ; from ORWGAPI3
109 D LRPXRM^LRPXAPI(.ORVALUE,NODE,ITEM,"VSC")
110 Q
111 ;
112LABNAME(Y) ; $$(item ien) -> item name
113 I $P(Y,";")="A",$P(Y,";",2)="S" Q $P(Y,".",2,99)
114 Q $$ITEMNM^LRPXAPIU(Y)
115 ;
116LABSUM(ORDATA,DFN,DATE1,DATE2,ORSUB) ; from ORWGAPID
117 D EN^LR7OSUM(.ORDATA,DFN,DATE1,DATE2,,80,.ORSUB)
118 Q
119 ;
120LRDFN(DFN) ; $$(dfn) -> lrdfn
121 Q $$LRDFN^LRPXAPIU(DFN)
122 ;
123LRIDT(LRDT) ; $$(date) -> inverse date
124 Q $$LRIDT^LRPXAPIU(LRDT)
125 ;
126NVASIG(NODE) ; $$(node) -> sig on non-va drug
127 N RESULTS,SIG K RESULTS
128 I '$L(NODE) Q ""
129 D RXNVA(NODE,.RESULTS)
130 S SIG=RESULTS("DOSAGE")
131 S SIG=SIG_" "_RESULTS("MEDICATION ROUTE")
132 S SIG=SIG_" "_RESULTS("SCHEDULE")
133 Q SIG
134 ;
135NVAX(DFN) ; $$(dfn) -> 1 if patient has data else 0
136 Q $L($O(^PXRMINDX("55NVA","PI",+$G(DFN),"")))>0
137 ;
138POINAME(IEN) ; $$(poi entry) - > name and dosage form else ""
139 N NAME,RESULT K ^TMP($J,"RX")
140 I '$G(IEN) Q ""
141 D ZERO^PSS50P7(IEN,,,"RX")
142 S NAME=$P($G(^TMP($J,"RX",IEN,.01)),U)
143 K ^TMP($J,"RX")
144 I NAME'=" " Q NAME
145 Q ""
146 ;
147RXIN(NODE,ORVALUE) ; from ORWGAPI3
148 D OEL^PSJPXRM1(NODE,.ORVALUE)
149 Q
150 ;
151RXNUM(DFN,RXIEN) ; $$(dfn,prescription ien) -> rx#
152 N RXNUM K ^TMP($J,"RX")
153 S RXIEN=+$G(RXIEN)
154 D RX^PSO52API(DFN,"RX",RXIEN,,0)
155 S RXNUM=$G(^TMP($J,"RX",DFN,RXIEN,.01))
156 I $L(RXNUM) S RXNUM=" RX#: "_+RXNUM
157 K ^TMP($J,"RX")
158 Q RXNUM
159 ;
160RXNVA(NODE,ORVALUE,XSTART,XSTOP) ; from ORWGAPI1, ORWGAPI3, ORWGAPID
161 S XSTART=1,XSTOP=1
162 D NVA^PSOPXRM1(NODE,.ORVALUE)
163 I '$G(ORVALUE("START DATE")) D
164 . S ORVALUE("START DATE")=$G(ORVALUE("DOCUMENTED DATE"))
165 . S XSTART=0
166 I '$G(ORVALUE("DISCONTINUED DATE")) D
167 . S XSTOP=0
168 Q
169 ;
170RXOUT(NODE,ORVALUE) ; from ORWGAPI3
171 D PSRX^PSOPXRM1(NODE,.ORVALUE)
172 Q
173 ;
174SIG(DFN,RXIEN) ; $$(dfn,prescription ien) -> sig
175 N LNUM,SIG K ^TMP($J,"RX")
176 S RXIEN=+$G(RXIEN)
177 D RX^PSO52API(DFN,"RX",RXIEN,,"M",,)
178 S SIG=""
179 S LNUM=0
180 F S LNUM=$O(^TMP($J,"RX",DFN,RXIEN,"M",LNUM)) Q:LNUM<1 D
181 . S SIG=SIG_$G(^TMP($J,"RX",DFN,RXIEN,"M",LNUM,0))_" "
182 I $L(SIG) S SIG=" Sig: "_$$LOW^ORWGAPIX(SIG)
183 K ^TMP($J,"RX")
184 Q SIG
185 ;
186SOLDRUG(IEN) ; $$(iv solution) -> drug in 50 else ""
187 N RESULT K ^TMP($J,"RX")
188 I '$G(IEN) Q ""
189 D ZERO^PSS52P7(IEN,,,"RX")
190 S RESULT=$P($G(^TMP($J,"RX",IEN,1)),U)
191 K ^TMP($J,"RX")
192 Q RESULT
193 ;
194TESTSPEC(DATA) ; from ORWGAPI
195 N CNT,LINE,TEST,TMP,SPEC
196 D RETURN^ORWGAPIW(.TMP,.DATA)
197 S CNT=0
198 S TEST=0
199 F S TEST=$O(^LAB(60,TEST)) Q:TEST<1 D
200 . S SPEC=0
201 . F S SPEC=$O(^LAB(60,TEST,1,SPEC)) Q:SPEC<1 D
202 .. S CNT=CNT+1
203 .. S LINE=TEST_U_$G(^LAB(60,TEST,1,SPEC,0))
204 .. I $P(LINE,U,3)[$C(34) S $P(LINE,U,3)=$$TRIM^ORWGAPIX($P(LINE,U,3),"LR",$C(34))
205 .. I $P(LINE,U,4)[$C(34) S $P(LINE,U,4)=$$TRIM^ORWGAPIX($P(LINE,U,4),"LR",$C(34))
206 .. I TMP S ^TMP(DATA,$J,CNT)=LINE Q
207 .. S DATA(CNT)=LINE
208 Q
209 ;
Note: See TracBrowser for help on using the repository browser.