source: WorldVistAEHR/trunk/r/ZZREGIONAL-A1C-A5C-CRHD-RGED-RGUT-RGWB-RG/CRHDDNR.m@ 1742

Last change on this file since 1742 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 3.6 KB
Line 
1CRHDDNR ; CAIRO/CLC - GET ACTIVE DNR ORDER ;4/23/08 07:48
2 ;;1.0;CRHD;****;Jan 28, 2008;Build 19
3 ;=================================================================
4 ;
5ENT(CRHDRTN,DFN,CRHDNRTT,CRHDDIV,CRHDMULT) ;
6 K CRHDRTN
7 N CRHDRN S CRHDRN=1
8 S CRHDMULT=$G(CRHDMULT)
9 D DNRPARM(.CRHDNRTT,DUZ,.CRHDDIV)
10 I 'CRHDNRTT S CRHDNRTT(1)="^DNR ORDER"
11 N CRHDFILE,CRHDSDAT,CRHDFND,CRHDTMP,CRHDEXDT,CRHDBY,CRHDDI
12 N CRHDOI,CRHDEXN,X,Y,CRHDBDNR
13 N CRHDDDNR,CRHDBI,CRHDFLG,CRHDZ,CRHDCNT,CRHDZCT,CRHDZZOR
14 S (CRHDFLG,CRHDZCT)=0,CRHDCNT=1
15 S CRHDFILE=$$TERMLKUP^ORB31(.CRHDBY,"DNR")
16 S CRHDSDAT=$$NOW^XLFDT
17 ;S CRHDEXDT=9999999.999999-CRHDSDAT
18 S CRHDEXDT=0
19 F S CRHDEXDT=$O(^OR(100,"AC",DFN_";DPT(",CRHDEXDT)) Q:'CRHDEXDT!(CRHDFLG) D
20 .S CRHDEXN="" F S CRHDEXN=$O(^OR(100,"AC",DFN_";DPT(",CRHDEXDT,CRHDEXN)) Q:CRHDEXN=""!(CRHDFLG) D
21 ..I $D(CRHDBY),(+$G(CRHDFILE)=101.43) D
22 ...F CRHDBI=1:1:CRHDBY D
23 ....S CRHDBDNR=$P(CRHDBY(CRHDBI),U)
24 ....S CRHDOI=$$OI^ORQOR2(CRHDEXN)
25 ....I CRHDBDNR=CRHDOI D
26 .....D DETAIL("CRHDRTN",CRHDEXN,.CRHDFLG,.CRHDCNT,CRHDMULT) ;,WRT("STMP")
27 ..;I '$$OI^ORQOR2(CRHDEXN)&('CRHDFLG) D
28 ..I 'CRHDFLG D
29 ...D DETAIL("CRHDRTN",CRHDEXN,.CRHDFLG,.CRHDCNT,CRHDMULT) ;,WRT("TMP")
30 I '$D(CRHDRTN) S CRHDRTN(1)=""
31 E S CRHDRTN(1)=$G(CRHDCNT)
32 Q
33DETAIL(CRHDY,CRHDIFN,CRHDFND,CRHDCNT,CRHDMDNR) ; -- Returns details of order CRHDIFN in CRHDY(#)
34 N CRHDMCNT,X,X2,I,CRHDILOG,CRHD0,CRHD3,CRHD6,CRHDSEQ,CRHDITEM,CRHDPRMT,CRHDMULT,CRHDFIRT,CRHDTITL,CRHDINST
35 N DIWL,DIWR,DIWF,CRHDACTI,CRHDII,VAIN,ORIGVIEW,CRHDNMSP,CRHDYT,CRHDDNR,CRHDXX,CRHDNX,CRHDGOTI,ORFLG
36 S CRHDIFN=+CRHDIFN,CRHD0=$G(^OR(100,CRHDIFN,0)),CRHD3=$G(^(3)),CRHD6=$G(^(6))
37 K CRHDYT S ORIGVIEW=1 D TEXT^CRHD8(.CRHDYT,+CRHDIFN_";"_+$P(CRHD3,U,7),254) ;CurrTx
38 I $D(CRHDYT) D
39 .Q:$D(CRHDZZOR(CRHDIFN))
40 .S CRHDDNR=0,CRHDDNR=$O(CRHDYT(CRHDDNR))
41 .S CRHDGOTI=0
42 .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
43 ..I ($G(CRHDYT(CRHDDNR))'[$P(CRHDNRTT(CRHDXX),"^",2))&($P(CRHDNRTT(CRHDXX),"^",2)'[CRHDYT(CRHDDNR)) Q
44 ..S CRHDZCT=$G(CRHDZCT)+1,CRHDGOTI=1
45 ..I 'CRHDMDNR S CRHDFND=1
46 ..I CRHDCNT>1 S CRHDCNT=CRHDCNT+1,@CRHDY@(CRHDCNT)=""
47 ..S CRHDMCNT=0 F CRHDII=1:1 S CRHDMCNT=$O(CRHDYT(CRHDMCNT)) Q:'CRHDMCNT S CRHDCNT=CRHDCNT+1 D
48 ...I CRHDII=1 S @CRHDY@(CRHDCNT)=CRHDEXDT_"~"_CRHDIFN_"~"_CRHDYT(CRHDMCNT)
49 ...E S @CRHDY@(CRHDCNT)=CRHDYT(CRHDMCNT)
50 ..S CRHDCNT=$G(CRHDCNT)+1
51 ..S @CRHDY@(CRHDCNT)="Start Date/Time: "_$S($P(CRHD0,U,8):$$DATE^ORQ20($P(CRHD0,U,8)),1:"")
52 ..I $P(CRHD3,U,5),$P(CRHD3,U,11)=2 S X=$$ORIG(CRHDIFN),@CRHDY@(CRHDCNT)=@CRHDY@(CRHDCNT)_" (originally "_$$DATE^ORQ20(X)_")"
53 ..S CRHDCNT=CRHDCNT+1
54 ..S:+$P(CRHD0,U,9) @CRHDY@(CRHDCNT)="Stop Date/Time: "_$S($P(CRHD0,U,9):$$DATE^ORQ20($P(CRHD0,U,9)),1:"")
55 ..S CRHDZZOR(CRHDIFN)=""
56 Q
57WRT(CRHDC,CRHDARRY,CRHDTRG) ;
58 Q:'$D(CRHDARRY)
59 N CRHDN
60 S CRHDN=0 F S CRHDN=$O(CRHDARRY(CRHDN)) Q:'CRHDN S CRHDC=$G(CRHDC)+1,@CRHDTRG@(CRHDC,0)=CRHDARRY(CRHDN)
61 Q
62ORIG(CRHDIFN) ; -- Return original start date of [renewal] order
63 N CRHDI,CRHDY,CRHDX3,CRHDDONE
64 S CRHDI=CRHDIFN,CRHDY=$P($G(^OR(100,CRHDIFN,0)),U,8),CRHDDONE=0
65 F S CRHDX3=$G(^OR(100,CRHDI,3)) D Q:CRHDDONE
66 . I $P(CRHDX3,U,11)=2,$P(CRHDX3,U,5) S CRHDI=$P(CRHDX3,U,5) Q ;loop
67 . S CRHDY=$P($G(^OR(100,CRHDI,0)),U,8),CRHDDONE=1
68 Q CRHDY
69DNRPARM(CRHDNRTT,DUZ,CRHDDIV) ;GET DNR TITLES
70 N CRHDPAR,CRHDDIVI
71 S CRHDNRTT=0
72 I '+$G(CRHDDIV) S CRHDDIV=+$$SITE^VASITE
73 I 'CRHDNRTT S CRHDPAR="DIV.`"_+CRHDDIV D GETLST^XPAR(.CRHDNRTT,CRHDPAR,"CRHD DNR ORDER TITLE")
74 I 'CRHDNRTT D
75 .S CRHDDIVI=$O(^DIC(4,"D",CRHDDIV,0))
76 .I CRHDDIVI S CRHDPAR="DIV.`"_CRHDDIVI D GETLST^XPAR(.CRHDNRTT,CRHDPAR,"CRHD DNR ORDER TITLE")
77 Q
Note: See TracBrowser for help on using the repository browser.