source: WorldVistAEHR/trunk/r/RADIOLOGY_NUCLEAR_MEDICINE-RA/RAPMW2.m@ 1800

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

initial load of WorldVistAEHR

File size: 8.4 KB
RevLine 
[613]1RAPMW2 ;HOIFO/SWM-Radiology Wait Time reports ;12/05/05 13:41
2 ;;5.0;Radiology/Nuclear Medicine;**67,79,83**;Mar 16, 1998;Build 4
3 ; IA 10063 allows check for Task Stop Request
4 ; detail
5 Q
6STORDET ;
7 S RAREC=""
8 S RACNL=$E(RAXDT,4,5)_$E(RAXDT,6,7)_$E(RAXDT,2,3)_"-"_+RACN0 ;long CN
9 S RA71REC=$G(^RAMIS(71,+$P(RACN0,U,2),0))
10 S RAXMST=$P(RA72,U) ;exam status name
11 S RACPT=$P($$NAMCODE^RACPTMSC($P(RA71REC,U,9),RAXDT),U) ;CPT code
12 S RAPROCNM=$P(RA71REC,U) ;procedure name
13 S RAPATNM=$$GET1^DIQ(2,RADFN,.01) S:RAPATNM="" RAPATNM=" " ;pt.name
14 S RAPATNM=$E(RAPATNM,1,12) ;use 1st 12 chars of pat name
15 S RAPATND=RAPATNM_"-"_RADFN ;patname-DFN
16 S RADTORD=$P($P(RAOREC,U,16),".") ;date ordered
17 ; store items in this order -- piece no.;field descrp/
18 ; 1;pt.name/ 2;long case no./ 3;dt ordered/ 4;dt desired/ 5;exam dt/
19 ; 6;no. days wait/ 7;exm stat name/ 8;CPT code/ 9; proc name/
20 ; 10;img typ name/ 11;* if canc & re-ord same day/ 12;Proc Typ Name/
21 ; 13;"p" if case from print set (highest ranked proc type)
22 ;
23 S RAREC=RAPATNM_U_RACNL_U_$E(RADTORD,1,7)_U_$E(RADSDT,1,7)
24 S RAREC=RAREC_U_$E(RAXDT,1,7)_U_RAWAITD_U_$E(RAXMST,1,11)_U_RACPT
25 S RAREC=RAREC_U_$E(RAPROCNM,1,45)_U_$E(RAIMGTYP,1,3)_U_$S(RASAME2:"*",1:"")_U_RAPTA
26 S RAREC=RAREC_U_$S(RACNI=99999:"p",1:"") ;flag printset case picked
27 ; subscript 3 is the sort value
28 ; subscripts 4-6 combined should be unique to a case, prevent over-
29 ; writing subscript 3 when >1 case has same sort value
30 ; subscript 4 is the exam date in Fileman notation
31 ; subcript 5 is the patient name (1st 12 chars) and DFN
32 ; subscript 6 is the "P" level ien of file 70
33 I RASORT="CN" S ^TMP($J,"RA WAIT3",RACNL,RADTE,RAPATND,RACNISAV)=RAREC
34 I RASORT="CPT" S ^TMP($J,"RA WAIT3",RACPT,RADTE,RAPATND,RACNISAV)=RAREC
35 I RASORT="DD" S ^TMP($J,"RA WAIT3",RADSDT,RADTE,RAPATND,RACNISAV)=RAREC
36 I RASORT="D" S ^TMP($J,"RA WAIT3",RAWAITD,RADTE,RAPATND,RACNISAV)=RAREC
37 I RASORT="DO" S ^TMP($J,"RA WAIT3",RADTORD,RADTE,RAPATND,RACNISAV)=RAREC
38 I RASORT="DR" S ^TMP($J,"RA WAIT3",RAXDT,RADTE,RAPATND,RACNISAV)=RAREC
39 I RASORT="I" S ^TMP($J,"RA WAIT3",RAIMGTYP,RADTE,RAPATND,RACNISAV)=RAREC
40 I RASORT="PT" S ^TMP($J,"RA WAIT3",RAPTA,RADTE,RAPATND,RACNISAV)=RAREC
41 I RASORT="PN" S ^TMP($J,"RA WAIT3",RAPATNM,RADTE,RAPATND,RACNISAV)=RAREC
42 I RASORT="PROC" S ^TMP($J,"RA WAIT3",RAPROCNM,RADTE,RAPATND,RACNISAV)=RAREC
43 Q
44WRTDET ;
45 S RAHD0="Detail",RAPG=1
46 D SETHD^RAPMW1
47 D PRTD Q:RAXIT
48 D FOOTD
49 Q
50HDDET ;
51 W !!,"Sorted by: ",RASORTNM,?38,"Print only cases with minimum Days Wait of: ",RASINCE
52 W !,"Total number of procedures registered during specified exam date range: ",RATOTAL
53 Q
54COLHDD ;
55 I RAPG>1 W @IOF,!,"Page: ",RAPG
56 S RAPG=RAPG+1
57 W !!?27,"Date",?36,"Date",?45,"Date",?54,"Days",?59,"Exam",?71,"CPT",?122,"Img",?127,"PROC."
58 W !,"Patient Name",?14,"Case #",?27,"Ordered",?36,"Desired",?45,"Register",?54,"Wait",?59,"Status",?71,"Code",?77,"Name of Procedure",?122,"Type",?127,"TYPE"
59 W !,$E(RADASH,1,12),?14,$E(RADASH,1,12),?27,$E(RADASH,1,8),?36,$E(RADASH,1,8),?45,$E(RADASH,1,8),?54,$E(RADASH,1,4),?59,$E(RADASH,1,11),?71,$E(RADASH,1,5),?77,RADASH,?123,$E(RADASH,1,4),?127,$E(RADASH,1,5)
60 I $D(ZTQUEUED) D STOPCHK^RAUTL9 S:$G(ZTSTOP)=1 RAXIT=1 ;user stopped task
61 Q
62PRTD ;
63 I RATYP="B" D PRESS^RAPMW1 Q:RAXIT
64 N X
65 D HD^RAPMW1 Q:RAXIT D HDDET,COLHDD
66 S RA0="",RAXIT=0
67 F S RA0=$O(^TMP($J,"RA WAIT3",RA0)) Q:RA0="" Q:RAXIT S RA1=0 D
68 .F S RA1=$O(^TMP($J,"RA WAIT3",RA0,RA1)) Q:'RA1 Q:RAXIT S RA2=0 D
69 ..F S RA2=$O(^TMP($J,"RA WAIT3",RA0,RA1,RA2)) Q:RA2="" Q:RAXIT S RA3=0 D
70 ...F S RA3=$O(^TMP($J,"RA WAIT3",RA0,RA1,RA2,RA3)) Q:'RA3 Q:RAXIT S X=^(RA3) D
71 ....D CKLINE Q:RAXIT
72 ....W !,$P(X,U),?13,$P(X,U,13),?14,$P(X,U,2),?27,$$FMTE^XLFDT($P(X,U,3),2),?36,$$FMTE^XLFDT($P(X,U,4),2),?45,$$FMTE^XLFDT($P(X,U,5),2),$P(X,U,11),?54,$J($P(X,U,6),4),?59,$P(X,U,7)
73 ....W ?71,$P(X,U,8),?77,$P(X,U,9),?123,$P(X,U,10),?127,$E($P(X,U,12),1,5)
74 ....Q
75 ...Q
76 ..Q
77 .Q
78 Q
79CKLINE ;
80 I ($Y+5)>IOSL D
81 . S RAXIT=$$S^%ZTLOAD("This task was in routine RAPMW2 when it was stopped.") I RAXIT S ZTSTOP=1 Q ;IA10063
82 .D PRESS^RAPMW1
83 .Q:RAXIT
84 .D COLHDD
85 .Q
86 Q
87FOOTD ;
88 D PRESS^RAPMW1 Q:RAXIT W:$E(IOST,1,2)="C-" @IOF
89 I RANEG W !!?3,"(There ",$S(RANEG=1:"is",1:"are")," ",RANEG," case",$S(RANEG=1:"",1:"s")," with negative days wait included in the listing.)",!
90 F I=1:1:28 Q:RAXIT W !?4,$P($T(FOOTD2+I),";;",2) I ($Y+5)>IOSL D PRESS^RAPMW1 Q:RAXIT W:$E(IOST,1,2)="C-" @IOF
91 Q
92CALC ;
93 S RASAME2=0 ;=1 if exm's order was cancelled & reordered same day
94 S RAORIEN=$P(RACN0,U,11)
95 S RAOREC=$G(^RAO(75.1,+RAORIEN,0))
96 I RAOREC="" S ^TMP($J,"RA WAIT NO ORD",RADFN,RADTI,RACNI)=RAORIEN Q
97 S RAXDT=9999999.9999-RADTI ; exam date FM format
98 S RADSDT=$P(RAOREC,U,21) ; Date Desired
99 I RADSDT="" S ^TMP($J,"RA WAIT NO DSR DT",RADFN,RADTI,RACNI)=RAORIEN Q
100 S RAWAITD=$$FMDIFF^XLFDT(RAXDT,RADSDT) ;Wait days btw exm & desired dt
101 S:RAWAITD<0 RANEG=RANEG+1
102 D STORSUM^RAPMW1 ;store summary counts for Summary, Detail, Both
103 S RA16=$P(RAOREC,U,16) ; request entered dt/tm
104 ; count if same proc cancelled and reordered same day
105 S RA1=$E(RA16,1,7)
106 ; loop start w Last Activity same date as order's entry date
107 F S RA1=$O(^RAO(75.1,"AO",RA1)) Q:'RA1 Q:RA1>RA16 D
108 .S RA2=0 F S RA2=$O(^RAO(75.1,"AO",RA1,RA2)) Q:'RA2 Q:RA2=RAORIEN D
109 ..S RA3=^RAO(75.1,RA2,0) ;skip exm's order
110 ..; other order is discontinued,same patient,same ordered procedure
111 ..I $P(RA3,U,5)=1,$P(RA3,U,1)=RADFN,$P(RA3,U,2)=$P(RAOREC,U,2) S RASAME=RASAME+1,RASAME2=1
112 ..Q
113 .Q
114 ; store detail rows for Detail,Both IF days wait at least = RASINCE
115 I "B^D"[RATYP,((RAWAITD<0)!(RAWAITD'<RASINCE)) D STORDET
116 Q
117PTA ; *79
118 S RAPRC=$P(RACN0,U,2)
119 I RAPRC="" S RAPTA="unknown" Q
120 S RACPTI=+$P($G(^RAMIS(71,+RAPRC,0)),U,9)
121 S RACPTC=$P($$NAMCODE^RACPTMSC(RACPTI,DT),U)
122 S RAPTA=$S(RACPTI:$O(^RA(73.2,"B",RACPTC,0)),1:"")
123 S RAPTA=$P($G(^RA(73.2,+RAPTA,0)),U,2)
124 S RAPTA=$S(RAPTA="":"unknown",'$D(RACOL(RAPTA)):"unknown",1:RAPTA)
125 ; RAPTA should match one of the RATOTAL(rapta)
126 Q
127COLHDS(X) ; moved from RAPMW1
128 I X=1 D
129 .W !,"PROCEDURE",?31,"<=30",?40,"31-60",?50,"61-90",?59,"91-120",?71,">120"
130 .W !,"TYPE",?31,"Days",?41,"Days",?51,"Days",?61,"Days",?71,"Days"
131 .W !,"--------------------------",?29,"------",?39,"------",?49,"------",?59,"------",?69,"------"
132 .Q
133 I X=2 D
134 .W !,"PROCEDURE",?30,"<=30",?36,"31-60",?43,"61-90",?50,"91-120",?58,">120",?66,"ROW",?73,"Avg."
135 .W !,"TYPE",?30,"Days",?37,"Days",?44,"Days",?51,"Days",?58,"Days",?65,"TOTAL",?73,"Days"
136 .W !,"--------------------------",?28,"------",?35,"------",?42,"------",?49,"------",?56,"------",?64,"------",?72,"-----"
137 .Q
138 Q
139FOOTD2 ;
140 ;;
141 ;;1. Cancelled, "No Credit", inpatient cases, and not the highest modality of a printset are excluded from this report.
142 ;; (See 3. below.)
143 ;;
144 ;;2. The "Days Wait" represent # of days from the Registered date (the date/time entered at the "Imaging Exam Date/Time:" prompt)
145 ;; backwards to the Date Desired for the ordered procedure. The calculation is based on the number of different days and
146 ;; not rounded off by hours.
147 ;;
148 ;;3. If the user did not select a specific CPT Code or Procedure Name, then the cases from a printset (group of cases that
149 ;; share the same report) will have only the case with the highest ranked modality printed. Modalities are ranked
150 ;; in this order, (1) being the highest:
151 ;; (1) Interventional, (2) MRI, (3) CT, (4) Cardiac Stress test, (5) Nuc Med, (6) US, (7) Mammo, (8) General Rad (9) Other
152 ;; However, all the cases from an examset (group of cases that have separate reports) will all be listed.
153 ;;
154 ;;4. "Procedure Types" are assigned by a national CPT code look-up table and may differ from locally defined "Imaging Types."
155 ;; Therefore the number of procedures in each category may not be the same as other radiology management reports.
156 ;;
157 ;;5. Procedure Type of "unknown" refers to either cases that have no matching procedure type in the spreadsheet of CPT Codes
158 ;; provided by the Office of Patient Care Services, or cases that are missing data for the procedure.
159 ;;
160 ;;6. CPT Code is not available for parent and broad procedures in the header section. CPT Code of the parent order's highest
161 ;; ranked modality case will be printed in the line by line section. (See 3. above.)
162 ;;
163 ;;7. Date/Time Registered is the "Imaging Exam Date/Time" entered by the user during Registration.
164 ;;
165 ;;8. "*" under the "Date Register" column denotes the request was cancelled and re-ordered on the same day that it was cancelled.
166 ;;
167 ;;9. "p" under the "Case #" column, before the case number, denotes printset case with the highest ranked Procedure Type.
Note: See TracBrowser for help on using the repository browser.