source: FOIAVistA/trunk/r/PHARMACY_DATA_MANAGEMENT-PSS/PSS50DAT.m@ 1671

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

initial load of FOIAVistA 6/30/08 version

File size: 8.4 KB
Line 
1PSS50DAT ;BHAM ISC/TSS - CONTINUATION OF API FOR INFORMATION FROM FILE 50; 5 Sep 03
2 ;;1.0;PHARMACY DATA MANAGEMENT;**85,92,112,118**;9/30/97;Build 8
3DATA ;
4 ;PSSIEN - IEN of entry in 50
5 ;PSSFT - Free Text name in 50
6 ;PSSFL - Inactive flag - "" - All entries
7 ; FileMan Date - Only entries with no Inactive Date or an Inactive Date greater than this date.
8 ;PSSPK - Application Package's Use - "" - All entries
9 ; Alphabetic codes that represent the DHCP packages that consider this drug to be
10 ; part of their formulary.
11 ;PSSRTOI - Orderable Item - return only entries matched to a Pharmacy Orderable Item
12 ;LIST - Subscript of ^TMP array in the form ^TMP($J,LIST,Field Number where Field Number is the Field Number of the data
13 ; piece being returned.
14 ;Reference to ^PSNDF(50.68 is supported by DBIA 3735
15 ;NEW UNPROTECTED FILEMAN VARIABLES
16 N DO,DINDEX,DISUB,DIVAL
17 N PSSBGCNT
18 N PSSCNT
19 N PSSTIEN
20 N PSSTMP
21 N PSSOLD
22 N PSSALT
23 N PSSMATCH
24 N PSSSYN
25 N PSSCAP
26 S PSSBGCNT=0
27 S SCR("S")=""
28 I $G(LIST)']"" Q
29 I +$G(PSSIEN)'>0,($G(PSSFT)']"") S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
30 K ^TMP("DILIST",$J)
31 K ^TMP($J,LIST)
32 S SCR("S")=""
33 I +$G(PSSFL)>0!($G(PSSPK)]"")!($G(PSSRTOI)=1) N PSS5ND,PSSZ3,PSSZ4 D SETSCRN^PSS50A
34 I +$G(PSSIEN)>0 N PSSIEN2 S PSSIEN2=$$FIND1^DIC(50,"","A","`"_PSSIEN,,SCR("S"),"") D K ^TMP("PSSP50",$J) D COUNTBG Q
35 .I PSSIEN2>0 D DIRREAD
36 I +$G(PSSIEN)=0 D
37 .I PSSFT="??" D LOOPDIR D COUNTBG Q
38 .D FIND^DIC(50,,"@;.01","QP",PSSFT,,"B",SCR("S"),,"") D LOOPDI D COUNTBG
39 Q
40 ;
41COUNTBG ;CHECKS PSSBGCNT AND FILLS COUNT IN ON 0 NODE OF ^TMP($J,LIST)
42 I PSSBGCNT>0 D
43 .S ^TMP($J,LIST,0)=PSSBGCNT
44 ELSE S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND"
45 Q
46 ;
47LOOPDI ;LOOPS ON "DILIST" FROM FILEMAN CALL (USED FOR RETURNING MULTIPLE DRUGS FROM PSSFT)
48 S PSSTIEN=0 ;TEMP IEN TO ITERATE OVER DILIST
49 F S PSSTIEN=$O(^TMP("DILIST",$J,PSSTIEN)) Q:PSSTIEN="" D
50 .S PSSIEN2=($P(^TMP("DILIST",$J,PSSTIEN,0),U,1))
51 .D DIRREAD
52 Q
53 ;
54LOOPDIR ;LOOP FOR A DIRECT READ. READS ALL IENs FOR ^PSDRUG(
55 S PSSIEN2=0
56 F S PSSIEN2=$O(^PSDRUG(PSSIEN2)) Q:'PSSIEN2 D
57 .I $P($G(^PSDRUG(PSSIEN2,0)),U,1)'="" D DIRALL
58 Q
59 ;
60DIRALL ;TEST FOR PSSFL, PSSRTOI, PSSPK, BAILS IF CONDITIONS MEET TRUE
61 I $G(PSSFL),$P($G(^PSDRUG(PSSIEN2,"I")),"^"),$P($G(^("I")),"^")'>PSSFL Q
62 I $G(PSSRTOI)=1,'$P($G(^PSDRUG(PSSIEN2,2)),"^") Q
63 I $G(PSSPK)]"" N PSSZ5,PSSZ6 S PSSZ5=0 F PSSZ6=1:1:$L(PSSPK) Q:PSSZ5 I $P($G(^PSDRUG(PSSIEN2,2)),U,3)[$E(PSSPK,PSSZ6) S PSSZ5=1
64 I $G(PSSPK)]"",'PSSZ5 Q
65 D DIRREAD
66 Q
67 ;
68DIRREAD ;MAIN DIRECT READ FOR ENTIRE ROUTINE
69 D DIRREAD^PSS50TMP
70 D SYNONYM
71 S ^TMP($J,LIST,"B",$G(^TMP($J,LIST,PSSIEN2,.01)),PSSIEN2)=""
72 D FORMALT
73 D OLD
74 D SRVCODE($P(^TMP($J,LIST,PSSIEN2,22),U,1))
75 S PSSBGCNT=PSSBGCNT+1
76 Q
77 ;
78SYNONYM ; FILLS SYNONYM MULTIPLE
79 S PSSCNT=0
80 S PSSTMP=""
81 S PSSSYN=""
82 F S PSSSYN=$O(^PSDRUG(PSSIEN2,1,PSSSYN)) Q:PSSSYN="" D
83 .I $P($G(^PSDRUG(PSSIEN2,1,PSSSYN,0)),U,1)'="" D
84 ..S ^TMP($J,LIST,PSSIEN2,"SYN",PSSSYN,.01)=$P($G(^PSDRUG(PSSIEN2,1,PSSSYN,0)),U,1)
85 ..;;;;;INTENDED USE
86 ..S PSSTMP=$P($G(^PSDRUG(PSSIEN2,1,PSSSYN,0)),U,3)
87 ..I PSSTMP="0" S ^TMP($J,LIST,PSSIEN2,"SYN",PSSSYN,1)=PSSTMP_U_"TRADE NAME"
88 ..I PSSTMP="1" S ^TMP($J,LIST,PSSIEN2,"SYN",PSSSYN,1)=PSSTMP_U_"QUICK CODE"
89 ..I PSSTMP="D" S ^TMP($J,LIST,PSSIEN2,"SYN",PSSSYN,1)=PSSTMP_U_"DRUG ACCOUNTABILITY"
90 ..I PSSTMP="C" S ^TMP($J,LIST,PSSIEN2,"SYN",PSSSYN,1)=PSSTMP_U_"CONTROLLED SUBSTANCES"
91 ..I PSSTMP="" S ^TMP($J,LIST,PSSIEN2,"SYN",PSSSYN,1)=""
92 ..;;;;;NDC CODE
93 ..S ^TMP($J,LIST,PSSIEN2,"SYN",PSSSYN,2)=$P($G(^PSDRUG(PSSIEN2,1,PSSSYN,0)),U,2)
94 ..S ^TMP($J,LIST,PSSIEN2,"SYN",PSSSYN,403)=$P($G(^PSDRUG(PSSIEN2,1,PSSSYN,0)),U,7)
95 ..S PSSCNT=PSSCNT+1
96 I PSSCNT=0 S ^TMP($J,LIST,PSSIEN2,"SYN",0)="-1^NO DATA FOUND"
97 ELSE S ^TMP($J,LIST,PSSIEN2,"SYN",0)=PSSCNT
98 Q
99 ;
100FORMALT ;FILLS FORMULARY ALTERATIVE MULTIPLE
101 S PSSCNT=0
102 S PSSALT=0
103 F S PSSALT=$O(^PSDRUG(PSSIEN2,65,PSSALT)) Q:PSSALT="" D
104 .I $P($G(^PSDRUG(PSSIEN2,65,PSSALT,0)),U,1)'="" D
105 ..S ^TMP($J,LIST,PSSIEN2,"FRM",PSSALT,2)=$P($G(^PSDRUG(PSSIEN2,65,PSSALT,0)),U,1)_U_$P($G(^PSDRUG($P($G(^PSDRUG(PSSIEN2,65,PSSALT,0)),U,1),0)),U,1)
106 ..S PSSCNT=PSSCNT+1
107 I PSSCNT=0 S ^TMP($J,LIST,PSSIEN2,"FRM",0)="-1^NO DATA FOUND"
108 ELSE S ^TMP($J,LIST,PSSIEN2,"FRM",0)=PSSCNT
109 Q
110 ;
111OLD ;FILLS THE OLD NAME MULTIPLE
112 S PSSCNT=0
113 S PSSOLD=0
114 F S PSSOLD=$O(^PSDRUG(PSSIEN2,900,PSSOLD)) Q:PSSOLD="" D
115 .I $P($G(^PSDRUG(PSSIEN2,900,PSSOLD,0)),U,2)'="" D
116 ..S PSSCAP=$$UP^XLFSTR($$FMTE^XLFDT($P(^PSDRUG(PSSIEN2,900,PSSOLD,0),U,2)))
117 ..S ^TMP($J,LIST,PSSIEN2,"OLD",PSSOLD,.02)=$P($G(^PSDRUG(PSSIEN2,900,PSSOLD,0)),U,2)_U_PSSCAP
118 .ELSE S ^TMP($J,LIST,PSSIEN2,"OLD",PSSOLD,.02)=""
119 .I $P($G(^PSDRUG(PSSIEN2,900,PSSOLD,0)),U,1)'="" D
120 ..S ^TMP($J,LIST,PSSIEN2,"OLD",PSSOLD,.01)=$P($G(^PSDRUG(PSSIEN2,900,PSSOLD,0)),U,1)
121 ..S PSSCNT=PSSCNT+1
122 .ELSE S ^TMP($J,LIST,PSSIEN2,"OLD",PSSOLD,.01)=""
123 I PSSCNT=0 S ^TMP($J,LIST,PSSIEN2,"OLD",0)="-1^NO DATA FOUND"
124 ELSE S ^TMP($J,LIST,PSSIEN2,"OLD",0)=PSSCNT
125 Q
126 ;
127SRVCODE(PSSMATCH) ;FILLS SERVICE CODE MULTIPLE
128 I PSSMATCH'="" S ^TMP($J,LIST,PSSIEN2,400)=$P($G(^PSNDF(50.68,PSSMATCH,"PFS")),U,1)
129 I $P($G(^TMP($J,LIST,PSSIEN2,400)),U,1)="" S ^TMP($J,LIST,PSSIEN2,400)=$P($G(^PSDRUG(PSSIEN2,"PFS")),U,1)
130 I $P($G(^TMP($J,LIST,PSSIEN2,400)),U,1)="" S ^TMP($J,LIST,PSSIEN2,400)=600000
131 Q
132 ;
133DRG ;
134 ;PSSIEN - IEN of entry in 50
135 ;PSSFT - Free Text name in 50
136 ;PSSFL - Inactive flag - "" - All entries
137 ; FileMan Date - Only entries with no Inactive Date or an Inactive Date greater than this date.
138 ;PSSPK - Application Package's Use - "" - All entries
139 ; Alphabetic codes that represent the DHCP packages that consider this drug to be
140 ; part of their formulary.
141 ;PSSRTOI - Orderable Item - return only entries matched to a Pharmacy Orderable Item
142 ;LIST - Subscript of ^TMP array in the form ^TMP($J,LIST,Field Number where Field Number is the Field Number of the data
143 ; piece being returned.
144 N DIERR,ZZERR,PSSP50,SCR,PSS,PSSMLCT
145 I $G(LIST)']"" Q
146 K ^TMP($J,LIST)
147 I +$G(PSSIEN)'>0,($G(PSSFT)']"") S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
148 S SCR("S")=""
149 I +$G(PSSFL)>0!($G(PSSPK)]"")!($G(PSSRTOI)=1) N PSS5ND,PSSZ3,PSSZ4 D SETSCRN^PSS50A
150 I +$G(PSSIEN)>0 N PSSIEN2 S PSSIEN2=$$FIND1^DIC(50,"","A","`"_PSSIEN,,SCR("S"),"") D K ^TMP("PSSP50",$J) Q
151 .K ^TMP("DIERR",$J)
152 .I +PSSIEN2'>0 S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
153 .S ^TMP($J,LIST,0)=1
154 .K ^TMP("PSSP50",$J) D GETS^DIQ(50,+PSSIEN2,".01;62.01:62.05;905","IE","^TMP(""PSSP50"",$J)") S PSS(1)=0
155 .F S PSS(1)=$O(^TMP("PSSP50",$J,50,PSS(1))) Q:'PSS(1) D SETDRG^PSS50A1
156 I $G(PSSIEN)'="" S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
157 I $G(PSSFT)]"" D
158 .I PSSFT["??" D LOOP^PSS50A1 Q
159 .K ^TMP("DILIST",$J)
160 .D FIND^DIC(50,,"@;.01","QP",PSSFT,,"B",SCR("S"),,"")
161 .I +$G(^TMP("DILIST",$J,0))=0 S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
162 .I +^TMP("DILIST",$J,0)>0 S ^TMP($J,LIST,0)=+^TMP("DILIST",$J,0) N PSSXX S PSSXX=0 F S PSSXX=$O(^TMP("DILIST",$J,PSSXX)) Q:'PSSXX D
163 ..S PSSIEN=+^TMP("DILIST",$J,PSSXX,0)
164 ..K ^TMP("PSSP50",$J) D GETS^DIQ(50,+PSSIEN,".01;62.01:62.05;905","IE","^TMP(""PSSP50"",$J)") S PSS(1)=0
165 ..F S PSS(1)=$O(^TMP("PSSP50",$J,50,PSS(1))) Q:'PSS(1) D SETDRG^PSS50A1
166 K ^TMP("DILIST",$J),^TMP("PSSP50",$J)
167 Q
168 ;
169LOOP ;
170 N PSS50DD1,PSS50DD2,PSS50DD3,PSS50DD4,PSS50ER1,PSS50ER2,PSS50ER3,PSS50ER4,PSS51NFD,PSS52NFD,PSSG2N,PSS501NX
171 D FIELD^DID(50,51,"Z","POINTER","PSS50DD1","PSS50ER1") S PSS51NFD=$G(PSS50DD1("POINTER"))
172 D FIELD^DID(50,52,"Z","POINTER","PSS50DD2","PSS50ER2") S PSS52NFD=$G(PSS50DD2("POINTER"))
173 D FIELD^DID(50,301,"Z","POINTER","PSS50DD3","PSS50ER3") S PSSG2N=$G(PSS50DD3("POINTER"))
174 D FIELD^DID(50.1,1,"Z","POINTER","PSS50DD4","PSS50ER4") S PSS501NX=$G(PSS50DD4("POINTER"))
175 N PSSENCT
176 S PSSENCT=0
177 S PSS(1)=0 F S PSS(1)=$O(^PSDRUG(PSS(1))) Q:'PSS(1) D
178 .I $P($G(^PSDRUG(PSS(1),0)),"^")="" Q
179 .I $G(PSSFL),$P($G(^PSDRUG(PSS(1),"I")),"^"),$P($G(^("I")),"^")'>PSSFL Q
180 .I $G(PSSRTOI)=1,'$P($G(^PSDRUG(PSS(1),2)),"^") Q
181 .;Naked reference below refers to ^PSDRUG(PSS(1),2)
182 .I $G(PSSPK)]"" N PSSZ5,PSSZ6 S PSSZ5=0 F PSSZ6=1:1:$L(PSSPK) Q:PSSZ5 I $P($G(^(2)),"^",3)[$E(PSSPK,PSSZ6) S PSSZ5=1
183 .I $G(PSSPK)]"",'PSSZ5 Q
184 .D SETSUB1^PSS50AQM(PSS(1)),SETSUB2^PSS50AQM(PSS(1)),SETSUB3^PSS50AQM(PSS(1))
185 .D SETALL^PSS50AQM,SETOLD^PSS50AQM,SETSYN^PSS50AQM,SETFMA^PSS50AQM
186 .S PSSENCT=PSSENCT+1
187 S ^TMP($J,LIST,0)=$S($G(PSSENCT):$G(PSSENCT),1:"-1^NO DATA FOUND")
188 Q
Note: See TracBrowser for help on using the repository browser.