source: WorldVistAEHR/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORQ20.m@ 1361

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

revised back to 6/30/08 version

File size: 7.6 KB
RevLine 
[623]1ORQ20 ; SLC/MKB - Detailed Order Report cont ;7/23/03 12:29
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**12,27,92,94,116,141,177,186,190,215**;Dec 17, 1997
3ACT ; -- add Activity [from ^ORQ2]
4 N ORACT S ORACT=$P(ACTION,U,2)
5 N NVA S:$P(^ORD(100.98,$P(^OR(100,+ORIFN,0),U,11),0),U)="NON-VA MEDICATIONS" NVA=1
6 S CNT=CNT+1,@ORY@(CNT)=$$DATE($P(ACTION,U))_" "_$$ACTION(ORACT)
7 I $P(ACTION,U,13) S @ORY@(CNT)=@ORY@(CNT)_" entered by "_$$USER(+$P(ACTION,U,13))
8 I ORACT="NW" D ;Show original order text
9 . N ORZ,I,ORIGVIEW S ORIGVIEW=2 D TEXT^ORQ12(.ORZ,ORIFN_";1",80)
10 . S CNT=CNT+1,@ORY@(CNT)=" Order Text: "_$G(ORZ(1))
11 . S I=1 F S I=$O(ORZ(I)) Q:I'>0 S CNT=CNT+1,@ORY@(CNT)=$$REPEAT^XLFSTR(" ",24)_$G(ORZ(I))
12 I ORACT="XX" D ;Changed - show new text
13 . N ORZ,I,ORIGVIEW S ORIGVIEW=2 D TEXT^ORQ12(.ORZ,ORIFN_";"_ORI,80)
14 . S CNT=CNT+1,@ORY@(CNT)=" Changed to: "_$G(ORZ(1))
15 . S I=1 F S I=$O(ORZ(I)) Q:I'>0 S CNT=CNT+1,@ORY@(CNT)=$$REPEAT^XLFSTR(" ",24)_$G(ORZ(I))
16A1 I $P(ACTION,U,12) D ;Nature of Order/Release
17 . N ORZ S ORZ=$G(^ORD(100.02,+$P(ACTION,U,12),0))
18 . S CNT=CNT+1,@ORY@(CNT)=" Nature of Order: "_$P(ORZ,U)
19 . I $P(OR0,U,17),(ORACT="NW") Q ;see event
20 . I "^V^P^"[(U_$P(ORZ,U,2)_U),$P(ACTION,U,16) S CNT=CNT+1,@ORY@(CNT)=" Released by: "_$$USER(+$P(ACTION,U,17))_" on "_$$DATE($P(ACTION,U,16))
21 I $P(OR0,U,17)&(ORACT="NW") D ;Delayed Release Event
22 . N EVT,X,ORV,I S EVT=+$P(OR0,U,17),X=$$NAME^OREVNTX(EVT)
23 . S:$E(X,1,8)="Delayed " X=$E(X,9,99)
24 . I $G(^ORE(100.2,EVT,1)),'$P(ACTION,U,16) S X=X_" on "_$$DATE(+^(1))
25 . S CNT=CNT+1,@ORY@(CNT)=" Delayed Until: "_X Q:'$P(ACTION,U,16)
26 . D EVENT(.ORV) S CNT=CNT+1,@ORY@(CNT)=" Released by: "_ORV(1)
27 . S I=1 F S I=$O(ORV(I)) Q:I'>0 S CNT=CNT+1,@ORY@(CNT)=$$REPEAT^XLFSTR(" ",24)_$G(ORV(I))
28A2 I $P(ACTION,U,5) S CNT=CNT+1,@ORY@(CNT)=$S($P(ACTION,U,4)=7:" Dig",1:" Elec")_" Signature: "_$$USER(+$P(ACTION,U,5))_" on "_$$DATE($P(ACTION,U,6))
29 I '$P(ACTION,U,5)!($P(ACTION,U,3)'=$P(ACTION,U,5)),'$$SERVCORR S CNT=CNT+1,@ORY@(CNT)=" "_$S($D(NVA):"Documented by:",1:"Ordered by: ")_" "_$$USER(+$P(ACTION,U,3))
30 I '$P(ACTION,U,5),$L($P(ACTION,U,4)) S:$P(ACTION,U,4)=0 CNT=CNT+1,@ORY@(CNT)=" Released by: "_$$USER(+$P(ACTION,U,7))_" on "_$$DATE($P(ACTION,U,16)) S CNT=CNT+1,@ORY@(CNT)=" Signature: "_$$SIG($P(ACTION,U,4)) ;186
31 I $P(ACTION,U,9) S CNT=CNT+1,@ORY@(CNT)=" Nurse Verified: "_$S($P(ACTION,U,8):$$USER(+$P(ACTION,U,8))_" on ",1:"")_$$DATE($P(ACTION,U,9))
32 I $P(ACTION,U,11) S CNT=CNT+1,@ORY@(CNT)=" Clerk Verified: "_$S($P(ACTION,U,10):$$USER(+$P(ACTION,U,10))_" on ",1:"")_$$DATE($P(ACTION,U,11))
33 I $P(ACTION,U,19) S CNT=CNT+1,@ORY@(CNT)=" Chart Reviewed: "_$S($P(ACTION,U,18):$$USER(+$P(ACTION,U,18))_" on ",1:"")_$$DATE($P(ACTION,U,19))
34A3 I $P(ACTION,U,2)="DC",$L(OR6) S X=$S($L($P(OR6,U,5)):$P(OR6,U,5),$P(OR6,U,4):$P($G(^ORD(100.03,+$P(OR6,U,4),0)),U),$P(OR6,U):$P($G(^ORD(100.02,+$P(OR6,U),0)),U),1:"") S:$L(X) CNT=CNT+1,@ORY@(CNT)=" Reason for DC: "_X
35 I $L($G(^OR(100,ORIFN,8,ORI,1))) S X=^(1) D ;add backdoor comments
36 . N LBL,I S LBL=""
37 . I $P(ACTION,U,15)="",$P(ACTION,U,2)'="DC" S LBL=" Comments: " ;DC shown above
38 . I $P(ACTION,U,15)=13,$P(ACTION,U,2)'="NW" S LBL=" Cancelled: " ;NW shown in ORQ2
39 . Q:'$L(LBL) I $L(X)'>56 S CNT=CNT+1,@ORY@(CNT)=LBL_X Q
40 . S DIWL=1,DIWR=56,DIWF="C56" K ^UTILITY($J,"W") D ^DIWP
41 . S I=0 F S I=$O(^UTILITY($J,"W",DIWL,I)) Q:I'>0 S CNT=CNT+1,@ORY@(CNT)=LBL_^(I,0),LBL=" "
42 I $D(^OR(100,ORIFN,8,ORI,5)) D ;Ward comments
43 . N X,ORJ K ^UTILITY($J,"W")
44 . S ORJ=0 F S ORJ=$O(^OR(100,ORIFN,8,ORI,5,ORJ)) Q:ORJ'>0 S X=^(ORJ,0) D ^DIWP
45 . S ORJ=0 F S ORJ=$O(^UTILITY($J,"W",DIWL,ORJ)) Q:ORJ'>0 S CNT=CNT+1,@ORY@(CNT)=$S(ORJ=1:" Ward/Clinic Cmmts: ",1:" ")_^(ORJ,0)
46 . K ^UTILITY($J,"W")
47A4 I $P(ACTION,U,2)="HD",$G(^OR(100,ORIFN,8,ORI,2)) S X2=^(2),CNT=CNT+1,@ORY@(CNT)=" Hold Released: "_$$FMTE^XLFDT($P(X2,U),"2P")_" by "_$$USER($P(X2,U,2))
48 I $D(^OR(100,ORIFN,8,ORI,3)) D ;Un-/Flagged
49 . N X S X=$G(^OR(100,ORIFN,8,ORI,3))
50 . S CNT=CNT+1,@ORY@(CNT)=" Flagged by: "_$$USER(+$P(X,U,4))_" on "_$$DATE($P(X,U,3))
51 . S CNT=CNT+1,@ORY@(CNT)=" "_$P(X,U,5)
52 . Q:X S CNT=CNT+1,@ORY@(CNT)=" Unflagged by: "_$$USER(+$P(X,U,7))_" on "_$$DATE($P(X,U,6))
53 . S CNT=CNT+1,@ORY@(CNT)=" "_$P(X,U,8)
54 Q
55 ;
56DC ; -- Add Reason for DC
57 S CNT=CNT+1,@ORY@(CNT)=$$DATE($P(OR6,U,3))_$S($P(OR6,U,8):" Auto-",1:" ")_"Discontinued"
58 I $P(OR6,U,8) D Q
59 . N EVT,PKG,ORV,I
60 . S EVT=$P(OR6,U,8),PKG=$P($G(^ORE(100.2,+EVT,3,ORIFN,0)),U,2)
61 . S @ORY@(CNT)=@ORY@(CNT)_" by "_$S(PKG="FH":"DIETETICS",PKG="LR":"LABORATORY",PKG="PS":"PHARMACY",1:"CPRS")
62 . D EVENT(.ORV,1) S CNT=CNT+1,@ORY@(CNT)=" Patient Movement: "_ORV(1)
63 . S I=1 F S I=$O(ORV(I)) Q:I'>0 S CNT=CNT+1,@ORY@(CNT)=$$REPEAT^XLFSTR(" ",24)_$G(ORV(I))
64 I $P(OR6,U,2),$P($G(^ORD(100.02,+$P(OR6,U),0)),U,2)'="A" S @ORY@(CNT)=@ORY@(CNT)_" by "_$$USER($P(OR6,U,2)) ;don't show user name if auto-dc
65 N X S X=$S($L($P(OR6,U,5)):$P(OR6,U,5),$P(OR6,U,4):$P($G(^ORD(100.03,+$P(OR6,U,4),0)),U),$P(OR6,U):$P($G(^ORD(100.02,+$P(OR6,U),0)),U),1:"") S:$L(X) CNT=CNT+1,@ORY@(CNT)=" Reason for DC: "_X
66 Q
67 ;
68ACTION(CODE) ; -- Return name of action CODE
69 N NAME S NAME=$S(CODE="NW":"New Order",CODE="DC":"Discontinue",CODE="HD":"Hold",CODE="RL":"Release Hold",CODE="RN":"Renewal",CODE="XX":"Change",1:"")
70 I CODE="NW",$P(OR3,U,11) S NAME=NAME_$S($P(OR3,U,11)=1:" (Change)",$P(OR3,U,11)=2:" (Renewal)",1:"")
71 Q NAME
72 ;
73XACT(X) ; -- Return name of transaction code X
74 N Y S X=$G(X)
75 S Y=$S(X="XX":"Edited",X="DC":"Discontinued",X="HD":"Held",X="RL":"Hold Released",X="FW":"Forwarded",X="CA":"Cancelled",1:"")
76 Q Y
77 ;
78DATE(X) ; -- Return date formatted as 00/00/0000 00:00
79 N T,Y S T=$P(X,".",2)_"0000"
80 S Y=$E(X,4,5)_"/"_$E(X,6,7)_"/"_(1700+$E(X,1,3))
81 I T S Y=Y_" "_$E(T,1,2)_":"_$E(T,3,4)
82 Q Y
83 ;
84USER(X) ; -- Returns NAME (TITLE) of New Person X
85 N X0,Y S X0=$G(^VA(200,+X,0)),Y=$P(X0,U)
86 S:$P(X0,U,9) Y=Y_" ("_$E($P($G(^DIC(3.1,+$P(X0,U,9),0)),U),1,15)_")"
87 Q Y
88 ;
89SIG(X) ; -- Returns text of signature status X
90 N Y S Y=""
91 I X=0 S Y="ON CHART WITH WRITTEN ORDERS"
92 I X=1 S Y="ELECTRONICALLY SIGNED"
93 I X=2 S Y="NOT SIGNED"
94 I X=3 S Y="NOT REQUIRED"
95 I X=4 S Y="ON CHART WITH PRINTED ORDERS"
96 I X=5 S Y="NOT REQUIRED DUE TO SERVICE CANCEL"
97 I X=6 S Y="SERVICE CORRECTION TO SIGNED ORDER"
98 Q Y
99 ;
100SERVCORR() ; -- Returns 1 or 0, if current ACTION is a serv corr change
101 N Y,NATURE,I,X S Y=0
102 G:ORACT'="XX" SCQ
103 S NATURE=+$P(ACTION,U,12),NATURE=$P($G(^ORD(100.02,NATURE,0)),U,2)
104 I "^S^I^"'[(U_NATURE_U) G SCQ
105 S I=$O(^OR(100,ORIFN,8,ORI),-1),X=$G(^(I,0))
106 I $P(X,U,3)'=$P(ACTION,U,3),$P(X,U,5)'=$P(ACTION,U,3) G SCQ ;show prov
107 S Y=1
108SCQ Q Y
109 ;
110EVENT(ORTX,DC) ; -- Returns patient event info for EVT
111 N EVT1,REL,X,Y,I,ORMAX
112 S ORTX(1)="" ;177
113 S EVT1=$G(^ORE(100.2,EVT,1)),REL=$G(^ORE(100.2,EVT,2,ORIFN,0))
114 ; Return event data if AutoDC or auto-released by an event:
115 I $G(DC)!(REL&'$L($P(REL,U,2))&($P(EVT1,U,2)!$P(EVT1,U,4))) D Q
116 . S Y=$S($P(EVT1,U,5):$P(EVT1,U,5),1:EVT) ;parent owns Activity
117 . S Y=+$O(^ORE(100.2,+Y,10,0)),Y=$G(^(Y,0)),X=$P(Y,U,4) Q:'$L(X)
118 . S X=$S(X="A":"ADMISSION",X="T":"TRANSFER",X="D":"DISCHARGE",X="S":"SPECIALTY CHANGE",1:"OUT OF O.R.")_" on "_$$DATE($P(EVT1,U))
119 . S ORTX(1)=X,ORTX=1,ORMAX=56
120 . I $P(Y,U,6) S X=$S($P(Y,U,4)="D":"from ",1:"to ")_$$GET1^DIQ(45.7,+$P(Y,U,6)_",",.01) D TXT^ORCHTAB
121 . I $P(Y,U,7) S X="on "_$$GET1^DIQ(42,+$P(Y,U,7)_",",.01) D TXT^ORCHTAB
122 S X=$$USER(+$P(ACTION,U,17))_" on "_$$DATE($P(ACTION,U,16))
123 I ORIFN'=+$P($G(^ORE(100.2,EVT,0)),U,4),$P(REL,U,2)="MN" S X=X_" (manually released)"
124 S ORTX(1)=X
125 Q
Note: See TracBrowser for help on using the repository browser.