ORWORR1 ; SLC/JLI - Utilities for Retrieve Orders for Broker ; 4/3/08 7:47am
;;3.0;ORDER ENTRY/RESULTS REPORTING;**141,243**;Dec 17, 1997;Build 242
;Called from ORWORR
GET1 ;
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
. I ORWTS,(+$P($G(^OR(100,+IFN,0)),U,13)'=ORWTS) K ^TMP("ORR",$J,ORLIST,I) S TOT=TOT-1 Q
. 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)
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
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))=""
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)
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
ORWORR1 ; SLC/JLI - Utilities for Retrieve Orders for Broker ; 4/3/08 7:47am
+1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**141,243**;Dec 17, 1997;Build 242
+2 ;Called from ORWORR
GET1 ;
+1 SET TOT=^TMP("ORR",$JOB,ORLIST,"TOT")
KILL ^TMP("ORR",$JOB,ORLIST,"TOT")
+2 SET I=.1
FOR
SET I=$ORDER(^TMP("ORR",$JOB,ORLIST,I))
IF 'I
QUIT
SET IFN=^(I)
Begin DoDot:1
+3 IF $GET(ORRECIP)&&($GET(FILTER)=12&&($$FLAGRULE(+IFN)))
KILL ^TMP("ORR",$JOB,ORLIST,I)
SET TOT=TOT-1
QUIT
+4 IF ORWTS
IF (+$PIECE($GET(^OR(100,+IFN,0)),U,13)'=ORWTS)
KILL ^TMP("ORR",$JOB,ORLIST,I)
SET TOT=TOT-1
QUIT
+5 SET PTEVTID=$PIECE($GET(^OR(100,+IFN,0)),U,17)
+6 IF PTEVTID>0
SET EVTNAME=$$NAME^OREVNTX(PTEVTID)
+7 SET ^TMP("ORR",$JOB,ORLIST,I)=IFN_U_$PIECE($GET(^OR(100,+IFN,0)),U,11)_U_$PIECE($GET(^(8,+$PIECE(IFN,";",2),0)),U)_U_PTEVTID_U_EVTNAME
End DoDot:1
+8 SET TXTVW=$SELECT(MULT:0,FILTER=2:2,1:1)
IF FILTER=2
DO ORYD^ORDD100
+9 SET ^TMP("ORR",$JOB,ORLIST,.1)=TOT_U_TXTVW_U_$GET(ORYD,0)
+10 SET REF=$NAME(^TMP("ORR",$JOB,ORLIST))
+11 QUIT
GET2 ; For AUTO DC/Event Release Orders
+1 NEW JDND,JDIX,JDCNT,DCSPLIT
+2 SET JDCNT=1
SET DCSPLIT=0
+3 SET TOT=^TMP("ORR",$JOB,ORLIST,"TOT")
KILL ^TMP("ORR",$JOB,ORLIST,"TOT")
+4 FOR JDND="RL","DC"
Begin DoDot:1
+5 SET I=.1
FOR
SET I=$ORDER(^TMP("ORR",$JOB,ORLIST,I))
IF 'I
QUIT
Begin DoDot:2
+6 IF '$DATA(^TMP("ORR",$JOB,ORLIST,I,JDND))
QUIT
+7 SET JDIX=0
FOR
SET JDIX=$ORDER(^TMP("ORR",$JOB,ORLIST,I,JDND,JDIX))
IF 'JDIX
QUIT
SET IFN=^(JDIX)
Begin DoDot:3
+8 IF 'DCSPLIT
IF (JDND="DC")
Begin DoDot:4
+9 SET ^TMP("ORRJD",$JOB,JDCNT)="DC START"
+10 SET DCSPLIT=1
SET JDCNT=JDCNT+1
SET TOT=TOT+1
End DoDot:4
+11 IF ORWTS
IF (+$PIECE($GET(^OR(100,+IFN,0)),U,13)'=ORWTS)
SET TOT=TOT-1
QUIT
+12 SET PTEVTID=$PIECE($GET(^OR(100,+IFN,0)),U,17)
+13 IF PTEVTID>0
SET EVTNAME=$$NAME^OREVNTX(PTEVTID)
+14 SET ^TMP("ORRJD",$JOB,JDCNT)=IFN_U_$PIECE($GET(^OR(100,+IFN,0)),U,11)_U_$PIECE($GET(^(8,+$PIECE(IFN,";",2),0)),U)_U_PTEVTID_U_EVTNAME
+15 SET JDCNT=JDCNT+1
End DoDot:3
End DoDot:2
End DoDot:1
+16 SET TXTVW=$SELECT(MULT:0,FILTER=2:2,1:1)
IF FILTER=2
DO ORYD^ORDD100
+17 SET ^TMP("ORRJD",$JOB,.1)=TOT_U_TXTVW_U_$GET(ORYD,0)
+18 SET REF=$NAME(^TMP("ORRJD",$JOB))
+19 QUIT
FLAGRULE(ORNUM,USR) ;
+1 ;returns 0 if we should keep ORNUM in the list
+2 ;returns 1 if we should remove ORNUM from the list
+3 ;determines based on whether the user USR should see these flagged orders
+4 ; based on presence in file 100 NODE 8 FIELD 39 and
+5 ; based on whether the user should have gotten the flag due to provider recipients
+6 NEW ORI,ORRET,ORQUIT,I,LST,ORDFN
+7 IF '$GET(USR)
SET USR=DUZ
+8 SET ORRET=1
SET ORQUIT=0
+9 SET ORI=0
FOR
SET ORI=$ORDER(^OR(100,ORNUM,8,ORI))
IF 'ORI
QUIT
Begin DoDot:1
+10 IF '$PIECE($GET(^OR(100,ORNUM,8,ORI,3)),U,6)&($PIECE($GET(^OR(100,ORNUM,8,ORI,3)),U,9))
SET LST($PIECE($GET(^OR(100,ORNUM,8,ORI,3)),U,9))=""
End DoDot:1
+11 SET ORDFN=+$PIECE($GET(^OR(100,ORNUM,0)),U,2)
+12 DO START^ORBPRCHK(.LST,ORNUM,6,ORDFN)
+13 ;add ordering provider
+14 NEW ORDPROV
+15 SET ORDPROV=$$ORDERER^ORQOR2(ORNUM)
+16 IF $GET(ORDPROV)
SET LST(ORDPROV)=""
+17 DO ADDSURR(.LST)
+18 IF $DATA(LST(USR))
SET ORRET=0
+19 QUIT ORRET
ADDSURR(LST) ;TAKE LIST OF USERS AND ADD SURROGATES TO THE LIST
+1 NEW I
+2 SET I=0
FOR
SET I=$ORDER(LST(I))
IF 'I
QUIT
SET LST($$CURRSURO^XQALSURO(I))=""
+3 QUIT