1 | ORQ1 ;slc/dcm-Get orders for a patient. ; 08 May 2002 2:12 PM
|
---|
2 | ;;3.0;ORDER ENTRY/RESULTS REPORTING;**27,72,78,141,190,215**;Dec 17, 1997
|
---|
3 | EN(PAT,GROUP,FLG,EXPAND,SDATE,EDATE,DETAIL,MULT,XREF,GETKID,EVENT) ;Get orders
|
---|
4 | ; Returns orders in ^TMP("ORR",$J,ORLIST,i) for defined context:
|
---|
5 | ;
|
---|
6 | ; PAT =patient variable ptr in format "DFN;DPT("
|
---|
7 | ; GROUP=Display group
|
---|
8 | ; FLG =#: Includes status:
|
---|
9 | ; 1. All => 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
|
---|
10 | ; 2. Active/Current => 3,4,5,6, 8,9, 11, 15
|
---|
11 | ; Includes CONTEXT HRS 1,2,7,13 & Action Status=13
|
---|
12 | ; Orders in ^OR(100,"AC",PAT,TM,IFN,ACTION)
|
---|
13 | ; 3. Discontinued => 1 12,13
|
---|
14 | ; 4. Completed/Expired => 2, 7
|
---|
15 | ; 5. Expiring => 3,4,5,6, 8,9
|
---|
16 | ; 6. Recent Activity => 1,2,3,4,5,6,7,8,9, 12, 15
|
---|
17 | ; Orders in ^OR(100,"AR",PAT,TM,IFN,ACTION)
|
---|
18 | ; 7. Pending => 5
|
---|
19 | ; 8. Unverified => 1, 3,4,5,6, 8,9, 15
|
---|
20 | ; 9. Unverified/Nurse => 1, 3,4,5,6, 8,9, 15
|
---|
21 | ;10. Unverified/Clerk => 1, 3,4,5,6, 8,9, 15
|
---|
22 | ;11. Unsigned => 1,2,3,4,5,6,7,8,9,10,11, 13,14,15
|
---|
23 | ; Orders in ^OR(100,"AS",PAT,TM,IFN)
|
---|
24 | ;12. Flagged => 1,2,3,4,5,6,7,8,9, 12,13,14,15
|
---|
25 | ;13. Verbal/Phoned => 1,2,3,4,5,6,7,8,9, 13,14,15
|
---|
26 | ; Nature of order of verbal or phoned
|
---|
27 | ;14. Verb/Phn unsigned => 1,2,3,4,5,6,7,8,9, 13,14,15
|
---|
28 | ; Nature of order V or P & unsigned
|
---|
29 | ;15. Admission => 6, 10
|
---|
30 | ;16. Discharge => 6, 10
|
---|
31 | ;17. Transfer => 6, 10
|
---|
32 | ; Orders in ^OR(100,"AEVNT",PAT,EVENT,IFN)
|
---|
33 | ;18. On Hold => 3
|
---|
34 | ;19. New Orders => 10,11
|
---|
35 | ; Orders in ^TMP("ORNEW",$J,ORIFN)
|
---|
36 | ;20. Chart Review => 1, 3,4,5,6, 8,9, 15
|
---|
37 | ;21. Chart Copy Summary=> same as All w/screen on Nature of order
|
---|
38 | ;22. Lapsed => 14
|
---|
39 | ;23. Active status => 5,6
|
---|
40 | ;24. All Delayed => 6, 10
|
---|
41 | ;25. Out of OR => 6, 10
|
---|
42 | ;26. Manual Release => 6, 10
|
---|
43 | ;27. Expired => 7
|
---|
44 | ;28. Discontinued Entered in Error => code handles this in ORQ12
|
---|
45 | ; Orders in ^OR(100,"AEVNT",PAT,EVENT,IFN)
|
---|
46 | EN0 ; where order status=#:
|
---|
47 | ; 1 => Discontinued (dc) 6 => Active (a) 11 => Unreleased (u)
|
---|
48 | ; 2 => Complete (c) 7 => Expired (e) 12 => DC/Edit (dce)
|
---|
49 | ; 3 => Hold (h) 8 => Scheduled (s) 13 => Cancelled (x)
|
---|
50 | ; 4 => Flagged (?) 9 => Partial Results (pr) 14 => Lapsed (l)
|
---|
51 | ; 5 => Pending (p) 10 => Delayed (d) 15 => Renewed (rn)
|
---|
52 | ; 99 => No Status (')
|
---|
53 | ; EXPAND=ifn of parent order, used to expand child orders
|
---|
54 | ; SDATE =Start date
|
---|
55 | ; EDATE =End date
|
---|
56 | ; DETAIL=Data to be returned (optional, default=0):
|
---|
57 | ; 0 => ^TMP("ORR",$J,ORLIST,i) = order #
|
---|
58 | ; 1 => ^TMP("ORR",$J,ORLIST,i) = order #^display group^when entered^
|
---|
59 | ; start d/t^stop d/t^status^sts abbrv
|
---|
60 | ; ^TMP("ORR",$J,ORLIST,i,"TX",j) = order text
|
---|
61 | ; MULT =0:Don't allow multiple occurrances of order
|
---|
62 | ; =1:Allow multiple occurances
|
---|
63 | ; XREF =cross reference to use instead of ACT (AW for completed orders)
|
---|
64 | ; GETKID=includes children of multiple orders
|
---|
65 | ; EVENT =ptr to Patient Event file #100.2, for orders tied to an event
|
---|
66 | ;
|
---|
67 | EN1 ; -- start here
|
---|
68 | Q:'$G(PAT) N X,ORLST,ORGRP,LAPSE
|
---|
69 | S:'$G(GROUP) GROUP=$O(^ORD(100.98,"B","ALL SERVICES",0))
|
---|
70 | S:'$G(FLG) FLG=2 S:'$G(DETAIL) DETAIL=0 S:'$G(MULT) MULT=0
|
---|
71 | I $G(EDATE)<$G(SDATE) S X=EDATE,EDATE=SDATE,SDATE=X
|
---|
72 | I $G(EDATE) S EDATE=$S($L(EDATE,".")=2:EDATE+.0001,1:EDATE+1)
|
---|
73 | I $G(SDATE) S SDATE=$S($L(SDATE,".")=2:SDATE-.0001,1:SDATE)
|
---|
74 | S SDATE=9999999-$S($G(SDATE):SDATE,FLG=6:DT-.7641,1:0),EDATE=9999999-$S($G(EDATE):EDATE,FLG=6:DT+.2359,1:9999998)
|
---|
75 | S ORLST=0,X=EDATE,EDATE=SDATE,SDATE=X D GRP(GROUP),LIST
|
---|
76 | S LAPSE=+$$GET^XPAR("ALL","OR DELAYED ORDERS LAPSE DAYS")
|
---|
77 | S:LAPSE LAPSE=$$FMADD^XLFDT(DT,(0-LAPSE)) ;=0 or cutoff date
|
---|
78 | I "^15^16^17^24^25^26^"[(U_FLG_U)!$G(EVENT) D EN^ORQ13 G ENQ
|
---|
79 | D @($S(FLG=2:"CUR",FLG=5:"EXG","^6^8^9^10^20^"[(U_FLG_U):"ACT",FLG=11:"SIG",FLG=19:"NEW","^1^3^4^7^12^13^14^18^21^22^23^27^28^"[(U_FLG_U):"LOOP",1:"QUIT")_"^ORQ11")
|
---|
80 | ENQ K ^TMP("ORGOTIT",$J)
|
---|
81 | Q
|
---|
82 | ;
|
---|
83 | LIST ;Get entry in ^TMP("ORR",$J,ORLIST)
|
---|
84 | S ORLIST=$H
|
---|
85 | L +^TMP("ORR",$J,ORLIST)
|
---|
86 | I $D(^TMP("ORR",$J,ORLIST)) L -^TMP("ORR",$J,ORLIST) H 1 G LIST
|
---|
87 | S ^TMP("ORR",$J,ORLIST)=""
|
---|
88 | L -^TMP("ORR",$J,ORLIST)
|
---|
89 | Q
|
---|
90 | ;
|
---|
91 | GRP(DG) ;Setup display groups
|
---|
92 | ;DG=Display group to expand
|
---|
93 | N STK,MEM
|
---|
94 | S ORGRP(DG)="",STK=1,STK(STK)=DG_"^0",STK(0)=0,MEM=0
|
---|
95 | F S MEM=$O(^ORD(100.98,+STK(STK),1,MEM)) D @$S(+MEM'>0:"POP",1:"PROC") Q:STK<1
|
---|
96 | Q
|
---|
97 | ;
|
---|
98 | POP S STK=STK-1,MEM=$P(STK(STK),"^",2)
|
---|
99 | Q
|
---|
100 | PROC S $P(STK(STK),"^",2)=MEM,DG=$P(^ORD(100.98,+STK(STK),1,MEM,0),"^",1)
|
---|
101 | S ORGRP(DG)="",STK=STK+1,STK(STK)=DG_"^0",MEM=0
|
---|
102 | Q
|
---|