RAO7RON1 ;HISC/GJC,FPT-Request message from OE/RR. (frontdoor) ; 7/26/05 2:08pm
;;5.0;Radiology/Nuclear Medicine;**69,75,98**;Mar 16, 1998;Build 2
;
;------------------------- Variable List -------------------------------
; RADATA=HL7 data minus seg. hdr RAHDR=Segment header
; RAHLFS="|" RAMSG=HL7 message passed in
; RAOBR12=danger code RAOBR18=modifier
; RAOBR19=Img. Loc. pntr (79.1) RAOBR30=trans. mode
; RAOBR31=Reason for Study RAOBX2=format of observ. value
; RAOBR4=univ. trans. mode RAOBX5=observ. value
; RAOBX3=observ. ID RAORC10=entered by (200
; RAORC1=order control RAORC15=order effective D/T
; RAORC12=ordering provider (200) RAORC2=placer order #_"^OR"
; RAORC16=order control reason RAORC7=start dt/freq. of service
; RAORC3=filler order #_"^RA" RAPID5=patient name (2)
; RAPID3=patient ID RAPV12=patient class
; RAPV119=visit # RASEG=message seg. including header
; RAPV13=patient location (44)
; ----------------------------------------------------------------------
;
OBR ; breakdown the 'OBR' segment
S RAOBR4=$P(RADATA,RAHLFS,4)
F I=1:1:$L(RAOBR4,RAECH(1)) S RAOBR4(I)=$P(RAOBR4,RAECH(1),I)
I RAOBR4(1)'="" S RACPTIEN=+$O(^ICPT("B",RAOBR4(1),0)) S:'RACPTIEN RAERR=8 Q:RAERR ;RA*5*69
S RAERR=$$EN2^RAO7VLD(71,+RAOBR4(4),RAOBR4(5)) S:RAERR RAERR=8 Q:RAERR
I $$UP^XLFSTR($P($G(^RAMIS(71,+RAOBR4(4),0)),"^",6))="P" D Q:RAERR
. S RAERR=$$EN6^RAO7VLD(+RAOBR4(4)) S:RAERR RAERR=32
. Q
I RAOBR4(1)'="" S:'$D(^RAMIS(71,"D",RACPTIEN,+RAOBR4(4))) RAERR=8 Q:RAERR ;RA*5*69
S RAOBR4(4,"I-TYPE")=+$P($G(^RAMIS(71,+RAOBR4(4),0)),"^",12)
S RANEW(75.1,"+1,",2)=RAOBR4(4)
S RAIT=$P(^RAMIS(71,+RAOBR4(4),0),U,12)
S RAERR=$$EN3^RAO7VLD(79.2,RAIT) Q:RAERR
S RANEW(75.1,"+1,",3)=RAIT
S RAOBR12=$P(RADATA,RAHLFS,12)
S RAOBR12=$S($E(RAOBR12)="":"n","yYiI"[$E(RAOBR12):"y",1:"n")
S RAERR=$$EN1^RAO7VLD(75.1,24,"E",RAOBR12,"RASULT","") S:RAERR RAERR=10 Q:RAERR
S RANEW(75.1,"+1,",24)=RAOBR12
S RAOBR18=$P(RADATA,RAHLFS,18)
N RASERIES,RAIMAG
F I=1:1:$L(RAOBR18,RAECH(2)) S:$L($P(RAOBR18,RAECH(2),I))>0 RAOBR18(I)=$P(RAOBR18,RAECH(2),I)
S I=0 F S I=$O(RAOBR18(I)) Q:I'>0 D Q:RAERR
. S RAMODIEN=+$O(^RAMIS(71.2,"B",RAOBR18(I),0))
. S:'RAMODIEN RAERR=11 Q:RAERR
. S RAIMAG=$P($G(^RAMIS(71,+RAOBR4(4),0)),U,12) ; type of imaging
. S:'$D(^RAMIS(71.2,"AB",RAIMAG,RAMODIEN)) RAERR=33 Q:RAERR
. S RASERIES=$S($P($G(^RAMIS(71,+RAOBR4(4),0)),"^",6)="S":1,1:0)
. S:RASERIES&($P($G(^RAMIS(71.2,RAMODIEN,0)),U,2)]"") RAERR=34 Q:RAERR
. S RAPLCHLD=RAPLCHLD+1
. S RANEW(75.1125,"+"_RAPLCHLD_",+1,",.01)=RAMODIEN
. Q
S RAOBR19=$P(RADATA,RAHLFS,19),RAOBR19(1)=$P(RAOBR19,U,1)
S RAOBR19(2)=$P(RAOBR19,U,2),RAOBR19(3)=+RAOBR19(1)
I RAOBR19(3) D Q:RAERR
. S RAOBR19(3,"I-TYPE")=+$P($G(^RA(79.1,+RAOBR19(3),0)),"^",6)
. I RAOBR4(4,"I-TYPE")'=RAOBR19(3,"I-TYPE") S RAERR=31
. Q
S RANEW(75.1,"+1,",20)=$S(RAOBR19(3)>0:RAOBR19(3),1:"")
S X=$P(RADATA,RAHLFS,30)
S RAOBR30=$S(X="CART":"s",X="PORT":"p",X="WALK":"a",X="WHLC":"w",1:"")
I RAOBR30']"" S RAERR=13
S:'RAERR RAERR=$$EN1^RAO7VLD(75.1,19,"E",RAOBR30,"RASULT","")
S:RAERR RAERR=13 Q:RAERR
S RANEW(75.1,"+1,",19)=RAOBR30
;--- Reason for Study P75 ---
;CPRS will not pass 'Reason for Study' data until OR*3.0*243
;(GUI CPRS V27) is released. Define a default Reason for Study
I '$$PATCH^XPDUTL("OR*3.0*243") S RAOBR31="See Clinical History:"
E D Q:RAERR ;CPRS V27 is installed
.S RAOBR31=$P($P(RADATA,RAHLFS,31),RAECH(1),2)
.S:RAOBR31="" RAERR=38 Q:RAERR
.S RAERR=$$EN1^RAO7VLD(75.1,1.1,"E",RAOBR31,"RASULT","")
.S:RAERR RAERR=39
.Q
S RAOBR31=$TR(RAOBR31,$C(10)," ") ;strip 'line feed' - P98
S RAOBR31=$TR(RAOBR31,$C(13)," ") ;strip 'carriage return' - P98
S:'RAERR RANEW(75.1,"+1,",1.1)=RAOBR31
K RAOBR31
Q
OBX ; breakdown the 'OBX' segment
S RAOBX2=$P(RADATA,RAHLFS,2)
S RAERR=$S(RAOBX2="TX":0,RAOBX2="CE":0,RAOBX2="TS":0,1:1) Q:RAERR=17
S RAOBX3=$P(RADATA,RAHLFS,3)
S RAOBX5=$P(RADATA,RAHLFS,5)
F I=1:1:$L(RAOBX3,RAECH(1)) S RAOBX3(I)=$P(RAOBX3,RAECH(1),I)
S X=RAOBX3(2) D UPPER^RAUTL4 S RAOBX3(2)=Y
;
;P75 check to see if CLINICAL HISTORY data is passed. If data is passed, and not yet
;determined if valid continue to check for validity until:
;1-valid data is found
;2-no data left to validate
I RAOBX3(1)=2000.02 D
.;check if a null value is sent for CLINICAL HISTORY which is
.;possible if the CPRS user does not enter a CLINICAL HISTORY
.I RAOBX5="",$P(RACLIN,U)'=1 Q
.;now if data was sent (RAOBX5'="") set the data received from CPRS flag
.S $P(RACLIN,U)=1
.;now that we know the CPRS user intended to send CLINICAL HISTORY data
.;radiology has to validate the format of that data. $$EN4^RAO7VLD(str)
.;returns 1 if the data passed in was valid, else 0. Once we establish
.;that valid data has been sent, all subsequent data is accepted, valid
.;or not.
.S:$$EN4^RAO7VLD(RAOBX5) $P(RACLIN,U,2)=1
.;now, if the current character string or any other character string
.;of data representing the CLINICAL HISTORY has been accepted as valid
.;($P(RACLIN,U,2)=1) save the character string
.I $P(RACLIN,U,2)=1 S RAWP=RAWP+1,^TMP("RAWP",$J,RAWP)=RAOBX5
;
I RAOBX3(1)=2000.33 D Q:RAERR
.S RAERR=$$EN1^RAO7VLD(75.1,13,"E",RAOBX5,"RASULT","") S:RAERR RAERR=14 Q:RAERR
.S RAPREG=$E(RAOBX5),RAPREG=$S(RAPREG="N"!(RAPREG="n"):"n",RAPREG="Y"!(RAPREG="y"):"y",1:"u")
.S RANEW(75.1,"+1,",13)=RAPREG
I RAOBX3(1)=34!(RAOBX2="CE") D Q:RAERR
.S RAERR=$$EN2^RAO7VLD(34,$P(RAOBX5,RAECH(1)),$P(RAOBX5,RAECH(1),2)) Q:RAERR
.S RANEW(75.1,"+1,",9)=+RAOBX5
I RAOBX3(2)["RESEARCH" D S:RAERR RAERR=18 Q:RAERR
.S RAERR=$$EN1^RAO7VLD(75.1,9.5,"E",RAOBX5,"RASULT","") S:RAERR RAERR=19 Q:RAERR
.S RANEW(75.1,"+1,",9.5)=RAOBX5
I RAOBX3(2)["PRE-OP" D Q:RAERR
.S RAOBX5=$$FMDATE^HLFNC(RAOBX5)
.S RAERR=$$EN1^RAO7VLD(75.1,12,"E",RAOBX5,"RASULT","") S:RAERR RAERR=20 Q:RAERR
.S RANEW(75.1,"+1,",12)=RAOBX5
I $D(RANEW(75.1,"+1,",9))&($D(RANEW(75.1,"+1,",9.5))) S RAERR=29
Q
RAO7RON1 ;HISC/GJC,FPT-Request message from OE/RR. (frontdoor) ; 7/26/05 2:08pm
+1 ;;5.0;Radiology/Nuclear Medicine;**69,75,98**;Mar 16, 1998;Build 2
+2 ;
+3 ;------------------------- Variable List -------------------------------
+4 ; RADATA=HL7 data minus seg. hdr RAHDR=Segment header
+5 ; RAHLFS="|" RAMSG=HL7 message passed in
+6 ; RAOBR12=danger code RAOBR18=modifier
+7 ; RAOBR19=Img. Loc. pntr (79.1) RAOBR30=trans. mode
+8 ; RAOBR31=Reason for Study RAOBX2=format of observ. value
+9 ; RAOBR4=univ. trans. mode RAOBX5=observ. value
+10 ; RAOBX3=observ. ID RAORC10=entered by (200
+11 ; RAORC1=order control RAORC15=order effective D/T
+12 ; RAORC12=ordering provider (200) RAORC2=placer order #_"^OR"
+13 ; RAORC16=order control reason RAORC7=start dt/freq. of service
+14 ; RAORC3=filler order #_"^RA" RAPID5=patient name (2)
+15 ; RAPID3=patient ID RAPV12=patient class
+16 ; RAPV119=visit # RASEG=message seg. including header
+17 ; RAPV13=patient location (44)
+18 ; ----------------------------------------------------------------------
+19 ;
OBR ; breakdown the 'OBR' segment
+1 SET RAOBR4=$PIECE(RADATA,RAHLFS,4)
+2 FOR I=1:1:$LENGTH(RAOBR4,RAECH(1))
SET RAOBR4(I)=$PIECE(RAOBR4,RAECH(1),I)
+3 ;RA*5*69
IF RAOBR4(1)'=""
SET RACPTIEN=+$ORDER(^ICPT("B",RAOBR4(1),0))
IF 'RACPTIEN
SET RAERR=8
IF RAERR
QUIT
+4 SET RAERR=$$EN2^RAO7VLD(71,+RAOBR4(4),RAOBR4(5))
IF RAERR
SET RAERR=8
IF RAERR
QUIT
+5 IF $$UP^XLFSTR($PIECE($GET(^RAMIS(71,+RAOBR4(4),0)),"^",6))="P"
Begin DoDot:1
+6 SET RAERR=$$EN6^RAO7VLD(+RAOBR4(4))
IF RAERR
SET RAERR=32
+7 QUIT
End DoDot:1
IF RAERR
QUIT
+8 ;RA*5*69
IF RAOBR4(1)'=""
IF '$DATA(^RAMIS(71,"D",RACPTIEN,+RAOBR4(4)))
SET RAERR=8
IF RAERR
QUIT
+9 SET RAOBR4(4,"I-TYPE")=+$PIECE($GET(^RAMIS(71,+RAOBR4(4),0)),"^",12)
+10 SET RANEW(75.1,"+1,",2)=RAOBR4(4)
+11 SET RAIT=$PIECE(^RAMIS(71,+RAOBR4(4),0),U,12)
+12 SET RAERR=$$EN3^RAO7VLD(79.2,RAIT)
IF RAERR
QUIT
+13 SET RANEW(75.1,"+1,",3)=RAIT
+14 SET RAOBR12=$PIECE(RADATA,RAHLFS,12)
+15 SET RAOBR12=$SELECT($EXTRACT(RAOBR12)="":"n","yYiI"[$EXTRACT(RAOBR12):"y",1:"n")
+16 SET RAERR=$$EN1^RAO7VLD(75.1,24,"E",RAOBR12,"RASULT","")
IF RAERR
SET RAERR=10
IF RAERR
QUIT
+17 SET RANEW(75.1,"+1,",24)=RAOBR12
+18 SET RAOBR18=$PIECE(RADATA,RAHLFS,18)
+19 NEW RASERIES,RAIMAG
+20 FOR I=1:1:$LENGTH(RAOBR18,RAECH(2))
IF $LENGTH($PIECE(RAOBR18,RAECH(2),I))>0
SET RAOBR18(I)=$PIECE(RAOBR18,RAECH(2),I)
+21 SET I=0
FOR
SET I=$ORDER(RAOBR18(I))
IF I'>0
QUIT
Begin DoDot:1
+22 SET RAMODIEN=+$ORDER(^RAMIS(71.2,"B",RAOBR18(I),0))
+23 IF 'RAMODIEN
SET RAERR=11
IF RAERR
QUIT
+24 ; type of imaging
SET RAIMAG=$PIECE($GET(^RAMIS(71,+RAOBR4(4),0)),U,12)
+25 IF '$DATA(^RAMIS(71.2,"AB",RAIMAG,RAMODIEN))
SET RAERR=33
IF RAERR
QUIT
+26 SET RASERIES=$SELECT($PIECE($GET(^RAMIS(71,+RAOBR4(4),0)),"^",6)="S":1,1:0)
+27 IF RASERIES&($PIECE($GET(^RAMIS(71.2,RAMODIEN,0)),U,2)]"")
SET RAERR=34
IF RAERR
QUIT
+28 SET RAPLCHLD=RAPLCHLD+1
+29 SET RANEW(75.1125,"+"_RAPLCHLD_",+1,",.01)=RAMODIEN
+30 QUIT
End DoDot:1
IF RAERR
QUIT
+31 SET RAOBR19=$PIECE(RADATA,RAHLFS,19)
SET RAOBR19(1)=$PIECE(RAOBR19,U,1)
+32 SET RAOBR19(2)=$PIECE(RAOBR19,U,2)
SET RAOBR19(3)=+RAOBR19(1)
+33 IF RAOBR19(3)
Begin DoDot:1
+34 SET RAOBR19(3,"I-TYPE")=+$PIECE($GET(^RA(79.1,+RAOBR19(3),0)),"^",6)
+35 IF RAOBR4(4,"I-TYPE")'=RAOBR19(3,"I-TYPE")
SET RAERR=31
+36 QUIT
End DoDot:1
IF RAERR
QUIT
+37 SET RANEW(75.1,"+1,",20)=$SELECT(RAOBR19(3)>0:RAOBR19(3),1:"")
+38 SET X=$PIECE(RADATA,RAHLFS,30)
+39 SET RAOBR30=$SELECT(X="CART":"s",X="PORT":"p",X="WALK":"a",X="WHLC":"w",1:"")
+40 IF RAOBR30']""
SET RAERR=13
+41 IF 'RAERR
SET RAERR=$$EN1^RAO7VLD(75.1,19,"E",RAOBR30,"RASULT","")
+42 IF RAERR
SET RAERR=13
IF RAERR
QUIT
+43 SET RANEW(75.1,"+1,",19)=RAOBR30
+44 ;--- Reason for Study P75 ---
+45 ;CPRS will not pass 'Reason for Study' data until OR*3.0*243
+46 ;(GUI CPRS V27) is released. Define a default Reason for Study
+47 IF '$$PATCH^XPDUTL("OR*3.0*243")
SET RAOBR31="See Clinical History:"
+48 ;CPRS V27 is installed
IF '$TEST
Begin DoDot:1
+49 SET RAOBR31=$PIECE($PIECE(RADATA,RAHLFS,31),RAECH(1),2)
+50 IF RAOBR31=""
SET RAERR=38
IF RAERR
QUIT
+51 SET RAERR=$$EN1^RAO7VLD(75.1,1.1,"E",RAOBR31,"RASULT","")
+52 IF RAERR
SET RAERR=39
+53 QUIT
End DoDot:1
IF RAERR
QUIT
+54 ;strip 'line feed' - P98
SET RAOBR31=$TRANSLATE(RAOBR31,$CHAR(10)," ")
+55 ;strip 'carriage return' - P98
SET RAOBR31=$TRANSLATE(RAOBR31,$CHAR(13)," ")
+56 IF 'RAERR
SET RANEW(75.1,"+1,",1.1)=RAOBR31
+57 KILL RAOBR31
+58 QUIT
OBX ; breakdown the 'OBX' segment
+1 SET RAOBX2=$PIECE(RADATA,RAHLFS,2)
+2 SET RAERR=$SELECT(RAOBX2="TX":0,RAOBX2="CE":0,RAOBX2="TS":0,1:1)
IF RAERR=17
QUIT
+3 SET RAOBX3=$PIECE(RADATA,RAHLFS,3)
+4 SET RAOBX5=$PIECE(RADATA,RAHLFS,5)
+5 FOR I=1:1:$LENGTH(RAOBX3,RAECH(1))
SET RAOBX3(I)=$PIECE(RAOBX3,RAECH(1),I)
+6 SET X=RAOBX3(2)
DO UPPER^RAUTL4
SET RAOBX3(2)=Y
+7 ;
+8 ;P75 check to see if CLINICAL HISTORY data is passed. If data is passed, and not yet
+9 ;determined if valid continue to check for validity until:
+10 ;1-valid data is found
+11 ;2-no data left to validate
+12 IF RAOBX3(1)=2000.02
Begin DoDot:1
+13 ;check if a null value is sent for CLINICAL HISTORY which is
+14 ;possible if the CPRS user does not enter a CLINICAL HISTORY
+15 IF RAOBX5=""
IF $PIECE(RACLIN,U)'=1
QUIT
+16 ;now if data was sent (RAOBX5'="") set the data received from CPRS flag
+17 SET $PIECE(RACLIN,U)=1
+18 ;now that we know the CPRS user intended to send CLINICAL HISTORY data
+19 ;radiology has to validate the format of that data. $$EN4^RAO7VLD(str)
+20 ;returns 1 if the data passed in was valid, else 0. Once we establish
+21 ;that valid data has been sent, all subsequent data is accepted, valid
+22 ;or not.
+23 IF $$EN4^RAO7VLD(RAOBX5)
SET $PIECE(RACLIN,U,2)=1
+24 ;now, if the current character string or any other character string
+25 ;of data representing the CLINICAL HISTORY has been accepted as valid
+26 ;($P(RACLIN,U,2)=1) save the character string
+27 IF $PIECE(RACLIN,U,2)=1
SET RAWP=RAWP+1
SET ^TMP("RAWP",$JOB,RAWP)=RAOBX5
End DoDot:1
+28 ;
+29 IF RAOBX3(1)=2000.33
Begin DoDot:1
+30 SET RAERR=$$EN1^RAO7VLD(75.1,13,"E",RAOBX5,"RASULT","")
IF RAERR
SET RAERR=14
IF RAERR
QUIT
+31 SET RAPREG=$EXTRACT(RAOBX5)
SET RAPREG=$SELECT(RAPREG="N"!(RAPREG="n"):"n",RAPREG="Y"!(RAPREG="y"):"y",1:"u")
+32 SET RANEW(75.1,"+1,",13)=RAPREG
End DoDot:1
IF RAERR
QUIT
+33 IF RAOBX3(1)=34!(RAOBX2="CE")
Begin DoDot:1
+34 SET RAERR=$$EN2^RAO7VLD(34,$PIECE(RAOBX5,RAECH(1)),$PIECE(RAOBX5,RAECH(1),2))
IF RAERR
QUIT
+35 SET RANEW(75.1,"+1,",9)=+RAOBX5
End DoDot:1
IF RAERR
QUIT
+36 IF RAOBX3(2)["RESEARCH"
Begin DoDot:1
+37 SET RAERR=$$EN1^RAO7VLD(75.1,9.5,"E",RAOBX5,"RASULT","")
IF RAERR
SET RAERR=19
IF RAERR
QUIT
+38 SET RANEW(75.1,"+1,",9.5)=RAOBX5
End DoDot:1
IF RAERR
SET RAERR=18
IF RAERR
QUIT
+39 IF RAOBX3(2)["PRE-OP"
Begin DoDot:1
+40 SET RAOBX5=$$FMDATE^HLFNC(RAOBX5)
+41 SET RAERR=$$EN1^RAO7VLD(75.1,12,"E",RAOBX5,"RASULT","")
IF RAERR
SET RAERR=20
IF RAERR
QUIT
+42 SET RANEW(75.1,"+1,",12)=RAOBX5
End DoDot:1
IF RAERR
QUIT
+43 IF $DATA(RANEW(75.1,"+1,",9))&($DATA(RANEW(75.1,"+1,",9.5)))
SET RAERR=29
+44 QUIT