source: FOIAVistA/tag/r/PROSTHETICS-RMPR-RMPO-RMPS/RMPRPIQ5.m@ 1424

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

initial load of FOIAVistA 6/30/08 version

File size: 6.0 KB
Line 
1RMPRPIQ5 ;HCIOFO/ODJ - INVENTORY REPORT - BUILD ^TMP SORT ARRAY ; 12/30/02 11:35
2 ;;3.0;PROSTHETICS;**61,127**;Feb 09, 1996
3 ;
4 ;RVD patch #61 modified to read the new PIP files; 661.11, 661.6
5 ; 661.7, 661.9
6 Q
7 ;
8 ; Start of Report build and print. Enter here after report params.
9 ; entered by user (see RMPR5HQ4).
10 ; Also called by TaskMan if report queued.
11 ;
12 ; Variables required
13 ;
14 ; RMPR("STA")
15 ; RMPRSDT
16 ; RMPREDT
17 ; RMPRDET
18 ; RMPRSEL
19 ; {IO vars}
20 ;
21REPORT I $E(IOST)["C" W !!,"Processing report......."
22 D GEN(RMPRSDT,RMPREDT,RMPRDET,.RMPRSEL,RMPR("STA")) ;generate ^TMP sort array
23 D CALC^RMPR5HQ6 ;calculations
24 U IO D ^RMPR5HQ2 ;print report
25 D ^%ZISC
26 ;K ^TMP($J,"RMPR5") ;make live after testing
27 N RMPR,RMPRSITE D KILL^XUSCLEAN
28 Q
29 ;
30 ; Entry point for national roll-up
31NATION N RMPRSEL,RMPRDET,RMPRSTN,RMPRSDT,RMPREDT,X
32 S RMPRSTN="*"
33 S RMPRDET="H"
34 ;D NOW^%DTC S RMPREDT=X S %H=%H-30 D YMD^%DTC S RMPRSDT=X
35 S RMPRSDT=RMPRPIP1,RMPREDT=RMPRPIP2
36 S RMPRSEL("*")=""
37 D GEN(RMPRSDT,RMPREDT,RMPRDET,.RMPRSEL,RMPRSTN)
38 D CALC^RMPR5HQ6 ;put calcs in TMP array
39 D MAIL^RMPR5HQ7 ;build ^TMP($J,"RMPR5A" array for mailing
40 Q
41 ;
42 ;
43 ; Generate temporary index global ^TMP($J,"RMPR5"
44 ; (as of 11/29/00 we use the 660 file, not 661.2)
45 ;
46GEN(STDT,ENDT,DETAIL,RMPRSEL,RMPRSTN) ;
47 N TNAM,FROM,EOF,DAT,HCDAT,HCPCIEN,NPGRP,NPLIN,S,HCPC,HCPCITEM
48 N OUPIEN,ITEM,ALLGRP,HCPCREF,SELECTED,STATION,QTY,STR,MULITEM
49 N ITMIEN,INVDT,SOURCE,ISCOST,PATIENT,COST
50 S TNAM="RMPR5" ;TMP global name
51 K ^TMP($J,TNAM)
52 D CURVAL(TNAM,RMPRSTN,.RMPRSEL,DETAIL)
53 ;S FROM="" S:$G(STDT)'="*" FROM=STDT-1
54 S EOF=0,ENDT=ENDT+1
55 F RSDT=STDT:0 S RSDT=$O(^RMPR(661.6,"XSTD",RMPRSTN,3,RSDT)) Q:(RSDT>ENDT)!(RSDT="") D Q:EOF
56 .; I INVDT="" S EOF=1 Q
57 .; I ENDT'="*",INVDT>ENDT S EOF=1 Q
58 . S OUPIEN=0
59 . F S OUPIEN=$O(^RMPR(661.6,"XSTD",RMPRSTN,3,RSDT,OUPIEN)) Q:OUPIEN'>0 D
60 .. S S=$G(^RMPR(661.6,OUPIEN,0))
61 .. S PATIENT=$P(S,"^",2) Q:PATIENT=""
62 .. S QTY=+$P(S,"^",5) Q:QTY<1
63 .. S HCPC=$P(S,"^",1) Q:HCPC=""
64 .. S HCPCIEN=$O(^RMPR(661.1,"B",HCPC,0)) Q:HCPCIEN=""
65 .. S STATION=RMPRSTN Q:STATION=""
66 .. I RMPRSTN'="*",STATION'=RMPRSTN Q
67 .. Q:'$D(^TMP($J,TNAM,"Z",HCPCIEN))
68 .. Q:$P(^TMP($J,TNAM,"Z",HCPCIEN),"^",3)=1
69 .. S HCPCITEM=HCPC_"-"_$P(S,"^",11)
70 .. S ITEM=$P(HCPCITEM,"-",2)
71 .. S:ITEM="" ITEM="?"
72 .. S ISCOST=$P(S,"^",6)
73 ..; S COST=$$PRECOST(OUPIEN,HCPCIEN,HCPCITEM,STATION)
74 ..; I COST'="" S ISCOST=COST-ISCOST
75 ..; S:COST="" ISCOST=QTY*$P(S,"^",5)
76 .. S R11=$O(^RMPR(661.11,"C",HCPCITEM,0))
77 .. S R11DAT=$G(^RMPR(661.11,R11,0))
78 .. S SOURCE=$P(R11DAT,"^",5)
79 .. S STR=^TMP($J,TNAM,"Z",HCPCIEN)
80 .. S NPGRP=$P(STR,"^",1)
81 .. S NPLIN=$P(STR,"^",2)
82 .. S HCPCREF=HCPC,$P(HCPCREF,"/",2)=HCPCIEN
83 .. I '$D(^TMP($J,TNAM,STATION,NPGRP,NPLIN,HCPCREF,ITEM)) D Q:'+QTY
84 ... S:+QTY ^TMP($J,TNAM,STATION,NPGRP,NPLIN,HCPCREF,ITEM)=""
85 ... Q
86 .. S ^TMP($J,TNAM,STATION,NPGRP,NPLIN,HCPCREF,ITEM,OUPIEN)=QTY_"^"_ISCOST_"^"_SOURCE
87 .. Q
88 . Q
89 Q
90 ;
91 ; Get total cost of item just prior to current issue
92PRECOST(INVIEN,HCPCIEN,HCPCITEM,STATION) ;
93 N IEN,COST,STR,LOC
94 S COST=""
95 S IEN=INVIEN,RD=RMPRSDT
96 S RD=$O(^RMPR(661.9,"ASHID",RMPRSTN,HCPC,IEN,RD),-1)
97 Q:'$G(RD) S RIEN=$O(^RMPR(661.9,"ASHID",RMPRSTN,HCPC,IEN,RD,0))
98 S STR=^RMPR(661.9,RIEN,0)
99 S COST=$P(STR,"^",9)
100 Q COST
101 ;
102 ; Get QOH for HCPC
103CURVAL(RMPRNAM,RMPRSTN,RMPRSEL,DETAIL) ;
104 N INVIEN,STR,IEN1,IEN2,LOCN,HCPCIEN,HCDAT,NPLIN,NPGRP,ALLGRP,SELECTED
105 N S,SOURCE,STATION,QOH,COST,HCPC,HCPCREF,ITEM
106 S ALLGRP=0 S:$O(RMPRSEL(""))="*" ALLGRP=1
107 S RH=""
108 F S RH=$O(^RMPR(661.9,"ASHID",RMPRSTN,RH)) Q:RH="" D
109 . S IEN1=0
110 . F S IEN1=$O(^RMPR(661.9,"ASHID",RMPRSTN,RH,IEN1)) Q:'+IEN1 D
111 .. S HCPCIEN=$O(^RMPR(661.1,"B",RH,0)) Q:HCPCIEN=""
112 .. I '$D(^TMP($J,RMPRNAM,"Z",HCPCIEN)) D
113 ... S S=^RMPR(661.1,HCPCIEN,0)
114 ... S NPLIN=$P(S,"^",7)
115 ... S:NPLIN="" NPLIN="999 X"
116 ... S NPGRP=$P(NPLIN," ",1) ;group num. is 1st set of digits of new line
117 ... S STR=NPGRP
118 ... S $P(STR,"^",2)=NPLIN
119 ... S ^TMP($J,RMPRNAM,"Z",HCPCIEN)=STR
120 ... Q
121 .. E D Q:$P(S,"^",3)=1
122 ... S S=^TMP($J,RMPRNAM,"Z",HCPCIEN)
123 ... S NPGRP=$P(S,"^",1)
124 ... S NPLIN=$P(S,"^",2)
125 ... Q
126 .. ;
127 .. ; Test if record matches selection criteria
128 .. ; (only needed if not all groups selected)
129 .. I 'ALLGRP D I 'SELECTED S $P(^TMP($J,RMPRNAM,"Z",HCPCIEN),"^",3)=1 Q
130 ... S SELECTED=0
131 ... I '$D(RMPRSEL(NPGRP)) Q
132 ... I DETAIL="G" S SELECTED=1 Q
133 ... I $O(RMPRSEL(NPGRP,""))="*" S SELECTED=1 Q
134 ... I '$D(RMPRSEL(NPGRP,NPLIN)) Q
135 ... I DETAIL="L" S SELECTED=1 Q
136 ... I $O(RMPRSEL(NPGRP,NPLIN,""))="*" S SELECTED=1 Q
137 ... I '$D(RMPRSEL(NPGRP,NPLIN,HCPCIEN)) Q
138 ... S SELECTED=1
139 ... Q
140 .. S RD=ENDT+1
141 .. S RD=$O(^RMPR(661.9,"ASHID",RMPRSTN,RH,IEN1,RD),-1) Q:RD="" S RIEN=$O(^RMPR(661.9,"ASHID",RMPRSTN,RH,IEN1,RD,""),-1) D
142 ... Q:'$D(^RMPR(661.9,RIEN,0))
143 ... S HCPC=RH,S=^RMPR(661.9,RIEN,0)
144 ... S QOH=+$P(S,"^",8) Q:'QOH
145 ... S COST=$P(S,"^",9)
146 ... S ITEM=IEN1
147 ... S RS=$O(^RMPR(661.11,"C",HCPC_"-"_ITEM,0)) Q:RS=""
148 ... S SOURCE=$P($G(^RMPR(661.11,RS,0)),U,5)
149 ... S HCPCREF=HCPC,$P(HCPCREF,"/",2)=HCPCIEN
150 ... S S=$G(^TMP($J,RMPRNAM,RMPRSTN,NPGRP,NPLIN,HCPCREF,ITEM))
151 ... I SOURCE="C" D
152 .... S $P(S,"^",9)=QOH+$P(S,"^",9)
153 .... S $P(S,"^",11)=COST+$P(S,"^",11)
154 .... Q
155 ... E D
156 .... S $P(S,"^",8)=QOH+$P(S,"^",8)
157 .... S $P(S,"^",10)=COST+$P(S,"^",10)
158 .... Q
159 ... S ^TMP($J,RMPRNAM,RMPRSTN,NPGRP,NPLIN,HCPCREF,ITEM)=S
160 ... Q
161 .. Q
162 . Q
163 Q
164 ;
165 ; return item text string given HCPC and ITEM IENs to 661.11
166 ; if null ITEMIEN passed the just return the HCPC short name text
167GETITEM(HCPCIEN,ITEMIEN) ;
168 N STR,ITEMTXT
169 S ITEMTXT=""
170 I ITEMIEN="" D G GETITEMX
171 . S STR=$G(^RMPR(661.1,HCPCIEN,0))
172 . S ITEMTXT=$P(STR,"^",2)
173 . Q
174 S HCPC=$P($G(^RMPR(661.1,HCPCIEN,0)),U,1)
175 S STR=$G(^RMPR(661.11,"C",HCPC_"-"_ITEMIEN,0))
176 I STR="" D
177 . S ITEMTXT=$P(^RMPR(661.1,HCPCIEN,0),"^",2)
178 . Q
179 E D
180 . S ITEMTXT=$P(STR,"^",1)
181 . Q
182 S:ITEMTXT="" ITEMTXT="ITEM "_ITEMIEN
183GETITEMX Q ITEMTXT
184 ;
185 ; return NPPD line text from line code (New lines only)
186NPLIN(CODE) ;
187 N I,S,LINTXT
188 S LINTXT=""
189 F I=1:1 S S=$P($T(DES+I^RMPRN62),";;",2) Q:$E(S,1,3)="END" D Q:LINTXT'=""
190 . I $P(S,";",1)=CODE S LINTXT=$P(S,";",2)
191 . Q
192 Q LINTXT
Note: See TracBrowser for help on using the repository browser.