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

ORTOULT4.m

Go to the documentation of this file.
ORTOULT4 ;EPIP/RTW-UNIFIED ACTION PROFILE RPCS. ;Mar 05, 2019@08:07:49
 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**444**;Dec 17, 1997;Build 48
 ;EPIP/RTW For the Unified Action Profile 26 Oct 2016
 ;ICR#   Type     Description
 ;-----  ----     -------------------------------------
 ;1014   Routine  LOW^XLFSTR
 ;
 ; RPC 'ORTO SET UAP FLAG'
 ; RPC 'ORTO SETRVW'
 ; RPC 'ORTO GETRVW'
 Q  ; NO DIRECT ENTRY
 ;
SETUAPF(ORTOK,ORTUAPF) ;
 N ORTUAP
 S ORTUAP=+$G(ORTUAPF) ;1=user in UAP view on orders tab, 0=user in any other view
 S ORTOK=1 ;dummy return variable
 Q
SETRVW(ORTOK,ORTRVW,ORTORIEN) ;
 ;
 N ORTIEN,ORTLRVW,ORTDT,ORTOK
 S ORTIEN=+$G(ORTORIEN),ORTLRVW=0,ORTOK=0
 Q:'ORTIEN
 Q:'$L($G(ORTRVW))
 N %,X,Y D NOW^%DTC S ORTDT=%
 N DR,DA,DIE
 S DIE="^OR(100,",DA=ORTIEN
 S DR=".61///^S X=ORTRVW;.62///^S X=ORTDT;.63///^S X=+$G(DUZ)"
 D ^DIE
 ;
 S ORTOK=1
 ;
 Q
GETRVW(ORTRVW,ORTORIEN) ;
 ;
 N ORTIEN
 S ORTRVW=0
 S ORTIEN=+$G(ORTORIEN)
 Q:'ORTIEN
 S ORTRVW=$P($G(^OR(100,ORTIEN,.61)),U,1)
 S ORTRVW=$S(ORTRVW="0":" ",ORTRVW="1":"yes",ORTRVW="C":"cont",ORTRVW="D":"dc",ORTRVW="G":"chg",ORTRVW="N":"new",ORTRVW="R":"renew",1:"")
 Q
 ;
REF ; REFORMAT ORDER LIST IN ALPHABETICAL ORDER
 ; FROM AGET^ORWORR
 N LIST,ORCITEM,ORI,ORJ,ORSUPPLY,ORTOADD,ORTIFN,ORTITEM,ORUI,ORUI2,ORUIEN,ORX,SUPPLY,ORTO,ORIGTA,ORKIEN,ORUAPIV,ORDG
 S (ORCNT,ORTO)=0  F ORI=0:0 S ORI=$O(^TMP("ORR",$J,ORLIST,ORI)) Q:ORI<.1  D
 .S (ORSUPPLY,ORUAPIV,SUPPLY)=0
 .S ORX=^TMP("ORR",$J,ORLIST,ORI)
 .S ORTIFN=$P($P(ORX,U),";")
 .S ORTITEM=$P($G(^OR(100,ORTIFN,.1,1,0)),U) Q:ORTITEM=""
 .S ORCITEM=$P($G(^ORD(101.43,ORTITEM,0)),U) ;Oitem name used for sorting.
 .S:$D(^ORD(101.43,ORTITEM,"PS")) ORTO=1,SUPPLY=$P($G(^("PS")),U,5) ;set ORTO is "PS" exists
 .S ORDG=$$GET1^DIQ(100,ORTIFN,23,"E") S:(ORDG["IV")!(ORDG["INFUSION") ORUAPIV=1 ;is the service IV or Infusion
 .I '$G(ORUAPIV) D UAPLASTX(ORTIFN,ORTITEM) ;all non IV reset ORCITEM if last Oitem/Otext mismatch
 .I $G(ORUAPIV) S ORCITEM=$$UAPIV(ORCITEM,ORTIFN) ; multiple Oitem IV no ADDITIVE get last text.
 .K ^TMP("ORR",$J,ORLIST,ORI)
 .I $$GET1^DIQ(100.98,GROUPS,.01)="PHARMACY UAP" D
 .. S ORUI=0 F  S ORUI=$O(^ORD(100.98,GROUPS,1,ORUI)) Q:'ORUI  D
 ... S ORUI2=$G(^ORD(100.98,GROUPS,1,ORUI,0)) I $$GET1^DIQ(100.98,ORUI2,.01)["SUPPL" S ORSUPPLY=1
 .Q:(SUPPLY)&'$G(ORSUPPLY)
 .S ORCNT=ORCNT+1
 .S ORCITEM=$$LOW^XLFSTR(ORCITEM) ;tallman lettering fix rtw
 .S LIST(ORCITEM,ORCNT)=ORX
 S ORICNT=0
 S ORCITEM="" F ORJ=0:0 S ORCITEM=$O(LIST(ORCITEM)) Q:ORCITEM=""  D
 .F ORK=0:0 S ORK=$O(LIST(ORCITEM,ORK)) Q:ORK<1  D
 ..S ORUIEN=$P(LIST(ORCITEM,ORK),";"),ORKIEN=$P($P(LIST(ORCITEM,ORK),U),";",2)
 ..S IENS=ORKIEN_","_ORUIEN Q:$$GET1^DIQ(100.008,IENS_",","15")["dc/edit"
 ..S ORICNT=ORICNT+1
 ..S ^TMP("ORR",$J,ORLIST,ORICNT)=LIST(ORCITEM,ORK)
 K ORCNT,ORICNT
 Q
 ;
UAPIV(ORCITEM,ORTIFN) ;this puts an IV in correct number order by first additive if it has one.
 N ORTITMN,ORTADD
 S (ORTITMN,ORTOADD)=0 F  S ORTITMN=$O(^OR(100,ORTIFN,.1,ORTITMN)) Q:('ORTITMN)!(ORTOADD=1)  D  ;new sort when INFUSION ORDER
 . S ORTITEM=$P($G(^OR(100,ORTIFN,.1,ORTITMN,0)),U)
 . Q:+$D(^ORD(101.43,ORTITEM,"PS"))'>0
 . S:$P(^ORD(101.43,ORTITEM,"PS"),U,3) ORTOADD=0
 . Q:$P(^ORD(101.43,ORTITEM,"PS"),U,3)
 . S:$P(^ORD(101.43,ORTITEM,"PS"),U,4) ORTOADD=1 ;end new code to handle infusion orders.
 . S ORCITEM=$G(^ORD(101.43,ORTITEM,0),U)
 S:'$G(ORTOADD) ORIGTA=$$LASTXT^ORQ12(ORTIFN),ORCITEM=$G(^OR(100,ORTIFN,8,ORIGTA,.1,1,0)) S:$E(ORCITEM,1,3)=">> " ORCITEM=$E(ORCITEM,4,999)
 Q ORCITEM
 ;
UAPALPHA(ORTOADD,ORTA,ORTIFN) ; called by ORQ12 resorts the order text field so that the first additive is on the top to match the sorted by orderable item name.
 K ^TMP("UAP",$J),^TMP("UAPTEXT",$J)
 N ORUAP1,ORUAP2,ORUTX,ORUTY,ORUAPCN2,ORUAPCN3,ORUAPCNT,ORTMSAVE
 S ORTITEM=$P($G(^OR(100,ORTIFN,.1,1,0)),U),ORTMSAVE=ORTITEM ;set item first in case there is no additive.
 S (ORTITMN,ORTOADD)=0 F  S ORTITMN=$O(^OR(100,ORTIFN,.1,ORTITMN)) Q:('ORTITMN)!(ORTOADD=1)  D  ;new sort when INFUSION ORDER
 . S ORTITEM=$P($G(^OR(100,ORTIFN,.1,ORTITMN,0)),U)
 . Q:+$D(^ORD(101.43,ORTITEM,"PS"))'>0
 . S:$P(^ORD(101.43,ORTITEM,"PS"),U,3) ORTOADD=0
 . Q:$P(^ORD(101.43,ORTITEM,"PS"),U,3)  ;this indicates a base.
 . S:$P(^ORD(101.43,ORTITEM,"PS"),U,4) ORTOADD=1 ;end new code to put first additive on top of infusion order display.
 S:'$G(ORTOADD) ORTITEM=ORTMSAVE  ;code to handle if the IV has no additive.
 S ^TMP("UAP",$J,ORTIFN,1)=ORTITEM
 S ORUAP1=0,ORUAPCNT=2 F  S ORUAP1=$O(^OR(100,ORTIFN,.1,ORUAP1)) Q:'ORUAP1  D
 . Q:$P(^OR(100,ORTIFN,.1,ORUAP1,0),U)=ORTITEM
 . S ^TMP("UAP",$J,ORTIFN,ORUAPCNT)=$P(^OR(100,ORTIFN,.1,ORUAP1,0),U)
 . S ORUAPCNT=ORUAPCNT+1
 S ORUAP2=0,ORUAPCN2=1 F  S ORUAP2=$O(^OR(100,ORTIFN,8,ORTA,.1,ORUAP2)) Q:'ORUAP2  D
 . S ORUTX=$G(^OR(100,ORTIFN,8,ORTA,.1,ORUAP2,0)) S ORUTY=$L(ORUTX)
 . I $E(ORUTX)=" ",ORUTY S ORUTX=$E(ORUTX,2,999) ;new line
 . S ^TMP("UAPTEXT",$J,ORTIFN,ORUAPCN2)=ORUTX
 . S ORUAPCN2=ORUAPCN2+1
 Q:'$G(ORTOADD) ORTOADD
UAPRTW ; part of the UAPALPHA above this part takes the original IV list and places it in the new order
 K ORTX
 N ORUAP3,ORUAP4,ORUAP5,ORTITE2
 S ORTITE2=$P(^TMP("UAP",$J,ORTIFN,1),U)
 S ORUAP3=0,ORUAP4=1,ORUAPCN3=1 F  S ORUAP3=$O(^TMP("UAPTEXT",$J,ORTIFN,ORUAP3)) Q:'ORUAP3  D
 . I $G(^TMP("UAPTEXT",$J,ORTIFN,ORUAP3))[$$GET1^DIQ(101.43,ORTITE2,.01,"I",) S ORTX(ORUAP4)=^TMP("UAPTEXT",$J,ORTIFN,ORUAP3),ORUAP4=ORUAP4+1 Q
 I ORUAP4>1 S ORUAP5=0 F  S ORUAP5=$O(^TMP("UAPTEXT",$J,ORTIFN,ORUAP5)) Q:'ORUAP5  D
 . I $G(^TMP("UAPTEXT",$J,ORTIFN,ORUAP5))'[$$GET1^DIQ(101.43,ORTITE2,.01,"I",) S ORTX(ORUAP4)=^TMP("UAPTEXT",$J,ORTIFN,ORUAP5)
 . S ^TMP("UAP3",$J,ORTIFN,ORUAPCN3)=^TMP("UAPTEXT",$J,ORTIFN,ORUAP5)
 . S ORUAPCN3=ORUAPCN3+1,ORUAP4=ORUAP4+1
 Q
DCREF  ; Reformat order list in special Discharge View order
 ; Active : Hold : Pending : Discontinued : Expired
 ; FROM AGET^ORWORR => GET1^ORWORR1 => here
 N LIST,ORI,ORK,ORX,ORTIFN,ORTITEM,ORCITEM,SUPPLY,ORTSTLST,ORTSTA,ORTIDX,ORCNT,ORICNT
 N ORTSVPT1
 ;
 S ORTSTLST(6)=1 ;Active/Suspended
 S ORTSTLST(3)=2 ;Hold
 S ORTSTLST(5)=3 ;Pending
 S ORTSTLST(7)=4 ;Expired
 S ORTSTLST(1)=5 ;Discontinued
 ;
 I $D(^TMP("ORR",$J,ORLIST,.1)) S ORTSVPT1=$G(^TMP("ORR",$J,ORLIST,.1))
 ;
 S (ORI,ORCNT)=0
 F  S ORI=$O(^TMP("ORR",$J,ORLIST,ORI)) Q:ORI<.1  D
 .S ORX=^TMP("ORR",$J,ORLIST,ORI)
 .S ORTIFN=$P($P(ORX,U),";")
 .;
 .S ORTSTA=+$P($G(^OR(100,ORTIFN,3)),U,3)
 .S ORTIDX=$S($D(ORTSTLST(ORTSTA)):ORTSTLST(ORTSTA),1:9)
 .S ORTITEM=$P($G(^OR(100,ORTIFN,.1,1,0)),U) Q:ORTITEM=""
 .S ORCITEM=$P($G(^ORD(101.43,ORTITEM,0)),U),SUPPLY=$P($G(^("PS")),U,5)
 .K ^TMP("ORR",$J,ORLIST,ORI)
 .S ORCNT=ORCNT+1
 .S ORCITEM=$$LOW^XLFSTR(ORCITEM)  ;tallman lettering fix rtw
 .S LIST(ORTIDX,ORCITEM,ORCNT)=ORX
 ;
 S ORICNT=0
 S ORTIDX=0 F  S ORTIDX=$O(LIST(ORTIDX)) Q:'ORTIDX  D
 . S ORCITEM="" F  S ORCITEM=$O(LIST(ORTIDX,ORCITEM)) Q:ORCITEM=""  D
 . . S ORK=0 F  S ORK=$O(LIST(ORTIDX,ORCITEM,ORK)) Q:'ORK  D
 . . . S ORICNT=ORICNT+1
 . . . S ^TMP("ORR",$J,ORLIST,ORICNT)=LIST(ORTIDX,ORCITEM,ORK)
 ;
 I $D(ORTSVPT1) S ^TMP("ORR",$J,ORLIST,.1)=ORTSVPT1
 ;
 Q
UAPOFF(ORUAPOFF) ;ON/OFF SWITCH
 ;
 S ORUAPOFF=$$GET^XPAR("ALL","OR UNIFIED ACTION PROFILE OFF")
 Q ORUAPOFF
DGROUP(ORDGNAME,ORX) ;RPC ORTO DGROUP to get the DGroup name
 S ORDGNAME=$P($G(^ORD(100.98,ORX,0)),U,1)
 Q
UAPLASTX(ORTIFN,ORTITEM) ;
 N OROTXT,OROTXTX
 S ORIGTA=$$LASTXT^ORQ12(ORTIFN) ; GETS THE LAST ORDERTEXT IEN
 S OROTXT=$G(^OR(100,ORTIFN,8,ORIGTA,.1,1,0)) S:$E(OROTXT,1,3)=">> " OROTXT=$E(OROTXT,4,999)
 S ORCITEM=$P($G(^ORD(101.43,ORTITEM,0)),U)
 S OROTXTX=$E(OROTXT,1,2),ORCITEMX=$E(ORCITEM,1,2)
 S:OROTXTX'=ORCITEMX ORCITEM=OROTXT
 Q