source: FOIAVistA/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORPR02.m@ 1582

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

initial load of FOIAVistA 6/30/08 version

File size: 7.3 KB
Line 
1ORPR02 ; slc/dcm/rv - Dances with Prints ;09/13/06 13:30
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**11,260**;Dec 17, 1997;Build 26
3PRINT(ORVP,ARAY,SARAY,LOC,SELECT,ALTPRAM,NOQUE,ORTIMES) ;Decisions
4 ;ORVP=DFN;DPT(
5 ;ARAY=Name of global storing list of orders or just the local aray
6 ;@ARAY@(#)=ORIFN;DA of action - Array of orders to print
7 ;SARAY(PKG,ORIFN)=Device ptr^# of copies (used by Consults service copies)
8 ;LOC=Location (ORL)
9 ;SELECT=Set for desired reports (chart^label^req^service^work)
10 ;ALTPRAM=Alternate for PARAM variable (overrides internal parameters):
11 ; PROMPT CC^CC DEVICE^L DEVICE^R DEVICE^PROMPT L^PROMPT R^PROMPT W^W DEVICE
12 ;NOQUE=1 to force interactive device selection; used for service copies
13 ;ORTIMES=# of copies
14 N PARAM,IFN,ORPARAY,VAR
15 S ORPARAY=$S($L($G(ARAY))&('$G(ARAY)):ARAY,1:"ARAY")
16 I '$G(ORVP) S ORVP=$$PAT(.ARAY) I '$G(ORVP) S VAR("ARAY")="" D EN^ORERR("PRINT~ORPR02 called with invalid ORVP",,.VAR) G END
17 I '$L($G(LOC)) S LOC=$$LOC(.ARAY) I 'LOC S VAR("ARAY")="" D EN^ORERR("PRINT~ORPR02 called with invalid LOC",,.VAR) G END
18 I $S('$O(@ORPARAY@(0)):1,+$G(LOC)'>0:1,1:0),'$D(SARAY) G END
19 N ORAL,ORIFN
20 K ^TMP("ORAL",$J)
21 S PARAM=$S($L($G(ALTPRAM)):ALTPRAM,1:""),ORAL="^TMP(""ORAL"",$J)"
22 D:'$L($G(ALTPRAM)) PARAM($G(LOC))
23 D ARAY(.ARAY)
24 I '$D(SELECT) D CHART(.ARAY,PARAM),LABEL(.ORAL,PARAM,$G(ORTIMES)),REQ(.ORAL,PARAM),SERV(.ORAL,PARAM,.SARAY,$G(NOQUE)),WORK(.ARAY,PARAM) G END
25 I $D(SELECT) D CHART(.ARAY,PARAM):$P(SELECT,"^"),LABEL(.ORAL,PARAM,$G(ORTIMES)):$P(SELECT,"^",2),REQ(.ORAL,PARAM):$P(SELECT,"^",3),SERV(.ORAL,PARAM,.SARAY,$G(NOQUE)):$P(SELECT,"^",4),WORK(.ARAY,PARAM):$P(SELECT,"^",5)
26 G END
27CHART(ARAY,PARAM) ;Chart copies
28 ;ARAY=Array of orders to print
29 ;PARAM=Print parameters based on location
30 S ARAY=$S($L($G(ARAY))&('$G(ARAY)):ARAY,1:"ARAY")
31 I $L($P(PARAM,"^"))!($L($P(PARAM,"^",2))) S X=$$DEVICE($P(PARAM,"^")_"^CHART COPY",$P(PARAM,"^",2),"C1^ORPR03")
32 Q
33WORK(ARAY,PARAM) ;Work Copy
34 S ARAY=$S($L($G(ARAY))&('$G(ARAY)):ARAY,1:"ARAY")
35 I $L($P(PARAM,"^",7))!($L($P(PARAM,"^",8))) S X=$$DEVICE($P(PARAM,"^",7)_"^WORK COPY",$P(PARAM,"^",8),"W1^ORPR03")
36 Q
37LABEL(ARAY,PARAM,ORTIMES) ;Labels
38 N ORPLF,ORTKG,ORPRMT
39 S ARAY=$S($L($G(ARAY))&('$G(ARAY)):ARAY,1:"ARAY")
40 I $L($P(PARAM,"^",3))!$L($P(PARAM,"^",5)) D
41 . S (ORPLF,ORTKG)=0
42 . I $O(@ARAY@(0)) F S ORTKG=$O(@ARAY@(ORTKG)) Q:ORTKG'>0!(ORPLF) D
43 .. S ORPLF=$S($$GET^XPAR("SYS","ORPF WARD LABEL FORMAT",ORTKG,"I"):1,1:0)
44 . S ORPRMT=$S(ORPLF:$P(PARAM,"^",5),1:"*")_"^LABELS"
45 . S X=$$DEVICE(ORPRMT,$P(PARAM,"^",3),"L1^ORPR03",$G(ORTIMES))
46 Q
47REQ(ARAY,PARAM) ;Requisitions
48 N ORPLF,ORTKG,ORPRMT,ORIFN,ORDLG
49 S ARAY=$S($L($G(ARAY))&('$G(ARAY)):ARAY,1:"ARAY")
50 I $L($P(PARAM,"^",4))!$L($P(PARAM,"^",6)) D
51 . S (ORPLF,ORTKG)=0
52 . I $O(@ARAY@(0)) F S ORTKG=$O(@ARAY@(ORTKG)) Q:ORTKG'>0!(ORPLF) D
53 .. S ORPLF=$S($$GET^XPAR("SYS","ORPF WARD REQUISITION FORMAT",ORTKG,"I"):1,1:0)
54 .. I ORTKG=$O(^DIC(9.4,"B","DIETETICS",0)) D
55 ... S ORIFN=0 F S ORIFN=$O(@ARAY@(ORTKG,ORIFN)) Q:'ORIFN D
56 .... S ORDLG=+$P(^OR(100,+ORIFN,0),U,5)
57 .... I ORDLG'=$O(^ORD(101.41,"B","FHW SPECIAL MEAL",0)) S ORPLF=0
58 . S ORPRMT=$S(ORPLF:$P(PARAM,"^",6),1:"*")_"^REQUISITIONS"
59 . S X=$$DEVICE(ORPRMT,$P(PARAM,"^",4),"R1^ORPR03")
60 Q
61SERV(ARAY,PARAM,SARAY,NOQUE) ;Service copies
62 N ZTRTN,ZTSAVE,ZTIO,ZTDTH,ZTSK,GLOB
63 S ARAY=$S($L($G(ARAY))&('$G(ARAY)):ARAY,1:"ARAY")
64 S GLOB=$S($E(ARAY)="^":$E(ARAY,1,$L(ARAY)-1)_",",1:ARAY_"(")
65 I $O(@ARAY@(0)) D
66 . I $G(NOQUE)'=1 D Q
67 .. S ZTRTN="SVCOPY^ORPR03()",(ZTSAVE("CHART"),ZTSAVE("ORVP"),ZTSAVE("ARAY"),ZTSAVE(GLOB),ZTSAVE("PARAM"),ZTSAVE("SARAY("),ZTSAVE("ORPRES"),ZTSAVE("LOC"),ZTSAVE("LOC("),ZTIO)="",ZTDTH=$H
68 .. S ZTDESC="Service copy root task" D ^%ZTLOAD
69 . D SVCOPY^ORPR03(1)
70 Q
71END ;Leave
72 D HOME^%ZIS
73 Q
74DEVICE(PRMT,DEF,ZTRTN,ORTIMES) ; Gets device for output
75 ;PRMT=Prompt?^Report name
76 ;DEF=Print device
77 ;ZTRTN=Routine
78 ;ORTIMES=# of copies
79 N %ZIS,DIC,DIR,IOP,FORCEQUE,X,Y,ZTIO,ZTDESC,ZTDTH,OREND,GLOB,ORIOPTR,ORION
80 I $P(PRMT,"^")="*" Q 1
81 I $P(PRMT,"^")=0,'$G(DEF) Q 1
82 I +PRMT S DIR("A")="Print "_$P(PRMT,"^",2)_" for the orders: ",DIR("B")="YES",DIR("?")="Answer YES to have "_$P(PRMT,"^",2)_" printed for the orders.",DIR(0)="YA" D ^DIR I 'Y Q 1
83 I +$G(DEF)>0 D
84 . N X,DIC
85 . S X="`"_+DEF,DIC(0)="NX",DIC=3.5
86 . D ^DIC
87 . I Y<1 S %ZIS("A")=$P(PRMT,"^",2)_"Print DEVICE: " Q
88 . S:+PRMT=1 %ZIS("B")=$P(Y,"^",2)
89 . S ORION=$P(Y,"^",2)
90 . S:+PRMT=0!(+PRMT=2) ORIOPTR="`"_+Y,%ZIS="QN"
91 I $L($G(ARAY)) S GLOB=$S($E(ARAY)="^":$E(ARAY,1,$L(ARAY)-1)_",",1:ARAY_"("),ZTSAVE(GLOB)="",ZTSAVE("ARAY")=""
92 S (ZTSAVE("ORTIMES"),ZTSAVE("ORTKG"),ZTSAVE("ORVP"),ZTSAVE("ORPRES"),ZTSAVE("ORSEQ"),ZTSAVE("ORCUM("),ZTSAVE("LOC"),ZTSAVE("LOC("),ZTSAVE("ORRACT"))="",ZTDESC=$P(PRMT,"^",2)
93 S:+PRMT'=1 FORCEQUE=1,ZTDTH=$H
94 D QUE^ORUTL1(ZTRTN,ZTDESC,.ZTSAVE,$G(ORIOPTR),$G(ZTDTH),.%ZIS,$G(FORCEQUE),1,$G(ORION))
95 Q ""
96PAT(ARAY) ;Get patient if not passed
97 S ARAY=$S($L($G(ARAY))&('$G(ARAY)):ARAY,1:"ARAY")
98 Q:'$O(@ARAY@(0)) ""
99 S X=$O(@ARAY@(0)),X=$P($G(^OR(100,+@ARAY@(X),0)),"^",2)
100 Q X
101LOC(ARAY) ;Get location if not passed
102 S ARAY=$S($L($G(ARAY))&('$G(ARAY)):ARAY,1:"ARAY")
103 Q:'$O(@ARAY@(0)) ""
104 S X=$O(@ARAY@(0)),X=$P($G(^OR(100,+@ARAY@(X),0)),"^",10)
105 Q X
106TEST ;Test call
107 N DALE,OREND S OREND=0
108 K ^TMP("ORPARAY",$J)
109 F ORI=6752:0 S ORI=$O(^OR(100,ORI)) Q:ORI<1!(ORI>8000) S ^TMP("ORPARAY",$J,ORI)=ORI_";1"
110 W @IOF
111 D PRINT("","^TMP(""ORPARAY"",$J)","","","1^1^1^1^1")
112 ;D GUI("^TMP(""ORPARAY"",$J)",63,"C",,1)
113 K ^TMP("ORPARAY",$J)
114 Q
115PARAM(LOC) ;Get Print parameters
116 ;LOC=Ptr to location SC(42,LOC,
117 ;Returns Parameters in PARAM
118 ;PARAM=Prompt for CC^CC device^L Device^R Device^Prompt for L^Prompt for R^Prompt for W^WC device
119 Q:'$G(LOC)
120 F I="ORPF PROMPT FOR CHART COPY","ORPF CHART COPY PRINT DEVICE","ORPF LABEL PRINT DEVICE","ORPF REQUISITION PRINT DEVICE","ORPF PROMPT FOR LABELS","ORPF PROMPT FOR REQUISITIONS","ORPF PROMPT FOR WORK COPY","ORPF WORK COPY PRINT DEVICE" D
121 . S PARAM=PARAM_$$GET^XPAR("ALL^"_+LOC_";SC(",I,1,"I")_"^"
122 Q
123ARAY(ARAY) ;Set aray up by package in ^TMP("ORAL",$J,package,orifn;action)
124 S ARAY=$S($L($G(ARAY))&('$G(ARAY)):ARAY,1:"ARAY")
125 N X,IFN S IFN=0
126 F S IFN=$O(@ARAY@(IFN)) Q:IFN<1 S X=$G(^OR(100,+@ARAY@(IFN),0)) K:$P(X,"^",2)'=ORVP @ARAY@(IFN) I +X,$P(X,"^",2)=ORVP,$P(X,"^",14) S ^TMP("ORAL",$J,$P(X,"^",14),@ARAY@(IFN))=""
127 Q
128GUI(ARAY,DEVICE,FMT,LOC,TASK,ORTIMES) ;Silence of the Prints
129 ;ARAY=Name of global storing list of orders or just the local aray
130 ;@ARAY@(#)=ORIFN;DA of action - Array of orders to print
131 ;DEVICE=printer (internal ptr value)
132 ;FMT=C:Chart copy, L:Labels, R:Requisitions, S:Service copies W:Work copies
133 ;LOC=Location (ORL)
134 ;TASK=1 to not task, 0 or undefined to task (default)
135 ; this affects the closing of devices in ^ORPR03
136 ;ORTIMES=# of copies
137 N ORPARAY,VAR
138 S ORPARAY=$S($L($G(ARAY))&('$G(ARAY)):ARAY,1:"ARAY"),ARAY=ORPARAY
139 Q:'$O(@ORPARAY@(0)) Q:'$D(IO) Q:'$D(FMT) Q:FMT="" Q:"CLRSW"'[FMT
140 N ORAL,ORVP,X,ZTRTN
141 K ^TMP("ORAL",$J)
142 S ORVP=$$PAT(.ARAY),ORAL="^TMP(""ORAL"",$J)"
143 I 'ORVP S VAR("ARAY")="" D EN^ORERR("GUI~ORPR02 called with invalid ORVP",,.VAR) Q
144 I '$G(LOC) S LOC=$$LOC(.ARAY)
145 D ARAY(.ARAY)
146 I "WC"'[FMT K ARAY S ARAY=ORAL
147 S X=0_"^"_$S(FMT="L":"Labels",FMT="R":"Requisitions",FMT="S":"Service Copies",FMT="C":"Chart Copies",FMT="W":"Work Copies",1:"")
148 S ZTRTN=$S(FMT="S":"SVCOPY^ORPR03()",1:FMT_"1^ORPR03")
149 S:FMT="S" TASK=1
150 I $G(TASK) D @ZTRTN Q
151 I '$G(TASK) S X=$$DEVICE(X,DEVICE,ZTRTN)
152 Q
Note: See TracBrowser for help on using the repository browser.