LA7COBX2 ;VA/DALOI/JMC - LAB OBX Segment message builder (AP subscripts) cont'd ; 22-Oct-2013 09:22 ; MAW
;;5.2;AUTOMATED LAB INSTRUMENTS;**46,1018,64,1027,68,1033**;NOV 01, 1997
;
AP ; Build OBX segments for resultss that are anatomic/surgical pathology subscripts
; Called by LA7VOBX
;
N LA7953,LA7ACODE,LA7CODE,LA7DIV,LA7IENS,LA7OBX5,LA7OBX5M,LA7SUB,LA7SUBFL,LA7VP,LA7WP,LA7X,LA7Y
;
S (LA7953,LA7DIV,LA7VP)=""
;
; Surgical pathology subscript
I LRSS="SP" S LA7SUBFL=63.08
;
; Cytology subscript
I LRSS="CY" S LA7SUBFL=63.09
;
; Electron microscopy subscript
I LRSS="EM" S LA7SUBFL=63.02
;
S LA7IENS=""
F I=3:-1:1 I $P(LRIDT,",",I) S LRIDT(I)=$P(LRIDT,",",I),LA7IENS=LA7IENS_LRIDT(I)_","
S LA7IENS=LA7IENS_LRDFN_","
S LRIDT=$P(LRIDT,",")
S LA7SUB(0)=$G(^LR(LRDFN,LRSS,LRIDT,0))
;
; Get default codes
S LA7CODE=$$DEFCODE^LA7VHLU5(LRSS,LRSB,"","")
;
; Initialize OBX segment
S LA7OBX(0)="OBX"
;
; Value type
S LA7X=LA7SUBFL,LA7Y=LRSB
I LRSB=1.2 S LA7X=$S(LRSS="SP":63.817,LRSS="CY":63.907,LRSS="EM":63.207,1:""),LA7Y=1
I LRSB="10,1.5" S LA7X=$S(LRSS="SP":63.82,LRSS="CY":63.982,LRSS="EM":63.282,1:""),LA7Y=.01
I LRSB="10,2",LRSS="SP" S LA7X=63.12,LA7Y=2
I LRSB="10,5" S LA7X=$S(LRSS="SP":63.819,LRSS="CY":63.919,LRSS="EM":63.219,1:""),LA7Y=1
S LA7OBX(2)=$$OBX2^LA7VOBX(LA7X,LA7Y)
;
; Observation identifier
S LA7OBX(3)=$$OBX3^LA7VOBX($P(LA7CODE,"!",2),$P(LA7CODE,"!",3),"",LA7FS,LA7ECH,$G(LA7INTYP))
;
; Observation sub-ID
; Create sub-ID for supplementary reports and special studies
D SUBID
;
; Build result field
I LRSB=.012 D
. N LA7I,LA7X,LA7Y
. S LA7I=0
. F S LA7I=$O(^LR(LRDFN,LRSS,LRIDT,.1,LA7I)) Q:'LA7I D
. . S LA7X=$G(^LR(LRDFN,LRSS,LRIDT,.1,LA7I,0))
. . S LA7Y(LA7I)=$P(LA7X,"^")
. . S LA7OBX(2)="CE" ; Override DD to conform to HL7 standard
. S LA7OBX(5)=$$OBX5R^LA7VOBX(.LA7Y,LA7OBX(2),LA7FS,LA7ECH)
;
I LRSB'=.012 D
. I $P(LRSB,",")=10,LRSB'="10,5" Q
. I LA7NVAF=1 D DOD Q
. I LRSB=1.2 N LRSB S LA7SUBFL=$S(LRSS="SP":63.817,LRSS="CY":63.907,LRSS="EM":63.207,1:""),LRSB=1
. I LRSB="10,5" N LRSB S LA7SUBFL=$S(LRSS="SP":63.819,LRSS="CY":63.919,LRSS="EM":63.219,1:""),LRSB=1
. D OBX5M^LA7VOBX(LA7SUBFL,LA7IENS,LRSB,.LA7WP,LA7FS,LA7ECH)
. D BUILDSEG^LA7VHLU(.LA7WP,.LA7OBX5M,"")
. M LA7OBX(5)=LA7OBX5M
;
I $P(LRSB,",")=10,LRSB'="10,5" D
. N LA7VAL,LA7SUBFL,X
. I LRSS="SP",LRSB="10,2" D Q
. . S LA7VAL=$$GET1^DIQ(63.12,LA7IENS,2)
. . S LA7OBX(5)=$$OBX5^LA7VOBX(LA7VAL,LA7OBX(2),LA7FS,LA7ECH)
. . S LA7OBX(6)=$$OBX6^LA7VOBX("g","",LA7FS,LA7ECH,$G(LA7INTYP))
. I LRSB=10 S LA7SUBFL=$S(LRSS="SP":63.12,LRSS="CY":63.912,LRSS="EM":63.212,1:"")
. I LRSB="10,1.5" S LA7SUBFL=$S(LRSS="SP":63.82,LRSS="CY":63.982,LRSS="EM":63.282,1:"")
. S LA7VAL=$$GET1^DIQ(LA7SUBFL,LA7IENS,.01)
. S X=$$GET1^DIQ(LA7SUBFL,LA7IENS,".01:2")
. I X'="" S LA7VAL=$S($E(X,1,2)="T-":"",1:"T-")_X_"^"_LA7VAL_"^SNM",LA7OBX(2)="CE"
. S LA7OBX(5)=$$OBX5^LA7VOBX(LA7VAL,LA7OBX(2),LA7FS,LA7ECH)
;
; Don't build this segment if no results/value to send
I $G(LA7OBX(5,0))="",$G(LA7OBX(5))="" Q
;
; Build sequence id
S LA7OBX(1)=$$OBX1^LA7VOBX(.LA7OBXSN)
;
; "P"artial, "F"inal , "A"mended results
; If not release date then pending
I '$P(LA7SUB(0),"^",11) S LA7OBX(11)="P"
;
; If release date then check for changes
I $P(LA7SUB(0),"^",11) D
. I $P(LA7SUB(0),"^",15) S LA7OBX(11)="C"
. E S LA7OBX(11)="F"
;
S LA7DIV=$P($G(^LR(LRDFN,LRSS,LRIDT,"RF")),"^")
I LA7DIV="",$P(LA7SUB(0),"^",13),$$DIV4^XUSER(.LA7DIV,$P(LA7SUB(0),"^",2)) S LA7DIV=$O(LA7DIV(0))
;
; Facility that performed the testing
S LA7OBX(15)=$$OBX15^LA7VOBX(LA7DIV,LA7FS,LA7ECH)
;
; Person that verified the test
S LA7VP=$P(LA7SUB(0),"^",13)
I LA7VP S LA7OBX(16)=$$OBX16^LA7VOBX(LA7VP,LA7DIV,LA7FS,LA7ECH)
;
; Performing organization name/address
I LA7DIV'="" D
. N LA7DT
. S LA7OBX(23)=$$OBX23^LA7VOBX(4,LA7DIV,LA7FS,LA7ECH)
. S LA7DT=$S($P(LA7SUB(0),"^",11):$P(LA7SUB(0),"^",11),1:$$NOW^XLFDT)
. S LA7OBX(24)=$$OBX24^LA7VOBX(4,LA7DIV,LA7DT,LA7FS,LA7ECH)
;
D BUILDSEG^LA7VHLU(.LA7OBX,.LA7ARRAY,LA7FS)
;
Q
;
;
SUBID ; Build sub-id for "SP" subscript
; Used to identify supplementary reports, specimens and related special
; studies performed on thoese specimens.
;
N LA7SUBID
;
S LA7SUBID=""
;
; Sub-id's for supplementary reports
I LRSB=1.2 S LA7SUBID="1."_$P(LA7IENS,",")
;
; Sub-id's for specimens and special studies
I LRSB=10!(LRSB="10,2") S LA7SUBID="10."_$P(LA7IENS,",")
I LRSB="10,1.5"!(LRSB="10,5") S LA7SUBID="10."_$P(LA7IENS,",",2)_"."_$P(LA7IENS,",")
;
I LA7SUBID'="" S LA7OBX(4)=$$OBX4^LA7VOBX(LA7SUBID,LA7FS,LA7ECH)
;
Q
;
;
DOD ; Build OBX segment's to special DoD specifications.
; Send word-processing fields as series of OBX's for DoD.
; DoD cannot handle formatted text (FT) data type.
;
S LA7OBX(2)="ST"
S LA7VAL=$G(^LR(LRDFN,LRSS,$P(LA7IDT,","),LA7SB,$P(LA7IDT,",",2),0))
I LA7VAL="" S LA7VAL=" "
S LA7OBX(5)=$$OBX5^LA7VOBX(LA7VAL,LA7OBX(2),LA7FS,LA7ECH)
Q
LA7COBX2 ;VA/DALOI/JMC - LAB OBX Segment message builder (AP subscripts) cont'd ; 22-Oct-2013 09:22 ; MAW
+1 ;;5.2;AUTOMATED LAB INSTRUMENTS;**46,1018,64,1027,68,1033**;NOV 01, 1997
+2 ;
AP ; Build OBX segments for resultss that are anatomic/surgical pathology subscripts
+1 ; Called by LA7VOBX
+2 ;
+3 NEW LA7953,LA7ACODE,LA7CODE,LA7DIV,LA7IENS,LA7OBX5,LA7OBX5M,LA7SUB,LA7SUBFL,LA7VP,LA7WP,LA7X,LA7Y
+4 ;
+5 SET (LA7953,LA7DIV,LA7VP)=""
+6 ;
+7 ; Surgical pathology subscript
+8 IF LRSS="SP"
SET LA7SUBFL=63.08
+9 ;
+10 ; Cytology subscript
+11 IF LRSS="CY"
SET LA7SUBFL=63.09
+12 ;
+13 ; Electron microscopy subscript
+14 IF LRSS="EM"
SET LA7SUBFL=63.02
+15 ;
+16 SET LA7IENS=""
+17 FOR I=3:-1:1
IF $PIECE(LRIDT,",",I)
SET LRIDT(I)=$PIECE(LRIDT,",",I)
SET LA7IENS=LA7IENS_LRIDT(I)_","
+18 SET LA7IENS=LA7IENS_LRDFN_","
+19 SET LRIDT=$PIECE(LRIDT,",")
+20 SET LA7SUB(0)=$GET(^LR(LRDFN,LRSS,LRIDT,0))
+21 ;
+22 ; Get default codes
+23 SET LA7CODE=$$DEFCODE^LA7VHLU5(LRSS,LRSB,"","")
+24 ;
+25 ; Initialize OBX segment
+26 SET LA7OBX(0)="OBX"
+27 ;
+28 ; Value type
+29 SET LA7X=LA7SUBFL
SET LA7Y=LRSB
+30 IF LRSB=1.2
SET LA7X=$SELECT(LRSS="SP":63.817,LRSS="CY":63.907,LRSS="EM":63.207,1:"")
SET LA7Y=1
+31 IF LRSB="10,1.5"
SET LA7X=$SELECT(LRSS="SP":63.82,LRSS="CY":63.982,LRSS="EM":63.282,1:"")
SET LA7Y=.01
+32 IF LRSB="10,2"
IF LRSS="SP"
SET LA7X=63.12
SET LA7Y=2
+33 IF LRSB="10,5"
SET LA7X=$SELECT(LRSS="SP":63.819,LRSS="CY":63.919,LRSS="EM":63.219,1:"")
SET LA7Y=1
+34 SET LA7OBX(2)=$$OBX2^LA7VOBX(LA7X,LA7Y)
+35 ;
+36 ; Observation identifier
+37 SET LA7OBX(3)=$$OBX3^LA7VOBX($PIECE(LA7CODE,"!",2),$PIECE(LA7CODE,"!",3),"",LA7FS,LA7ECH,$GET(LA7INTYP))
+38 ;
+39 ; Observation sub-ID
+40 ; Create sub-ID for supplementary reports and special studies
+41 DO SUBID
+42 ;
+43 ; Build result field
+44 IF LRSB=.012
Begin DoDot:1
+45 NEW LA7I,LA7X,LA7Y
+46 SET LA7I=0
+47 FOR
SET LA7I=$ORDER(^LR(LRDFN,LRSS,LRIDT,.1,LA7I))
IF 'LA7I
QUIT
Begin DoDot:2
+48 SET LA7X=$GET(^LR(LRDFN,LRSS,LRIDT,.1,LA7I,0))
+49 SET LA7Y(LA7I)=$PIECE(LA7X,"^")
+50 ; Override DD to conform to HL7 standard
SET LA7OBX(2)="CE"
End DoDot:2
+51 SET LA7OBX(5)=$$OBX5R^LA7VOBX(.LA7Y,LA7OBX(2),LA7FS,LA7ECH)
End DoDot:1
+52 ;
+53 IF LRSB'=.012
Begin DoDot:1
+54 IF $PIECE(LRSB,",")=10
IF LRSB'="10,5"
QUIT
+55 IF LA7NVAF=1
DO DOD
QUIT
+56 IF LRSB=1.2
NEW LRSB
SET LA7SUBFL=$SELECT(LRSS="SP":63.817,LRSS="CY":63.907,LRSS="EM":63.207,1:"")
SET LRSB=1
+57 IF LRSB="10,5"
NEW LRSB
SET LA7SUBFL=$SELECT(LRSS="SP":63.819,LRSS="CY":63.919,LRSS="EM":63.219,1:"")
SET LRSB=1
+58 DO OBX5M^LA7VOBX(LA7SUBFL,LA7IENS,LRSB,.LA7WP,LA7FS,LA7ECH)
+59 DO BUILDSEG^LA7VHLU(.LA7WP,.LA7OBX5M,"")
+60 MERGE LA7OBX(5)=LA7OBX5M
End DoDot:1
+61 ;
+62 IF $PIECE(LRSB,",")=10
IF LRSB'="10,5"
Begin DoDot:1
+63 NEW LA7VAL,LA7SUBFL,X
+64 IF LRSS="SP"
IF LRSB="10,2"
Begin DoDot:2
+65 SET LA7VAL=$$GET1^DIQ(63.12,LA7IENS,2)
+66 SET LA7OBX(5)=$$OBX5^LA7VOBX(LA7VAL,LA7OBX(2),LA7FS,LA7ECH)
+67 SET LA7OBX(6)=$$OBX6^LA7VOBX("g","",LA7FS,LA7ECH,$GET(LA7INTYP))
End DoDot:2
QUIT
+68 IF LRSB=10
SET LA7SUBFL=$SELECT(LRSS="SP":63.12,LRSS="CY":63.912,LRSS="EM":63.212,1:"")
+69 IF LRSB="10,1.5"
SET LA7SUBFL=$SELECT(LRSS="SP":63.82,LRSS="CY":63.982,LRSS="EM":63.282,1:"")
+70 SET LA7VAL=$$GET1^DIQ(LA7SUBFL,LA7IENS,.01)
+71 SET X=$$GET1^DIQ(LA7SUBFL,LA7IENS,".01:2")
+72 IF X'=""
SET LA7VAL=$SELECT($EXTRACT(X,1,2)="T-":"",1:"T-")_X_"^"_LA7VAL_"^SNM"
SET LA7OBX(2)="CE"
+73 SET LA7OBX(5)=$$OBX5^LA7VOBX(LA7VAL,LA7OBX(2),LA7FS,LA7ECH)
End DoDot:1
+74 ;
+75 ; Don't build this segment if no results/value to send
+76 IF $GET(LA7OBX(5,0))=""
IF $GET(LA7OBX(5))=""
QUIT
+77 ;
+78 ; Build sequence id
+79 SET LA7OBX(1)=$$OBX1^LA7VOBX(.LA7OBXSN)
+80 ;
+81 ; "P"artial, "F"inal , "A"mended results
+82 ; If not release date then pending
+83 IF '$PIECE(LA7SUB(0),"^",11)
SET LA7OBX(11)="P"
+84 ;
+85 ; If release date then check for changes
+86 IF $PIECE(LA7SUB(0),"^",11)
Begin DoDot:1
+87 IF $PIECE(LA7SUB(0),"^",15)
SET LA7OBX(11)="C"
+88 IF '$TEST
SET LA7OBX(11)="F"
End DoDot:1
+89 ;
+90 SET LA7DIV=$PIECE($GET(^LR(LRDFN,LRSS,LRIDT,"RF")),"^")
+91 IF LA7DIV=""
IF $PIECE(LA7SUB(0),"^",13)
IF $$DIV4^XUSER(.LA7DIV,$PIECE(LA7SUB(0),"^",2))
SET LA7DIV=$ORDER(LA7DIV(0))
+92 ;
+93 ; Facility that performed the testing
+94 SET LA7OBX(15)=$$OBX15^LA7VOBX(LA7DIV,LA7FS,LA7ECH)
+95 ;
+96 ; Person that verified the test
+97 SET LA7VP=$PIECE(LA7SUB(0),"^",13)
+98 IF LA7VP
SET LA7OBX(16)=$$OBX16^LA7VOBX(LA7VP,LA7DIV,LA7FS,LA7ECH)
+99 ;
+100 ; Performing organization name/address
+101 IF LA7DIV'=""
Begin DoDot:1
+102 NEW LA7DT
+103 SET LA7OBX(23)=$$OBX23^LA7VOBX(4,LA7DIV,LA7FS,LA7ECH)
+104 SET LA7DT=$SELECT($PIECE(LA7SUB(0),"^",11):$PIECE(LA7SUB(0),"^",11),1:$$NOW^XLFDT)
+105 SET LA7OBX(24)=$$OBX24^LA7VOBX(4,LA7DIV,LA7DT,LA7FS,LA7ECH)
End DoDot:1
+106 ;
+107 DO BUILDSEG^LA7VHLU(.LA7OBX,.LA7ARRAY,LA7FS)
+108 ;
+109 QUIT
+110 ;
+111 ;
SUBID ; Build sub-id for "SP" subscript
+1 ; Used to identify supplementary reports, specimens and related special
+2 ; studies performed on thoese specimens.
+3 ;
+4 NEW LA7SUBID
+5 ;
+6 SET LA7SUBID=""
+7 ;
+8 ; Sub-id's for supplementary reports
+9 IF LRSB=1.2
SET LA7SUBID="1."_$PIECE(LA7IENS,",")
+10 ;
+11 ; Sub-id's for specimens and special studies
+12 IF LRSB=10!(LRSB="10,2")
SET LA7SUBID="10."_$PIECE(LA7IENS,",")
+13 IF LRSB="10,1.5"!(LRSB="10,5")
SET LA7SUBID="10."_$PIECE(LA7IENS,",",2)_"."_$PIECE(LA7IENS,",")
+14 ;
+15 IF LA7SUBID'=""
SET LA7OBX(4)=$$OBX4^LA7VOBX(LA7SUBID,LA7FS,LA7ECH)
+16 ;
+17 QUIT
+18 ;
+19 ;
DOD ; Build OBX segment's to special DoD specifications.
+1 ; Send word-processing fields as series of OBX's for DoD.
+2 ; DoD cannot handle formatted text (FT) data type.
+3 ;
+4 SET LA7OBX(2)="ST"
+5 SET LA7VAL=$GET(^LR(LRDFN,LRSS,$PIECE(LA7IDT,","),LA7SB,$PIECE(LA7IDT,",",2),0))
+6 IF LA7VAL=""
SET LA7VAL=" "
+7 SET LA7OBX(5)=$$OBX5^LA7VOBX(LA7VAL,LA7OBX(2),LA7FS,LA7ECH)
+8 QUIT