Ignore:
Timestamp:
Apr 16, 2012, 1:40:04 PM (13 years ago)
Author:
Sam Habiel
Message:

updated file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pharmacy-utils/drug-file-cleanup/VWPSSXPD.m

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