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

ORWORR1.m

Go to the documentation of this file.
ORWORR1 ; SLC/JLI - Utilities for Retrieve Orders for Broker ;Dec 07, 2020@12:26:20
 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**141,243,456,444,539**;Dec 17, 1997;Build 41
 ;Called from ORWORR
 ;EPIP/RTW Modified for the Unified Action Profile 26 Oct 2016
 ; External References
 ;   DBIA  4834  GETUSER1^XQALDATA
 ;   DBIA  2790  $$CURRSURO^XQALSURO
 ;
GET1 ;
 N ORGROUP
 S TOT=^TMP("ORR",$J,ORLIST,"TOT") K ^TMP("ORR",$J,ORLIST,"TOT")
 S I=.1 F  S I=$O(^TMP("ORR",$J,ORLIST,I)) Q:'I  S IFN=^(I) D
 . ;I $G(ORRECIP)&&($G(FILTER)=12&&($$FLAGRULE(+IFN))) K ^TMP("ORR",$J,ORLIST,I) S TOT=TOT-1 Q
 . ;correction above line, error in XINDEX ;OR*405
 . I $G(ORRECIP),$G(FILTER)=12,$$FLAGRULE(+IFN) K ^TMP("ORR",$J,ORLIST,I) S TOT=TOT-1 Q
 . I ORWTS,(+$P($G(^OR(100,+IFN,0)),U,13)'=ORWTS) K ^TMP("ORR",$J,ORLIST,I) S TOT=TOT-1 Q
 . ;EPIP/RTW BEGIN ***UNIFIED ACTION PROFILE Modification*** 9/27/2017
 . ;FILTER OUT NON OUTPATIENT ORDERS
 . S ORGROUP=$O(^ORD(100.98,"B","OUTPATIENT MEDICATIONS",0))
 . I $G(GROUPS),$$GET1^DIQ(100.98,GROUPS,.01)="DISCHARGE MEDS",$P($G(^OR(100,+IFN,0)),U,11)'=ORGROUP K ^TMP("ORR",$J,ORLIST,I) S TOT=TOT-1 Q
 . ;END ***UNIFIED ACTION PROFILE Modification*** 9/27/2017
 . S PTEVTID=$P($G(^OR(100,+IFN,0)),U,17)
 . S:PTEVTID>0 EVTNAME=$$NAME^OREVNTX(PTEVTID)
 . S ^TMP("ORR",$J,ORLIST,I)=IFN_U_$P($G(^OR(100,+IFN,0)),U,11)_U_$P($G(^(8,+$P(IFN,";",2),0)),U)_U_PTEVTID_U_EVTNAME
 S TXTVW=$S(MULT:0,FILTER=2:2,1:1) D:FILTER=2 ORYD^ORDD100
 S ^TMP("ORR",$J,ORLIST,.1)=TOT_U_TXTVW_U_$G(ORYD,0)
 ;EPIP/RTW BEGIN ***UNIFIED ACTION PROFILE Modification*** 26/OCT/2016
 ;ALPHABETICAL ORDER SORT FOR UAP View
 ; Special sort for Discharge View
 I $G(GROUPS),$$GET1^DIQ(100.98,GROUPS,.01)="DISCHARGE MEDS" D DCREF^ORTOULT4
 I $G(GROUPS),$$GET1^DIQ(100.98,GROUPS,.01)="PHARMACY UAP" D REF^ORTOULT4
 ; END UAP modification
 S REF=$NA(^TMP("ORR",$J,ORLIST))
 Q
GET2 ; For AUTO DC/Event Release Orders
 N JDND,JDIX,JDCNT,DCSPLIT
 S JDCNT=1,DCSPLIT=0
 S TOT=^TMP("ORR",$J,ORLIST,"TOT") K ^TMP("ORR",$J,ORLIST,"TOT")
 F JDND="RL","DC" D
 . S I=.1 F  S I=$O(^TMP("ORR",$J,ORLIST,I)) Q:'I  D
 . . I '$D(^TMP("ORR",$J,ORLIST,I,JDND)) Q
 . . S JDIX=0 F  S JDIX=$O(^TMP("ORR",$J,ORLIST,I,JDND,JDIX)) Q:'JDIX  S IFN=^(JDIX)  D
 . . . I 'DCSPLIT,(JDND="DC") D
 . . . . S ^TMP("ORRJD",$J,JDCNT)="DC START"
 . . . . S DCSPLIT=1,JDCNT=JDCNT+1,TOT=TOT+1
 . . . I ORWTS,(+$P($G(^OR(100,+IFN,0)),U,13)'=ORWTS) S TOT=TOT-1 Q
 . . . S PTEVTID=$P($G(^OR(100,+IFN,0)),U,17)
 . . . S:PTEVTID>0 EVTNAME=$$NAME^OREVNTX(PTEVTID)
 . . . S ^TMP("ORRJD",$J,JDCNT)=IFN_U_$P($G(^OR(100,+IFN,0)),U,11)_U_$P($G(^(8,+$P(IFN,";",2),0)),U)_U_PTEVTID_U_EVTNAME
 . . . S JDCNT=JDCNT+1
 S TXTVW=$S(MULT:0,FILTER=2:2,1:1) D:FILTER=2 ORYD^ORDD100
 S ^TMP("ORRJD",$J,.1)=TOT_U_TXTVW_U_$G(ORYD,0)
 S REF=$NA(^TMP("ORRJD",$J))
 Q
FLAGRULE(ORNUM,USR) ;
 ;returns 0 if we should keep ORNUM in the list
 ;returns 1 if we should remove ORNUM from the list
 ;determines based on whether the user USR should see these flagged orders
 ; based on presence in file 100 NODE 8 FIELD 39 and
 ; based on whether the user should have gotten the flag due to provider recipients
 N ORI,ORRET,ORQUIT,I,LST,ORDFN,IEN3,FUSR
 I '$G(USR) S USR=DUZ
 S ORRET=1,ORQUIT=0
 S ORI=0 F  S ORI=$O(^OR(100,ORNUM,8,ORI)) Q:'ORI  D
 .I '$P($G(^OR(100,ORNUM,8,ORI,3)),U,6)&($P($G(^OR(100,ORNUM,8,ORI,3)),U,9)) S LST($P($G(^OR(100,ORNUM,8,ORI,3)),U,9))=""
 .;p539 add recipients who received notification for the current order
 .I '$P($G(^OR(100,ORNUM,8,ORI,3)),U,6) S IEN3=0 D
 ..F  S IEN3=$O(^OR(100,ORNUM,8,ORI,6,IEN3)) Q:'IEN3  S FUSR=+$G(^(IEN3,0)) I FUSR S LST(FUSR)=""
 S ORDFN=+$P($G(^OR(100,ORNUM,0)),U,2)
 D START^ORBPRCHK(.LST,ORNUM,6,ORDFN)
 ;add ordering provider
 N ORDPROV
 S ORDPROV=$$ORDERER^ORQOR2(ORNUM)
 I $G(ORDPROV) S LST(ORDPROV)=""
 D ADDSURR(.LST)
 ;p456 add the current user if they have a notification associated with the current order
 N ORNLST,ORI,ORRTN,ORMTCH S ORNLST=0,ORI=0,ORMTCH=0,ORRTN=""
 D GETUSER1^XQALDATA("ORNLST",DUZ) I ORNLST D
 .F  S ORI=$O(ORNLST(ORI)) Q:'ORI  D  Q:ORMTCH
 ..D GETDATA^ORWORB(.ORRTN,$P(ORNLST(ORI),U,2))
 ..I +ORRTN=ORNUM S LST(DUZ)="",ORMTCH=1
 I $D(LST(USR)) S ORRET=0
 Q ORRET
ADDSURR(LST) ;TAKE LIST OF USERS AND ADD SURROGATES TO THE LIST
 N I
 S I=0 F  S I=$O(LST(I)) Q:'I  S LST($$CURRSURO^XQALSURO(I))=""
 Q