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