Changeset 1399 for pharmacy-utils


Ignore:
Timestamp:
Apr 12, 2012, 7:19:50 PM (13 years ago)
Author:
Sam Habiel
Message:

KIDS hooks added

File:
1 edited

Legend:

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

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