source: FOIAVistA/trunk/r/PHARMACY_DATA_MANAGEMENT-PSS/PSSUTLA1.m@ 1540

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

initial load of FOIAVistA 6/30/08 version

File size: 7.9 KB
Line 
1PSSUTLA1 ;BHAM ISC/RTR-PSS utility routine ;08/21/00
2 ;;1.0;PHARMACY DATA MANAGEMENT;**38,49,53,54,66,69**;9/30/97
3 ;Reference to EN^DDIOL supported by DBIA 10142
4 ;
5EN3(PSSBINTR,PSSBLGTH) ;
6 ;Pass in to EN3 the internal number from 50.7, and the length of the
7 ;array you want. Returns expanded Instructions is PSSBSIG array
8 K PSSBSIG N X,BVAR,BVAR1,III,CNT,NNN,BLIM,Y,PISIG,Z0,Z1,CNTZ,FFF
9 Q:'$G(PSSBINTR)!('$G(PSSBLGTH))
10 S X=$P($G(^PS(50.7,PSSBINTR,"INS")),"^") Q:X=""
11 S PISIG(1)="",CNTZ=1 Q:$L(X)<1 F Z0=1:1:$L(X," ") G:Z0="" START S Z1=$P(X," ",Z0) D G:'$D(X) START
12 .D:$D(X)&($G(Z1)]"") D ADD
13 ..S Y=$O(^PS(51,"B",Z1,0)) Q:'Y!($P($G(^PS(51,+Y,0)),"^",4)>1) S Z1=$P($G(^PS(51,Y,0)),"^",2) Q:'$D(^(9)) S Y=$P(X," ",Z0-1),Y=$E(Y,$L(Y)) S:Y>1 Z1=^(9)
14START ;
15 S (BVAR,BVAR1)="",III=1
16 F FFF=0:0 S FFF=$O(PISIG(FFF)) Q:'FFF S CNT=0 F NNN=1:1:$L(PISIG(FFF)) I $E(PISIG(FFF),NNN)=" "!($L(PISIG(FFF))=NNN) S CNT=CNT+1 D I $L(BVAR)>PSSBLGTH S PSSBSIG(III)=BLIM_" ",III=III+1,BVAR=BVAR1
17 .S BVAR1=$P(PISIG(FFF)," ",(CNT))
18 .S BLIM=BVAR
19 .S BVAR=$S(BVAR="":BVAR1,1:BVAR_" "_BVAR1)
20 I $G(BVAR)'="" S PSSBSIG(III)=BVAR
21 I $G(PSSBSIG(1))=""!($G(PSSBSIG(1))=" ") S PSSBSIG(1)=$G(PSSBSIG(2)) K PSSBSIG(2)
22 F CNTZ=0:0 S CNTZ=$O(PSSBSIG(CNTZ)) Q:'CNTZ S PSSX("PI",CNTZ)=$G(PSSBSIG(CNTZ))
23 K PSSBSIG
24 Q
25ADD ;
26 I $L(PISIG(CNTZ))+$L(Z1)+1<246 S PISIG(CNTZ)=PISIG(CNTZ)_" "_Z1 Q
27 S CNTZ=CNTZ+1 S PISIG(CNTZ)=Z1
28 Q
29 ;
30DEA(PSSDIENM) ;Return DEA Special Handling for CPRS Dose Call
31 ;1 Requires wet sig, DEA contains 1, or a 2
32 ;2 = Controlled Sub, no wet sig required, DEA contains 3, 4, or 5
33 ;0 = others
34 Q:'$G(PSSDIENM)
35 N PSSDEAX,PSSDEAXV
36 S PSSDEAX=$P($G(^PSDRUG(PSSDIENM,0)),"^",3)
37 I PSSDEAX[1!(PSSDEAX[2) S PSSDEAXV=1 G DSET
38 I PSSDEAX[3!(PSSDEAX[4)!(PSSDEAX[5) S PSSDEAXV=2 G DSET
39 S PSSDEAXV=0
40DSET ;
41 S PSSX("DD",PSSDIENM)=PSSX("DD",PSSDIENM)_"^"_PSSDEAXV_"^"_$S($D(PSSHLF(PSSDIENM)):1,1:0)
42 Q
43HELP ;
44 Q:$G(X)=""
45 N PSSSIG,PSSYX,PSSZ0,PSSZ1,PSSCTX,PSSLPX,PSSBVAR,PSSBVAR1,PSSIII,PSSFFF,PCT,PNNN,PSSBLIM,PSSIG
46 S PSSIG(1)="",PSSCTX=1 Q:$L(X)<1 F PSSZ0=1:1:$L(X," ") G:PSSZ0="" HELP1 S PSSZ1=$P(X," ",PSSZ0) D G:'$D(X) HELP1
47 .D:$D(X)&($G(PSSZ1)]"") D HELPADD
48 ..S PSSYX=$O(^PS(51,"B",PSSZ1,0)) Q:'PSSYX!($P($G(^PS(51,+PSSYX,0)),"^",4)>1) S PSSZ1=$P($G(^PS(51,PSSYX,0)),"^",2) Q:'$D(^(9)) S PSSYX=$P(X," ",PSSZ0-1),PSSYX=$E(PSSYX,$L(PSSYX)) S:PSSYX>1 PSSZ1=^(9)
49HELP1 ;
50 S (PSSBVAR,PSSBVAR1)="",PSSIII=1
51 F PSSFFF=0:0 S PSSFFF=$O(PSSIG(PSSFFF)) Q:'PSSFFF S PCT=0 F PNNN=1:1:$L(PSSIG(PSSFFF)) I $E(PSSIG(PSSFFF),PNNN)=" "!($L(PSSIG(PSSFFF))=PNNN) S PCT=PCT+1 D I $L(PSSBVAR)>70 S PSSSIG(PSSIII)=PSSBLIM_" ",PSSIII=PSSIII+1,PSSBVAR=PSSBVAR1
52 .S PSSBVAR1=$P(PSSIG(PSSFFF)," ",(PCT))
53 .S PSSBLIM=PSSBVAR
54 .S PSSBVAR=$S(PSSBVAR="":PSSBVAR1,1:PSSBVAR_" "_PSSBVAR1)
55 I $G(PSSBVAR)'="" S PSSSIG(PSSIII)=PSSBVAR
56 I $G(PSSSIG(1))=""!($G(PSSSIG(1))=" ") S PSSSIG(1)=$G(PSSSIG(2)) K PSSSIG(2)
57 F PSSLPX=0:0 S PSSLPX=$O(PSSSIG(PSSLPX)) Q:'PSSLPX D:PSSLPX=1 EN^DDIOL(" ") D EN^DDIOL(" "_$G(PSSSIG(PSSLPX)))
58 Q
59HELPADD ;
60 I $L(PSSIG(PSSCTX))+$L(PSSZ1)+1<246 S PSSIG(PSSCTX)=PSSIG(PSSCTX)_" "_PSSZ1 Q
61 S PSSCTX=PSSCTX+1 S PSSIG(PSSCTX)=PSSZ1
62 Q
63PRICE() ;Return price per dose for CPRS Dose call
64 ;DLOOP = Internal entry number from Drug file
65 ;PSSUDOS = Dispense units per Dose
66 N PSSPRICE,PSSPRQ
67 I '$G(DLOOP) Q ""
68 S PSSPRICE=$P($G(^PSDRUG(DLOOP,660)),"^",6) I 'PSSPRICE Q ""
69 I $G(PSSUDOS) S PSSPRQ=PSSUDOS*PSSPRICE G PRICEQ
70 I $G(PSSBCM) S PSSPRQ=PSSBCM*PSSPRICE
71PRICEQ ;
72 I $E($G(PSSPRQ))="." S PSSPRQ=0_$G(PSSPRQ)
73 Q $G(PSSPRQ)
74 ;
75 Q
76 ;
77OIDEA(PSSXOI,PSSXOIP) ;
78 ;DEA return based on Orderable Item, Item and Usage passed in
79 ;1 means DEA contains a 1, or a 2
80 ;2 means DEA contains a 3, or a 4, or a 5
81 ;0 means all others
82 N PSSXOLP,PSSXOLPD,PSSXOLPX,PSSXNODD,PSSPKLX
83 S (PSSXOLPD,PSSXNODD)=0 I PSSXOIP="X" G OIDQ
84 I '$G(PSSXOI)!($G(PSSXOIP)="") G OIDQ
85 S PSSPKLX=$S(PSSXOIP="I":1,PSSXOIP="U":1,1:0)
86 F PSSXOLP=0:0 S PSSXOLP=$O(^PSDRUG("ASP",PSSXOI,PSSXOLP)) Q:'PSSXOLP!(PSSXOLPD=1) D
87 .I $P($G(^PSDRUG(PSSXOLP,"I")),"^"),$P($G(^("I")),"^")<DT Q
88 .I 'PSSPKLX,$P($G(^PSDRUG(PSSXOLP,2)),"^",3)'["O" Q
89 .I PSSPKLX I $P($G(^PSDRUG(PSSXOLP,2)),"^",3)'["U",$P($G(^(2)),"^",3)'["I" Q
90 .S PSSXNODD=1
91 .S PSSXOLPX=$P($G(^PSDRUG(PSSXOLP,0)),"^",3)
92 .I PSSXOLPX[1!(PSSXOLPX[2) S PSSXOLPD=1 Q
93 .I PSSXOLPX[3!(PSSXOLPX[4)!(PSSXOLPX[5) S PSSXOLPD=2
94OIDQ ;
95 I PSSXOLPD=0,'PSSXNODD S PSSXOLPD=""
96 Q PSSXOLPD
97 ;
98 Q
99 ;
100LEAD ;Leading zeros, CPRS Dosage call
101 N PSSBK,PSSBK1,PSSBKD
102 F PSSLD=0:0 S PSSLD=$O(PSSX(PSSLD)) Q:'PSSLD D
103 .I $E($P(PSSX(PSSLD),"^"),1)="." S $P(PSSX(PSSLD),"^")="0"_$P(PSSX(PSSLD),"^")
104 .I $E($P(PSSX(PSSLD),"^",2),1)="." S $P(PSSX(PSSLD),"^",2)="0"_$P(PSSX(PSSLD),"^",2)
105 .I $P(PSSX(PSSLD),"^",2)["/." S PSSBKD=$P(PSSX(PSSLD),"^",2) D
106 ..S PSSBK=$P(PSSBKD,"/."),PSSBK1=$P(PSSBKD,"/.",2)
107 ..S $P(PSSX(PSSLD),"^",2)=$G(PSSBK)_"/0."_$G(PSSBK1)
108 .I $E($P(PSSX(PSSLD),"^",5),1)="." S $P(PSSX(PSSLD),"^",5)="0"_$P(PSSX(PSSLD),"^",5)
109 .I $P(PSSX(PSSLD),"^",5)["/." S PSSBKD=$P(PSSX(PSSLD),"^",5) D
110 ..S PSSBK=$P(PSSBKD,"/."),PSSBK1=$P(PSSBKD,"/.",2)
111 ..S $P(PSSX(PSSLD),"^",5)=$G(PSSBK)_"/0."_$G(PSSBK1)
112 .I $O(PSSX(PSSLD,0)) D
113 ..F PSSLD1=0:0 S PSSLD1=$O(PSSX(PSSLD,PSSLD1)) Q:'PSSLD1 D
114 ...I $E($P(PSSX(PSSLD,PSSLD1),"^"),1)="." S $P(PSSX(PSSLD,PSSLD1),"^")="0"_$P(PSSX(PSSLD,PSSLD1),"^")
115 ...I $E($P(PSSX(PSSLD,PSSLD1),"^",2),1)="." S $P(PSSX(PSSLD,PSSLD1),"^",2)="0"_$P(PSSX(PSSLD,PSSLD1),"^",2)
116 ...I $P(PSSX(PSSLD,PSSLD1),"^",2)["/." S PSSBKD=$P(PSSX(PSSLD,PSSLD1),"^",2) D
117 ....S PSSBK=$P(PSSBKD,"/."),PSSBK1=$P(PSSBKD,"/.",2)
118 ....S $P(PSSX(PSSLD,PSSLD1),"^",2)=$G(PSSBK)_"/0."_$G(PSSBK1)
119 ...I $E($P(PSSX(PSSLD,PSSLD1),"^",5),1)="." S $P(PSSX(PSSLD,PSSLD1),"^",5)="0"_$P(PSSX(PSSLD,PSSLD1),"^",5)
120 ...I $P(PSSX(PSSLD,PSSLD1),"^",5)["/." S PSSBKD=$P(PSSX(PSSLD,PSSLD1),"^",5) D
121 ....S PSSBK=$P(PSSBKD,"/."),PSSBK1=$P(PSSBKD,"/.",2)
122 ....S $P(PSSX(PSSLD,PSSLD1),"^",5)=$G(PSSBK)_"/0."_$G(PSSBK1)
123 S PSSLD="" F S PSSLD=$O(PSSX("DD",PSSLD)) Q:PSSLD="" D
124 .I $E($P(PSSX("DD",PSSLD),"^",5),1)="." S $P(PSSX("DD",PSSLD),"^",5)="0"_$P(PSSX("DD",PSSLD),"^",5)
125 Q
126LEADP ;Leading zeros pharmacy call
127 N PSSBB,PSSBB1,PSSBBD
128 F PSSMD=0:0 S PSSMD=$O(PSSX(PSSMD)) Q:'PSSMD D
129 .F PSSMDN=1,3,5,11 I $E($P(PSSX(PSSMD),"^",PSSMDN),1)="." S $P(PSSX(PSSMD),"^",PSSMDN)="0"_$P(PSSX(PSSMD),"^",PSSMDN)
130 .I $P(PSSX(PSSMD),"^",2)["/." S PSSBBD=$P(PSSX(PSSMD),"^",2) D
131 ..S PSSBB=$P(PSSBBD,"/."),PSSBB1=$P(PSSBBD,"/.",2)
132 ..S $P(PSSX(PSSMD),"^",2)=$G(PSSBB)_"/0."_$G(PSSBB1)
133 .I $P(PSSX(PSSMD),"^",11)["/." S PSSBBD=$P(PSSX(PSSMD),"^",11) D
134 ..S PSSBB=$P(PSSBBD,"/."),PSSBB1=$P(PSSBBD,"/.",2)
135 ..S $P(PSSX(PSSMD),"^",11)=$G(PSSBB)_"/0."_$G(PSSBB1)
136 .I $O(PSSX(PSSMD,0)) D
137 ..F PSSMD1=0:0 S PSSMD1=$O(PSSX(PSSMD,PSSMD1)) Q:'PSSMD1 D
138 ...F PSSMDN=1,3,5,11 I $E($P(PSSX(PSSMD,PSSMD1),"^",PSSMDN),1)="." S $P(PSSX(PSSMD,PSSMD1),"^",PSSMDN)="0"_$P(PSSX(PSSMD,PSSMD1),"^",PSSMDN)
139 ...I $P(PSSX(PSSMD,PSSMD1),"^",2)["/." S PSSBBD=$P(PSSX(PSSMD,PSSMD1),"^",2) D
140 ....S PSSBB=$P(PSSBBD,"/."),PSSBB1=$P(PSSBBD,"/.",2)
141 ....S $P(PSSX(PSSMD,PSSMD1),"^",2)=$G(PSSBB)_"/0."_$G(PSSBB1)
142 ...I $P(PSSX(PSSMD,PSSMD1),"^",11)["/." S PSSBBD=$P(PSSX(PSSMD,PSSMD1),"^",11) D
143 ....S PSSBB=$P(PSSBBD,"/."),PSSBB1=$P(PSSBBD,"/.",2)
144 ....S $P(PSSX(PSSMD,PSSMD1),"^",11)=$G(PSSBB)_"/0."_$G(PSSBB1)
145 S PSSMD="" F S PSSMD=$O(PSSX("DD",PSSMD)) Q:PSSMD="" D
146 .I $E($P(PSSX("DD",PSSMD),"^",5),1)="." S $P(PSSX("DD",PSSMD),"^",5)="0"_$P(PSSX("DD",PSSMD),"^",5)
147 Q
148DUP ;delete str/unit if duplicate local doses with strength are found
149 N PSSLXA,PSSLXL,PSSLXFL,PSSLXQ,PSSLXLD,PSSLXMED,PSSLXSTR,PSSLXND,PSSLXX
150 S PSSLXFL=0
151 S PSSLXL="" F S PSSLXL=$O(PSSX(PSSLXL)) Q:PSSLXL=""!(PSSLXFL) D
152 .S PSSLXND=$G(PSSX(PSSLXL)),PSSLXSTR=""
153 .S PSSLXLD=$P(PSSLXND,"^",5),PSSLXMED=$P(PSSLXND,"^",6) I PSSLXMED S PSSLXSTR=$P($G(PSSX("DD",PSSLXMED)),"^",5)
154 .I PSSLXLD'="",PSSLXMED'="",PSSLXSTR'="" D
155 ..S PSSLXA(PSSLXLD,PSSLXSTR,PSSLXMED)=""
156 ..S PSSLXX="" F S PSSLXX=$O(PSSLXA(PSSLXLD,PSSLXSTR,PSSLXX)) Q:PSSLXX=""!(PSSLXFL) I PSSLXX'=PSSLXMED S PSSLXFL=1
157 I PSSLXFL S PSSLXQ="" F S PSSLXQ=$O(PSSX("DD",PSSLXQ)) Q:PSSLXQ="" S $P(PSSX("DD",PSSLXQ),"^",5)="",$P(PSSX("DD",PSSLXQ),"^",6)=""
158 Q
Note: See TracBrowser for help on using the repository browser.