RAO7PC2 ;HISC/GJC-Part two for Return Narrative (EN3^RAO7PC1) ;8/18/08 09:47
;;5.0;Radiology/Nuclear Medicine;**1,11,14,16,22,27,45,75,56,95,97**;Mar 16, 1998;Build 6
;Supported IA #1571 ^LEX(757.01
;Supported IA #10104 UP^XLFSTR
;Supported IA #2055 EXTERNAL^DILFD
;Supported IA #10060 ^VA(200
CASE(Y) ; Retrieve exam data for specified inverse exam date range.
; 'Y'-> Exam node IEN
N RABNOR,RACNT,RAEXAM,RAI,RAIMPRES,RAINCLUD,RAOPRC,RAORD,RAPDIAG
N RAPIST,RAPIRE,RAPROC,RARDE,RADTI,RACNI,RADUPHX,RAREASDY
N RARPT,RARPTST,RARPTXT,RASBN,RASDIAG,RAVER,RAERRFLG,Z,Z1,Z2,RATMP
S RACNT=1
S RAEXAM(0)=$G(^RADPT(RADFN,"DT",RAINVXDT,"P",Y,0)) Q:RAEXAM(0)']""
S:$P(RAEXAM(0),"^",25)=2 RAPSET=1
S:RAPSET=1 ^TMP($J,"RAE2",RADFN,"PRINT_SET")="" ; xam set with same rpt
S RAPROC(0)=$G(^RAMIS(71,+$P(RAEXAM(0),"^",2),0))
S RAPROC=$S($P(RAPROC(0),"^")]"":$P(RAPROC(0),"^"),1:"Unknown")
S RAORD(0)=$G(^RAO(75.1,+$P(RAEXAM(0),"^",11),0))
S RAORD(7)=$P(RAORD(0),"^",7) ; CPRS order ien
S RAREASDY=$P($G(^RAO(75.1,+$P(RAEXAM(0),"^",11),.1)),"^") ;REASON FOR STUDY
S RAOPRC(0)=$G(^RAMIS(71,+$P(RAORD(0),"^",2),0))
S RAOPRC=$S($P(RAOPRC(0),"^")]"":$P(RAOPRC(0),"^"),1:"Unknown")
S RAPDIAG(0)=$G(^RA(78.3,+$P(RAEXAM(0),"^",13),0))
S RATMP=$$GET1^DIQ(757.01,$P($G(^RA(78.3,+$P(RAEXAM(0),U,13),0)),U,6),.01)
S RAPDIAG=$P(RAPDIAG(0),"^")_$S(RATMP="":"",1:" ("_RATMP_")")
S RARPT=+$P(RAEXAM(0),"^",17)
; RARPTST="NO REPORT" if no ^RARPT(ien) OR no data for Report Status
S RARPT(0)=$G(^RARPT(RARPT,0)),RARPTST=$$UL^RAO7PC1A($$RSTAT^RAO7PC1A())
; set the following flag variable: RAINCLUD
; RAINCLUD=1 includes V, R, EF <-- patch 95
S RAINCLUD=$S("RVE"[$E(RARPTST):1,1:0)
I $E(RARPTST)="V",(RAPSET'<0) D
. S RAVER=$P(RARPT(0),"^",9),RASBN=$P($G(^VA(200,+RAVER,20)),"^",2)
. S ^TMP($J,"RAE2",RADFN,Y,RAPROC,"V")=RAVER_"^"_RASBN
. Q
S RABNOR=$$UP^XLFSTR($P(RAPDIAG(0),"^",4)) S:RABNOR'="Y" RABNOR=""
I RAPDIAG]"",(RAINCLUD),(RAPSET'<0) D ; if diag & verif'd or released/unverif'd & first pass if part of xam set (many xams - one rpt)
. S ^TMP($J,"RAE2",RADFN,Y,RAPROC,"D",RACNT)=RAPDIAG
. Q
S ^TMP($J,"RAE2",RADFN,Y,RAPROC,"RFS")=RAREASDY ;REASON FOR STUDY
; 1st, get clnhist from file70. 2nd, get addl clnhist form file74
; 1st:
I +$O(^RADPT(RADFN,"DT",RAINVXDT,"P",Y,"H",0)) D
. N RAI S (RAI,Z)=0
. F S Z=$O(^RADPT(RADFN,"DT",RAINVXDT,"P",Y,"H",Z)) Q:Z'>0 D
.. S RAI=RAI+1
.. S ^TMP($J,"RAE2",RADFN,Y,RAPROC,"H",RAI)=$G(^RADPT(RADFN,"DT",RAINVXDT,"P",Y,"H",Z,0))
.. Q
. Q
;2nd:
S RADTI=RAINVXDT,RACNI=Y D CHKDUPHX^RART1 ;chk if file74 clnhist is dupl
I 'RADUPHX,$O(^RARPT(RARPT,"H",0)) S Z="H" D RPTXT(RARPT,Z)
;
I +$O(^RADPT(RADFN,"DT",RAINVXDT,"P",Y,"M",0)) D ; save modifiers
. N RAI S (RAI,Z)=0
. F S Z=$O(^RADPT(RADFN,"DT",RAINVXDT,"P",Y,"M",Z)) Q:Z'>0 D
.. S RAI=RAI+1
.. S ^TMP($J,"RAE2",RADFN,Y,RAPROC,"M",RAI)=$P($G(^RAMIS(71.2,+$G(^RADPT(RADFN,"DT",RAINVXDT,"P",Y,"M",Z,0)),0)),"^")
.. Q
. Q
I +$O(^RADPT(RADFN,"DT",RAINVXDT,"P",Y,"DX",0)),(RAPSET'<0) D
. S Z=0 F S Z=$O(^RADPT(RADFN,"DT",RAINVXDT,"P",Y,"DX",Z)) Q:Z'>0 D
.. S RASDIAG=+$G(^RADPT(RADFN,"DT",RAINVXDT,"P",Y,"DX",Z,0))
.. S RASDIAG(0)=$G(^RA(78.3,RASDIAG,0))
.. S RATMP=$$GET1^DIQ(757.01,$P($G(^RA(78.3,+RASDIAG,0)),U,6),.01)
.. S RASDIAG(1)=$P(RASDIAG(0),"^")_$S(RATMP="":"",1:" ("_RATMP_")")
.. I RASDIAG(1)]"",(RAINCLUD) D
... S RACNT=RACNT+1,^TMP($J,"RAE2",RADFN,Y,RAPROC,"D",RACNT)=RASDIAG(1)
... I RABNOR'="Y" D
.... S RABNOR=$$UP^XLFSTR($P(RASDIAG(0),"^",4)) S:RABNOR'="Y" RABNOR=""
.... Q
... Q
.. Q
. Q
I RAINCLUD,(RAPSET'<0) D
. I +$O(^RARPT(RARPT,"I",0)) S Z="I" D RPTXT(RARPT,Z)
. I +$O(^RARPT(RARPT,"R",0)) S Z="R" D RPTXT(RARPT,Z)
. Q
I $P(RAEXAM(0),"^",25) S ^TMP($J,"RAE2",RADFN,"ORD")=RAOPRC
I '$P(RAEXAM(0),"^",25) S ^TMP($J,"RAE2",RADFN,"ORD",Y)=RAOPRC
;
; Check to see if amended report
I RAPSET'<0,+$O(^RARPT(RARPT,"ERR",0)) S RAERRFLG="A"
;
S:RAPSET'<0 ^TMP($J,"RAE2",RADFN,Y,RAPROC)=RARPTST_"^"_$G(RABNOR)_"^"_$G(RAORD(7))_"^"_$G(RAERRFLG)
S:RAPSET<0 ^TMP($J,"RAE2",RADFN,Y,RAPROC)=""
S:RAPSET=1 RAPSET=-1
;
I RARPTST'="No Report" D
.; Add Prim Int Staff, Prim Int Resident & Reported Date
.S RAPIST=$P(RAEXAM(0),"^",15)
.S RAPIRE=$P(RAEXAM(0),"^",12)
.S RARDE=$P(RARPT(0),"^",8)
.S ^TMP($J,"RAE2",RADFN,Y,RAPROC,"P")=RAPIST_"^"_RAPIRE_"^"_RARDE
;If contrast media was involved in the exam pass that information.
I +$O(^RADPT(RADFN,"DT",RAINVXDT,"P",Y,"CM",0)) S (RACNT,RAI)=0 D
.F S RAI=$O(^RADPT(RADFN,"DT",RAINVXDT,"P",Y,"CM",RAI)) Q:'RAI D
..S RACNT=RACNT+1
..S RAI(0)=$G(^RADPT(RADFN,"DT",RAINVXDT,"P",Y,"CM",RAI,0))
..S ^TMP($J,"RAE2",RADFN,Y,RAPROC,"CM",RACNT)=$P(RAI(0),U)_"^"_$$EXTERNAL^DILFD(70.3225,.01,"",$P(RAI(0),U))
..Q
Q
;
RPTXT(RARPT,Z) ; Retrieve report text & store in ^TMP
; 'RARPT' -> Report IEN
; 'Z' -> "I":Impression Text <> "R":Report Text
S (Z1,Z2)=0
;file 74's "H" nodes are now additional clinical history
I Z="H" S Z2=$O(^TMP($J,"RAE2",RADFN,Y,RAPROC,Z,""),-1) I $O(^RARPT(RARPT,Z,Z1)) S Z2=Z2+1,^TMP($J,"RAE2",RADFN,Y,RAPROC,Z,Z2)="Additional Clinical History:"
F S Z1=$O(^RARPT(RARPT,Z,Z1)) Q:Z1'>0 D
. S Z1(0)=$G(^RARPT(RARPT,Z,Z1,0)),Z2=Z2+1
. S ^TMP($J,"RAE2",RADFN,Y,RAPROC,Z,Z2)=Z1(0)
. Q
Q
;
CLIN(DFN,PROCLIST) ;Radiology and Clinical Reminders API
;
; Created by Cameron Taylor March 1999
;
; This API recieves a patient and a list of procedures. For each
; Procedure, the details of the last 'complete' procedure and/or the
; last 'cancelled' & 'in progress' procedure details and returns them
; in ^TMP($J,"RADPROC"
N XX,PROC,DATE,STATUS,PROVIDER,EXAM,X,Y,EXAMIEN,RADPTIEN,ORDER,SUCCESS
;
S DFN=$G(DFN) ; Patient Name
S PROCLIST=$G(PROCLIST) ; List of Procedures (separated by '^')
K ^TMP($J,"RADPROC")
;
S RADPTIEN=$O(^RADPT("B",DFN,""))
I (RADPTIEN="")!(RADPTIEN=0) D Q
.S ^TMP($J,"RADPROC")="Invalid/Unknown Radiology Patient"
;
F XX=1:1 S PROC=$P(PROCLIST,U,XX) Q:PROC="" D
.S SUCCESS=0 ; Quit searching if SUCCESS=3 (comp, canc & in prog)
.S DATE=0 F S DATE=$O(^RADPT(RADPTIEN,"DT",DATE)) Q:DATE'?7N1".".N!(SUCCESS=3) D
..S EXAMIEN=0 F S EXAMIEN=$O(^RADPT(RADPTIEN,"DT",DATE,"P",EXAMIEN)) Q:'EXAMIEN!(SUCCESS=3) D
...S EXAM=$G(^RADPT(RADPTIEN,"DT",DATE,"P",EXAMIEN,0))
...Q:$P(EXAM,U,2)'=PROC
...;
...; Continue, get STATUS and ORDER
...; (0 is cancelled, 1-8 in progress & 9 is COMPLETE)
...; (ignore if null)
...;
...S STATUS=$P(EXAM,U,3)
...I STATUS'="" D
....S ORDER=$P(^RA(72,STATUS,0),U,3)
....S STATUS=$P(^RA(72,STATUS,0),U) ; description
...;
...; Only one of each type (ORDER)
...;
...Q:ORDER=""
...I ORDER=0 Q:$D(^TMP($J,"RADPROC",RADPTIEN,PROC,"CANCELLED")) S ORDER="CANCELLED"
...I ORDER=9 Q:$D(^TMP($J,"RADPROC",RADPTIEN,PROC,"COMPLETE")) S ORDER="COMPLETE"
...I ORDER<9,ORDER>0 Q:$D(^TMP($J,"RADPROC",RADPTIEN,PROC,"IN PROGRESS")) S ORDER="IN PROGRESS"
...;
...; Now for the PROVIDER. Check PRIMARY INTERPRETING STAFF
...; if none, then default to PRIMARY INTERPRETING RESIDENT.
...;
...S PROVIDER=$P(EXAM,U,15)
...S:PROVIDER="" PROVIDER=$P(EXAM,U,12)
...S:PROVIDER'="" PROVIDER=$P($G(^VA(200,PROVIDER,0)),U,1) ; description
...;
...; Create return info. on ^TMP (1st manipulate DATE)
...;
...S Y=9999999.9999-DATE
...S ^TMP($J,"RADPROC",RADPTIEN,PROC,ORDER)=Y_U_STATUS_U_PROVIDER
...S SUCCESS=SUCCESS+1
.;
.; Finished searching Patient file. Any Procedures with no activity?
.;
.I '$D(^TMP($J,"RADPROC",RADPTIEN,PROC)) S ^TMP($J,"RADPROC",RADPTIEN,PROC,"NONE")=""
Q
;
RAO7PC2 ;HISC/GJC-Part two for Return Narrative (EN3^RAO7PC1) ;8/18/08 09:47
+1 ;;5.0;Radiology/Nuclear Medicine;**1,11,14,16,22,27,45,75,56,95,97**;Mar 16, 1998;Build 6
+2 ;Supported IA #1571 ^LEX(757.01
+3 ;Supported IA #10104 UP^XLFSTR
+4 ;Supported IA #2055 EXTERNAL^DILFD
+5 ;Supported IA #10060 ^VA(200
CASE(Y) ; Retrieve exam data for specified inverse exam date range.
+1 ; 'Y'-> Exam node IEN
+2 NEW RABNOR,RACNT,RAEXAM,RAI,RAIMPRES,RAINCLUD,RAOPRC,RAORD,RAPDIAG
+3 NEW RAPIST,RAPIRE,RAPROC,RARDE,RADTI,RACNI,RADUPHX,RAREASDY
+4 NEW RARPT,RARPTST,RARPTXT,RASBN,RASDIAG,RAVER,RAERRFLG,Z,Z1,Z2,RATMP
+5 SET RACNT=1
+6 SET RAEXAM(0)=$GET(^RADPT(RADFN,"DT",RAINVXDT,"P",Y,0))
IF RAEXAM(0)']""
QUIT
+7 IF $PIECE(RAEXAM(0),"^",25)=2
SET RAPSET=1
+8 ; xam set with same rpt
IF RAPSET=1
SET ^TMP($JOB,"RAE2",RADFN,"PRINT_SET")=""
+9 SET RAPROC(0)=$GET(^RAMIS(71,+$PIECE(RAEXAM(0),"^",2),0))
+10 SET RAPROC=$SELECT($PIECE(RAPROC(0),"^")]"":$PIECE(RAPROC(0),"^"),1:"Unknown")
+11 SET RAORD(0)=$GET(^RAO(75.1,+$PIECE(RAEXAM(0),"^",11),0))
+12 ; CPRS order ien
SET RAORD(7)=$PIECE(RAORD(0),"^",7)
+13 ;REASON FOR STUDY
SET RAREASDY=$PIECE($GET(^RAO(75.1,+$PIECE(RAEXAM(0),"^",11),.1)),"^")
+14 SET RAOPRC(0)=$GET(^RAMIS(71,+$PIECE(RAORD(0),"^",2),0))
+15 SET RAOPRC=$SELECT($PIECE(RAOPRC(0),"^")]"":$PIECE(RAOPRC(0),"^"),1:"Unknown")
+16 SET RAPDIAG(0)=$GET(^RA(78.3,+$PIECE(RAEXAM(0),"^",13),0))
+17 SET RATMP=$$GET1^DIQ(757.01,$PIECE($GET(^RA(78.3,+$PIECE(RAEXAM(0),U,13),0)),U,6),.01)
+18 SET RAPDIAG=$PIECE(RAPDIAG(0),"^")_$SELECT(RATMP="":"",1:" ("_RATMP_")")
+19 SET RARPT=+$PIECE(RAEXAM(0),"^",17)
+20 ; RARPTST="NO REPORT" if no ^RARPT(ien) OR no data for Report Status
+21 SET RARPT(0)=$GET(^RARPT(RARPT,0))
SET RARPTST=$$UL^RAO7PC1A($$RSTAT^RAO7PC1A())
+22 ; set the following flag variable: RAINCLUD
+23 ; RAINCLUD=1 includes V, R, EF <-- patch 95
+24 SET RAINCLUD=$SELECT("RVE"[$EXTRACT(RARPTST):1,1:0)
+25 IF $EXTRACT(RARPTST)="V"
IF (RAPSET'<0)
Begin DoDot:1
+26 SET RAVER=$PIECE(RARPT(0),"^",9)
SET RASBN=$PIECE($GET(^VA(200,+RAVER,20)),"^",2)
+27 SET ^TMP($JOB,"RAE2",RADFN,Y,RAPROC,"V")=RAVER_"^"_RASBN
+28 QUIT
End DoDot:1
+29 SET RABNOR=$$UP^XLFSTR($PIECE(RAPDIAG(0),"^",4))
IF RABNOR'="Y"
SET RABNOR=""
+30 ; if diag & verif'd or released/unverif'd & first pass if part of xam set (many xams - one rpt)
IF RAPDIAG]""
IF (RAINCLUD)
IF (RAPSET'<0)
Begin DoDot:1
+31 SET ^TMP($JOB,"RAE2",RADFN,Y,RAPROC,"D",RACNT)=RAPDIAG
+32 QUIT
End DoDot:1
+33 ;REASON FOR STUDY
SET ^TMP($JOB,"RAE2",RADFN,Y,RAPROC,"RFS")=RAREASDY
+34 ; 1st, get clnhist from file70. 2nd, get addl clnhist form file74
+35 ; 1st:
+36 IF +$ORDER(^RADPT(RADFN,"DT",RAINVXDT,"P",Y,"H",0))
Begin DoDot:1
+37 NEW RAI
SET (RAI,Z)=0
+38 FOR
SET Z=$ORDER(^RADPT(RADFN,"DT",RAINVXDT,"P",Y,"H",Z))
IF Z'>0
QUIT
Begin DoDot:2
+39 SET RAI=RAI+1
+40 SET ^TMP($JOB,"RAE2",RADFN,Y,RAPROC,"H",RAI)=$GET(^RADPT(RADFN,"DT",RAINVXDT,"P",Y,"H",Z,0))
+41 QUIT
End DoDot:2
+42 QUIT
End DoDot:1
+43 ;2nd:
+44 ;chk if file74 clnhist is dupl
SET RADTI=RAINVXDT
SET RACNI=Y
DO CHKDUPHX^RART1
+45 IF 'RADUPHX
IF $ORDER(^RARPT(RARPT,"H",0))
SET Z="H"
DO RPTXT(RARPT,Z)
+46 ;
+47 ; save modifiers
IF +$ORDER(^RADPT(RADFN,"DT",RAINVXDT,"P",Y,"M",0))
Begin DoDot:1
+48 NEW RAI
SET (RAI,Z)=0
+49 FOR
SET Z=$ORDER(^RADPT(RADFN,"DT",RAINVXDT,"P",Y,"M",Z))
IF Z'>0
QUIT
Begin DoDot:2
+50 SET RAI=RAI+1
+51 SET ^TMP($JOB,"RAE2",RADFN,Y,RAPROC,"M",RAI)=$PIECE($GET(^RAMIS(71.2,+$GET(^RADPT(RADFN,"DT",RAINVXDT,"P",Y,"M",Z,0)),0)),"^")
+52 QUIT
End DoDot:2
+53 QUIT
End DoDot:1
+54 IF +$ORDER(^RADPT(RADFN,"DT",RAINVXDT,"P",Y,"DX",0))
IF (RAPSET'<0)
Begin DoDot:1
+55 SET Z=0
FOR
SET Z=$ORDER(^RADPT(RADFN,"DT",RAINVXDT,"P",Y,"DX",Z))
IF Z'>0
QUIT
Begin DoDot:2
+56 SET RASDIAG=+$GET(^RADPT(RADFN,"DT",RAINVXDT,"P",Y,"DX",Z,0))
+57 SET RASDIAG(0)=$GET(^RA(78.3,RASDIAG,0))
+58 SET RATMP=$$GET1^DIQ(757.01,$PIECE($GET(^RA(78.3,+RASDIAG,0)),U,6),.01)
+59 SET RASDIAG(1)=$PIECE(RASDIAG(0),"^")_$SELECT(RATMP="":"",1:" ("_RATMP_")")
+60 IF RASDIAG(1)]""
IF (RAINCLUD)
Begin DoDot:3
+61 SET RACNT=RACNT+1
SET ^TMP($JOB,"RAE2",RADFN,Y,RAPROC,"D",RACNT)=RASDIAG(1)
+62 IF RABNOR'="Y"
Begin DoDot:4
+63 SET RABNOR=$$UP^XLFSTR($PIECE(RASDIAG(0),"^",4))
IF RABNOR'="Y"
SET RABNOR=""
+64 QUIT
End DoDot:4
+65 QUIT
End DoDot:3
+66 QUIT
End DoDot:2
+67 QUIT
End DoDot:1
+68 IF RAINCLUD
IF (RAPSET'<0)
Begin DoDot:1
+69 IF +$ORDER(^RARPT(RARPT,"I",0))
SET Z="I"
DO RPTXT(RARPT,Z)
+70 IF +$ORDER(^RARPT(RARPT,"R",0))
SET Z="R"
DO RPTXT(RARPT,Z)
+71 QUIT
End DoDot:1
+72 IF $PIECE(RAEXAM(0),"^",25)
SET ^TMP($JOB,"RAE2",RADFN,"ORD")=RAOPRC
+73 IF '$PIECE(RAEXAM(0),"^",25)
SET ^TMP($JOB,"RAE2",RADFN,"ORD",Y)=RAOPRC
+74 ;
+75 ; Check to see if amended report
+76 IF RAPSET'<0
IF +$ORDER(^RARPT(RARPT,"ERR",0))
SET RAERRFLG="A"
+77 ;
+78 IF RAPSET'<0
SET ^TMP($JOB,"RAE2",RADFN,Y,RAPROC)=RARPTST_"^"_$GET(RABNOR)_"^"_$GET(RAORD(7))_"^"_$GET(RAERRFLG)
+79 IF RAPSET<0
SET ^TMP($JOB,"RAE2",RADFN,Y,RAPROC)=""
+80 IF RAPSET=1
SET RAPSET=-1
+81 ;
+82 IF RARPTST'="No Report"
Begin DoDot:1
+83 ; Add Prim Int Staff, Prim Int Resident & Reported Date
+84 SET RAPIST=$PIECE(RAEXAM(0),"^",15)
+85 SET RAPIRE=$PIECE(RAEXAM(0),"^",12)
+86 SET RARDE=$PIECE(RARPT(0),"^",8)
+87 SET ^TMP($JOB,"RAE2",RADFN,Y,RAPROC,"P")=RAPIST_"^"_RAPIRE_"^"_RARDE
End DoDot:1
+88 ;If contrast media was involved in the exam pass that information.
+89 IF +$ORDER(^RADPT(RADFN,"DT",RAINVXDT,"P",Y,"CM",0))
SET (RACNT,RAI)=0
Begin DoDot:1
+90 FOR
SET RAI=$ORDER(^RADPT(RADFN,"DT",RAINVXDT,"P",Y,"CM",RAI))
IF 'RAI
QUIT
Begin DoDot:2
+91 SET RACNT=RACNT+1
+92 SET RAI(0)=$GET(^RADPT(RADFN,"DT",RAINVXDT,"P",Y,"CM",RAI,0))
+93 SET ^TMP($JOB,"RAE2",RADFN,Y,RAPROC,"CM",RACNT)=$PIECE(RAI(0),U)_"^"_$$EXTERNAL^DILFD(70.3225,.01,"",$PIECE(RAI(0),U))
+94 QUIT
End DoDot:2
End DoDot:1
+95 QUIT
+96 ;
RPTXT(RARPT,Z) ; Retrieve report text & store in ^TMP
+1 ; 'RARPT' -> Report IEN
+2 ; 'Z' -> "I":Impression Text <> "R":Report Text
+3 SET (Z1,Z2)=0
+4 ;file 74's "H" nodes are now additional clinical history
+5 IF Z="H"
SET Z2=$ORDER(^TMP($JOB,"RAE2",RADFN,Y,RAPROC,Z,""),-1)
IF $ORDER(^RARPT(RARPT,Z,Z1))
SET Z2=Z2+1
SET ^TMP($JOB,"RAE2",RADFN,Y,RAPROC,Z,Z2)="Additional Clinical History:"
+6 FOR
SET Z1=$ORDER(^RARPT(RARPT,Z,Z1))
IF Z1'>0
QUIT
Begin DoDot:1
+7 SET Z1(0)=$GET(^RARPT(RARPT,Z,Z1,0))
SET Z2=Z2+1
+8 SET ^TMP($JOB,"RAE2",RADFN,Y,RAPROC,Z,Z2)=Z1(0)
+9 QUIT
End DoDot:1
+10 QUIT
+11 ;
CLIN(DFN,PROCLIST) ;Radiology and Clinical Reminders API
+1 ;
+2 ; Created by Cameron Taylor March 1999
+3 ;
+4 ; This API recieves a patient and a list of procedures. For each
+5 ; Procedure, the details of the last 'complete' procedure and/or the
+6 ; last 'cancelled' & 'in progress' procedure details and returns them
+7 ; in ^TMP($J,"RADPROC"
+8 NEW XX,PROC,DATE,STATUS,PROVIDER,EXAM,X,Y,EXAMIEN,RADPTIEN,ORDER,SUCCESS
+9 ;
+10 ; Patient Name
SET DFN=$GET(DFN)
+11 ; List of Procedures (separated by '^')
SET PROCLIST=$GET(PROCLIST)
+12 KILL ^TMP($JOB,"RADPROC")
+13 ;
+14 SET RADPTIEN=$ORDER(^RADPT("B",DFN,""))
+15 IF (RADPTIEN="")!(RADPTIEN=0)
Begin DoDot:1
+16 SET ^TMP($JOB,"RADPROC")="Invalid/Unknown Radiology Patient"
End DoDot:1
QUIT
+17 ;
+18 FOR XX=1:1
SET PROC=$PIECE(PROCLIST,U,XX)
IF PROC=""
QUIT
Begin DoDot:1
+19 ; Quit searching if SUCCESS=3 (comp, canc & in prog)
SET SUCCESS=0
+20 SET DATE=0
FOR
SET DATE=$ORDER(^RADPT(RADPTIEN,"DT",DATE))
IF DATE'?7N1".".N!(SUCCESS=3)
QUIT
Begin DoDot:2
+21 SET EXAMIEN=0
FOR
SET EXAMIEN=$ORDER(^RADPT(RADPTIEN,"DT",DATE,"P",EXAMIEN))
IF 'EXAMIEN!(SUCCESS=3)
QUIT
Begin DoDot:3
+22 SET EXAM=$GET(^RADPT(RADPTIEN,"DT",DATE,"P",EXAMIEN,0))
+23 IF $PIECE(EXAM,U,2)'=PROC
QUIT
+24 ;
+25 ; Continue, get STATUS and ORDER
+26 ; (0 is cancelled, 1-8 in progress & 9 is COMPLETE)
+27 ; (ignore if null)
+28 ;
+29 SET STATUS=$PIECE(EXAM,U,3)
+30 IF STATUS'=""
Begin DoDot:4
+31 SET ORDER=$PIECE(^RA(72,STATUS,0),U,3)
+32 ; description
SET STATUS=$PIECE(^RA(72,STATUS,0),U)
End DoDot:4
+33 ;
+34 ; Only one of each type (ORDER)
+35 ;
+36 IF ORDER=""
QUIT
+37 IF ORDER=0
IF $DATA(^TMP($JOB,"RADPROC",RADPTIEN,PROC,"CANCELLED"))
QUIT
SET ORDER="CANCELLED"
+38 IF ORDER=9
IF $DATA(^TMP($JOB,"RADPROC",RADPTIEN,PROC,"COMPLETE"))
QUIT
SET ORDER="COMPLETE"
+39 IF ORDER<9
IF ORDER>0
IF $DATA(^TMP($JOB,"RADPROC",RADPTIEN,PROC,"IN PROGRESS"))
QUIT
SET ORDER="IN PROGRESS"
+40 ;
+41 ; Now for the PROVIDER. Check PRIMARY INTERPRETING STAFF
+42 ; if none, then default to PRIMARY INTERPRETING RESIDENT.
+43 ;
+44 SET PROVIDER=$PIECE(EXAM,U,15)
+45 IF PROVIDER=""
SET PROVIDER=$PIECE(EXAM,U,12)
+46 ; description
IF PROVIDER'=""
SET PROVIDER=$PIECE($GET(^VA(200,PROVIDER,0)),U,1)
+47 ;
+48 ; Create return info. on ^TMP (1st manipulate DATE)
+49 ;
+50 SET Y=9999999.9999-DATE
+51 SET ^TMP($JOB,"RADPROC",RADPTIEN,PROC,ORDER)=Y_U_STATUS_U_PROVIDER
+52 SET SUCCESS=SUCCESS+1
End DoDot:3
End DoDot:2
+53 ;
+54 ; Finished searching Patient file. Any Procedures with no activity?
+55 ;
+56 IF '$DATA(^TMP($JOB,"RADPROC",RADPTIEN,PROC))
SET ^TMP($JOB,"RADPROC",RADPTIEN,PROC,"NONE")=""
End DoDot:1
+57 QUIT
+58 ;