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

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

Updated routine. Now includes Drug Text. Not thouroughly tested yet

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