Difference between revisions of "Prescription Auto-Finishing"

From VistApedia
Jump to: navigation, search
Line 1: Line 1:
(placeholder)
+
=== 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.
 
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.
Line 123: Line 123:
 
         .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)
 
         .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)
  
 +
 +
=== From Docs ===
  
 
Below if from the accompanying documentation.  I will make comments below.
 
Below if from the accompanying documentation.  I will make comments below.

Revision as of 23:09, 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.

This is a list of modified files:

  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)
 I went through these files, and all were OK to overwrite by files (except 1)

... 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)


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.