VistA-WorldVistAEHR/r/ZZREGIONAL-A1C-A5C-CRHD-RGE.../CRHDDNR.m

78 lines
3.6 KiB
Mathematica

CRHDDNR ; CAIRO/CLC - GET ACTIVE DNR ORDER ;4/23/08 07:48
;;1.0;CRHD;****;Jan 28, 2008;Build 19
;=================================================================
;
ENT(CRHDRTN,DFN,CRHDNRTT,CRHDDIV,CRHDMULT) ;
K CRHDRTN
N CRHDRN S CRHDRN=1
S CRHDMULT=$G(CRHDMULT)
D DNRPARM(.CRHDNRTT,DUZ,.CRHDDIV)
I 'CRHDNRTT S CRHDNRTT(1)="^DNR ORDER"
N CRHDFILE,CRHDSDAT,CRHDFND,CRHDTMP,CRHDEXDT,CRHDBY,CRHDDI
N CRHDOI,CRHDEXN,X,Y,CRHDBDNR
N CRHDDDNR,CRHDBI,CRHDFLG,CRHDZ,CRHDCNT,CRHDZCT,CRHDZZOR
S (CRHDFLG,CRHDZCT)=0,CRHDCNT=1
S CRHDFILE=$$TERMLKUP^ORB31(.CRHDBY,"DNR")
S CRHDSDAT=$$NOW^XLFDT
;S CRHDEXDT=9999999.999999-CRHDSDAT
S CRHDEXDT=0
F S CRHDEXDT=$O(^OR(100,"AC",DFN_";DPT(",CRHDEXDT)) Q:'CRHDEXDT!(CRHDFLG) D
.S CRHDEXN="" F S CRHDEXN=$O(^OR(100,"AC",DFN_";DPT(",CRHDEXDT,CRHDEXN)) Q:CRHDEXN=""!(CRHDFLG) D
..I $D(CRHDBY),(+$G(CRHDFILE)=101.43) D
...F CRHDBI=1:1:CRHDBY D
....S CRHDBDNR=$P(CRHDBY(CRHDBI),U)
....S CRHDOI=$$OI^ORQOR2(CRHDEXN)
....I CRHDBDNR=CRHDOI D
.....D DETAIL("CRHDRTN",CRHDEXN,.CRHDFLG,.CRHDCNT,CRHDMULT) ;,WRT("STMP")
..;I '$$OI^ORQOR2(CRHDEXN)&('CRHDFLG) D
..I 'CRHDFLG D
...D DETAIL("CRHDRTN",CRHDEXN,.CRHDFLG,.CRHDCNT,CRHDMULT) ;,WRT("TMP")
I '$D(CRHDRTN) S CRHDRTN(1)=""
E S CRHDRTN(1)=$G(CRHDCNT)
Q
DETAIL(CRHDY,CRHDIFN,CRHDFND,CRHDCNT,CRHDMDNR) ; -- Returns details of order CRHDIFN in CRHDY(#)
N CRHDMCNT,X,X2,I,CRHDILOG,CRHD0,CRHD3,CRHD6,CRHDSEQ,CRHDITEM,CRHDPRMT,CRHDMULT,CRHDFIRT,CRHDTITL,CRHDINST
N DIWL,DIWR,DIWF,CRHDACTI,CRHDII,VAIN,ORIGVIEW,CRHDNMSP,CRHDYT,CRHDDNR,CRHDXX,CRHDNX,CRHDGOTI,ORFLG
S CRHDIFN=+CRHDIFN,CRHD0=$G(^OR(100,CRHDIFN,0)),CRHD3=$G(^(3)),CRHD6=$G(^(6))
K CRHDYT S ORIGVIEW=1 D TEXT^CRHD8(.CRHDYT,+CRHDIFN_";"_+$P(CRHD3,U,7),254) ;CurrTx
I $D(CRHDYT) D
.Q:$D(CRHDZZOR(CRHDIFN))
.S CRHDDNR=0,CRHDDNR=$O(CRHDYT(CRHDDNR))
.S CRHDGOTI=0
.S CRHDXX="" F S CRHDXX=$O(CRHDNRTT(CRHDXX)) Q:CRHDXX=""!(CRHDGOTI)!(CRHDFND) D ;S NX=0 F S NX=$O(CRHDNRTT(XX,NX)) Q:'NX!(CRHDFND) D
..I ($G(CRHDYT(CRHDDNR))'[$P(CRHDNRTT(CRHDXX),"^",2))&($P(CRHDNRTT(CRHDXX),"^",2)'[CRHDYT(CRHDDNR)) Q
..S CRHDZCT=$G(CRHDZCT)+1,CRHDGOTI=1
..I 'CRHDMDNR S CRHDFND=1
..I CRHDCNT>1 S CRHDCNT=CRHDCNT+1,@CRHDY@(CRHDCNT)=""
..S CRHDMCNT=0 F CRHDII=1:1 S CRHDMCNT=$O(CRHDYT(CRHDMCNT)) Q:'CRHDMCNT S CRHDCNT=CRHDCNT+1 D
...I CRHDII=1 S @CRHDY@(CRHDCNT)=CRHDEXDT_"~"_CRHDIFN_"~"_CRHDYT(CRHDMCNT)
...E S @CRHDY@(CRHDCNT)=CRHDYT(CRHDMCNT)
..S CRHDCNT=$G(CRHDCNT)+1
..S @CRHDY@(CRHDCNT)="Start Date/Time: "_$S($P(CRHD0,U,8):$$DATE^ORQ20($P(CRHD0,U,8)),1:"")
..I $P(CRHD3,U,5),$P(CRHD3,U,11)=2 S X=$$ORIG(CRHDIFN),@CRHDY@(CRHDCNT)=@CRHDY@(CRHDCNT)_" (originally "_$$DATE^ORQ20(X)_")"
..S CRHDCNT=CRHDCNT+1
..S:+$P(CRHD0,U,9) @CRHDY@(CRHDCNT)="Stop Date/Time: "_$S($P(CRHD0,U,9):$$DATE^ORQ20($P(CRHD0,U,9)),1:"")
..S CRHDZZOR(CRHDIFN)=""
Q
WRT(CRHDC,CRHDARRY,CRHDTRG) ;
Q:'$D(CRHDARRY)
N CRHDN
S CRHDN=0 F S CRHDN=$O(CRHDARRY(CRHDN)) Q:'CRHDN S CRHDC=$G(CRHDC)+1,@CRHDTRG@(CRHDC,0)=CRHDARRY(CRHDN)
Q
ORIG(CRHDIFN) ; -- Return original start date of [renewal] order
N CRHDI,CRHDY,CRHDX3,CRHDDONE
S CRHDI=CRHDIFN,CRHDY=$P($G(^OR(100,CRHDIFN,0)),U,8),CRHDDONE=0
F S CRHDX3=$G(^OR(100,CRHDI,3)) D Q:CRHDDONE
. I $P(CRHDX3,U,11)=2,$P(CRHDX3,U,5) S CRHDI=$P(CRHDX3,U,5) Q ;loop
. S CRHDY=$P($G(^OR(100,CRHDI,0)),U,8),CRHDDONE=1
Q CRHDY
DNRPARM(CRHDNRTT,DUZ,CRHDDIV) ;GET DNR TITLES
N CRHDPAR,CRHDDIVI
S CRHDNRTT=0
I '+$G(CRHDDIV) S CRHDDIV=+$$SITE^VASITE
I 'CRHDNRTT S CRHDPAR="DIV.`"_+CRHDDIV D GETLST^XPAR(.CRHDNRTT,CRHDPAR,"CRHD DNR ORDER TITLE")
I 'CRHDNRTT D
.S CRHDDIVI=$O(^DIC(4,"D",CRHDDIV,0))
.I CRHDDIVI S CRHDPAR="DIV.`"_CRHDDIVI D GETLST^XPAR(.CRHDNRTT,CRHDPAR,"CRHD DNR ORDER TITLE")
Q