source: pharmacy-utils/drug-file-cleanup/VWPSSXPD.m@ 1409

Last change on this file since 1409 was 1409, checked in by Sam Habiel, 12 years ago

updated file

File size: 7.2 KB
Line 
1VWPSSXPD ; VW/SMH - Update the Drug File and friends... ; Wed Apr 13 2012 ; 4/16/12 11:02am
2 ;;1.0;WorldVista Modifications;;;Build 5
3 ; (C) Sam Habiel
4 ; Licensed under AGPL
5 ;
6 ; This routine contains utilities to remove a drug file and install a new drug
7 ; file in VISTA originating in another system. As of Build 3, you can use KIDS
8 ; to transport the file.
9 ;
10 ; Workflow (Manual, without using KIDS)
11 ; On the Origin System:
12 ; - Create a Global Output containing:
13 ; ^PSDRUG DRUG
14 ; ^PS(50.7) PHARMACY ORDERABLE ITEM
15 ; ^PS(51.7) DRUG TEXT
16 ; ^PS(52.6) IV ADDITIVES
17 ; ^PS(52.7) IV SOLUTIONS
18 ; ^PS(50.4) DRUG ELECTROLYTES
19 ;
20 ; On the Destination System:
21 ; 1. Call KILLDRUG to remove all Drug Data
22 ; 2. Restore the global created above.
23 ; 3. Call RESTOCK to sync CPRS files back with drug files.
24 ;
25 ; Workflow (using KIDS):
26 ; On the Origin System:
27 ; - Create a KIDS build that calls the follwing:
28 ; 1. ENV is the Environment Check for the Build
29 ; 2. TRAN is the Pre-Transport Routine for your originating system drug data
30 ; 3. PRE is the Pre-Init for the Destination System
31 ; 4. POST is the Post-Init for the Destination System
32 ; - Generate the KIDS Build
33 ; On the Destination System:
34 ; - Install the KIDS Build
35 ;
36 ; Limitations:
37 ; - If the Administration Schedules from the originating system and destination
38 ; system don't match, you need to either change the schedules on the orderable
39 ; items, or make the schedules on the destination system the same as the
40 ; ones from incoming drug file, otherwise, the problems you run into is this:
41 ; - Orders do not calculate frequency correctly if the schedule is not present
42 ; in the destination system. This means that the proper number of pills cannot
43 ; be calculated.
44 ; - In Outpatient Pharmacy, Schedules do not expand into patient readable
45 ; instructions
46 ; - If the National Drug Files are not up to date in the destination system, there
47 ; will be some broken pointers. All you have to do is update them.
48 ; - If some drugs are linked with lab tests, these need to be re-linked. Preferably,
49 ; these should be removed prior to transporting the drug file.
50 ;
51 ; --- ()()() ---
52 ;
53 ; PEPs: KILLDRUG to remove all Drugs
54 ; RESTOCK to add the drugs back to CPRS
55 ;
56 ; KIDS EPs:
57 ; ENV -> Environment Check (call the routine from the top)
58 ; TRAN -> Pre-Transport Routine (to get data from original system)
59 ; PRE -> Pre-Init for the Destination System
60 ; POST -> Post-Init for the Destination System
61 ;
62 ; KIDS EPs call PEPs to do their work.
63 ;
64 ; Environment Check falls through from the top
65 ;
66 ; -- START KIDS HOOKS --
67 ;
68ENV ; Environment Check Routine; KIDS EP; top fallthough
69 W $$CJ^XLFSTR("------ WARNING WARNING WARNING -----",80),!! ; Center Justify
70 W "This package will delete your drug file and add a new drug file contained",!
71 W "in the distribution.",!!
72 W "If you have patient pharmacy data, this will CORRUPT your database.",!!
73 N VWPROD S VWPROD=$$PROD^XUPROD() ; Check if a production acc; +ve val is yes
74 W "You are running in a "_$S(VWPROD:"Production",1:"Test")_" Environment.",!!
75 W "Are you sure you want to continue? Type a full YES/yes if you want to proceed)",!
76 N X R "ANSWER: ",X:60
77 S X=$$UP^XLFSTR(X) ; uppercase
78 I X'="YES" S XPDQUIT=1 ; Quit if the user doesn't say yes
79 QUIT
80 ;
81TRAN ; Pre-Transport routine for KIDS to ship off the 50, 50.7, 51.7 globals
82 M @XPDGREF@("VWPSSXPD",50)=^PSDRUG ; DRUG
83 M @XPDGREF@("VWPSSXPD",50.7)=^PS(50.7) ; PHARMACY ORDERABLE ITEM
84 M @XPDGREF@("VWPSSXPD",51.7)=^PS(51.7) ; DRUG TEXT
85 M @XPDGREF@("VWPSSXPD",52.6)=^PS(52.6) ; IV ADDITIVES
86 M @XPDGREF@("VWPSSXPD",52.7)=^PS(52.7) ; IV SOLUTIONS
87 M @XPDGREF@("VWPSSXPD",50.4)=^PS(50.4) ; DRUG ELECTROLYTES
88 QUIT
89 ;
90PRE ; Pre-Init routine for KIDS
91 DO KILLDRUG ; Remove old drugs from system.
92 QUIT
93 ;
94POST ; Post-Init routine for KIDS
95 ; Load new drugs into system
96 M ^PSDRUG=@XPDGREF@("VWPSSXPD",50) ; DRUG
97 M ^PS(50.7)=@XPDGREF@("VWPSSXPD",50.7) ; PHARMACY ORDERABLE ITEM
98 M ^PS(51.7)=@XPDGREF@("VWPSSXPD",51.7) ; DRUG TEXT
99 M ^PS(52.6)=@XPDGREF@("VWPSSXPD",52.6) ; IV ADDITIVES
100 M ^PS(52.7)=@XPDGREF@("VWPSSXPD",52.7) ; IV SOLUTIONS
101 M ^PS(50.4)=@XPDGREF@("VWPSSXPD",50.4) ; DRUG ELECTROLYTES
102 ; Restock the CPRS files from the new drug files
103 DO RESTOCK
104 QUIT
105 ;
106 ; -- END KIDS HOOKS --
107 ;
108 ; -- BEGIN Public Entry Points --
109KILLDRUG ; Remove all Drug Data. PEP. Use this to call the routine.
110 D DT^DICRW ; Min FM Vars
111 D MES^XPDUTL("Killing Drug (50)") D DRUG
112 D MES^XPDUTL("Killing Pharmacy Orderable Item (OI) (50.7)") D PO
113 D MES^XPDUTL("Killing Drug Text (51.7)") D DRUGTEXT
114 D MES^XPDUTL("Killing IV Additives (52.6)") D IVADD
115 D MES^XPDUTL("Killing IV Solutions (52.7)") D IVSOL
116 D MES^XPDUTL("Killing Drug Electrolytes (50.4)") D DRUGELEC
117 D MES^XPDUTL("Removing Pharmacy OIs from the Orderable Item (101.43)") D O
118 D MES^XPDUTL("Syncing the Order Quick View (101.44)") D CPRS
119 QUIT
120 ;
121RESTOCK ; Restock CPRS Orderable Items from new Drug & Pharmacy Orderable Item
122 ; File. Public Entry Point.
123 ; Call this after repopulating the drug file (50) and the pharmacy orderable
124 ; item file (50.7)
125 N PSOIEN ; Looper variable
126 D DT^DICRW ; Establish FM Basic Variables
127 ;
128 ; Loop through Orderable Item file and call
129 ; 1. The Active/Inactive Updater for the Orderable Item
130 ; 2. the protocol file updater to CPRS Files
131 S PSOIEN=0 F S PSOIEN=$O(^PS(50.7,PSOIEN)) Q:'PSOIEN D
132 . D MES^XPDUTL("Syncing Pharamcy Orderable Item "_PSOIEN)
133 . D EN^PSSPOIDT(PSOIEN),EN2^PSSHL1(PSOIEN,"MUP")
134 D CPRS ; Update Orderable Item View files
135 QUIT
136 ;
137 ; -- END Public Entry Points --
138 ;
139 ; -- The rest is private --
140DRUG ; Kill Drug File; Private
141 N %1 S %1=^PSDRUG(0)
142 K ^PSDRUG
143 S ^PSDRUG(0)=%1
144 S $P(^PSDRUG(0),"^",3,4)=""
145 QUIT
146 ;
147PO ; Kill Pharmacy Orderable Items; Private
148 N %1 S %1=^PS(50.7,0)
149 K ^PS(50.7)
150 S ^PS(50.7,0)=%1
151 S $P(^PS(50.7,0),"^",3,4)=""
152 QUIT
153 ;
154DRUGTEXT ; Kill Drug Text Entries ; Private
155 N %1 S %1=^PS(51.7,0)
156 K ^PS(51.7)
157 S ^PS(51.7,0)=%1
158 S $P(^PS(51.7,0),"^",3,4)=""
159 QUIT
160 ;
161IVADD ; Kill IV Additives ; Private
162 N %1 S %1=^PS(52.6,0)
163 K ^PS(52.6)
164 S ^PS(52.6,0)=%1
165 S $P(^PS(52.6,0),"^",3,4)=""
166 QUIT
167 ;
168IVSOL ; Kill IV Solutions ; Private
169 N %1 S %1=^PS(52.7,0)
170 K ^PS(52.7)
171 S ^PS(52.7,0)=%1
172 S $P(^PS(52.7,0),"^",3,4)=""
173 QUIT
174 ;
175DRUGELEC ; Kill Drug Electrolytes ; Private
176 N %1 S %1=^PS(50.4,0)
177 K ^PS(50.4)
178 S ^PS(50.4,0)=%1
179 S $P(^PS(50.4,0),"^",3,4)=""
180 QUIT
181 ;
182O ; Kill off Pharamcy Order Items (Only!) in the Orderable Item file; Private
183 N DA ; Used in For loop below
184 N DIK S DIK="^ORD(101.43,"
185 N I S I=0
186 FOR S I=$O(^ORD(101.43,"ID",I)) QUIT:I="" DO
187 . I I["PSP" S DA=$O(^ORD(101.43,"ID",I,"")) D ^DIK
188 QUIT
189 ;
190CPRS ; Now, update the CPRS lists (sync with Orderable Item file) -
191 ; Uses a CPRS API to do this; Private
192 ; Next 3 variables are required as inputs
193 N ATTEMPT S ATTEMPT=0 ; Attempt to Update
194 N UPDTIME S UPDTIME=$HOROLOG ; Update Time
195 N DGNM ; Dialog Name
196 ; IVA RX -> Additives; IVB RX -> Solutions
197 ; IVM RX -> Inpatient Meds for Outpatients
198 ; NV RX -> Non-VA Meds ; O RX -> Outpatient
199 ; UD RX -> Unit Dose
200 FOR DGNM="IVA RX","IVB RX","IVM RX","NV RX","O RX","UD RX" DO
201 . D MES^XPDUTL(" --> Rebuilding "_DGNM)
202 . D FVBLD^ORWUL
203 QUIT
204 ;
Note: See TracBrowser for help on using the repository browser.