source: WorldVistAEHR/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORCHART.m@ 841

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

initial load of WorldVistAEHR

File size: 8.7 KB
Line 
1ORCHART ;SLC/MKB/REV-OE/RR ; 11 March 2003 14:02
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**7,27,48,70,72,92,141,181**;Dec 17, 1997
3EN ; -- main entry point
4 K ^TMP("OR",$J) ;ensure fresh start
5 D EN^ORQPT Q:+$G(ORVP)'>0
6 D EN^VALM("OR CHART") G:'$G(OREXIT) EN
7 K OREXIT
8 Q
9 ;
10INIT ; -- init variables and list array
11 S:'$D(ORTAB) ORTAB=$$UP^XLFSTR($$GET^XPAR("ALL","ORCH INITIAL TAB",1,"E"))
12 S:ORTAB="DCSUMM" ORTAB="SUMMRIES" S:'$L(ORTAB) ORTAB="COVER"
13 S ORACTION=0 D TAB(ORTAB)
14 Q
15 ;
16PHDR ; -- protocol header code
17 N ORM,ORI,ORS,ORSYN K ORNMBR,OREBUILD
18 S:$G(ORTAB)'="LABS" VALMSG=$$MSG D SHOW^VALM
19 S:XQORM("B")="Quit" XQORM("B")=$S('$G(DGPMT):"Chart Contents",1:"Close Patient Chart")
20 S:$G(^TMP("OR",$J,"CURRENT","#")) XQORM("#")=^("#")
21 S ORM=$S(ORTAB="CONSULTS":+$O(^ORD(101,"B","ORC CONSULT SERVICE MENU",0)),1:+$G(XQORM("#"))),ORI=0 ;set XQORM("KEY",<synonym>)
22 F S ORI=$O(^ORD(101,ORM,10,"B",ORI)) Q:ORI'>0 I $D(^ORD(101,+ORI,2)) D
23 . S ORS=0 F S ORS=$O(^ORD(101,+ORI,2,ORS)) Q:ORS'>0 S ORSYN=$G(^(ORS,0)) S:$L(ORSYN) XQORM("KEY",ORSYN)=+ORI_"^1"
24 S XQORM("KEY","EX")=$O(^ORD(101,"B","ORC EXIT",0))_"^1"
25 S XQORM("KEY","NEXT")=$O(^ORD(101,"B","ORC NEXT SCREEN",0))_"^1"
26 S XQORM("KEY","PL")=$O(^ORD(101,"B","ORC PRINT LIST",0))_"^1"
27 Q
28 ;
29HDR ; -- header code
30 ; Expects ORPNM, ORSSN, ORL, ORDOB, ORAGE [, ORPD]
31 ; N DFN S DFN=+ORVP D SLCT1^ORQPT if any are missing ??
32 N ORX,ORX1,ORX2,ORX3,ORCWAD,L,SP K VALMHDR
33 S ORX1=$P($G(^DPT(+ORVP,0)),U,3),ORX3=$$FMTE^XLFDT(ORX1,2)_"("_ORAGE_")"
34 S ORX2="" I +$G(ORL) D S:$L($G(ORL(1))) ORX2=ORX2_"/"_ORL(1)
35 . S L=$G(^SC(+ORL,0)),ORX2=$P(L,U,2)
36 . S:'$L(ORX2) ORX2=$E($P(L,U),1,4)
37 S L=80-$L(ORPNM)-$L(ORSSN)-$L(ORX2)-$L(ORX3),SP=$$REPEAT^XLFSTR(" ",L\3)
38 S ORX1=ORPNM_SP_ORSSN_SP_ORX2,VALMHDR(1)=ORX1_$J(ORX3,80-$L(ORX1))
39 S ORX1=$S(ORATTEND:"Attend: "_$$LNAMEF^ORCHTAB(ORATTEND),1:"")
40 S ORX2="PrimCare: "_$$LNAMEF^ORCHTAB(+$$OUTPTPR^SDUTL3(+ORVP))
41 S ORX3="PCTeam: "_$P($$OUTPTTM^SDUTL3(+ORVP),U,2)
42 S ORX=$S($L(ORX1):$$LJ^XLFSTR(ORX1,20),1:"")_ORX2,VALMHDR(2)=$$LJ^XLFSTR(ORX,42)_ORX3
43 S ORCWAD=$$CWAD^ORQPT2(+ORVP) S:ORCWAD]"" ORCWAD="<"_ORCWAD_">"
44 S ORX=$S($G(ORTAB)="COVER":"",$G(ORTAB)="REPORTS":"",1:$$VIEW),VALMHDR(3)=ORX_$J(ORCWAD,80-$L(ORX))
45 Q
46 ;
47MSG() ; -- LMgr message bar
48 Q "Enter the numbers of the items you wish to act on."
49 ;
50HELP ; -- help code
51 N X,DX,DY D FULL^VALM1
52 W !!,"Enter the display numbers of the items you wish to change or act on; a menu of",!,"available actions will then be presented for selection."
53 W !!,"To see a different 'page' of the chart, enter CC; if you'd like another view of",!,"the current page, by date range for example, enter CV. You may add new orders"
54 W !,"for this patient from any page in the chart by entering AD and review them",!,"using RV. Enter ?? to see a list of actions available for navigating the list."
55 W:ORTAB="PROBLEMS" !!,"* = Acute problem",!,"$ = Unverified problem",!,"# = Problem references inactive code"
56 W:(ORTAB="SUMMRIES")!(ORTAB="NOTES") !!,"+ = Addenda attached"
57 W:(ORTAB="ORDERS")!(ORTAB="MEDS") !!,"* = Order has been updated by service"
58 W:ORTAB="ORDERS" !,"+ = Sub-orders exist"
59 W !!,"Press <return> to continue ..." R X:DTIME
60 S VALMBCK="R" S:$G(ORTAB)'="LABS" VALMSG=$$MSG
61 S (DX,DY)=0 X ^%ZOSF("XY")
62 Q
63 ;
64ITEMHELP ; -- help code for action menus
65 N X
66 W !!,"Enter the action you wish to take on the items selected and highlighted",!,"above; each item will be processed in order, one at a time."
67 W !!,"Press <return> to continue ..." R X:DTIME
68 S X="?" D DISP^XQORM1 W !
69 Q
70 ;
71EXIT ; -- exit code
72 I $G(ORVP),$$MORE^ORCMENU2 D ;unsig orders
73 . ;I '$D(^TMP("ORNEW",$J)),'$D(^XUSEC("ORES",DUZ)) Q ;msg like 2.5??
74 . W !!,"You have new or unsigned orders for this patient!" H 1
75 . S ORRV=1 D EN1^ORCMENU2,NOTIF^ORCMENU2 ;sign, notif if not all signed
76 D UNLOCK^ORX2(+ORVP) K ^TMP("OR",$J),^TMP("ORNEW",$J),^TMP("LRRR",$J)
77 K VALMCNT,VALMHDR,VALMBG,ORQUIT,ORVP,ORSEX,ORTAB,ORPNM,ORSSN,ORL,ORDOB,ORAGE,ORPD,ORNP,ORSC,ORTS,ORWARD,ORATTEND,ORNMBR,ORACTION,OREBUILD,OREBLD,ORRV,OREVENT
78 Q
79 ;
80TAB(NEWTAB,REBUILD) ; -- switch focus to new chart tab from ORTAB
81 S VALMBCK="",VALMBG=$S($G(ORTAB)'=NEWTAB:1,'$G(VALMBG):1,1:VALMBG)
82 S ORTAB=NEWTAB I '$G(^TMP("OR",$J,ORTAB,0))!($G(REBUILD)) D
83 . W !,"Searching the patient's chart ..."
84 . D FULL^VALM1,EN^ORCHTAB ; [re]build list
85 D CLEAN^VALM10 M ^TMP("OR",$J,"CURRENT")=^TMP("OR",$J,ORTAB)
86 M ^TMP("VALM VIDEO",$J,VALMEVL)=^TMP("OR",$J,"CURRENT","VIDEO")
87 I $D(^TMP("OR",$J,"CURRENT","CAPTION")) D
88 . N FLD,LBL S FLD=""
89 . F S FLD=$O(^TMP("OR",$J,"CURRENT","CAPTION",FLD)) Q:FLD="" S LBL=$G(^(FLD)) D CHGCAP^VALM(FLD,LBL)
90 S VALM("TITLE")=$G(^TMP("OR",$J,"CURRENT","TITLE")),VALM("RM")=^("RM")
91 S:$D(^TMP("OR",$J,"CURRENT","MENU")) XQORM("HIJACK")=^("MENU")
92 S VALMCNT=+$G(^TMP("OR",$J,"CURRENT",0)),VALMLFT=$P(VALMDDF("DATA"),U,2)
93 D HDR S VALMBCK="R" ; reset VALMHDR nodes
94 Q
95 ;
96NEWPAT ; -- Select new patient
97 I $$MORE^ORCMENU2 D ;unsigned orders
98 . ;I '$D(^TMP("ORNEW",$J)),'$D(^XUSEC("ORES",DUZ)) Q
99 . W !!,"You have new or unsigned orders for this patient!" H 1
100 . S ORRV=1 D EN1^ORCMENU2,NOTIF^ORCMENU2 ;sign, notif if not all signed
101 N TAB,OLD,T,ORT,CTXT K ORRV S OLD=+ORVP,TAB=ORTAB
102 D EN^ORQPT I OLD=+ORVP S VALMBCK="R" D:$G(OREBUILD) REBLD^ORCMENU K OREBUILD Q ; no change
103 S T="" F S T=$O(^TMP("OR",$J,T)) Q:T="" D
104 . I T="MEDS" K ^TMP("OR",$J,T) Q
105 . S CTXT=$P($G(^TMP("OR",$J,T,0)),U,3) S:$L(CTXT) ORT(T,0)="^^"_$S(T="NOTES"&($P(CTXT,";",3)=1):"",1:CTXT)_U_$P(^(0),U,4) ; save tab contexts
106 D UNLOCK^ORX2(+ORVP) K ^TMP("OR",$J),^TMP("ORNEW",$J),^TMP("LRRR",$J)
107 K VALMHDR,ORTAB,ORNEW,OREBUILD,OREBLD
108 M ^TMP("OR",$J)=ORT D TAB(TAB) S VALMBCK="R"
109 Q
110 ;
111ORDERS(ACTION) ; -- Return order numbers to act on, if action chosen first
112 N X,Y,DIR,MAX S:'$L($G(ACTION)) ACTION="act on"
113 S MAX=+$P($G(^TMP("OR",$J,ORTAB,0)),U,2) Q:MAX'>0 "^"
114 S DIR(0)="LAO^1:"_MAX,DIR("A")="Select item(s): " S:MAX=1 DIR("B")=1
115 S DIR("?")="Enter the items you wish to "_ACTION_", as a range or list of numbers"
116 D ^DIR S:$D(DTOUT)!(Y="") Y="^"
117 Q Y
118 ;
119ALL ; -- Return all items on ORTAB
120 N X,Y,DIR,MAX
121 S MAX=+$P($G(^TMP("OR",$J,ORTAB,0)),U,2) Q:MAX'>0 ""
122 S DIR(0)="L^1:"_MAX,DIR("V")="",X="1-"_MAX D ^DIR
123 Q Y
124 ;
125SELECT(NMBR) ; -- rev video on selected items
126 N ORI,ORJ,NUM,ROW,ROWS,VALID S VALID=0
127 F ORI=1:1:$L(NMBR,",") S NUM=$P(NMBR,",",ORI) I NUM D
128 . I '$L($P($G(@VALMAR@("IDX",NUM)),U)) W !,NUM_" is not a valid selection." H 2 Q
129 . S VALID=1
130 . S ROW=$P(@VALMAR@("IDX",NUM),U,2),ROWS=$P(^(NUM),U,3)
131 . F ORJ=ROW:1:(ROW+ROWS-1) I ORJ'<VALMBG,ORJ'>(VALMBG+VALM("LINES")-1) D
132 . . K ^TMP("VALM VIDEO",$J,VALMEVL,ORJ)
133 . . D CNTRL^VALM10(ORJ,1,80,IORVON,IORVOFF)
134 . . D WRITE^VALM10(ORJ)
135 I 'VALID S XQORQUIT=1
136 Q
137 ;
138DESELECT(NMBR) ; -- norm video on selected items
139 N ORI,ORJ,NUM,IFN,ROW,ROWS,ON,OFF,I,IDX
140 F ORI=1:1:$L(NMBR,",") S NUM=$P(NMBR,",",ORI) I NUM D
141 . S IDX=$G(@VALMAR@("IDX",NUM)) Q:'$L(IDX) ;invalid NUM
142 . S IFN=$P(IDX,U),ROW=$P(IDX,U,2),ROWS=$P(IDX,U,3)
143 . F ORJ=ROW:1:(ROW+ROWS-1) I ORJ'<VALMBG,ORJ'>(VALMBG+VALM("LINES")-1) D
144 . . K ^TMP("VALM VIDEO",$J,VALMEVL,ORJ) Q:'$L(IFN) ;deleted
145 . . S ON=IOINHI,OFF=IOINORM
146 . . I ORTAB="ORDERS",$G(^OR(100,+IFN,8,+$P(IFN,";",2),3)) S ON=IORVON,OFF=IORVOFF ; flagged
147 . . D CNTRL^VALM10(ORJ,1,5,ON,OFF)
148 . . I ORTAB="ORDERS" S I=$F(^TMP("OR",$J,ORTAB,ORJ,0),"*UNSIGNED*") I I D CNTRL^VALM10(ORJ,I-10,10,IOINHI,IOINORM)
149 . . I ORTAB="XRAYS" S I=$F(^TMP("OR",$J,ORTAB,ORJ,0),"*ABNORMAL*") I I D CNTRL^VALM10(ORJ,I-10,10,IOINHI,IOINORM)
150 . . I ORTAB="LABS" D CNTRL^VALM10(ORJ,24,2,IOINHI,IOINORM)
151 . . D:VALMBCK="" WRITE^VALM10(ORJ)
152 Q
153 ;
154CHANGE ; -- Change view of current list
155 G EN^ORCHANGE
156 Q
157 ;
158REV(ORVP) ; -- Review orders for patient
159 Q:'$G(ORVP) Q:$D(ZTQUEUED) Q:$G(DGQUIET) ;silent
160 I $D(SDAMEVT) Q:$S(SDAMEVT=1:0,1:1) ;continue if new appt
161 Q:'$$GET^XPAR("ALL","ORPF REVIEW ON PATIENT MVMT")
162 Q:'$$ACCESS^ORCHTAB ;CPRS not in user's option menu tree
163 N X,Y,DIR,DTOUT,DUOUT,DIRUT,DIROUT,DFN ;protect DFN
164 S DFN=+ORVP,ORVP=DFN_";DPT(" Q:'$D(^OR(100,"AC",ORVP)) ; no orders
165 S DIR(0)="YA",DIR("A")="Review active orders? ",DIR("B")="YES"
166 S DIR("?")="Answer YES to review this patient's active orders"
167 D ^DIR Q:Y'>0 K DIR
168 D SLCT1^ORQPT Q:'$G(ORVP)
169 S ORTAB="ORDERS" D EN^VALM("OR CHART")
170 Q
171 ;
172VIEW() ; -- return line 3 of header w/current view of tab
173 N BEGIN,END,ITEMS,STS,TEXT,X
174 I $G(ORTAB)']"" Q ""
175 S X=$P($G(^TMP("OR",$J,ORTAB,0)),U,3),TEXT=""
176 S BEGIN=$P(X,";"),END=$P(X,";",2),STS=$P(X,";",3),ITEMS=$P(X,";",5)
177 I ORTAB="NOTES",(STS'=5) S TEXT=$S(ITEMS:"up to "_ITEMS,1:"all")_$S(STS=1:" notes",STS=2:" unsigned notes",STS=3:" uncosigned notes",STS=4:" signed notes by author",1:"")
178 E D
179 . S:$L(BEGIN)!$L(END) TEXT=$$FDATE^VALM1($$DT^ORCHTAB1(BEGIN))_" thru "_$$FDATE^VALM1($$DT^ORCHTAB1(END))
180 . I ORTAB="XRAYS",ITEMS>0 S TEXT=$S($L(TEXT):TEXT_", ",1:"")_"limit "_ITEMS
181 S:$L(TEXT) TEXT="Current View: "_TEXT,TEXT=$J(TEXT,40+($L(TEXT)\2))
182 Q TEXT
Note: See TracBrowser for help on using the repository browser.