LR7OU01 ;slc/dcm - Build HL7 Components ;8/11/97
;;5.2;LAB SERVICE;**121,187**;Sep 27, 1994
;
ORC(COUNT) ;ORC segment
;X1 = Order Control (SN-backdoor new order, OC-Cancel, SC-on collection
; SC-collected, RE-completed) See table 119
;X2 = Lab Number
;X3 = Order Status (table 38)
;X4 = Quantity/Timing - Quantity^Interval^Duration^Start D/T^End D/T^Priority^Condition^Text^Conjunction
;X5 = Date ordered/entered
;X6 = Provider # (ptr to file 200)
;X7 = Order effective D/T
;X8 = Order Control Reason
;X9 = OE/RR Order #
;X10 = Entered by
N ORC,CTR,ARAY
S CTR=0,ARAY=""
D BUILD("ORC|"),BUILD(X1_"|"_$S($L(X9):X9_"^OR",1:"")_"|"),BUILD(X2_"^||"),BUILD(X3_"||"),BUILD(X4_"||"),BUILD(X5_"|"),BUILD($$PERSON(X10)_"||")
D BUILD($$PERSON(X6)_"|||"),BUILD(X7_"|"),BUILD(X8)
M @MSG@(COUNT)=ARAY
Q
OBR(COUNT) ;OBR segment
;COUNT=Current count for MSG array
;X1 = Universal ID - ^^^ifn (from file 60)^Test Name^99_SectionID
; SectionID: LRT=Chem Hem Tox Micro AP, LRB=Bloodbank
;X2 = Observation D/T
;X3 = Specimen Action Code (table 65)
;X4 = Specimen Recieved D/T
;X5 = Specimen Source (table 70)
;X6 = Accession (Filler Field 1)
;X7 = Results reported or Status changed D/T
;X8 = Result Status (table 123)
;X9 = Quantity/timing
;X10 = Result copies to: location
;COBR = OBR counter
N OBR,CTR,ARAY
S CTR=0,ARAY=""
D BUILD("OBR|"),BUILD(COBR_"|||"),BUILD(X1_"|||"),BUILD(X2_"||||"),BUILD(X3_"|||"),BUILD(X4_"|"),BUILD(X5_"|||||")
D BUILD(X6_"||"),BUILD(X7_"|||"),BUILD(X8_"||"),BUILD(X9_"|"),BUILD(X10)
M @MSG@(COUNT)=ARAY
Q
OBX(COUNT) ;OBX Result segment
;X1 = Value type (table 125)
;X2 = Observation ID - ^^^ifn (from file 60)^Test Name^99_SectionID
;X3 = Observation Sub-ID
;X4 = Result
;X5 = coded per table 36
;X6 = Reference Range
;X7 = Abnormal Flag (table 78)
;X8 = Observ Result Status (table 85)
;COBX = OBX Counter
;X10 = User Defined Access Checks
;X11 = Verified by
N OBX,CTR,ARAY
S CTR=0,ARAY=""
D BUILD("OBX|"_COBX_"|"),BUILD(X1_"|"),BUILD(X2_"|"),BUILD(X3_"|"),BUILD(X4_"|"),BUILD(X5_"|"),BUILD(X6_"|"),BUILD(X7_"|||"),BUILD(X8_"||"),BUILD(X10_"||"),BUILD($$PERSON(X11))
M @MSG@(COUNT)=ARAY
Q
NTE(ID,SOURCE,NODE,CTR) ;NTE Notes segment
;ID=SET ID
;SOURCE = Source of comment P=>Placer, L=>Filler, O=>Other system
;NODE=Local array with text in the form ARRAY( or ARRAY(I,
;CTR=Counter for 1st subscript in MSG(ctr) array
Q:'$L(NODE) N NTE,FIRST,SUB,X,IFN
S NTE="NTE|"_ID_"|"_SOURCE,IFN=0,FIRST=1
F S IFN=$O(@(NODE_IFN_")")) Q:IFN<1 S X=@(NODE_IFN_")") D
. I X["For Test: " Q ;Screen out unecessary test text
. I FIRST S @MSG@(CTR)=NTE_"|"_X S FIRST=0,SUB=0 Q
. S SUB=SUB+1,@MSG@(CTR,SUB)=X
Q
PERSON(X) ;Get person in external format
I '$G(X) Q 0
I '$D(^VA(200,+X,0)) Q X
S X=+X_"^"_$P(^VA(200,+X,0),"^")
Q X
BUILD(FIELD) ;Build a segment
;FIELD=text/field to add to segment
;ARAY is built until length is >244 characters then
;ARAY(ifn) is created
S:'$D(ARAY) ARAY="" Q:'$D(FIELD) Q:'$D(CTR)
N IFN,X
S X=$S($O(ARAY(0)):$O(ARAY(9999),-1),1:ARAY)
S:$L(FIELD)>244 FIELD=$E(FIELD,1,244)
I $L(FIELD)+$L(X)>244 S CTR=CTR+1,ARAY(CTR)=""
S:CTR=0 ARAY=ARAY_FIELD
S:CTR ARAY(CTR)=ARAY(CTR)_FIELD
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HLR7OU01 3276 printed Dec 13, 2024@02:05:48 Page 2
LR7OU01 ;slc/dcm - Build HL7 Components ;8/11/97
+1 ;;5.2;LAB SERVICE;**121,187**;Sep 27, 1994
+2 ;
ORC(COUNT) ;ORC segment
+1 ;X1 = Order Control (SN-backdoor new order, OC-Cancel, SC-on collection
+2 ; SC-collected, RE-completed) See table 119
+3 ;X2 = Lab Number
+4 ;X3 = Order Status (table 38)
+5 ;X4 = Quantity/Timing - Quantity^Interval^Duration^Start D/T^End D/T^Priority^Condition^Text^Conjunction
+6 ;X5 = Date ordered/entered
+7 ;X6 = Provider # (ptr to file 200)
+8 ;X7 = Order effective D/T
+9 ;X8 = Order Control Reason
+10 ;X9 = OE/RR Order #
+11 ;X10 = Entered by
+12 NEW ORC,CTR,ARAY
+13 SET CTR=0
SET ARAY=""
+14 DO BUILD("ORC|")
DO BUILD(X1_"|"_$SELECT($LENGTH(X9):X9_"^OR",1:"")_"|")
DO BUILD(X2_"^||")
DO BUILD(X3_"||")
DO BUILD(X4_"||")
DO BUILD(X5_"|")
DO BUILD($$PERSON(X10)_"||")
+15 DO BUILD($$PERSON(X6)_"|||")
DO BUILD(X7_"|")
DO BUILD(X8)
+16 MERGE @MSG@(COUNT)=ARAY
+17 QUIT
OBR(COUNT) ;OBR segment
+1 ;COUNT=Current count for MSG array
+2 ;X1 = Universal ID - ^^^ifn (from file 60)^Test Name^99_SectionID
+3 ; SectionID: LRT=Chem Hem Tox Micro AP, LRB=Bloodbank
+4 ;X2 = Observation D/T
+5 ;X3 = Specimen Action Code (table 65)
+6 ;X4 = Specimen Recieved D/T
+7 ;X5 = Specimen Source (table 70)
+8 ;X6 = Accession (Filler Field 1)
+9 ;X7 = Results reported or Status changed D/T
+10 ;X8 = Result Status (table 123)
+11 ;X9 = Quantity/timing
+12 ;X10 = Result copies to: location
+13 ;COBR = OBR counter
+14 NEW OBR,CTR,ARAY
+15 SET CTR=0
SET ARAY=""
+16 DO BUILD("OBR|")
DO BUILD(COBR_"|||")
DO BUILD(X1_"|||")
DO BUILD(X2_"||||")
DO BUILD(X3_"|||")
DO BUILD(X4_"|")
DO BUILD(X5_"|||||")
+17 DO BUILD(X6_"||")
DO BUILD(X7_"|||")
DO BUILD(X8_"||")
DO BUILD(X9_"|")
DO BUILD(X10)
+18 MERGE @MSG@(COUNT)=ARAY
+19 QUIT
OBX(COUNT) ;OBX Result segment
+1 ;X1 = Value type (table 125)
+2 ;X2 = Observation ID - ^^^ifn (from file 60)^Test Name^99_SectionID
+3 ;X3 = Observation Sub-ID
+4 ;X4 = Result
+5 ;X5 = coded per table 36
+6 ;X6 = Reference Range
+7 ;X7 = Abnormal Flag (table 78)
+8 ;X8 = Observ Result Status (table 85)
+9 ;COBX = OBX Counter
+10 ;X10 = User Defined Access Checks
+11 ;X11 = Verified by
+12 NEW OBX,CTR,ARAY
+13 SET CTR=0
SET ARAY=""
+14 DO BUILD("OBX|"_COBX_"|")
DO BUILD(X1_"|")
DO BUILD(X2_"|")
DO BUILD(X3_"|")
DO BUILD(X4_"|")
DO BUILD(X5_"|")
DO BUILD(X6_"|")
DO BUILD(X7_"|||")
DO BUILD(X8_"||")
DO BUILD(X10_"||")
DO BUILD($$PERSON(X11))
+15 MERGE @MSG@(COUNT)=ARAY
+16 QUIT
NTE(ID,SOURCE,NODE,CTR) ;NTE Notes segment
+1 ;ID=SET ID
+2 ;SOURCE = Source of comment P=>Placer, L=>Filler, O=>Other system
+3 ;NODE=Local array with text in the form ARRAY( or ARRAY(I,
+4 ;CTR=Counter for 1st subscript in MSG(ctr) array
+5 if '$LENGTH(NODE)
QUIT
NEW NTE,FIRST,SUB,X,IFN
+6 SET NTE="NTE|"_ID_"|"_SOURCE
SET IFN=0
SET FIRST=1
+7 FOR
SET IFN=$ORDER(@(NODE_IFN_")"))
if IFN<1
QUIT
SET X=@(NODE_IFN_")")
Begin DoDot:1
+8 ;Screen out unecessary test text
IF X["For Test: "
QUIT
+9 IF FIRST
SET @MSG@(CTR)=NTE_"|"_X
SET FIRST=0
SET SUB=0
QUIT
+10 SET SUB=SUB+1
SET @MSG@(CTR,SUB)=X
End DoDot:1
+11 QUIT
PERSON(X) ;Get person in external format
+1 IF '$GET(X)
QUIT 0
+2 IF '$DATA(^VA(200,+X,0))
QUIT X
+3 SET X=+X_"^"_$PIECE(^VA(200,+X,0),"^")
+4 QUIT X
BUILD(FIELD) ;Build a segment
+1 ;FIELD=text/field to add to segment
+2 ;ARAY is built until length is >244 characters then
+3 ;ARAY(ifn) is created
+4 if '$DATA(ARAY)
SET ARAY=""
if '$DATA(FIELD)
QUIT
if '$DATA(CTR)
QUIT
+5 NEW IFN,X
+6 SET X=$SELECT($ORDER(ARAY(0)):$ORDER(ARAY(9999),-1),1:ARAY)
+7 if $LENGTH(FIELD)>244
SET FIELD=$EXTRACT(FIELD,1,244)
+8 IF $LENGTH(FIELD)+$LENGTH(X)>244
SET CTR=CTR+1
SET ARAY(CTR)=""
+9 if CTR=0
SET ARAY=ARAY_FIELD
+10 if CTR
SET ARAY(CTR)=ARAY(CTR)_FIELD
+11 QUIT