source: WorldVistAEHR/trunk/r/NATIONAL_DRUG_FILE-PSN/PSNAPIS.m@ 1799

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

initial load of WorldVistAEHR

File size: 7.1 KB
RevLine 
[613]1PSNAPIS ;BIR/DMA-APIs for NDF ; 07/02/03 14:07
2 ;;4.0; NATIONAL DRUG FILE;**2,3,47,70**; 30 Oct 98
3 ;
4 ;Reference to ^PSDRUG supported by DBIA #2192
5 ;Reference to ^PS(50.606 supported by DBIA #2174
6 ;
7PSA(NDC,LIST) ;ENTRY FOR DRUG ACCOUNTABILITY
8 N Y,PN,PN1,P50,J
9 S Y=$Q(^PSNDF(50.67,"NDC",NDC)) I $QS(Y,3)'=NDC Q 0
10 S Y=^PSNDF(50.67,$QS(Y,4),0),Y=$P(Y,"^",6),PN=$P(^PSNDF(50.68,Y,0),"^"),PN1=$E(PN,1,30)
11 S P50=0,J=0 F S P50=$O(^PSDRUG("VAPN",PN1,P50)) Q:'P50 I $P(^PSDRUG(P50,"ND"),"^",2)=PN S LIST(P50)=$P(^PSDRUG(P50,0),"^"),J=J+1
12 Q J
13 ;
14PSJING(DA1,K,LIST) ;ENTRY FOR INGREDIENTS
15 N X,CT
16 ;DA1 IS SUPERFLUOUS, BUT WE LEAVE IN FOR COMPATABILITY
17 I 'K!('$D(^PSNDF(50.68,+K))) Q 0
18 S DA=0 F CT=0:1 S DA=$O(^PSNDF(50.68,K,2,DA)) Q:'DA S X=^(DA,0),LIST(+X)=+X_"^"_$P(^PS(50.416,+X,0),"^")_"^"_$P(X,"^",2)_"^" S:$P(X,"^",3)]"" LIST(+X)=LIST(+X)_$P($G(^PS(50.607,$P(X,"^",3),0)),"^")
19 Q CT
20 ;
21PSJDF(DA,K) ;GET DOSE FORM
22 N X,DF
23 ;AGAIN DA IS SUPERFLUOUS
24 I 'K!('$D(^PSNDF(50.68,+K))) Q 0
25 S X=$P(^PSNDF(50.68,K,0),"^",3),DF=$P($G(^PS(50.606,X,0)),"^")
26 Q X_"^"_DF
27 ;
28PSJST(DA,K) ;ENTRY FOR STRENGTH
29 I 'K!('$D(^PSNDF(50.68,K))) Q 0
30 Q 1_"^"_$P(^PSNDF(50.68,K,0),"^",4)
31 ;
32CLASS(CL) ;ENTRY FOR OE/RR TO GET CLASS $D
33 I CL']"" Q 0
34 Q $D(^PS(50.605,"C",CL))>0
35 ;
36DRUG(DA) ;ENTRY FOR OE/RR TO GET DRUG $D
37 I DA']"" Q 0
38 Q $D(^PSNDF(50.6,"B",DA))!$D(^PSNDF(50.67,"T",DA))
39 ;
40PROD0(P1,P2) ;GET INFO IN THE FORM OF THE OLD 0 PRODUCT NODE
41 N A,B
42 ;P1 IS SUPERFLUOUS
43 I P2']"" Q ""
44 S A=$G(^PSNDF(50.68,P2,0)),B=$G(^(1))
45 Q $P(A,"^")_"^"_$P(A,"^",3,5)_"^^^"_$P(B,"^",5,6)
46 ;
47PROD2(P1,P2) ;GET OLD 2 NODE
48 ;P1 STILL SUPERFLUOUS
49 I P2']"" Q ""
50 Q $P($G(^PSNDF(50.68,P2,1)),"^",1,3)_"^"_$P($G(^PSNDF(50.64,+$P(^PSNDF(50.68,P2,1),"^",4),0)),"^")
51 ;
52DCLASS(DA,K) ;GET CLASS FOR PRODUCT
53 I K']"" Q ""
54 S X=+$P($G(^PSNDF(50.68,+K,3)),"^"),Y=$P($G(^PS(50.605,X,0)),"^",2)
55 Q X_"^"_Y
56 ;
57DCLCODE(DA,K) ;RETURN VA CLASS CODE
58 I K']"" Q ""
59 S X=+$P($G(^PSNDF(50.68,+K,3)),"^"),X=$P($G(^PS(50.605,X,0)),"^")
60 Q X
61 ;
62 ;DA IS SUPERFLUOUS
63VAGN(DA) ;GET VA GENERIC NAME
64 I 'DA!'$D(^PSNDF(50.6,+DA,0)) Q 0
65 Q $P(^PSNDF(50.6,+DA,0),"^")
66 ;
67FORMI(DA,K) ;GET FORMULARY INDICATOR FOR VA PRODUCT
68 ;DA IS SUPERFLUOUS
69 ;1 if yes, 0 if no, null if not entered
70 Q $P($G(^PSNDF(50.68,+K,5)),"^")
71 ;
72FORMR(DA,K) ;GET EXISTENCE OF FORMULARY RESTRICTIONS
73 ;DA IS SUPERFLUOUS
74 Q $O(^PSNDF(50.68,+K,6,0))]""
75 ;
76DFSU(DA,K) ;RETURN DOSE FORM, STRENGTH, AND UNITS FOR PDM AND CPRS
77 N U1,UN
78 I 'K!('$D(^PSNDF(50.68,+K,0))) Q 0
79 S U1=+$P(^PSNDF(50.68,+K,0),"^",5),UN=$P($G(^PS(50.607,U1,0)),"^")
80 Q $$PSJDF(DA,K)_"^"_$$PSJST(DA,K)_"^"_U1_"^"_UN
81 ;
82VAP(DA,LIST) ;GIVEN GENERIC RETURN ARRAY LIST(IEN)=IEN^PRODUCT^DF PTR^DOSE FOMR
83 N PR,J,X
84 I 'DA!'$D(^PSNDF(50.6,+DA)) Q 0
85 S PR=0,J=0 F S PR=$O(^PSNDF(50.6,"APRO",DA,PR)) Q:'PR S X=^PSNDF(50.68,PR,0),DAT=$P($G(^(7)),"^",3) D
86 .S LIST(PR)=PR_"^"_$P(X,"^")_"^"_$P(X,"^",3)_"^"_$P($G(^PS(50.606,+$P(X,"^",3),0)),"^")_"^"_$P(^PSNDF(50.68,PR,3),"^")_"^"_$P($G(^PS(50.605,+$P(^PSNDF(50.68,PR,3),"^"),0)),"^"),J=J+1 I DAT,(DAT<DT) S LIST(PR)=LIST(PR)_"^I"
87 Q J
88 ;
89PSPT(DA,K,LIST) ;GIVEN PRODUCT K RETURN LIST(INE1^IEN2)=IEN1^PSIZE^IEN1^PTYPE
90 N NDC,J,PT,PS
91 ;DA SUPERFLUOUS
92 I 'K!'$D(^PSNDF(50.68,+K)) Q 0
93 S NDC=0 F J=0:1 S NDC=$O(^PSNDF(50.68,"ANDC",K,NDC)) Q:'NDC S X=^PSNDF(50.67,NDC,0),PS=$P(X,"^",8),PT=$P(X,"^",9),LIST(PS_"^"_PT)=PS_"^"_$P($G(^PS(50.609,PS,0)),"^")_"^"_PT_"^"_$P($G(^PS(50.608,PT,0)),"^")
94 Q J
95 ;
96DSS(DA,K,DATE) ;RETURN DSS FEEDER KEY
97 ;NEW STYLE IF DATE IS MISSING OR NOT LESS THAN 199810
98 ;OLD STYLE OTHERWISE
99 S DATE=$G(DATE,999999)
100 I DATE'<199810 Q $S($D(^PSNDF(50.68,+K)):$$RJ^XLFSTR(K,5,0),1:"00000")
101 I $D(^PSNDF(50.6,+DA)),$D(^PSNDF(50.68,+K,7)) Q $$RJ^XLFSTR(DA,4,0)_$$RJ^XLFSTR($P(^PSNDF(50.68,+K,7),"^",9),3,0)
102 Q "0000000"
103 ;
104CPRS(DA,K) ;CALL FOR CPRS
105 N CL,X,DF,ST,UN
106 ;RETURNS X=DOSE FORM^CLASS^STRENGTH^UNITS
107 I '$D(^PSNDF(50.68,+K)) Q 0
108 S CL=$P($G(^PS(50.605,+$P(^PSNDF(50.68,K,3),"^"),0)),"^")
109 S X=^PSNDF(50.68,K,0),DF=+$P(X,"^",3),ST=$P(X,"^",4),UN=+$P(X,"^",5)
110 Q $P($G(^PS(50.606,DF,0)),"^")_"^"_CL_"^"_ST_"^"_$P($G(^PS(50.607,UN,0)),"^")
111 ;
112CIRN(NDC,LIST) ;CALL FOR CIRN
113 N DA,X,A
114 I NDC["-" S NDC=$$RJ^XLFSTR($P(NDC,"-"),6,0)_$$RJ^XLFSTR($P(NDC,"-",2),4,0)_$$RJ^XLFSTR($P(NDC,"-",3),2,0)
115 K LIST S LIST="000000000000" F J=1:1:7 S LIST(J)=""
116 S DA=$O(^PSNDF(50.67,"NDC",NDC,0)) Q:'DA S X=^PSNDF(50.67,DA,0),LIST(7)=$P(X,"^",2)_"^"_$P(X,"^",4,6)_"^",A=0 F S A=$O(^PSNDF(50.67,DA,1,A)) Q:'A S LIST(7)=LIST(7)_^(A,0)_" "
117 S LIST(6)=$P(X,"^",9),LIST(5)=$P(X,"^",8),A=$P(X,"^",6),X=^PSNDF(50.68,A,0)
118 S LIST(2)=$P(X,"^",3)_"^^"_$P(^PSNDF(50.68,A,3),"^"),LIST(3)=$P(X,"^",4),LIST(4)=$P(X,"^",5)
119 S LIST(0)=$P(X,"^",2),LIST(1)=^PSNDF(50.6,$P(X,"^",2),0),LIST=NDC
120 F J=1:1:7 I LIST(J)="NO DATA" S LIST(J)=""
121 Q
122 ;
123B() ;RETURNS THE GLOBAL ROOT OF THE "B" CROSSREFERENCE IN NDF
124 Q "^PSNDF(50.6,""B"")"
125 ;
126T() ;RETURNS THE GLOBAL ROOT OF THE "T" CROSSREFERENCE IN NDF
127 Q "^PSNDF(50.67,""T"")"
128 ;
129TTOG(TRADE,LIST) ;RETURNS LIST(IEN)=IEN_"^"GENERIC FOR EVERY ENTRY IN 50.6 WHICH MATCHES THE TRADE NAME
130 I TRADE="" Q 0
131 N X,CT
132 I '$O(^PSNDF(50.67,"T",TRADE,0)) Q 0
133 S (X,CT)=0 F S X=$O(^PSNDF(50.67,"T",TRADE,X)) Q:'X S Y=$P(^PSNDF(50.67,X,0),"^",6),Y=$P(^PSNDF(50.68,Y,0),"^",2) I '$D(LIST(Y)) S LIST(Y)=Y_"^"_$P(^PSNDF(50.6,Y,0),"^"),CT=CT+1
134 Q CT
135 ;
136CLIST(DA,LIST) ;RETURNS LIST(IEN)=IEN IN 50.605^CLASS CODE
137 ;FOR EVERY CLASS IN PSNDF(50.6,DA)
138 I 'DA Q 0
139 I '$D(^PSNDF(50.6,+DA)) Q 0
140 N K,CT S (K,CT)=0 F S K=$O(^PSNDF(50.6,"APRO",DA,K)) Q:'K S IEN=$P(^PSNDF(50.68,K,3),"^") I '$D(LIST(IEN)) S LIST(IEN)=IEN_"^"_$P(^PS(50.605,IEN,0),"^"),CT=CT+1
141 Q CT
142 ;
143TGTOG(NAME) ;GIVEN NAME TRY TO FIND IT IN T OR B CROSS REFERENCE AND RETURN IEN
144 N X
145 I NAME="" Q 0
146 S X=$O(^PSNDF(50.6,"B",NAME,0)) I X Q X
147 I '$O(^PSNDF(50.67,"T",NAME,0)) Q 0
148 S X=$O(^PSNDF(50.67,"T",NAME,0)),X=$P(^PSNDF(50.67,X,0),"^",6),X=$P(^PSNDF(50.68,X,0),"^",2) Q X
149 ;
150TGTOG2(NAME,LIST) ;PARTIAL LOOKUP ON T OR B
151 I NAME="" Q
152 N NAM,X,Y,CT
153 S CT=0
154 S NAM=$E(NAME,1,$L(NAME)-1)_$C($A($E(NAME,$L(NAME)))-1)_"z" F S NAM=$O(^PSNDF(50.6,"B",NAM)),X=0 Q:NAM'[NAME F S X=$O(^PSNDF(50.6,"B",NAM,X)) Q:'X S LIST(X)=X_"^"_$P(^PSNDF(50.6,X,0),"^"),CT=CT+1
155 S NAM=$E(NAME,1,$L(NAME)-1)_$C($A($E(NAME,$L(NAME)))-1)_"z" F S NAM=$O(^PSNDF(50.67,"T",NAM)),X=0 Q:NAM'[NAME F S X=$O(^PSNDF(50.67,"T",NAM,X)) Q:'X S Y=$P(^PSNDF(50.67,X,0),"^",6),Y=$P(^PSNDF(50.68,Y,0),"^",2) D
156 .I '$D(LIST(Y)) S LIST(Y)=Y_"^"_$P(^PSNDF(50.6,Y,0),"^"),CT=CT+1
157 Q CT
158 ;
159CIRN2(P1,P3,LIST) ;RETURN LIST OF NDCS FOR A PRODUCT
160 I 'P3 Q 0
161 I '$D(^PSNDF(50.68,+P3)) Q 0
162 N D,N,J
163 S N=0
164 F J=0:1 S N=$O(^PSNDF(50.68,"ANDC",P3,N)) Q:'N S LIST(J)=$P(^PSNDF(50.67,N,0),"^",2)
165 Q J
166 ;
167CLASS2(IEN) ;RETURNS FIRST 2 PIECES OF ZERO NODE OF 50.605
168 Q $P($G(^PS(50.605,+IEN,0)),"^",1,2)
169 ;
170CMOP(CODE) ;CODE = 5 CHARACTER CMOP CODE RETURNS PRODUCT NAME
171 I CODE="" Q ""
172 I '$O(^PSNDF(50.68,"C",CODE,0)) Q ""
173 Q $P(^PSNDF(50.68,+$O(^PSNDF(50.68,"C",CODE,0)),0),"^")
174 ;
175FORMRX(DA,K,LIST) ;RETURN X=1 FOR RESTRICTIONS, 0 FOR NO
176 ;RETURNS LIST=WORD PROCESSING FIELD FOR RESTRICTIONS
177 ;
178 I '$O(^PSNDF(50.68,+K,6,0)) Q 0
179 M LIST=^PSNDF(50.68,+K,6) Q 1
180 ;
181DDIEX(DA,K) ;RETURN X=1 FOR EXCLUDE DDI CHECK, 0 FOR CONTINUE DDI CHECK
182 ;
183 I '$G(^PSNDF(50.68,+K,8)) Q 0
184 I $G(^PSNDF(50.68,+K,8)) Q 1
185 ;
Note: See TracBrowser for help on using the repository browser.