source: WorldVistAEHR/trunk/r/OUTPATIENT_PHARMACY-PSO-APSP-HUIP/PSO52API.m@ 724

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

initial load of WorldVistAEHR

File size: 8.3 KB
Line 
1PSO52API ;BHAM ISC/SAB- Encap II API to return Rx data ;04/07/05 10:30 am
2 ;;7.0;OUTPATIENT PHARMACY;**213,229,252**;DEC 1997;Build 12
3 ;
4 ;Reference to ^PS(55 supported by DBIA 2228
5 ;
6RX(DFN,LIST,IEN,RX,NODE,SDATE,EDATE) ;
7 ;DFN: IEN from the PATIENT file (#2) [REQUIRED]
8 ;LIST: Subscript name used in ^TMP global [REQUIRED]
9 ;IEN: Internal prescription number [optional]
10 ;RX#: RX # field (#.01) of the PRESCRIPTION file (#52) [optional]
11 ;NODE: Determines data elements returned [optional]
12 ;SDATE: Start Date [optional]
13 ;EDATE: End Date [optional]
14 ;
15 Q:'$G(DFN) Q:$G(LIST)=""
16 N DA,DR,PST,DIC,DIQ,ND,LK,DTE,DAT,I,X,D0 K ^TMP($J,LIST) S ^TMP($J,LIST,DFN,0)=0
17 I $G(IEN) D PROCESS G CLEAN
18 I $G(RX)]"",'$G(IEN) S IEN=$O(^PSRX("B",RX,0)) D G CLEAN
19 .I 'IEN S ^TMP($J,LIST,DFN,0)="-1^NO DATA FOUND" Q
20 .D PROCESS
21 D DATE
22CLEAN F I=0:0 S I=$O(^TMP($J,LIST,DFN,I)) Q:'I S ^TMP($J,LIST,DFN,0)=^TMP($J,LIST,DFN,0)+1
23 I ^TMP($J,LIST,DFN,0)=0 S ^TMP($J,LIST,DFN,0)="-1^NO DATA FOUND"
24 K DA,DR,DIC,ND,DAT,PST,LK,DIQ,DTE,I,X
25 Q
26PROCESS ;
27 I DFN'=$P($G(^PSRX(IEN,0)),"^",2) S ^TMP($J,LIST,IEN,0)="-1^NO DATA FOUND (MISMATCHED PATIENT)" Q
28 I $G(^PSRX(IEN,0))']"" S ^TMP($J,LIST,IEN,0)="-1^NO RX DATA FOUND" Q
29 I $G(NODE)']"" D ZE,TW,TH,MI,ST,RF,CM,AT,LB,PT^PSO52B,SD^PSO52B,TB^PSO52B,OI^PSO52B,MLT^PSO52B S DAT="I" D IB Q
30 D ST F LK=1:1:$L(NODE,",") S DAT=$P(NODE,",",LK),ND=$P(DAT,"^") D
31 .I ND=0 D ZE Q
32 .I ND=2 D ZE,TW Q
33 .I ND=3 D TW,TH Q
34 .I ND="R" D RF Q
35 .I ND="I" D IB Q
36 .I ND="P" D PT^PSO52B Q
37 .I ND="O" D OI^PSO52B Q
38 .I ND="T" D TB^PSO52B Q
39 .I ND="L" D LB Q
40 .I ND="S" D SD^PSO52B Q
41 .I ND="M" D MI Q
42 .I ND="C" D CM Q
43 .I ND="A" D AT Q
44 .I ND="ST" D ST Q
45 .I ND="ICD" D MLT^PSO52B Q
46 .S ^TMP($J,LIST,DFN,IEN,"INVALID REQUEST",ND)="Invalid Data Requested"
47 Q
48ZE ;zero
49 K PST S DIC=52,DA=IEN,DR=".01:9;10.3;10.6;11;16;17" D DIQ
50 F DR=.01,1,2,3,4,5,6,6.5,7,8,9,10.3,10.6,11,16,17 D
51 .I PST(52,DA,DR,"E")'=PST(52,DA,DR,"I") S ^TMP($J,LIST,DFN,IEN,DR)=PST(52,DA,DR,"I")_"^"_PST(52,DA,DR,"E") Q
52 .S ^TMP($J,LIST,DFN,IEN,DR)=PST(52,DA,DR,"I")
53 K DA,DR,PST,DIC,DIQ
54 Q
55TW ;two
56 Q:'$D(^PSRX(IEN,2))
57 K PST S DIC=52,DA=IEN,DR="20:31;32.1;32.2;32.3;104" D DIQ
58 F DR=20,21,22,23,24,25,26,27,28,29,30,31,32.1,32.2,32.3,104 D
59 .I PST(52,DA,DR,"E")'=PST(52,DA,DR,"I") S ^TMP($J,LIST,DFN,IEN,DR)=PST(52,DA,DR,"I")_"^"_PST(52,DA,DR,"E") Q
60 .S ^TMP($J,LIST,DFN,IEN,DR)=PST(52,DA,DR,"I")
61 K DA,DR,PST,DIC,DIQ
62 Q
63TH ;three
64 Q:'$D(^PSRX(IEN,3))
65 K PST S DIC=52,DA=IEN,DR="12;26.1;34.1;101;102;102.1;102.2;109;112" D DIQ
66 F DR=12,26.1,34.1,101,102,102.1,102.2,109,112 D
67 .I PST(52,DA,DR,"E")'=PST(52,DA,DR,"I") S ^TMP($J,LIST,DFN,IEN,DR)=PST(52,DA,DR,"I")_"^"_PST(52,DA,DR,"E") Q
68 .S ^TMP($J,LIST,DFN,IEN,DR)=PST(52,DA,DR,"I")
69 K DA,DR,PST,DIC,DIQ
70 Q
71MI ;sig
72 I $P($G(^PSRX(IEN,"SIG")),"^",2) D Q
73 .I '$O(^PSRX(IEN,"SIG1",0)) S ^TMP($J,LIST,DFN,IEN,"M",0)="-1^NO DATA FOUND" Q
74 .F I=0:0 S I=$O(^PSRX(IEN,"SIG1",I)) Q:'I S ^TMP($J,LIST,DFN,IEN,"M",I,0)=^PSRX(IEN,"SIG1",I,0),^TMP($J,LIST,DFN,IEN,"M",0)=$G(^TMP($J,LIST,DFN,IEN,"M",0))+1
75 I $P($G(^PSRX(IEN,"SIG")),"^")']"" S ^TMP($J,LIST,DFN,IEN,"M",0)="-1^NO DATA FOUND" Q
76 S X=$P($G(^PSRX(IEN,"SIG")),"^") D SIG^PSOHELP S ^TMP($J,LIST,DFN,IEN,"M",1,0)=$E(INS1,2,9999999),^TMP($J,LIST,DFN,IEN,"M",0)=1
77 K X,INS1
78 Q
79ST ;status
80 I DT>$P(^PSRX(IEN,2),"^",6),$P(^PSRX(IEN,"STA"),"^")<11 D
81 .N PSOEXRX,PSOEXSTA,ORN,PIFN,PSUSD,PRFDT,PDA,PSST
82 .S PSOEXRX=IEN D EN2^PSOMAUEX K PSOEXRX,PSONM,PSONMX
83 K PST S DIC=52,DA=IEN,DR=".01;100" D DIQ
84 S ^TMP($J,LIST,DFN,IEN,100)=PST(52,DA,100,"I")_"^"_PST(52,DA,100,"E")
85 S ^TMP($J,LIST,"B",PST(52,DA,.01,"E"),IEN)=""
86 K DA,DR,PST,DIC,DIQ
87 Q
88RF ;refill
89 I '$O(^PSRX(IEN,1,0)) S ^TMP($J,LIST,DFN,IEN,"RF",0)="-1^NO DATA FOUND" Q
90 I $P($G(DAT),"^",3) S DA(52.1)=$P(DAT,"^",3) D RFD K DA,DR,PST,DIC,DIQ Q
91 F RF=0:0 S RF=$O(^PSRX(IEN,1,RF)) Q:'RF S DA(52.1)=RF D RFD
92 K DA,DR,PST,DIC,DIQ,RF
93 Q
94RFD K PST S DR(52.1)=".01:8;10.1;12;13;14;15;17",DIC=52,DA=IEN,DR=52 D DIQ
95 I $P($G(DAT),"^",3),'$G(PST(52.1,DA(52.1),.01,"I")) S ^TMP($J,LIST,DFN,IEN,"RF",0)="-1^NO DATA FOUND" Q
96 S ^TMP($J,LIST,DFN,IEN,"RF",0)=$G(^TMP($J,LIST,DFN,IEN,"RF",0))+1
97 F DR=.01,1,1.1,1.2,2,3,4,5,6,7,8,10.1,12,13,14,15,17 D
98 .I PST(52.1,DA(52.1),DR,"E")'=PST(52.1,DA(52.1),DR,"I") S ^TMP($J,LIST,DFN,IEN,"RF",DA(52.1),DR)=PST(52.1,DA(52.1),DR,"I")_"^"_PST(52.1,DA(52.1),DR,"E") Q
99 .S ^TMP($J,LIST,DFN,IEN,"RF",DA(52.1),DR)=PST(52.1,DA(52.1),DR,"I")
100 Q
101IB ;ib ori
102 I $P($G(DAT),"^",2)="R" D IBR Q
103 I $G(^PSRX(IEN,"IB"))']"" S ^TMP($J,LIST,DFN,IEN,"IB",0)="-1^NO DATA FOUND" Q
104 K PST S DIC=52,DA=IEN,DR="105;106;106.5;106.6" D DIQ
105 F DR=105,106,106.5,106.6 D
106 .I PST(52,DA,DR,"E")'=PST(52,DA,DR,"I") S ^TMP($J,LIST,DFN,IEN,DR)=PST(52,DA,DR,"I")_"^"_PST(52,DA,DR,"E") Q
107 .S ^TMP($J,LIST,DFN,IEN,DR)=PST(52,DA,DR,"E")
108 K DA,DR,PST,DIC,DIQ
109 I $P($G(DAT),"^",2)="" D IBR Q
110 Q
111IBR ;ib ref
112 I '$O(^PSRX(IEN,1,0)) S ^TMP($J,LIST,DFN,IEN,"IB",0)="-1^NO DATA FOUND" Q
113 I $P($G(DAT),"^",2)="R",$P($G(DAT),"^",3) S DA(52.1)=$P(DAT,"^",3) D IBS K DA,DR,PST,DIC,DIQ Q
114 N IB F IB=0:0 S IB=$O(^PSRX(IEN,1,IB)) Q:'IB S DA(52.1)=IB D IBS
115 I '$G(^TMP($J,LIST,DFN,IEN,"IB",0)) K ^TMP($J,LIST,DFN,IEN,"IB") S ^TMP($J,LIST,DFN,IEN,"IB",0)="-1^NO DATA FOUND"
116 K DA,DR,PST,DIC,DIQ,IB
117 Q
118IBS I $P($G(DAT),"^",3),'$G(^PSRX(IEN,1,DA(52.1),"IB")) S ^TMP($J,LIST,DFN,IEN,"IB",0)="-1^NO DATA FOUND" Q
119 I '$D(^PSRX(IEN,1,DA(52.1),"IB")) S ^TMP($J,LIST,DFN,IEN,"IB",DA(52.1),0)="-1^NO DATA FOUND" Q
120 K PST S DR(52.1)="9;9.1",DIC=52,DA=IEN,DR=52 D DIQ
121 S ^TMP($J,LIST,DFN,IEN,"IB",0)=$G(^TMP($J,LIST,DFN,IEN,"IB",0))+1
122 F DR=9,9.1 D
123 .I PST(52.1,DA(52.1),DR,"E")'=PST(52.1,DA(52.1),DR,"I") S ^TMP($J,LIST,DFN,IEN,"IB",DA(52.1),DR)=PST(52.1,DA(52.1),DR,"I")_"^"_PST(52.1,DA(52.1),DR,"E") Q
124 .S ^TMP($J,LIST,DFN,IEN,"IB",DA(52.1),DR)=PST(52.1,DA(52.1),DR,"I")
125 Q
126CM ;cmop
127 I '$O(^PSRX(IEN,4,0)) S ^TMP($J,LIST,DFN,IEN,"C",0)="-1^NO DATA FOUND" Q
128 N CM F CM=0:0 S CM=$O(^PSRX(IEN,4,CM)) Q:'CM S DA(52.01)=CM D CMP
129 K DA,DR,PST,DIC,DIQ,CM
130 Q
131CMP S ^TMP($J,LIST,DFN,IEN,"C",0)=$G(^TMP($J,LIST,DFN,IEN,"C",0))+1
132 K PST S DR(52.01)="2;3;4",DIC=52,DA=IEN,DR=400 D DIQ
133 F DR=2,3,4 D
134 .I PST(52.01,DA(52.01),DR,"E")'=PST(52.01,DA(52.01),DR,"I") S ^TMP($J,LIST,DFN,IEN,"C",DA(52.01),DR)=PST(52.01,DA(52.01),DR,"I")_"^"_PST(52.01,DA(52.01),DR,"E") Q
135 .S ^TMP($J,LIST,DFN,IEN,"C",DA(52.01),DR)=PST(52.01,DA(52.01),DR,"I")
136 Q
137AT ;activity log
138 I '$O(^PSRX(IEN,"A",0)) S ^TMP($J,LIST,DFN,IEN,"A",0)="-1^NO DATA FOUND" Q
139 N AT F AT=0:0 S AT=$O(^PSRX(IEN,"A",AT)) Q:'AT S DA(52.3)=AT D ATP
140 K DA,DR,PST,DIC,DIQ,AT
141 Q
142ATP K PST S DR(52.3)=".01;.02;.03;.04;.05" S DIC=52,DA=IEN,DR=40 D DIQ
143 S ^TMP($J,LIST,DFN,IEN,"A",0)=$G(^TMP($J,LIST,DFN,IEN,"A",0))+1
144 F DR=.01,.02,.03,.04,.05 D
145 .I DR=.04 S ^TMP($J,LIST,DFN,IEN,"A",DA(52.3),DR)=PST(52.3,DA(52.3),DR,"E") Q
146 .I PST(52.3,DA(52.3),DR,"E")'=PST(52.3,DA(52.3),DR,"I") S ^TMP($J,LIST,DFN,IEN,"A",DA(52.3),DR)=PST(52.3,DA(52.3),DR,"I")_"^"_PST(52.3,DA(52.3),DR,"E") Q
147 .S ^TMP($J,LIST,DFN,IEN,"A",DA(52.3),DR)=PST(52.3,DA(52.3),DR,"I")
148 Q
149LB ;label log
150 I '$O(^PSRX(IEN,"L",0)) S ^TMP($J,LIST,DFN,IEN,"L",0)="-1^NO DATA FOUND" Q
151 N LB F LB=0:0 S LB=$O(^PSRX(IEN,"L",LB)) Q:'LB S DA(52.032)=LB D LBP
152 K DA,DR,PST,DIC,DIQ,LB
153 Q
154LBP S ^TMP($J,LIST,DFN,IEN,"L",0)=$G(^TMP($J,LIST,DFN,IEN,"L",0))+1
155 K PST S DR(52.032)=".01;1;2;3;4" S DIC=52,DA=IEN,DR=32 D DIQ
156 F DR=.01,1,2,3,4 D
157 .I DR=1 S ^TMP($J,LIST,DFN,IEN,"L",DA(52.032),DR)=PST(52.032,DA(52.032),DR,"E") Q
158 .I PST(52.032,DA(52.032),DR,"E")'=PST(52.032,DA(52.032),DR,"I") S ^TMP($J,LIST,DFN,IEN,"L",DA(52.032),DR)=PST(52.032,DA(52.032),DR,"I")_"^"_PST(52.032,DA(52.032),DR,"E") Q
159 .S ^TMP($J,LIST,DFN,IEN,"L",DA(52.032),DR)=PST(52.032,DA(52.032),DR,"I")
160 K DA,DR,PST,DIC,DIQ
161 Q
162DATE ;date range
163 I $G(SDATE) S DTE=SDATE-1 D Q
164 .I $G(EDATE) D Q
165 ..F S DTE=$O(^PS(55,DFN,"P","A",DTE)) Q:'DTE!(DTE>EDATE) F IEN=0:0 S IEN=$O(^PS(55,DFN,"P","A",DTE,IEN)) Q:'IEN D:$P($G(^PSRX(IEN,"STA")),"^")'=13 PROCESS
166 .F S DTE=$O(^PS(55,DFN,"P","A",DTE)) Q:'DTE F IEN=0:0 S IEN=$O(^PS(55,DFN,"P","A",DTE,IEN)) Q:'IEN D:$P($G(^PSRX(IEN,"STA")),"^")'=13 PROCESS
167 I $G(EDATE),'$G(SDATE) S DTE=DT-1 D Q
168 .F S DTE=$O(^PS(55,DFN,"P","A",DTE)) Q:'DTE!(DTE>EDATE) F IEN=0:0 S IEN=$O(^PS(55,DFN,"P","A",DTE,IEN)) Q:'IEN D:$P($G(^PSRX(IEN,"STA")),"^")'=13 PROCESS
169 S DTE=DT-1 F S DTE=$O(^PS(55,DFN,"P","A",DTE)) Q:'DTE F IEN=0:0 S IEN=$O(^PS(55,DFN,"P","A",DTE,IEN)) Q:'IEN D:$P($G(^PSRX(IEN,"STA")),"^")'=13 PROCESS
170 Q
171PROF(DFN,LIST,SDATE,EDATE) ;
172 D ^PSO52AP1
173 Q
174DIQ ;process fields
175 S DIQ="PST",DIQ(0)="IE" D EN^DIQ1
176 Q
Note: See TracBrowser for help on using the repository browser.