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

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

All writes support KIDS now; Added ENV check routine

File size: 3.2 KB
Line 
1VWPSSXPD ; VW/SMH - Update the Drug File and friends... ; Wed Apr 12 2012
2 ;;WorldVista Modifications;1.0
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.
8 ; Workflow:
9 ; 1. Call KILLDRUG to remove all Drug Data
10 ; 2. Restore a global containing a Drug File (^PSDRUG) and Pharmacy Orderable
11 ; Item file (^PS(50.6)). Can use a KIDS global transport.
12 ; 3. Call RESTOCK to sync CPRS files back with drug files.
13 ;
14 ; PEPs: KILLDRUG to remove all Drugs
15 ; RESTOCK to add the drugs back to CPRS
16 ;
17 ;
18KILLDRUG ; Remove all Drug Data. PEP. Use this to call the routine.
19 D DT^DICRW ; Min FM Vars
20 D MES^XPDUTL("Killing Drug File (50)") D DRUG
21 D MES^XPDUTL("Killing Pharmacy Orderable Item (OI) File (50.7)") D PO
22 D MES^XPDUTL("Removing Pharmacy OIs from the Orderable Item file (101.43)") D O
23 D MES^XPDUTL("Syncing the Order Quick View file (101.44)") D CPRS
24 QUIT
25 ;
26RESTOCK ; Restock CPRS Orderable Items from new Drug & Pharmacy Orderable Item
27 ; File. Public Entry Point.
28 ; Call this after repopulating the drug file (50) and the pharmacy orderable
29 ; item file (50.7)
30 N PSOIEN ; Looper variable
31 D DT^DICRW ; Establish FM Basic Variables
32 ;
33 ; Loop through Orderable Item file and call the protocol file updater to CPRS
34 ; Files
35 S PSOIEN=0 F S PSOIEN=$O(^PS(50.7,PSOIEN)) Q:'PSOIEN D
36 . D MES^XPDUTL("Updating Pharamcy Orderable Item "_PSOIEN)
37 . D EN^PSSPOIDT(PSOIEN),EN2^PSSHL1(PSOIEN,"MUP")
38 D CPRS ; Update Orderable Item View files
39 QUIT
40 ;
41ENV ; Environment Check Routine; KIDS EP
42 N VWPROD S VWPROD=$$PROD^XUPROD() ; Check if a production acc; +ve val is yes
43 W $$CJ^XLFSTR("------ WARNING WARNING WARNING -----",80),!! ; Center Justify
44 W "This package will delete your drug file and add a new drug file contained",!
45 W "in the distribution.",!!
46 W "If you have patient pharmacy data, this will CORRUPT your database.",!!
47 W "You are running in a "_$S(VWPROD:"Production",1:"Test")_" Environment.",!!
48 W "Are you sure you want to continue? Type a full YES/yes if you want to proceed)",!
49 N X R "ANSWER: ",X
50 S X=$$UP^XLFSTR(X) ; uppercase
51 I X'="YES" S XPDQUIT=1 ; Quit if the user doesn't say yes
52 QUIT
53 ;
54DRUG ; Kill Drug File; Private
55 N %1 S %1=^PSDRUG(0)
56 K ^PSDRUG
57 S ^PSDRUG(0)=%1
58 S $P(^PSDRUG(0),"^",3,4)=""
59 QUIT
60 ;
61PO ; Kill Pharmacy Orderable Items; Private
62 N %1 S %1=^PS(50.7,0)
63 K ^PS(50.7)
64 S ^PS(50.7,0)=%1
65 S $P(^PS(50.7,0),"^",3,4)=""
66 QUIT
67 ;
68O ; Kill off Pharamcy Order Items (Only!) in the Orderable Item file; Private
69 N DA ; Used in For loop below
70 N DIK S DIK="^ORD(101.43,"
71 N I S I=0
72 FOR S I=$O(^ORD(101.43,"ID",I)) QUIT:I="" DO
73 . I I["PSP" S DA=$O(^ORD(101.43,"ID",I,"")) D ^DIK
74 QUIT
75 ;
76CPRS ; Now, update the CPRS lists (sync with Orderable Item file) -
77 ; Uses a CPRS API to do this; Private
78 ; Next 3 variables are required as inputs
79 N ATTEMPT S ATTEMPT=0 ; Attempt to Update
80 N UPDTIME S UPDTIME=$HOROLOG ; Update Time
81 N DGNM ; Dialog Name
82 ; IVA RX -> Additives; IVB RX -> Solutions
83 ; IVM RX -> Inpatient Meds for Outpatients
84 ; NV RX -> Non-VA Meds ; O RX -> Outpatient
85 ; UD RX -> Unit Dose
86 FOR DGNM="IVA RX","IVB RX","IVM RX","NV RX","O RX","UD RX" DO
87 . D MES^XPDUTL("Rebuilding "_DGNM)
88 . D FVBLD^ORWUL
89 QUIT
90 ;
Note: See TracBrowser for help on using the repository browser.