source: WorldVistAEHR/trunk/r/RADIOLOGY_NUCLEAR_MEDICINE-RA/RAUTL1.m@ 1484

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

revised back to 6/30/08 version

File size: 7.9 KB
Line 
1RAUTL1 ;HISC/CAH,FPT,GJC AISC/MJK,RMO-Utility Routine ;10/22/97 13:54
2 ;;5.0;Radiology/Nuclear Medicine;**5,9,18,71,82**;Mar 16, 1998;Build 8
3 ;last modification by SS for P18 June 19,00
4 ;02/10/2006 BAY/KAM RA*5*71 Add ability to update exam data to V/R
5 I "IOSCR"'[X!(X="") S X="Unknown" Q
6 G @($E(X))
7 ;Set X=Inpatient Location
8I S X=$S($D(^DIC(42,+$P(^RADPT(D0,"DT",D1,"P",D2,0),"^",6),0)):$P(^(0),"^"),1:"Unknown")
9 Q
10 ;
11 ;Set X=Outpatient Location
12O S X=$S($D(^SC(+$P(^RADPT(D0,"DT",D1,"P",D2,0),"^",8),0)):$P(^(0),"^"),1:"Unknown")
13 Q
14 ;
15 ;Set X=Contract/Sharing Agreement patient location
16S ;
17C S X=$S($D(^DIC(34,+$P(^RADPT(D0,"DT",D1,"P",D2,0),"^",9),0)):$P(^(0),"^"),1:"Unknown")
18 Q
19 ;
20 ;Set X=Research patient location
21R S X=$S($D(^RADPT(D0,"DT",D1,"P",D2,"R")):$P(^("R"),"^"),1:"Unknown") Q
22 ;
23 ;Set X=time of day in external format (ex: 2:28 PM)
24NOW S %=$P($H,",",2),X=DT_(%\60#60/100+(%\3600)+(%#60/10000)/100) D TIME
25 Q
26 ;Input X=FM date/time, Output X=time (external format)
27TIME S X=$E($P(X,".",2)_"0000",1,4),%=X>1159 S:X>1259 X=X-1200 S X=X\100_":"_$E(X#100+100,2,3)_" "_$E("AP",%+1)_"M" S:$P(X,":")=0 X=12_":"_$P(X,":",2)
28 Q
29 ;
30ELAPSED ;Pass parameters X (from date) and X1 (to date)
31 ;Variable Y is returned as either an elapsed time in the form DD:HH:MM where DD=days, HH=hours, MM=minutes or as the string 'Neg. Time' indicating a negative elapsed time
32 ;Variable Y1 is returned as the # of minutes of elapsed time
33 I '$D(RAMTIME) S DIC="^DD(""FUNC"",",DIC(0)="FX",RAX=X,X="MINUTES" D ^DIC K DIC S X=RAX S:$D(^DD("FUNC",+Y,1)) RAMTIME=^(1) I '$D(RAMTIME) W *7,!!,"Can't continue --- No 'MINUTES' function found in File Manager" K Y,Y1 G Q
34 X RAMTIME S Y1=X I X<0 S Y="Neg. Time" G Q
35MINUTS S X(1)=X\1440,X=X-(1440*X(1)),X(2)=X\60,X(3)=X-(60*X(2)),Y=$E(100+X(1),2,3)_":"_$E(100+X(2),2,3)_":"_$E(100+X(3),2,3)
36Q K RAX,X Q
37 ;
38UPDATE ;Entry point for Update Rad/Nuc Med Exam Status option
39 I $O(RACCESS(DUZ,""))="" D SETVARS^RAPSET1(0)
40 I $G(RAIMGTY)="" D SETVARS^RAPSET1(1)
41 I $G(RAIMGTY)="" K XQUIT Q ; didn't sign-on to an imaging location
42 D ^RACNLU G UPQ:"^"[X
43 I $D(^RA(72,"AA",RAIMGTY,9,+RAST)),'$D(^XUSEC("RA MGR",DUZ)) W !!?3,*7,"You do not have the appropriate access privileges to act on completed exams." G UPDATE
44 I $D(^RA(72,"AA",RAIMGTY,0,+RAST)) W !!?3,*7,"Exam has been 'cancelled' therefore the status cannot be changed." G UPDATE
45 ;D UP1 I RAOR>0 S DA(2)=RADFN,DA(1)=RADTI,DA=RACNI,DIE="^RADPT("_DA(2)_",""DT"","_DA(1)_",""P"",",DR="100///""NOW""",DR(2,70.07)="2///U;3////"_$S($G(RADUZ):RADUZ,1:DUZ) D ^DIE
46 D UP1 I RAOR>0 D
47 .L +^RADPT(RADFN,"DT",RADTI,"P",RACNI)
48 .N RAIEN
49 .S RAIENS="+1,"_RACNI_","_RADTI_","_RADFN_","
50 .S RAFDA(70.07,RAIENS,.01)="NOW"
51 .K RAERR D UPDATE^DIE("E","RAFDA","RAIEN","RAERR")
52 .K RAFDA,RAIENS
53 .I $D(RAERR) L -^RADPT(RADFN,"DT",RADTI,"P",RACNI) K RAIEN Q
54 .S RAIENS=RAIEN(1)_","_RACNI_","_RADTI_","_RADFN_","
55 .S RAFDA(70.07,RAIENS,2)="U"
56 .S RAFDA(70.07,RAIENS,3)=$S($G(RADUZ):RADUZ,1:DUZ)
57 .D FILE^DIE(,"RAFDA")
58 .L -^RADPT(RADFN,"DT",RADTI,"P",RACNI)
59UPQ K RAFDA,RAIENS
60 K %,D,DA,DE,DIC,DIE,DQ,DR,I,J,POP,RACS,RAEND,RAF5,RAFL,RAFST,RAI,RAIX,RAJ1,RAORDIFN,RAPRIT,RAHEAD,RASN,RAOR,RASTI,RASSN,RADATE,RAST,RACN,RACNI,RADFN,RADTE,RADTI,RANME,RAPRC,RARPT,X,Y,Z,^TMP($J,"RAEX"),C,DIPGM Q
61 ;
62 ;Exam status updating and accompanying updates to status log, oe/rr
63UP1 N RA8,RAEXEDT S RA8=0 ;use this to flag when one alert has been sent
64 ;Line change for RA*5*82
65 S RAEXEDT=$$CMPAFTR^RAO7XX(1) ;P18 if procedure changed in RAEDCN or RAEDPT sends XX message to CPRS if needed
66 ; RA EDITCN and RA EDITPT should process this case only
67 I $D(RAOPT("EDITCN"))!($D(RAOPT("EDITPT"))) D UP2,UPK Q
68 ; see if this case belongs to a printset
69 N:'$D(RAPRTSET) RAPRTSET N:'$D(RAMEMARR) RAMEMARR
70 D EN2^RAUTL20(.RAMEMARR) ;043099 always recalculate RAPRTSET
71 ; if not print set, then just process this case only
72 I 'RAPRTSET D UP2,UPK Q
73 ;case belongs to print set, so process all members of same print set
74 N RACNISAV,RA7
75 S RACNISAV=RACNI,RA7=0
76 F S RA7=$O(RAMEMARR(RA7)) Q:RA7="" S RACNI=RA7 D UP2
77 S RACNI=RACNISAV
78 G UPK
79UP2 ;Remedy Call 124379 Patch *71 BAY/KAM Added next line
80 ;Patch RA*5*82 next line commented out
81 ;D:$G(RAHLTCPB)'=1 EXM^RAHLRPC
82 ;
83 S DA(2)=RADFN,DA(1)=RADTI,DA=RACNI,DIE="^RADPT("_DA(2)_",""DT"","_DA(1)_",""P"","
84 N RAAFTER,RABEFORE
85 D STUFF^RASTREQ1 I RAOR<0,$D(RASN) W:'$D(RAONLINE)&('$D(ZTQUEUED)) !?5,"...exam status remains '",RASN,"'." K DIE,RACS,RAPRIT D Q
86 .D:$G(RAEXEDT) EXM^RAHLRPC ; DO statement added by RA*5*82
87 W:'$D(RAONLINE)&('$D(ZTQUEUED)) !?3,"...will now designate exam status as '",RASN,"'... for case no. ",$P($G(^RADPT(RADFN,"DT",RADTI,"P",RACNI,0)),U)
88 ; S DR="3////"_RASTI_$S($P(RAMDV,"^",10):";75///^S X=$$MIDNGHT^RAUTL5($$NOW^XLFDT())",1:"")
89 ; user duz could be in RADUZ, if session is from the Voice recognition
90 ;S DR(2,70.05)=$S($P(RAMDV,"^",11)&('$D(ZTQUEUED)):".01;",1:"")_"2////"_RASTI_";3////"_$S($G(RADUZ):RADUZ,1:DUZ)
91 ;D ^DIE
92 L +^RADPT(RADFN,"DT",RADTI,"P",RACNI)
93 N RAIEN
94 S RAIENS=RACNI_","_RADTI_","_RADFN_","
95 S RAFDA(70.03,RAIENS,3)=RASTI
96 K RAERR D FILE^DIE(,"RAFDA","RAERR")
97 I $D(RAERR) L -^RADPT(RADFN,"DT",RADTI,"P",RACNI) G UP2K ;L - P18
98 I $P(RAMDV,"^",10) D
99 .S RAIENS="+1,"_RACNI_","_RADTI_","_RADFN_","
100 .S RAFDA(70.05,RAIENS,.01)=$$MIDNGHT^RAUTL5($$NOW^XLFDT())
101 .D UPDATE^DIE(,"RAFDA","RAIEN")
102 .K RAFDA,RAIENS
103 .Q:'$D(RAIEN(1))
104 .I $P(RAMDV,"^",11),('$D(ZTQUEUED)) D
105 ..S DIE=DIE_RACNI_",""T"",",DA=RAIEN(1)
106 ..S DR=".01"
107 ..D ^DIE
108 .S RAIENS=RAIEN(1)_","_RACNI_","_RADTI_","_RADFN_","
109 .S RAFDA(70.05,RAIENS,2)=RASTI
110 .S RAFDA(70.05,RAIENS,3)=$S($G(RADUZ):RADUZ,1:DUZ)
111 .K RAERR2 D FILE^DIE(,"RAFDA")
112 ;Patch RA*5*82 added next line send EXM message after status update, not before the update
113 D EXM^RAHLRPC
114 L -^RADPT(RADFN,"DT",RADTI,"P",RACNI)
115 ;
116UP2K K DE,DQ,DIE,DR,RAFDA,RAIENS K:$D(RAERR) RACS,RAPRIT Q:$D(RAERR) W:'$D(RAONLINE)&('$D(ZTQUEUED)) !?10,"...exam status ",$S($G(RABEFORE)>$G(RAAFTER):"backed down",1:"successfully updated"),"." D ^RAORDC
117 I RA8=0,$D(^RA(72,RASTI,"ALERT")),$P(^("ALERT"),"^")="y" D:$$ORVR^RAORDU()=2.5 OERR D:$$ORVR^RAORDU()'<3 OERR3 S RA8=1
118 I $D(^RA(72,RASTI,0)),$P(^(0),"^",3)>1,RACS'="Y",$S('$D(RAF5):1,$P(^DIC(42,+RAF5,0),U,3)="D":1,1:0) D EN^RAUTL0
119 K RACS,RAORDIFN,RAPRIT,RAF5
120 Q
121UPK K ORIFN,ORVP,ORNOTE,ORBPMSG,RACS,RAORDIFN,RAPRIT,RAF5
122 Q
123OERR ;Send Alert to OERR after pt examined
124 S ORVP=RADFN_";DPT(",ORBPMSG="Rad Pt Examined - "_$S($D(^RAMIS(71,RAPRIT,0)):$E($P(^(0),"^"),1,24),1:"Unknown") S:$D(^RAO(75.1,+RAORDIFN,0)) ORIFN=+$P(^(0),"^",7) S ORNOTE(21)=$S($D(ORIFN):1,1:"") D NOTE^ORX3
125 Q
126OERR3 ; Send RADIOLOGY PATIENT EXAMINED notification via oe/rr v3
127 ; Called from UP1
128 ;
129 ; RADFN,RADTI,RACNI,RAPRIT must be defined
130 Q:'$D(RADFN)!('$D(RADTI))!('$D(RACNI))!('$D(RAPRIT))
131 ;
132 N RAIENS,RAMSG,RAOIFN,RAOSTS,RAONODE,RADPTNDE,RAREQPHY
133 S RADPTNDE=$G(^RADPT(RADFN,"DT",RADTI,"P",RACNI,0))
134 S RAOIFN=$P(RADPTNDE,U,11) Q:'RAOIFN ;file 75.1 ien
135 S RAONODE=$G(^RAO(75.1,+RAOIFN,0))
136 S RAOSTS=$P(RAONODE,U,5) Q:RAOSTS'=6 ;active exams only
137 S RAOIFN=$P(RAONODE,U,7) ;file 100 ien
138 S RAREQPHY=+$P(RADPTNDE,U,14) ;ordering provider
139 S RAREQPHY(RAREQPHY)=""
140 S RAMSG="Imaging Pt Examined - "_$S($D(^RAMIS(71,RAPRIT,0)):$E($P(^(0),U),1,24),1:"Unknown"),RAMSG=$E(RAMSG,1,51)
141 S RAIENS=RADTI_"~"_RACNI
142 ;
143 ; oe parameters:
144 ; ORN: notification id (#100.9 ien)
145 ; | ORBDFN: patient id (#2 ien)
146 ; | | ORNUM: order number (#100 ien)
147 ; | | | ORBADUZ: recipient array
148 ; | | | | ORBPMSG: message text
149 ; | | | | | ORBPDATA exam dt~case iens
150 ; | | | | | |
151 D EN^ORB3(21,RADFN,RAOIFN,.RAREQPHY,RAMSG,RAIENS)
152 Q
153 ;
154 ;Called by many report programs. Sets RACRT() array containing all
155 ;exam statuses that are to be included on the report. RACRT is set
156 ;to the piece of the Exam Status File #72 record that corresponds
157 ;to the report being generated.
158CRIT F I=0:0 S I=$O(^RA(72,I)) Q:'I I $D(^(I,.3)),$P(^(.3),"^",RACRT)="y" S RACRT(I)=""
159 Q
Note: See TracBrowser for help on using the repository browser.