1 | VWPSSXPD ; VW/SMH - Update the Drug File and friends... ; Wed Apr 12 2012
|
---|
2 | ;;WorldVista Modifications;1.0;;;Build 3
|
---|
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 and ^PS(50.6)
|
---|
13 | ; On the Destination System:
|
---|
14 | ; 1. Call KILLDRUG to remove all Drug Data
|
---|
15 | ; 2. Restore a global containing a Drug File (^PSDRUG) and Pharmacy Orderable
|
---|
16 | ; Item file (^PS(50.6)) created on the origin system.
|
---|
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 problem 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 | ;
|
---|
39 | ; --- ()()() ---
|
---|
40 | ;
|
---|
41 | ; PEPs: KILLDRUG to remove all Drugs
|
---|
42 | ; RESTOCK to add the drugs back to CPRS
|
---|
43 | ;
|
---|
44 | ; KIDS EPs:
|
---|
45 | ; ENV -> Environment Check
|
---|
46 | ; TRAN -> Pre-Transport Routine (to get data from original system)
|
---|
47 | ; PRE -> Pre-Init for the Destination System
|
---|
48 | ; POST -> Post-Init for the Destination System
|
---|
49 | ;
|
---|
50 | ; KIDS EPs call PEPs to do their work.
|
---|
51 | ;
|
---|
52 | ; Environment Check falls through from the top
|
---|
53 | ;
|
---|
54 | ; -- START KIDS HOOKS --
|
---|
55 | ;
|
---|
56 | ENV ; Environment Check Routine; KIDS EP; top fallthough
|
---|
57 | N VWPROD S VWPROD=$$PROD^XUPROD() ; Check if a production acc; +ve val is yes
|
---|
58 | W $$CJ^XLFSTR("------ WARNING WARNING WARNING -----",80),!! ; Center Justify
|
---|
59 | W "This package will delete your drug file and add a new drug file contained",!
|
---|
60 | W "in the distribution.",!!
|
---|
61 | W "If you have patient pharmacy data, this will CORRUPT your database.",!!
|
---|
62 | W "You are running in a "_$S(VWPROD:"Production",1:"Test")_" Environment.",!!
|
---|
63 | W "Are you sure you want to continue? Type a full YES/yes if you want to proceed)",!
|
---|
64 | N X R "ANSWER: ",X
|
---|
65 | S X=$$UP^XLFSTR(X) ; uppercase
|
---|
66 | I X'="YES" S XPDQUIT=1 ; Quit if the user doesn't say yes
|
---|
67 | QUIT
|
---|
68 | ;
|
---|
69 | TRAN ; Pre-Transport routine for KIDS to ship off the 50 and 50.7 globals
|
---|
70 | M @XPDGREF@("VWPSSXPD",50)=^PSDRUG
|
---|
71 | M @XPDGREF@("VWPSSXPD",50.7)=^PS(50.7)
|
---|
72 | QUIT
|
---|
73 | ;
|
---|
74 | PRE ; Pre-Init routine for KIDS
|
---|
75 | DO KILLDRUG ; Remove old drugs from system.
|
---|
76 | QUIT
|
---|
77 | ;
|
---|
78 | POST ; Post-Init routine for KIDS
|
---|
79 | ; Load new drugs into system
|
---|
80 | M ^PSDRUG=@XPDGREF@("VWPSSXPD",50)
|
---|
81 | M ^PS(50.7)=@XPDGREF@("VWPSSXPD",50.7)
|
---|
82 | ; Restock the CPRS files from the new drug files
|
---|
83 | DO RESTOCK
|
---|
84 | QUIT
|
---|
85 | ;
|
---|
86 | ; -- END KIDS HOOKS --
|
---|
87 | ;
|
---|
88 | ; -- BEGIN Public Entry Points --
|
---|
89 | KILLDRUG ; Remove all Drug Data. PEP. Use this to call the routine.
|
---|
90 | D DT^DICRW ; Min FM Vars
|
---|
91 | D MES^XPDUTL("Killing Drug File (50)") D DRUG
|
---|
92 | D MES^XPDUTL("Killing Pharmacy Orderable Item (OI) File (50.7)") D PO
|
---|
93 | D MES^XPDUTL("Removing Pharmacy OIs from the Orderable Item file (101.43)") D O
|
---|
94 | D MES^XPDUTL("Syncing the Order Quick View file (101.44)") D CPRS
|
---|
95 | QUIT
|
---|
96 | ;
|
---|
97 | RESTOCK ; Restock CPRS Orderable Items from new Drug & Pharmacy Orderable Item
|
---|
98 | ; File. Public Entry Point.
|
---|
99 | ; Call this after repopulating the drug file (50) and the pharmacy orderable
|
---|
100 | ; item file (50.7)
|
---|
101 | N PSOIEN ; Looper variable
|
---|
102 | D DT^DICRW ; Establish FM Basic Variables
|
---|
103 | ;
|
---|
104 | ; Loop through Orderable Item file and call the protocol file updater to CPRS
|
---|
105 | ; Files
|
---|
106 | S PSOIEN=0 F S PSOIEN=$O(^PS(50.7,PSOIEN)) Q:'PSOIEN D
|
---|
107 | . D MES^XPDUTL("Syncing Pharamcy Orderable Item "_PSOIEN)
|
---|
108 | . D EN^PSSPOIDT(PSOIEN),EN2^PSSHL1(PSOIEN,"MUP")
|
---|
109 | D CPRS ; Update Orderable Item View files
|
---|
110 | QUIT
|
---|
111 | ;
|
---|
112 | ; -- END Public Entry Points --
|
---|
113 | ;
|
---|
114 | ; -- The rest is private --
|
---|
115 | DRUG ; Kill Drug File; Private
|
---|
116 | N %1 S %1=^PSDRUG(0)
|
---|
117 | K ^PSDRUG
|
---|
118 | S ^PSDRUG(0)=%1
|
---|
119 | S $P(^PSDRUG(0),"^",3,4)=""
|
---|
120 | QUIT
|
---|
121 | ;
|
---|
122 | PO ; Kill Pharmacy Orderable Items; Private
|
---|
123 | N %1 S %1=^PS(50.7,0)
|
---|
124 | K ^PS(50.7)
|
---|
125 | S ^PS(50.7,0)=%1
|
---|
126 | S $P(^PS(50.7,0),"^",3,4)=""
|
---|
127 | QUIT
|
---|
128 | ;
|
---|
129 | O ; Kill off Pharamcy Order Items (Only!) in the Orderable Item file; Private
|
---|
130 | N DA ; Used in For loop below
|
---|
131 | N DIK S DIK="^ORD(101.43,"
|
---|
132 | N I S I=0
|
---|
133 | FOR S I=$O(^ORD(101.43,"ID",I)) QUIT:I="" DO
|
---|
134 | . I I["PSP" S DA=$O(^ORD(101.43,"ID",I,"")) D ^DIK
|
---|
135 | QUIT
|
---|
136 | ;
|
---|
137 | CPRS ; Now, update the CPRS lists (sync with Orderable Item file) -
|
---|
138 | ; Uses a CPRS API to do this; Private
|
---|
139 | ; Next 3 variables are required as inputs
|
---|
140 | N ATTEMPT S ATTEMPT=0 ; Attempt to Update
|
---|
141 | N UPDTIME S UPDTIME=$HOROLOG ; Update Time
|
---|
142 | N DGNM ; Dialog Name
|
---|
143 | ; IVA RX -> Additives; IVB RX -> Solutions
|
---|
144 | ; IVM RX -> Inpatient Meds for Outpatients
|
---|
145 | ; NV RX -> Non-VA Meds ; O RX -> Outpatient
|
---|
146 | ; UD RX -> Unit Dose
|
---|
147 | FOR DGNM="IVA RX","IVB RX","IVM RX","NV RX","O RX","UD RX" DO
|
---|
148 | . D MES^XPDUTL(" --> Rebuilding "_DGNM)
|
---|
149 | . D FVBLD^ORWUL
|
---|
150 | QUIT
|
---|
151 | ;
|
---|