ORWORR ; SLC/KCM/JLI - Retrieve Orders for Broker ;7/24/05 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**10,92,116,110,132,141,163,189,195,215**;Dec 17, 1997 ; GET(LST,DFN,FILTER,GROUPS) ; procedure Q ; don't call until using same treating specialty logic as AGET ; & until MULT, ORWARD, & ORIGVIEW implemented ; & until the date ranges implemented ; Get orders for patient ; 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ; .LST=~IFN^Grp^ActTm^StrtTm^StopTm^Sts^Sig^Nrs^Clk^PrvID^PrvNam^ActDA^Flag^DCType^ChrtRev^DEA#^^Schedule ; .LST=tOrder Text (repeating as necessary) ; DFN=Patient ID ; FILTER=# indicates which orders to return, default=2 (current) ; GROUPS=display grp of orders to show (default=ALL) ; -- this section uses ORQ1 to get orders list rather than XGET -- N ORLIST,ORIFN,X0,X3,X8,IDX,IFN,ACT,PRV,LN,TXT,STRT,STOP,CSTS,EYE,DEA ;PKI K ^TMP("ORR",$J) S (IDX,LST)=0 S:'$D(GROUPS) GROUPS=1 S:'$D(FILTER) FILTER=2 D EN^ORQ1(DFN_";DPT(",GROUPS,FILTER,"","","",0,1) S EYE=0 F S EYE=$O(^TMP("ORR",$J,ORLIST,EYE)) Q:'EYE S IFN=^(EYE) D . S ACT=$P(IFN,";",2),IFN=+IFN,X0=^OR(100,IFN,0),X3=^(3),X8=^(8,ACT,0) . D GETFLDS K ^TMP("ORR",$J) G EXIT AGET(REF,DFN,FILTER,GROUPS,DTFROM,DTTHRU,EVENT) ;Get an abbrev. event delayed order list for patient ; returns ^TMP("ORR",$J,ORLIST,n)=IFN^DGrp^ActTm ; see input parameters above ; -- from ORWORR ; -- section uses ORQ1 to get the orders list rather than XGET -- N ORLIST,ORIFN,IFN,I,ORWTS,TOT,MULT,ORWARD,TXTVW,ORYD,PTEVTID,EVTNAME S (PTEVTID,EVTNAME)="" K ^TMP("ORR",$J),^TMP("ORRJD",$J) S:'$D(GROUPS) GROUPS=1 S:'$D(FILTER) FILTER=2 S ORWTS=+$P(FILTER,U,2),FILTER=+FILTER S MULT=$S("^1^6^8^9^10^11^13^14^20^22^"[(U_FILTER_U):1,1:0) I $L($G(^DPT(DFN,.1))) S ORWARD=1 ; normally ptr to 42 S:'$L($G(DTFROM)) DTFROM=0 S:'$L($G(DTTHRU)) DTTHRU=0 S:'$L($G(EVENT)) EVENT=0 I $G(EVTDCREL)="TRUE" D . D EN^ORQ1(DFN_";DPT(",GROUPS,FILTER,"",DTFROM,DTTHRU,2,MULT,"",1,EVENT) . D GET2^ORWORR1 E D . D EN^ORQ1(DFN_";DPT(",GROUPS,FILTER,"",DTFROM,DTTHRU,0,MULT,"",1,EVENT) . D GET1^ORWORR1 Q RGET(REF,DFN,FILTER,GROUPS,DTFROM,DTTHRU,EVENT) ;Orders of AutoDC/Release Event N EVTDCREL S EVTDCREL="TRUE" D AGET(.REF,DFN,FILTER,GROUPS,DTFROM,DTTHRU,EVENT) Q XGET ; -- the retrieval algorithm before all the AC xref changes N X,X0,X3,IDX,IFN,LN,TIME,DGRP,MASK,TXT,ACT,PRV,ID,DEA,PASS ;PKI S DFN=DFN_";DPT(",IDX=0,LST=0 I '$G(FILTER) S FILTER=2 ; Default: Current/Active I $D(GROUPS)=1 D . S:'GROUPS GROUPS=$O(^ORD(100.98,"B",GROUPS,0)) . D XPND(GROUPS) I FILTER=1 D DOALL G EXIT ; All I FILTER=2 D DOCUR G EXIT ; Current I FILTER=3 S PASS=";1;" ; Discontinued I FILTER=4 S PASS=";2;7;" ; Comp/Expired I FILTER=5 S PASS=";3;4;5;6;8;9;" ; Expiring I FILTER=6 S PASS=";1;2;3;4;5;6;7;8;9;11;" ; New Activity I FILTER=7 S PASS=";5;" ; Pending I FILTER=8 Q ; Expanded I FILTER=9 S PASS=";3;4;5;6;8;9;11;" ; Unverified by Nurse I FILTER=10 S PASS=";3;4;5;6;8;9;11;" ; Unverified by Clerk I FILTER=11 S PASS=";3;4;5;6;7;8;11;" ; Unsigned I FILTER=12 S PASS=";4;" ; Flagged I FILTER=13 S PASS="" ; Verbal/Phone I FILTER=14 S PASS="" ; Verbal/Phone Unsigned D DOGET EXIT I LST=0 D . N %,X,%I D NOW^%DTC . S LST(1)="~0^0^"_%_"^^^97",LST(2)="tNo Orders Found." Q DOGET ; Come here to filter orders S TIME=0 F S TIME=$O(^OR(100,"AO",DFN,TIME)) Q:'TIME D . S DGRP=0 F S DGRP=$O(^OR(100,"AO",DFN,TIME,DGRP)) Q:'DGRP D . . I $D(GROUPS)>1 Q:'$D(GROUPS(DGRP)) ;filter by display grp . . S IFN=0 F S IFN=$O(^OR(100,"AO",DFN,TIME,DGRP,IFN)) Q:'IFN D . . . S X0=^OR(100,IFN,0),X3=^(3) ;get main nodes . . . I $P(X3,U,8)!$P(X3,U,9)!($P(X3,U,3)=99) Q ;skip veil,chld,sts=99 . . . I $L(PASS),(PASS'[(";"_$P(X3,U,3)_";")) Q ;filter by status . . . ; do any other filtering . . . D GETFLDS Q DOALL ; Come here to get all orders (no filter by status) S TIME=0 F S TIME=$O(^OR(100,"AO",DFN,TIME)) Q:'TIME D . S DGRP=0 F S DGRP=$O(^OR(100,"AO",DFN,TIME,DGRP)) Q:'DGRP D . . I $D(GROUPS)>1 Q:'$D(GROUPS(DGRP)) ;filter by display grp . . S IFN=0 F S IFN=$O(^OR(100,"AO",DFN,TIME,DGRP,IFN)) Q:'IFN D . . . S X0=^OR(100,IFN,0),X3=^(3) ;get main nodes . . . I $P(X3,U,8)!$P(X3,U,9)!($P(X3,U,3)=99) Q ;skip veil,chld,sts=99 . . . D GETFLDS Q DOCUR ; Come here to get all current orders N AOCTXT,STS,STOP,% S X=-$$GET^XPAR("ALL","ORPF ACTIVE ORDERS CONTEXT HRS") S %H=$H,X=(%H*86400+$P(%H,",",2))+(X*3600),%H=(X\86400)_","_(X#86400) D YMD^%DTC S AOCTXT=X_% S MASK="110000100101110" ; mask out STS=1,2,7,10,12,13,14 S TIME=0 F S TIME=$O(^OR(100,"AC",DFN,TIME)) Q:'TIME D . S IFN=0 F S IFN=$O(^OR(100,"AC",DFN,TIME,IFN)) Q:'IFN D . . ; filter out display groups here . . S ACT=0 F S ACT=$O(^OR(100,"AC",DFN,TIME,IFN,ACT)) Q:'ACT D . . . S X0=^OR(100,IFN,0),X3=^(3),X8=^(8,ACT,0) . . . S STS=$P(X3,U,3),STOP=$P(X0,U,9) . . . I $P(X3,U,8)!$P(X3,U,9)!(STS=99) Q . . . I $P(X8,U,15)=13,($P(X8,U)0 Y=$P(^DIC(9.4,PKGID,0),U,2) Q