Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: PSBVDLIV

PSBVDLIV.m

Go to the documentation of this file.
  1. PSBVDLIV ;BIRMINGHAM/EFC-BCMA IV VIRTUAL DUE LIST ;Mar 2004
  1. ;;3.0;BAR CODE MED ADMIN;**6,38,32**;Mar 2004;Build 32
  1. ;Per VHA Directive 2004-038 (or future revisions regarding same), this routine should not be modified.
  1. ;
  1. ; Reference/IA
  1. ; EN^PSJBCMA/2828
  1. ; EN^PSJBCMA1/2829
  1. ;
  1. EN(DFN,PSBDT) ; Default Order List Return for Today
  1. ;
  1. ; RPC: PSB GETORDERLIST
  1. ;
  1. ; Description:
  1. ; Returns the current IV order set for today to display on the
  1. ; client VDL
  1. ;
  1. N PSBDATA,PSBTBOUT,PSBDOADD
  1. S PSBTBOUT=0,PSBDOADD=0
  1. S:PSBTAB="IVTAB" PSBDOADD=1
  1. ;
  1. ; Passing PSBDT as 3rd parameter turns off the V.1.0 One-Time lookback
  1. K ^TMP("PSJ",$J),^TMP("PSB",$J,"ON IVTAB") S X1=PSBDT,X2=-3 D C^%DTC S PSBDT2=X D EN^PSJBCMA(DFN,PSBDT2,PSBDT)
  1. ;
  1. I $G(^TMP("PSJ",$J,1,0))=-1 Q ; No orders
  1. ;
  1. F PSBX=0:0 S PSBX=$O(^TMP("PSJ",$J,PSBX)) Q:('PSBX)!(PSBTBOUT) D
  1. .D CLEAN^PSBVT,PSJ^PSBVT(PSBX)
  1. .;
  1. .; << Standard checks for ALL orders >>
  1. .;
  1. .Q:PSBONX'["V" ; IVs only
  1. .Q:PSBIVT["P" ; No piggybacks
  1. .Q:PSBONX["P" ; No Pending Orders
  1. .Q:PSBOST>($$FMADD^XLFDT($$NOW^XLFDT,,,$$GET^XPAR("DIV","PSB ADMIN BEFORE")))
  1. .; Need to see if "last order" in chain is active/not pending.
  1. .S PSBFON1=PSBFON,PSBLOOP=0 I $G(PSBFON)]"" S PSBLACTV=$S($G(PSBFON)["P":0,1:1) S PSBFON2=$G(PSBFON) I 'PSBLACTV F D Q:($G(PSBFON)="")!($G(PSBFON1)=$G(PSBFON2))!(PSBLOOP)!(PSBLACTV) ;
  1. ..I $G(PSBFON)["P" K ^TMP("PSJ1",$J) D EN^PSJBCMA1(DFN,PSBFON2,1) I ^TMP("PSJ1",$J,0)=-1 S PSBFON=""
  1. ..D:$G(PSBFON)["" CLEAN^PSBVT,PSJ1^PSBVT(DFN,PSBFON2)
  1. ..I PSBFON=PSBFON2 S PSBLOOP=1,PSBLACTV=0 Q
  1. ..S PSBLACTV=$S($G(PSBFON)["P":0,$G(PSBFON)']"":PSBLACTV,1:1),PSBFON2=$G(PSBFON)
  1. ..S:(PSBLACTV)&($G(PSBOST)>($$FMADD^XLFDT($$NOW^XLFDT,,,$$GET^XPAR("DIV","PSB ADMIN BEFORE")))) PSBLACTV=0
  1. .D CLEAN^PSBVT,PSJ^PSBVT(PSBX) ;Refresh data
  1. .K PSBCOMP,PSBCOMPX,PSBINFDT,PSBINFST D INFUSING^PSBVDLU2
  1. .D NOW^%DTC
  1. .I ((PSBOSTS="A")!(PSBOSTS="R"))&(PSBOSP<%) S PSBOSTS="E"
  1. .I (PSBOSTS["D")&(PSBCOMP=0) Q ; Is it DC'd and not infusing or stopped
  1. .I PSBOSTS="E",PSBCOMP=0 Q ; Is expired and not infusing or stopped
  1. .I PSBOSTS="D",PSBCOMP=1,($G(PSBFON)]""),PSBLACTV Q ; order is DC'ed will be picked up by following order
  1. .I PSBOSTS="E",PSBCOMP=1,($G(PSBFON)]""),PSBLACTV Q ; order is expired will be picked up by following order
  1. .I PSBOSTS="R",PSBFOR="R",PSBOSP<PSBWBEG Q ; order is renewed bag picked up by following order
  1. .Q:$G(^TMP("PSB",$J,"ON IVTAB",PSBDFN,PSBONX))=1 ; The "previous order" is displayed on the VDL!
  1. .I (PSBOSTS["E")&(PSBCOMP=0) Q ; Is it expired and not infusing
  1. .I PSBIVT["S",PSBISYR=1 Q ; No intermittent syringes - done on PB tab
  1. .I PSBIVT["C",PSBISYR=1 Q ; No intermittent syringes - done on PB tab
  1. .I PSBIVT["C",PSBCHEMT="P" Q ; No Piggyback Chemos
  1. .I PSBNGF&(PSBCOMP=1) Q ; Is it marked DO NOT GIVE!
  1. .;
  1. .; Non One-Times with stop date/time < now
  1. .;
  1. .D NOW^%DTC
  1. .I PSBOSP<%,PSBOSTS'="R",PSBCOMP'=1 Q
  1. .;
  1. .; include Active, Renewed, ReInstated and On Call and Hold and Expired infusing
  1. .; (Is it not one time)&(Is it not active or renewed or On Call or Hold)
  1. .Q:PSBSCHT'="O"&((PSBOSTS'="A")&(PSBOSTS'="R")&(PSBOSTS'="RE")&(PSBOSTS'="O")&(PSBOSTS'="D")&(PSBOSTS'="H")&(PSBOSTS'="E"))
  1. .;
  1. .; Is One Time Given
  1. .;
  1. .I PSBSCHT="O" D Q:PSBGVN
  1. ..S (PSBGVN,X,Y)=""
  1. ..F S X=$O(^PSB(53.79,"AOIP",DFN,PSBOIT,X),-1) Q:'X D
  1. ...F S Y=$O(^PSB(53.79,"AOIP",DFN,PSBOIT,X,Y),-1) Q:'Y D
  1. ....I $P(^PSB(53.79,Y,.1),U)=PSBON,$P(^PSB(53.79,Y,0),U,9)="G" S PSBGVN=1,(X,Y)=0
  1. .;
  1. .; Is On-Call Given, Can it be given more than once
  1. .;
  1. .I PSBSCHT="OC" D Q:PSBGVN&('$$GET^XPAR("DIV","PSB ADMIN MULTIPLE ONCALL"))
  1. ..S (PSBGVN,X,Y)=""
  1. ..F S X=$O(^PSB(53.79,"AOIP",DFN,PSBOIT,X),-1) Q:'X D
  1. ...F S Y=$O(^PSB(53.79,"AOIP",DFN,PSBOIT,X,Y),-1) Q:'Y D
  1. ....I $P(^PSB(53.79,Y,.1),U)=PSBON,$P(^PSB(53.79,Y,0),U,9)="G" S PSBGVN=1,(X,Y)=0
  1. .;
  1. OK .S PSBSTRT=PSBOST ; Order Start Date/Time
  1. .S PSBSTOP=PSBOSP ; Order Stop Date/Time
  1. .;
  1. .S PSBREC=""
  1. .S $P(PSBREC,U,1)=DFN ; dfn
  1. .S $P(PSBREC,U,2)=PSBONX ; Order
  1. .S $P(PSBREC,U,3)=+PSBON ; order ien
  1. .S $P(PSBREC,U,4)=PSBOTYP ; iv/ud/pending
  1. .S $P(PSBREC,U,5)=PSBSCHT ; schedule type
  1. .S $P(PSBREC,U,6)=PSBSCH ; schedule
  1. .S Y=""
  1. .S:PSBSM Y="SM"
  1. .S:PSBHSM Y="HSM"
  1. .S $P(PSBREC,U,7)=Y ; self med
  1. .S $P(PSBREC,U,8)=PSBOITX ; drugname
  1. .S $P(PSBREC,U,9)=PSBDOSE_" "_PSBIFR ; dosage
  1. .S $P(PSBREC,U,10)=PSBMR ; med route
  1. .; IV Information Column *new* - status date/time
  1. .; (only stopped or infusing)
  1. .;
  1. .D:PSBCOMP
  1. ..S $P(PSBREC,U,11)=PSBINFDT K PSBINFDT
  1. ..S PSBSTUS=PSBINFST,$P(PSBREC,U,20)=PSBSTUS K PSBINFST
  1. .S $P(PSBREC,U,14)="" ; admin date inserted below
  1. .S $P(PSBREC,U,15)=PSBOIT ; OI Pointer
  1. .S $P(PSBREC,U,16)=PSBNJECT ;Set injectable med route flag
  1. .; Variable dosage entered as ####-####?
  1. .I $P(PSBREC,U,9)?1.4N1"-"1.4N.E S $P(PSBREC,U,17)=1
  1. .E S $P(PSBREC,U,17)=0
  1. .S $P(PSBREC,U,18)=PSBIVT ;IV TYPE
  1. .S $P(PSBREC,U,21)=PSBOST
  1. .S $P(PSBREC,U,22)=PSBOSTS
  1. .S $P(PSBREC,U,26)=PSBSTOP
  1. .S $P(PSBREC,U,27)=$$LASTG^PSBCSUTL(DFN,PSBOIT)
  1. .;
  1. .; Gather Dispense Drugs
  1. .D NOW^%DTC
  1. .S (PSBDDS,PSBSOLS,PSBADDS)="0"
  1. .F Y=0:0 S Y=$O(PSBDDA(Y)) Q:'Y D
  1. ..Q:$P(PSBDDA(Y),U,4)&($P(PSBDDA(Y),U,4)<%) ; Inactive
  1. ..S:$P(PSBDDA(Y),U,3)="" $P(PSBDDA(Y),U,3)=1
  1. ..S PSBDDS=PSBDDS_U_$P(PSBDDA(Y),U,1,3)
  1. ..S $P(PSBDDS,U,1)=PSBDDS+1
  1. .; On-Call One Time PRN orders
  1. .S PSBQRR=0
  1. .I "^O^OC^P^"[(U_PSBSCHT_U) D Q
  1. ..I 'PSBDOADD S PSBTBOUT=1,^TMP("PSB",$J,"IVTAB",0)=2,^TMP("PSB",$J,"IVTAB",1)=1,^TMP("PSB",$J,"IVTAB",2)=1 Q
  1. ..D ADD^PSBVDLU1(PSBREC,PSBOTXT,PSBNOW\1,PSBDDS,PSBSOLS,PSBADDS,"IVTAB")
  1. ..S:$G(PSBFON)'="" ^TMP("PSB",$J,"ON IVTAB",PSBDFN,PSBFON)=1 ; Now do not have to place "following order" on VDL!
  1. .;
  1. .; IV's - don't worry about admin times if blank
  1. .I PSBONX["V",PSBIVT'="P",PSBADST="" D Q
  1. ..I 'PSBDOADD S PSBTBOUT=1,^TMP("PSB",$J,"IVTAB",0)=2,^TMP("PSB",$J,"IVTAB",1)=1,^TMP("PSB",$J,"IVTAB",2)=1 Q
  1. ..D ADD^PSBVDLU1(PSBREC,PSBOTXT,PSBNOW\1_".",PSBDDS,PSBSOLS,PSBADDS,"IVTAB")
  1. ..S:$G(PSBFON)'="" ^TMP("PSB",$J,"ON IVTAB",PSBDFN,PSBFON)=1 ; Now do not have to place "following order" on VDL!
  1. .;
  1. .; Now we deal with only continuous
  1. .; process admintimes
  1. .S PSBFREQ=$$GETFREQ^PSBVDLU1(DFN,PSBONX)
  1. .S PSBADMIN=PSBADST
  1. .; process admin times against beginning and ending date
  1. .; build all orders for both days.
  1. .F PSBY=1:1 Q:$P(PSBADMIN,"-",PSBY)="" D
  1. ..; apply this time to the beginning window date
  1. ..S PSB=+(PSBWBEG\1_"."_$P(PSBADMIN,"-",PSBY))
  1. ..D:(PSB'<PSBWBEG)&(PSB'>PSBWEND) ; Make sure it is in the window
  1. ...D:(PSB'<PSBSTRT)&(PSB<PSBSTOP) ; Make sure this time is active
  1. ....D:$$OKAY^PSBVDLU1(PSBSTRT,$P(PSB,"."),PSBSCH,PSBON,PSBOITX,PSBFREQ) ; Okay on this date?
  1. .....I 'PSBDOADD S PSBTBOUT=1,^TMP("PSB",$J,"IVTAB",0)=2,^TMP("PSB",$J,"IVTAB",1)=1,^TMP("PSB",$J,"IVTAB",2)=1 Q
  1. .....D ADD^PSBVDLU1(PSBREC,PSBOTXT,PSB,PSBDDS,PSBSOLS,PSBADDS,"IVTAB")
  1. .....S:$G(PSBFON)'="" ^TMP("PSB",$J,"ON IVTAB",PSBDFN,PSBFON)=1 ; Now do not have to place "following order" on VDL!
  1. ..;
  1. ..Q:(PSBWBEG\1)=(PSBWEND\1) ; Window only has one day rare but possible
  1. ..;
  1. ..; apply this time to the ending window date
  1. ..S PSB=+(PSBWEND\1_"."_$P(PSBADMIN,"-",PSBY))
  1. ..D:(PSB'<PSBWBEG)&(PSB'>PSBWEND) ; Make sure it is in the window
  1. ...D:(PSB'<PSBSTRT)&(PSB<PSBSTOP) ; Make sure this time is active
  1. ....D:$$OKAY^PSBVDLU1(PSBSTRT,$P(PSB,"."),PSBSCH,PSBON,PSBOITX,PSBFREQ) ; Okay on this date?
  1. .....I 'PSBDOADD S PSBTBOUT=1,^TMP("PSB",$J,"IVTAB",0)=2,^TMP("PSB",$J,"IVTAB",1)=1,^TMP("PSB",$J,"IVTAB",2)=1 Q
  1. .....D ADD^PSBVDLU1(PSBREC,PSBOTXT,PSB,PSBDDS,PSBSOLS,PSBADDS,"IVTAB")
  1. .....S:$G(PSBFON)'="" ^TMP("PSB",$J,"ON IVTAB",PSBDFN,PSBFON)=1 ; Now do not have to place "following order" on VDL!
  1. K ^TMP("PSB",$J,"ON IVTAB")
  1. ;
  1. ;add initials of verifying pharmacist/verifying nurse
  1. D:PSBDOADD VNURSE^PSBVDLU1("IVTAB")
  1. Q
  1. ;