Difference between revisions of "Prescription Auto-Finishing"

From VistApedia
Jump to: navigation, search
(Notes)
(Notes on Newer PSO Autocompletion code)
Line 178: Line 178:
 
=== Notes on Newer PSO Autocompletion code ===
 
=== Notes on Newer PSO Autocompletion code ===
  
ass
+
NOTES:
 +
I took the patch, and manuall extracted each of the separate .m files.  I then
 +
compared them to my local system.  See notes about each comparison above.
 +
I then took the patch (PSO-7-0-208.KID) for autofinish and cut out all the
 +
files and installed just the part that contained the data dictionary entries
 +
and installed that.
 +
Below are instructions from the patch.
 +
 
 +
This patch for Auto-Finish Rx (AutoRx) and Auto Prescription Printing
 +
adds the functionality for automatically finishing a medication order
 +
entered via the medication ordering process in CPRS.  Then it prints
 +
a prescription based on the order entered by the physician to give
 +
to the patient.
 +
 
 +
  Installation instructions are in the multi-build containing this build.
 +
 
 +
The following section describes the technical components of this patch.
 +
 
 +
1. The following FIELDS will be added to OUTPATIENT SITE (#59)
 +
 
 +
    Added Fields:
 +
    ===============
 +
 
 +
    Field #  Field Name                            Field Type
 +
    -------  --------------                        ----------
 +
    22900    AUTOFINISH  RX                Set of Codes
 +
    22901    AUTOFINISH DEFAULT PAT STATUS  Pointer to RX PATIENT STATUS
 +
    22902    AUTO-FINISH ELIGIBILITY        Multiple (#59.022902)
 +
      .01    -AUTO-FINISH ELIGIBILITY      Pointer to ELIGIBILITY CODE
 +
    22903    AUTOFINISH ES                  Set of Codes
 +
    22904    AUTOFINISH HEADER LINE        Free Text
 +
    22905    AUTOFINISH TRADE NAME PRINT    Set of Codes
 +
    22906    AUTOFINISH WET SIG ON CSII    Set of Codes
 +
    22907    AUTOFINISH DOB                Set of Codes
 +
    22908    AUTOFINISH DIAGNOSIS          Set of Codes
 +
    22909    AUTOFINISH LINE 1-2-3          Set of Codes
 +
    22910    AUTOFINISH FAX SERVER LOCATION Free Text
 +
    22911    AUTOFINISH FAXED FROM NUMBER  Free Text
 +
 
 +
(Note: I entered these values)
 +
  22900-AUTOFINISH RX : YES
 +
  22901-AUTOFINISH DEFAULT PAT STATUS : NON-VA
 +
  22903-AUTOFINISH ES : YES
 +
  22904-AUTOFINISH HEADER LINE : K.Toppenberg TN30xxxxxx
 +
  22906-AUTOFINISH WET SIG ON CSII : YES
 +
  22907-AUTOFINISH DOB : YES
 +
  22908-AUTOFINISH DIAGNOSIS : YES
 +
  22910-AUTOFINISH FAX SERVER LOCATION : /tmp/tempfaxes
 +
  22911-AUTOFINISH FAXED FROM NUMBER : 423-787-xxxxxxx
 +
459001-AUTOFINISH RX : YES
 +
(continuing)
 +
 
 +
2. The following FIELDS will be added to PRESCRIPTION (#52)
 +
 
 +
  Added Fields:
 +
  ===============
 +
 
 +
  Field #  Field Name                      Field Type
 +
  -------  --------------                ----------
 +
  22900    AUTOFINISH COMPLEX ORDER        Free Text
 +
 
 +
(No entry needed)
 +
 
 +
3. The following new file will be added
 +
 
 +
  PSO AUTOFINISH PHARMACY file 22900
 +
 
 +
  .01      NAME                      Free Text
 +
  2        STREET ADDRESS 1          Free Text
 +
  3        STREET ADDRESS 2          Free Text
 +
  4        STREET ADDRESS 3          Free Text
 +
  5        CITY                      Free Text
 +
  6        STATE                    Pointer to State file
 +
  7        ZIP CODE                  Free Text
 +
  8        BILLING NUMBER            Free Text
 +
  9        PRIMARY CONTACT PERSON    Free Text
 +
  10        PHARMACIST IN CHARGE      Free Text
 +
  11        VOICE PHONE DIRECT TO RPH Free Text
 +
  12        VOICE PHONE TO PHARMACY  Free Text
 +
  13        FAX PHONE                Free Text
 +
  14        IP ADDRESS                Free Text
 +
 
 +
(I am not going to enter these for now, as I plan to NOT fax scripts)
 +
 
 +
4. The following PROTOCOLS will be addded.
 +
 
 +
    Name                  Item Text          Entry Action
 +
Exit Action
 +
==============      ==================  ========================  =======
 +
 
 +
PSO AF REPRINT      Autofinish Reprint  S POERR=1 D BCK^PSOAFRPT  K POERR
 +
PSO AF SPEED REPRINT AF REPRINT          D ^PSOAFRP1              NA
 +
 
 +
5. The following PROTOCOLS will be USE AS LINK FOR MENU ITEMS
 +
for the above two Protocols, respectively.
 +
 
 +
PSO HIDDEN ACTIONS
 +
PSO HIDDEN ACTIONS #2
  
 
=== From Docs ===
 
=== From Docs ===

Revision as of 23:21, 27 April 2009

Intro

This section will hold information as I investigate the HUI autoprescription code that I was given at one point. I will note that this was beta code, and there are likely better versions now.

Modified Files

This is a list of modified files, from the originial HUI patch:

  ORWDX
  PSOCAN4
  PSODRDUP
  PSODRG
  PSOLBLN
  PSOLBLN2
  PSOLMPO
  PSONEW
  PSOORFI1
  PSOORFI2
  PSOORFI4
  PSOORFIN
  PSOORNE4
  PSOORNEW (was older than my system --> changes merged in)
  PSOORRNW
  PSORXL
  PSOZHUIF
  PSOZLSET
 (PSOTPCAN NOTE: not in the HUI package, but required mod, see below)
 (PSODGAL  NOTE: not in the HUI package, but required mod, see below)
 (PSORX1   NOTE: not in the HUI package, but required mod, see below)


Below are the files modified with the newer PSO-7-0-280 patch for autocompletion.

 (ORWDX) -- missing
 PSOCAN4.m -- old     --> no signif change from old patch. 
 PSODRDUP.m  -- old   --> no signif change from old patch. 
 PSODRG.m -- old      --> +/- no signif change from old patch.
 PSOLBLN.m -- old     --> new changes copied into TMG code. 
 PSOLBLN2.m -- old    --> +/- no signif change from old patch.
 PSOLMPO.m -- old     --> no signif change from old patch. 
 PSONEW.m -- old      --> no signif change from old patch. 
 PSOORFI1.m -- old    --> new changes copied into TMG code. 
 PSOORFI2.m -- old    --> no signif change from old patch. 
 PSOORFI4.m -- old    --> new changes copied into TMG code. 
 PSOORFIN.m -- old    --> new changes copied into TMG code. 
 PSOORNE4.m -- old    --> no signif change from old patch. 
 PSOORNEW.m -- old    --> new changes copied into TMG code. 
 PSOORRNW.m -- old    --> no signif change from old patch.
 PSORXL.m -- old      --> new changes copied into TMG code.
 (PSOZHUIF) -- missing (i.e. not present in new patch)
 (PSOZLSET) -- missing (i.e. not present in new patch)
 (PSODGAL) -- missing (i.e. not present in new patch)  
 PSOLSET.m -- old     --> new changes copied into TMG code.  
 PSOAFIN.m  new   <-- copied into TMG codebase 
 PSOAFPT1.m  new  <-- copied into TMG codebase  
 PSOAFPTL.m  new  <-- copied into TMG codebase (Makes use of custom fields)
 PSOAFPTS.m  new  <-- copied into TMG codebase (Makes use of custom fields) 
 PSOAFRP1.m  new  <-- copied into TMG codebase 
 PSOAFRPT.m  new  <-- copied into TMG codebase 
 PSOAFSET.m  new  <-- copied into TMG codebase 
 PSODISP.m   new  <-- copied over into TMG codebase
 PSODISPS.m  new  <-- copied over into TMG codebase
 PSON52.m   new   <-- copied over into TMG codebase 
 PSONEWF.m   new  <-- copied over into TMG codebase (introduces new calls also)
 PSOOREDT.m   new <-- copied over into TMG codebase (introduces new calls also)
 PSOORFI3.m   new <-- copied over into TMG codebase (little changed)
 PSOORFI5.m   new <-- copied new into TMG codebase 
 PSOORNW2.m   new <-- copied over into TMG codebase (little changed)
 PSOREF.m   new   <-- copied over into TMG codebase (little changed)
 PSORN52.m   new  <-- copied over into TMG codebase 
 PSORX1.m   new   <-- copied over into TMG codebase (prior changes merged in) 
 PSORXPA1.m   new <-- copied over into TMG codebase 
 PSORXRP1.m   new <-- copied over into TMG codebase 
 PSORXRP2.m   new <-- copied over into TMG codebase 
 PSORXRPT.m   new <-- copied over into TMG codebase 
 PSOTPCAN.m   new <-- copied over into TMG codebase (prior changes merged in)


Notes on HUI Code

First I started with the older HUI code. Notes on newer PSO-7-0-280 below.

OK. I have copied the above files into my routines folder. I then have stepped through the RPC code and found a hang-up. --first, pick a drug that is a non-va drug. On my system, Abilify TAB is such a drug. Order the drug. Then look at the RPC calls for SAVE ORWDX. Find the order number at piece 1 in the results.

Then on the server setup as follows:

 x="do SEND^ORWDX(.list,70685,73,6," (U?Ec%U{,",.array)"
 set array(1)=1945;1^1^1^E"
 (replace 1945 with the order number from above)
 Then trace into: xecute x
 
 for patient 70772, use " /)Bv@})H%"
 3 --> " *6tLxj68."

I have this to SPAT+12 (the line that starts with "S ORD"), to the place where the message is given, and "press return to continue" is encountered. I think in the loop a D ORD is the culprit. I need to finish tracing through this to find the exact spot.

... OK. Found it. Rather than tracing through the code, I called this manually as above, and let it run to the point where it stopped and asked for a prompt. I then used ^ZJOB to examine the process, and looked at it's variable table ("V"), and got the stack, showing the path of execution.

The culprit is in DISPL^PSOTPCAN

I am going to put in a code guard to not do this, as follows:

 DSPL+8^PSOTPCAN
       . . I $G(HUIFIN)="Y" Q ;vf //kt       
 DSPL+15^PSOTPCAN
       . I $G(HUIFIN)="Y" Q ;vf //kt

I also changed ABORT^PSOORNEW from

 ABORT   S VALMBCK="Q",DIR(0)="E",DIR("A")="Press Return to Continue" D ^DIR,CLEAN^PSOVER1,KV
       Q

To:

ABORT   ;"//kt S VALMBCK="Q",DIR(0)="E",DIR("A")="Press Return to Continue" D ^DIR,CLEAN^PSOVER1,KV
       S VALMBCK="Q"
       I $G(HUIFIN)'="Y" D
       . S DIR(0)="E",DIR("A")="Press Return to Continue" D ^DIR
       D CLEAN^PSOVER1,KV
       Q

I also changed the line at ACP+12&PSOORNEW to ensure non-interactive. I had not encountered this as a problem, but thought it was a potential one.

       I $G(PSOCPZ("DFLG")) DO  QUIT  ;"//kt added HUIFIN guard to ensure non-interactive
       . I $G(HUIFIN)'="Y" DO
       . . W !!,"No action taken!",! K DIR S DIR(0)="E",DIR("A")="Press Return to continue" DO ^DIR
       . D KV K PSOCPZ("DFLG"),DRET,PSOANSQD S VALMBCK="Q" Q

I then found that the auto-completion code was trying to act on ALL orders, including for example, text-only WP orders. So I added the following to prevent this. It will only work on orders pointing to an ORDERABLE ITEM marked as coming from the PSxxx package.

EN^PSOZHUIF  (at the beginning of the routine)
       ;"//kt start mod ------------  4/8/09
       KILL HUIFIN,HUIDUZ,HUIDFN
       NEW TMGOIY,TMGI,TMGPKG
       ;"NOTE: I am only checking the first entry in this multiple.  I don't know
       ;"      what it would mean if the order referred to multiple orderable items.
       SET TMGOIY=$ORDER(^OR(100,+ORDERID,.1,"B","")) ;"Ptr to 101.43 ORDERABLE ITEM
       QUIT:(+TMGOIY'>0)
       SET TMGPKG=$PIECE($GET(^ORD(101.43,TMGOIY,0)),"^",2)
       QUIT:(TMGPKG'["PS")  ;"Only auto-complete package PSxxx Orderable Items
       if '$get(TMGDEBUG) quit; "TEMP!!!!! -- disable for now.
       ;"//kt end mod ------------

I also changed the following to ignore drug interactions (i.e. not prompt for user response):

 DSPLY+7^PSODGAL...
       .;//kt orig-> S DIR(0)="SA^1:YES;0:NO",DIR("A")="Do you want to Intervene? ",DIR("B")="Y" W ! D ^DIR
       .I $G(HUIFIN)'="Y" S DIR(0)="SA^1:YES;0:NO",DIR("A")="Do you want to Intervene? ",DIR("B")="Y" W ! D ^DIR ;"//kt
       .I $G(HUIFIN)="Y" SET Y=0 ;"Force 'NO' if Autofinishing ;"//kt
 and
 CLASS+11^PSODGAL..
       ..;"//kt orig-> S DIR(0)="SA^1:YES;0:NO",DIR("A")="Do you want to Intervene? ",DIR("B")="Y" W ! D ^DIR
       ..I $G(HUIFIN)'="Y" S DIR(0)="SA^1:YES;0:NO",DIR("A")="Do you want to Intervene? ",DIR("B")="Y" W ! D ^DIR ;"//kt
       ..I $G(HUIFIN)="Y" SET Y=0 ;"Force 'NO' if Autofinishing ;"//kt        


I also changed the following to automatically set up a PHARMACY PATIENT record stubb for those without one. Again, to avoid user queries

 OERR+14^PSORX1
       .L +^PS(55,PSODFN):0 I '$T W $C(7),!!,"Patient Data is Being Edited by Another User!",! S POERR("QFLG")=1 S:$G(PSOFIN) PSOQUIT=1 Q
       .IF $GET(HUIFIN)="Y" DO  QUIT  ;"//kt mod (entire block)
       . . NEW TMGFDA,TMGMSG,TMGIEN
       . . SET TMGFDA(55,"+1,",.01)=PSODFN
       . . SET TMGFDA(55,"+1,",3)=20  ;"Force NON-VA as status.
       . . SET TMGIEN(1)=PSODFN
       . . DO UPDATE^DIE("S","TMGFDA","TMGIEN","TMGMSG")
       . . IF $DATA(TMGMSG) SET POERR("QFLG")=1
       . . L -^PS(55,PSODFN)
       .S PSOXFLG=1,SSN=$P(^DPT(PSODFN,0),"^",9) W !!?10,$C(7),PSORX("NAME")_" ("_$E(SSN,1,3)_"-"_$E(SSN,4,5)_"-"_$E(SSN,6,9)_")",! K SSN
       .S DIE=55,DR=".02;.03;.04;.05;1;D ELIG^PSORX1;3;50;106;106.1",DA=PSODFN W !!,?5,">>PHARMACY PATIENT DATA<<",! D ^DIE L -^PS(55,PSODFN)


Notes on Newer PSO Autocompletion code

NOTES: I took the patch, and manuall extracted each of the separate .m files. I then compared them to my local system. See notes about each comparison above. I then took the patch (PSO-7-0-208.KID) for autofinish and cut out all the files and installed just the part that contained the data dictionary entries and installed that. Below are instructions from the patch.

This patch for Auto-Finish Rx (AutoRx) and Auto Prescription Printing adds the functionality for automatically finishing a medication order entered via the medication ordering process in CPRS. Then it prints a prescription based on the order entered by the physician to give to the patient.

 Installation instructions are in the multi-build containing this build.
The following section describes the technical components of this patch.
1. The following FIELDS will be added to OUTPATIENT SITE (#59)
   Added Fields:
   ===============
   Field #   Field Name                            Field Type
   -------   --------------                        ----------
   22900     AUTOFINISH  RX                 Set of Codes
   22901     AUTOFINISH DEFAULT PAT STATUS  Pointer to RX PATIENT STATUS
   22902     AUTO-FINISH ELIGIBILITY        Multiple (#59.022902)
     .01     -AUTO-FINISH ELIGIBILITY       Pointer to ELIGIBILITY CODE
   22903     AUTOFINISH ES                  Set of Codes
   22904     AUTOFINISH HEADER LINE         Free Text
   22905     AUTOFINISH TRADE NAME PRINT    Set of Codes
   22906     AUTOFINISH WET SIG ON CSII     Set of Codes
   22907     AUTOFINISH DOB                 Set of Codes
   22908     AUTOFINISH DIAGNOSIS           Set of Codes
   22909     AUTOFINISH LINE 1-2-3          Set of Codes
   22910     AUTOFINISH FAX SERVER LOCATION Free Text
   22911     AUTOFINISH FAXED FROM NUMBER   Free Text

(Note: I entered these values)

 22900-AUTOFINISH RX : YES
 22901-AUTOFINISH DEFAULT PAT STATUS : NON-VA
 22903-AUTOFINISH ES : YES
 22904-AUTOFINISH HEADER LINE : K.Toppenberg TN30xxxxxx
 22906-AUTOFINISH WET SIG ON CSII : YES
 22907-AUTOFINISH DOB : YES
 22908-AUTOFINISH DIAGNOSIS : YES
 22910-AUTOFINISH FAX SERVER LOCATION : /tmp/tempfaxes
 22911-AUTOFINISH FAXED FROM NUMBER : 423-787-xxxxxxx
459001-AUTOFINISH RX : YES

(continuing)

2. The following FIELDS will be added to PRESCRIPTION (#52)
  Added Fields:
  ===============
  Field #   Field Name                      Field Type
  -------   --------------                 ----------
  22900     AUTOFINISH COMPLEX ORDER        Free Text

(No entry needed)

3. The following new file will be added
  PSO AUTOFINISH PHARMACY file 22900
 .01       NAME                      Free Text
 2         STREET ADDRESS 1          Free Text
 3         STREET ADDRESS 2          Free Text
 4         STREET ADDRESS 3          Free Text
 5         CITY                      Free Text
 6         STATE                     Pointer to State file
 7         ZIP CODE                  Free Text
 8         BILLING NUMBER            Free Text
 9         PRIMARY CONTACT PERSON    Free Text
 10        PHARMACIST IN CHARGE      Free Text
 11        VOICE PHONE DIRECT TO RPH Free Text
 12        VOICE PHONE TO PHARMACY   Free Text
 13        FAX PHONE                 Free Text
 14        IP ADDRESS                Free Text

(I am not going to enter these for now, as I plan to NOT fax scripts)

4. The following PROTOCOLS will be addded.
   Name                  Item Text           Entry Action
Exit Action
==============       ==================  ========================  =======
PSO AF REPRINT       Autofinish Reprint  S POERR=1 D BCK^PSOAFRPT  K POERR
PSO AF SPEED REPRINT AF REPRINT          D ^PSOAFRP1               NA
5. The following PROTOCOLS will be USE AS LINK FOR MENU ITEMS
for the above two Protocols, respectively.
PSO HIDDEN ACTIONS
PSO HIDDEN ACTIONS #2

From Docs

Below if from the accompanying documentation. I will make comments below.


Processing Overview

The AutoFinish process starts by a call in ORWDX after a medication orders has had a provider sign with a valid e-signature and the prescription exists in file 52.41. The call in ORWDX goes to PSOZHUIF

 This is found at SEND+19^ORWDX (or line 171 from top of file) in new 
 ORWDX file.

which determines the status of the AUTOFINISH RX field of the associated OUTPATIENT SITE, if “YES” the AutoFinish and printing process will be executed. The user AUTOFINISH,RX must also be able to be identified in the NEW PERSON(File#200) in order to initiate the AutoFinishing functionality. If these conditions are not satisfied the normal provider signing functionality continues without AutoFinishing (i.e., the CPRS prescription will be left in a signed, ‘pending’ status). If these conditions are met and AutoFinishing takes place, the CPRS prescription will be left in signed; ‘active’ status and a hard copy patient prescription will be printed.

 PSOZHUIF sets up an environement, then calls D ^PSOORFIN

PSOZHUIF will set the variable HUIFIN equal to “Y” if the medication order is to be AutoFinished, the modified routines have lines that begin with either, I $G(HUIFIN)="Y" or “I $G(HUIFIN)’="Y". If the line in the routine begins with I $G(HUIFIN)’="Y" and AutoFinishing is turned OFF the routines will work and behave with the original functionality. If the line in the routine begins with I $G(HUIFIN)’="Y" and AutoFinishing is turned ON the routines will not execute this line of code. If the line in the routine begins with I $G(HUIFIN)="Y" and AutoFinishing is turned ON and the routines will AutoFinish and print the prescription. These lines either automate the points in the finishing process where normally a pharmacist will respond to prompts or if the line of the code is to display prompts to the screen the line removes the display function.


PSOZLSET is a modified version of PSOLSET that sets up the normal variables that are needed in the PSO* routines. It removes all prompts for data input and provides the appropriate values to the routine.

It is important to NOTE that one part of the code that is bypassed in the AutoFinish process is all the interacting checking, allergy checking, drug duplication checking, laboratory prompts and other checks that a pharmacist normally process in the manual finish process. All of the checks processed in the CPRS medication order process are still processed by the provider entering the order.

Comments can be found throughout all the routines describing functionality and variables. Lines changed in the routines by this patch are ended with the comment “;vfa*” where * is a single letter.

When the AUTOFINISHING functionality is turned on existing Class I audit trails are preserved. In addition the Class 1 “Method of Pickup” field will be populated with the phrase “AutoFinished for Rx Printing”. The Class 1 “Finished by” or “Finishing Person” field will be populated with the user name “AUTOFINISH, RX” AND the prescription label log will populate the Class 1 “Printed by” field with the user name “AUTOFINISH, RX”. The date/time stamp for label printing can be found by using FileMan to look at the label log for a prescription in PRESCRIPTION(File #52).

Patients who are processed with the AutoFinish process must have a STATUS assigned to them, if they do not the code can not process the medications orders. The AutoFinish Rx routines check to see if a patient has a status assigned to them, if no status exists the routine will print a message to the printer and not AutoFinish the medication order. See below for an example of the message printed.