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

Last change on this file since 1684 was 1415, checked in by Sam Habiel, 13 years ago

Create trunk

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