RAUTL1 ;HISC/CAH,FPT,GJC AISC/MJK,RMO-Utility Routine ; 20 Apr 2011 7:16 PM
;;5.0;Radiology/Nuclear Medicine;**5,9,18,71,82,84,94,1003**;Nov 01, 2010;Build 3
;last modification by SS for P18 June 19,00
;07/28/2008 BAY/KAM RA*5*94 Remove patch 81 from 2nd line of routine
;02/10/2006 BAY/KAM RA*5*71 Add ability to update exam data to V/R
;
;Integration Agreements
;----------------------
;DIC(10006); DIE(10018); FILE^DIE(2053); UPDATE^DIE(2053); EN^ORB3(1362); NOTE^ORX3(868)
;
I "IOSCR"'[X!(X="") S X="Unknown" Q
G @($E(X))
;Set X=Inpatient Location
I S X=$S($D(^DIC(42,+$P(^RADPT(D0,"DT",D1,"P",D2,0),"^",6),0)):$P(^(0),"^"),1:"Unknown")
Q
;
;Set X=Outpatient Location
O S X=$S($D(^SC(+$P(^RADPT(D0,"DT",D1,"P",D2,0),"^",8),0)):$P(^(0),"^"),1:"Unknown")
Q
;
;Set X=Contract/Sharing Agreement patient location
S ;
C S X=$S($D(^DIC(34,+$P(^RADPT(D0,"DT",D1,"P",D2,0),"^",9),0)):$P(^(0),"^"),1:"Unknown")
Q
;
;Set X=Research patient location
R S X=$S($D(^RADPT(D0,"DT",D1,"P",D2,"R")):$P(^("R"),"^"),1:"Unknown") Q
;
;Set X=time of day in external format (ex: 2:28 PM)
NOW S %=$P($H,",",2),X=DT_(%\60#60/100+(%\3600)+(%#60/10000)/100) D TIME
Q
;Input X=FM date/time, Output X=time (external format)
TIME 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)
Q
;
ELAPSED ;Pass parameters X (from date) and X1 (to date)
;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
;Variable Y1 is returned as the # of minutes of elapsed time
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 $C(7),!!,"Can't continue --- No 'MINUTES' function found in File Manager" K Y,Y1 G Q
X RAMTIME S Y1=X I X<0 S Y="Neg. Time" G Q
MINUTS 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)
Q K RAX,X Q
;
UPDATE ;Entry point for Update Rad/Nuc Med Exam Status option
I $O(RACCESS(DUZ,""))="" D SETVARS^RAPSET1(0)
I $G(RAIMGTY)="" D SETVARS^RAPSET1(1)
I $G(RAIMGTY)="" K XQUIT Q ; didn't sign-on to an imaging location
D ^RACNLU G UPQ:"^"[X
I $D(^RA(72,"AA",RAIMGTY,9,+RAST)),'$D(^XUSEC("RA MGR",DUZ)) W !!?3,$C(7),"You do not have the appropriate access privileges to act on completed exams." G UPDATE
I $D(^RA(72,"AA",RAIMGTY,0,+RAST)) W !!?3,$C(7),"Exam has been 'cancelled' therefore the status cannot be changed." G UPDATE
;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
D UP1 I RAOR>0 D
.L +^RADPT(RADFN,"DT",RADTI,"P",RACNI):$G(DILOCKTM,3)
.N RAIEN
.S RAIENS="+1,"_RACNI_","_RADTI_","_RADFN_","
.S RAFDA(70.07,RAIENS,.01)="NOW"
.K RAERR D UPDATE^DIE("E","RAFDA","RAIEN","RAERR")
.K RAFDA,RAIENS
.I $D(RAERR) S RAERR="Error in update of 70.07, .01 "_$G(RAERR("DIERR",1,"TEXT",1)) K RAERR("DIERR") L -^RADPT(RADFN,"DT",RADTI,"P",RACNI) K RAIEN Q
.S RAIENS=RAIEN(1)_","_RACNI_","_RADTI_","_RADFN_","
.S RAFDA(70.07,RAIENS,2)="U"
.S RAFDA(70.07,RAIENS,3)=$S($G(RADUZ):RADUZ,1:DUZ)
.D FILE^DIE(,"RAFDA","RAERR")
.L -^RADPT(RADFN,"DT",RADTI,"P",RACNI)
.I $D(RAERR) S RAERR="Error in update of 70.07, 2,3 "_$G(RAERR("DIERR",1,"TEXT",1)) K RAERR("DIERR")
UPQ K RAFDA,RAIENS
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
;
;Exam status updating and accompanying updates to status log, oe/rr
UP1 N RA8,RAEXEDT S RA8=0 ;use this to flag when one alert has been sent
;Line change for RA*5*82
S RAEXEDT=$$CMPAFTR^RAO7XX(1) ;P18 if procedure changed in RAEDCN or RAEDPT sends XX message to CPRS if needed
; RA EDITCN and RA EDITPT should process this case only
I $D(RAOPT("EDITCN"))!($D(RAOPT("EDITPT"))) D UP2,UPK Q
; see if this case belongs to a printset
N:'$D(RAPRTSET) RAPRTSET N:'$D(RAMEMARR) RAMEMARR
D EN2^RAUTL20(.RAMEMARR) ;043099 always recalculate RAPRTSET
; if not print set, then just process this case only
I 'RAPRTSET D UP2,UPK Q
;case belongs to print set, so process all members of same print set
N RACNISAV,RA7
S RACNISAV=RACNI,RA7=0
F S RA7=$O(RAMEMARR(RA7)) Q:RA7="" S RACNI=RA7 D UP2
S RACNI=RACNISAV
G UPK
UP2 ;Remedy Call 124379 Patch *71 BAY/KAM Added next line
;Patch RA*5*82 next line commented out
;D:$G(RAHLTCPB)'=1 EXM^RAHLRPC
;
S DA(2)=RADFN,DA(1)=RADTI,DA=RACNI,DIE="^RADPT("_DA(2)_",""DT"","_DA(1)_",""P"","
N RAAFTER,RABEFORE
D STUFF^RASTREQ1 I RAOR<0,$D(RASN) W:'$D(RAONLINE)&('$D(ZTQUEUED)) !?5,"...exam status remains '",RASN,"'." K DIE,RACS,RAPRIT D Q
.D:$G(RAEXEDT) EXM^RAHLRPC ; DO statement added by RA*5*82
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)
; S DR="3////"_RASTI_$S($P(RAMDV,"^",10):";75///^S X=$$MIDNGHT^RAUTL5($$NOW^XLFDT())",1:"")
; user duz could be in RADUZ, if session is from the Voice recognition
;S DR(2,70.05)=$S($P(RAMDV,"^",11)&('$D(ZTQUEUED)):".01;",1:"")_"2////"_RASTI_";3////"_$S($G(RADUZ):RADUZ,1:DUZ)
;D ^DIE
L +^RADPT(RADFN,"DT",RADTI,"P",RACNI):$G(DILOCKTM,3)
N RAIEN
S RAIENS=RACNI_","_RADTI_","_RADFN_","
S RAFDA(70.03,RAIENS,3)=RASTI
K RAERR D FILE^DIE(,"RAFDA","RAERR")
I $D(RAERR) S RAERR="Error in update of 70.03 "_$G(RAERR("DIERR",1,"TEXT",1)) K RAERR("DIERR") L -^RADPT(RADFN,"DT",RADTI,"P",RACNI) G UP2K ;L - P18
I $P(RAMDV,"^",10) D
.N RAERR2
.S RAIENS="+1,"_RACNI_","_RADTI_","_RADFN_","
.S RAFDA(70.05,RAIENS,.01)=$$MIDNGHT^RAUTL5($$NOW^XLFDT())
.D UPDATE^DIE(,"RAFDA","RAIEN","RAERR")
.K RAFDA,RAIENS
.I $D(RAERR) S RAERR="Error in update of 70.05, .01 "_$G(RAERR("DIERR",1,"TEXT",1)) K RAERR("DIERR")
.Q:'$D(RAIEN(1))
.I $P(RAMDV,"^",11),('$D(ZTQUEUED)) D
..S DIE=DIE_RACNI_",""T"",",DA=RAIEN(1)
..S DR=".01"
..D ^DIE
.S RAIENS=RAIEN(1)_","_RACNI_","_RADTI_","_RADFN_","
.S RAFDA(70.05,RAIENS,2)=RASTI
.S RAFDA(70.05,RAIENS,3)=$S($G(RADUZ):RADUZ,1:DUZ)
.K RAERR2 D FILE^DIE(,"RAFDA","RAERR2")
.I $D(RAERR2) S RAERR2="Error in update of 70.05 2,3 "_$G(RAERR2("DIERR",1,"TEXT",1)),RAERR=$S($D(RAERR):RAERR_";"_RAERR2,1:RAERR2)
;Patch RA*5*82 added next line send EXM message after status update, not before the update
D:'$D(RAERR) EXM^RAHLRPC
L -^RADPT(RADFN,"DT",RADTI,"P",RACNI)
;
UP2K 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
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
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
K RACS,RAORDIFN,RAPRIT,RAF5
Q
UPK K ORIFN,ORVP,ORNOTE,ORBPMSG,RACS,RAORDIFN,RAPRIT,RAF5
Q
OERR ;Send Alert to OERR after pt examined
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
Q
OERR3 ; Send RADIOLOGY PATIENT EXAMINED notification via oe/rr v3
; Called from UP1
;
; RADFN,RADTI,RACNI,RAPRIT must be defined
Q:'$D(RADFN)!('$D(RADTI))!('$D(RACNI))!('$D(RAPRIT))
;
N RAIENS,RAMSG,RAOIFN,RAOSTS,RAONODE,RADPTNDE,RAREQPHY
S RADPTNDE=$G(^RADPT(RADFN,"DT",RADTI,"P",RACNI,0))
S RAOIFN=$P(RADPTNDE,U,11) Q:'RAOIFN ;file 75.1 ien
S RAONODE=$G(^RAO(75.1,+RAOIFN,0))
S RAOSTS=$P(RAONODE,U,5) Q:RAOSTS'=6 ;active exams only
S RAOIFN=$P(RAONODE,U,7) ;file 100 ien
S RAREQPHY=+$P(RADPTNDE,U,14) ;ordering provider
S RAREQPHY(RAREQPHY)=""
S RAMSG="Imaging Pt Examined - "_$S($D(^RAMIS(71,RAPRIT,0)):$E($P(^(0),U),1,24),1:"Unknown"),RAMSG=$E(RAMSG,1,51)
S RAIENS=RADTI_"~"_RACNI
;
; oe parameters:
; ORN: notification id (#100.9 ien)
; | ORBDFN: patient id (#2 ien)
; | | ORNUM: order number (#100 ien)
; | | | ORBADUZ: recipient array
; | | | | ORBPMSG: message text
; | | | | | ORBPDATA exam dt~case iens
; | | | | | |
D EN^ORB3(21,RADFN,RAOIFN,.RAREQPHY,RAMSG,RAIENS)
Q
;
;Called by many report programs. Sets RACRT() array containing all
;exam statuses that are to be included on the report. RACRT is set
;to the piece of the Exam Status File #72 record that corresponds
;to the report being generated.
CRIT F I=0:0 S I=$O(^RA(72,I)) Q:'I I $D(^(I,.3)),$P(^(.3),"^",RACRT)="y" S RACRT(I)=""
Q
RAUTL1 ;HISC/CAH,FPT,GJC AISC/MJK,RMO-Utility Routine ; 20 Apr 2011 7:16 PM
+1 ;;5.0;Radiology/Nuclear Medicine;**5,9,18,71,82,84,94,1003**;Nov 01, 2010;Build 3
+2 ;last modification by SS for P18 June 19,00
+3 ;07/28/2008 BAY/KAM RA*5*94 Remove patch 81 from 2nd line of routine
+4 ;02/10/2006 BAY/KAM RA*5*71 Add ability to update exam data to V/R
+5 ;
+6 ;Integration Agreements
+7 ;----------------------
+8 ;DIC(10006); DIE(10018); FILE^DIE(2053); UPDATE^DIE(2053); EN^ORB3(1362); NOTE^ORX3(868)
+9 ;
+10 IF "IOSCR"'[X!(X="")
SET X="Unknown"
QUIT
+11 GOTO @($EXTRACT(X))
+12 ;Set X=Inpatient Location
I SET X=$SELECT($DATA(^DIC(42,+$PIECE(^RADPT(D0,"DT",D1,"P",D2,0),"^",6),0)):$PIECE(^(0),"^"),1:"Unknown")
+1 QUIT
+2 ;
+3 ;Set X=Outpatient Location
O SET X=$SELECT($DATA(^SC(+$PIECE(^RADPT(D0,"DT",D1,"P",D2,0),"^",8),0)):$PIECE(^(0),"^"),1:"Unknown")
+1 QUIT
+2 ;
+3 ;Set X=Contract/Sharing Agreement patient location
S ;
C SET X=$SELECT($DATA(^DIC(34,+$PIECE(^RADPT(D0,"DT",D1,"P",D2,0),"^",9),0)):$PIECE(^(0),"^"),1:"Unknown")
+1 QUIT
+2 ;
+3 ;Set X=Research patient location
R SET X=$SELECT($DATA(^RADPT(D0,"DT",D1,"P",D2,"R")):$PIECE(^("R"),"^"),1:"Unknown")
QUIT
+1 ;
+2 ;Set X=time of day in external format (ex: 2:28 PM)
NOW SET %=$PIECE($HOROLOG,",",2)
SET X=DT_(%\60#60/100+(%\3600)+(%#60/10000)/100)
DO TIME
+1 QUIT
+2 ;Input X=FM date/time, Output X=time (external format)
TIME SET X=$EXTRACT($PIECE(X,".",2)_"0000",1,4)
SET %=X>1159
IF X>1259
SET X=X-1200
SET X=X\100_":"_$EXTRACT(X#100+100,2,3)_" "_$EXTRACT("AP",%+1)_"M"
IF $PIECE(X,"
SET X=12_":"_$PIECE(X,":",2)
+1 QUIT
+2 ;
ELAPSED ;Pass parameters X (from date) and X1 (to date)
+1 ;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
+2 ;Variable Y1 is returned as the # of minutes of elapsed time
+3 IF '$DATA(RAMTIME)
SET DIC="^DD(""FUNC"","
SET DIC(0)="FX"
SET RAX=X
SET X="MINUTES"
DO ^DIC
KILL DIC
SET X=RAX
IF $DATA(^DD("FUNC",+Y,1))
SET RAMTIME=^(1)
IF '$DATA(RAMTIME)
WRITE $CHAR(7),!!,"Can't continue --- No 'MINUTES' function found in File Manager"
KILL Y,Y1
GOTO Q
+4 XECUTE RAMTIME
SET Y1=X
IF X<0
SET Y="Neg. Time"
GOTO Q
MINUTS SET X(1)=X\1440
SET X=X-(1440*X(1))
SET X(2)=X\60
SET X(3)=X-(60*X(2))
SET Y=$EXTRACT(100+X(1),2,3)_":"_$EXTRACT(100+X(2),2,3)_":"_$EXTRACT(100+X(3),2,3)
Q KILL RAX,X
QUIT
+1 ;
UPDATE ;Entry point for Update Rad/Nuc Med Exam Status option
+1 IF $ORDER(RACCESS(DUZ,""))=""
DO SETVARS^RAPSET1(0)
+2 IF $GET(RAIMGTY)=""
DO SETVARS^RAPSET1(1)
+3 ; didn't sign-on to an imaging location
IF $GET(RAIMGTY)=""
KILL XQUIT
QUIT
+4 DO ^RACNLU
IF "^"[X
GOTO UPQ
+5 IF $DATA(^RA(72,"AA",RAIMGTY,9,+RAST))
IF '$DATA(^XUSEC("RA MGR",DUZ))
WRITE !!?3,$CHAR(7),"You do not have the appropriate access privileges to act on completed exams."
GOTO UPDATE
+6 IF $DATA(^RA(72,"AA",RAIMGTY,0,+RAST))
WRITE !!?3,$CHAR(7),"Exam has been 'cancelled' therefore the status cannot be changed."
GOTO UPDATE
+7 ;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
+8 DO UP1
IF RAOR>0
Begin DoDot:1
+9 LOCK +^RADPT(RADFN,"DT",RADTI,"P",RACNI):$GET(DILOCKTM,3)
+10 NEW RAIEN
+11 SET RAIENS="+1,"_RACNI_","_RADTI_","_RADFN_","
+12 SET RAFDA(70.07,RAIENS,.01)="NOW"
+13 KILL RAERR
DO UPDATE^DIE("E","RAFDA","RAIEN","RAERR")
+14 KILL RAFDA,RAIENS
+15 IF $DATA(RAERR)
SET RAERR="Error in update of 70.07, .01 "_$GET(RAERR("DIERR",1,"TEXT",1))
KILL RAERR("DIERR")
LOCK -^RADPT(RADFN,"DT",RADTI,"P",RACNI)
KILL RAIEN
QUIT
+16 SET RAIENS=RAIEN(1)_","_RACNI_","_RADTI_","_RADFN_","
+17 SET RAFDA(70.07,RAIENS,2)="U"
+18 SET RAFDA(70.07,RAIENS,3)=$SELECT($GET(RADUZ):RADUZ,1:DUZ)
+19 DO FILE^DIE(,"RAFDA","RAERR")
+20 LOCK -^RADPT(RADFN,"DT",RADTI,"P",RACNI)
+21 IF $DATA(RAERR)
SET RAERR="Error in update of 70.07, 2,3 "_$GET(RAERR("DIERR",1,"TEXT",1))
KILL RAERR("DIERR")
End DoDot:1
UPQ KILL RAFDA,RAIENS
+1 KILL %,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($JOB,"RAEX"),C,DIPGM
QUIT
+2 ;
+3 ;Exam status updating and accompanying updates to status log, oe/rr
UP1 ;use this to flag when one alert has been sent
NEW RA8,RAEXEDT
SET RA8=0
+1 ;Line change for RA*5*82
+2 ;P18 if procedure changed in RAEDCN or RAEDPT sends XX message to CPRS if needed
SET RAEXEDT=$$CMPAFTR^RAO7XX(1)
+3 ; RA EDITCN and RA EDITPT should process this case only
+4 IF $DATA(RAOPT("EDITCN"))!($DATA(RAOPT("EDITPT")))
DO UP2
DO UPK
QUIT
+5 ; see if this case belongs to a printset
+6 IF '$DATA(RAPRTSET)
NEW RAPRTSET
IF '$DATA(RAMEMARR)
NEW RAMEMARR
+7 ;043099 always recalculate RAPRTSET
DO EN2^RAUTL20(.RAMEMARR)
+8 ; if not print set, then just process this case only
+9 IF 'RAPRTSET
DO UP2
DO UPK
QUIT
+10 ;case belongs to print set, so process all members of same print set
+11 NEW RACNISAV,RA7
+12 SET RACNISAV=RACNI
SET RA7=0
+13 FOR
SET RA7=$ORDER(RAMEMARR(RA7))
IF RA7=""
QUIT
SET RACNI=RA7
DO UP2
+14 SET RACNI=RACNISAV
+15 GOTO UPK
UP2 ;Remedy Call 124379 Patch *71 BAY/KAM Added next line
+1 ;Patch RA*5*82 next line commented out
+2 ;D:$G(RAHLTCPB)'=1 EXM^RAHLRPC
+3 ;
+4 SET DA(2)=RADFN
SET DA(1)=RADTI
SET DA=RACNI
SET DIE="^RADPT("_DA(2)_",""DT"","_DA(1)_",""P"","
+5 NEW RAAFTER,RABEFORE
+6 DO STUFF^RASTREQ1
IF RAOR<0
IF $DATA(RASN)
IF '$DATA(RAONLINE)&('$DATA(ZTQUEUED))
WRITE !?5,"...exam status remains '",RASN,"'."
KILL DIE,RACS,RAPRIT
Begin DoDot:1
+7 ; DO statement added by RA*5*82
IF $GET(RAEXEDT)
DO EXM^RAHLRPC
End DoDot:1
QUIT
+8 IF '$DATA(RAONLINE)&('$DATA(ZTQUEUED))
WRITE !?3,"...will now designate exam status as '",RASN,"'... for case no. ",$PIECE($GET(^RADPT(RADFN,"DT",RADTI,"P",RACNI,0)),U)
+9 ; S DR="3////"_RASTI_$S($P(RAMDV,"^",10):";75///^S X=$$MIDNGHT^RAUTL5($$NOW^XLFDT())",1:"")
+10 ; user duz could be in RADUZ, if session is from the Voice recognition
+11 ;S DR(2,70.05)=$S($P(RAMDV,"^",11)&('$D(ZTQUEUED)):".01;",1:"")_"2////"_RASTI_";3////"_$S($G(RADUZ):RADUZ,1:DUZ)
+12 ;D ^DIE
+13 LOCK +^RADPT(RADFN,"DT",RADTI,"P",RACNI):$GET(DILOCKTM,3)
+14 NEW RAIEN
+15 SET RAIENS=RACNI_","_RADTI_","_RADFN_","
+16 SET RAFDA(70.03,RAIENS,3)=RASTI
+17 KILL RAERR
DO FILE^DIE(,"RAFDA","RAERR")
+18 ;L - P18
IF $DATA(RAERR)
SET RAERR="Error in update of 70.03 "_$GET(RAERR("DIERR",1,"TEXT",1))
KILL RAERR("DIERR")
LOCK -^RADPT(RADFN,"DT",RADTI,"P",RACNI)
GOTO UP2K
+19 IF $PIECE(RAMDV,"^",10)
Begin DoDot:1
+20 NEW RAERR2
+21 SET RAIENS="+1,"_RACNI_","_RADTI_","_RADFN_","
+22 SET RAFDA(70.05,RAIENS,.01)=$$MIDNGHT^RAUTL5($$NOW^XLFDT())
+23 DO UPDATE^DIE(,"RAFDA","RAIEN","RAERR")
+24 KILL RAFDA,RAIENS
+25 IF $DATA(RAERR)
SET RAERR="Error in update of 70.05, .01 "_$GET(RAERR("DIERR",1,"TEXT",1))
KILL RAERR("DIERR")
+26 IF '$DATA(RAIEN(1))
QUIT
+27 IF $PIECE(RAMDV,"^",11)
IF ('$DATA(ZTQUEUED))
Begin DoDot:2
+28 SET DIE=DIE_RACNI_",""T"","
SET DA=RAIEN(1)
+29 SET DR=".01"
+30 DO ^DIE
End DoDot:2
+31 SET RAIENS=RAIEN(1)_","_RACNI_","_RADTI_","_RADFN_","
+32 SET RAFDA(70.05,RAIENS,2)=RASTI
+33 SET RAFDA(70.05,RAIENS,3)=$SELECT($GET(RADUZ):RADUZ,1:DUZ)
+34 KILL RAERR2
DO FILE^DIE(,"RAFDA","RAERR2")
+35 IF $DATA(RAERR2)
SET RAERR2="Error in update of 70.05 2,3 "_$GET(RAERR2("DIERR",1,"TEXT",1))
SET RAERR=$SELECT($DATA(RAERR):RAERR_";"_RAERR2,1:RAERR2)
End DoDot:1
+36 ;Patch RA*5*82 added next line send EXM message after status update, not before the update
+37 IF '$DATA(RAERR)
DO EXM^RAHLRPC
+38 LOCK -^RADPT(RADFN,"DT",RADTI,"P",RACNI)
+39 ;
UP2K KILL DE,DQ,DIE,DR,RAFDA,RAIENS
IF $DATA(RAERR)
KILL RACS,RAPRIT
IF $DATA(RAERR)
QUIT
IF '$DATA(RAONLINE)&('$DATA(ZTQUEUED))
WRITE !?10,"...exam status ",$SELECT($GET(RABEFORE)>$GET(RAAFTER):"backed down",1:"successfully updated"),"."
DO ^RAORDC
+1 IF RA8=0
IF $DATA(^RA(72,RASTI,"ALERT"))
IF $PIECE(^("ALERT"),"^")="y"
IF $$ORVR^RAORDU()=2.5
DO OERR
IF $$ORVR^RAORDU()'<3
DO OERR3
SET RA8=1
+2 IF $DATA(^RA(72,RASTI,0))
IF $PIECE(^(0),"^",3)>1
IF RACS'="Y"
IF $SELECT('$DATA(RAF5):1,$PIECE(^DIC(42,+RAF5,0),U,3)="D":1,1:0)
DO EN^RAUTL0
+3 KILL RACS,RAORDIFN,RAPRIT,RAF5
+4 QUIT
UPK KILL ORIFN,ORVP,ORNOTE,ORBPMSG,RACS,RAORDIFN,RAPRIT,RAF5
+1 QUIT
OERR ;Send Alert to OERR after pt examined
+1 SET ORVP=RADFN_";DPT("
SET ORBPMSG="Rad Pt Examined - "_$SELECT($DATA(^RAMIS(71,RAPRIT,0)):$EXTRACT($PIECE(^(0),"^"),1,24),1:"Unknown")
IF $DATA(^RAO(75.1,+RAORDIFN,0))
SET ORIFN=+$PIECE(^(0),"^",7)
SET ORNOTE(21)=$SELECT($DATA(ORIFN):1,1:"")
DO NOTE^ORX3
+2 QUIT
OERR3 ; Send RADIOLOGY PATIENT EXAMINED notification via oe/rr v3
+1 ; Called from UP1
+2 ;
+3 ; RADFN,RADTI,RACNI,RAPRIT must be defined
+4 IF '$DATA(RADFN)!('$DATA(RADTI))!('$DATA(RACNI))!('$DATA(RAPRIT))
QUIT
+5 ;
+6 NEW RAIENS,RAMSG,RAOIFN,RAOSTS,RAONODE,RADPTNDE,RAREQPHY
+7 SET RADPTNDE=$GET(^RADPT(RADFN,"DT",RADTI,"P",RACNI,0))
+8 ;file 75.1 ien
SET RAOIFN=$PIECE(RADPTNDE,U,11)
IF 'RAOIFN
QUIT
+9 SET RAONODE=$GET(^RAO(75.1,+RAOIFN,0))
+10 ;active exams only
SET RAOSTS=$PIECE(RAONODE,U,5)
IF RAOSTS'=6
QUIT
+11 ;file 100 ien
SET RAOIFN=$PIECE(RAONODE,U,7)
+12 ;ordering provider
SET RAREQPHY=+$PIECE(RADPTNDE,U,14)
+13 SET RAREQPHY(RAREQPHY)=""
+14 SET RAMSG="Imaging Pt Examined - "_$SELECT($DATA(^RAMIS(71,RAPRIT,0)):$EXTRACT($PIECE(^(0),U),1,24),1:"Unknown")
SET RAMSG=$EXTRACT(RAMSG,1,51)
+15 SET RAIENS=RADTI_"~"_RACNI
+16 ;
+17 ; oe parameters:
+18 ; ORN: notification id (#100.9 ien)
+19 ; | ORBDFN: patient id (#2 ien)
+20 ; | | ORNUM: order number (#100 ien)
+21 ; | | | ORBADUZ: recipient array
+22 ; | | | | ORBPMSG: message text
+23 ; | | | | | ORBPDATA exam dt~case iens
+24 ; | | | | | |
+25 DO EN^ORB3(21,RADFN,RAOIFN,.RAREQPHY,RAMSG,RAIENS)
+26 QUIT
+27 ;
+28 ;Called by many report programs. Sets RACRT() array containing all
+29 ;exam statuses that are to be included on the report. RACRT is set
+30 ;to the piece of the Exam Status File #72 record that corresponds
+31 ;to the report being generated.
CRIT FOR I=0:0
SET I=$ORDER(^RA(72,I))
IF 'I
QUIT
IF $DATA(^(I,.3))
IF $PIECE(^(.3),"^",RACRT)="y"
SET RACRT(I)=""
+1 QUIT