LA7VIN5 ;VA/DALOI/JMC - Process Incoming UI Msgs, continued ; 13-Aug-2013 09:09 ; MKK
;;5.2;AUTOMATED LAB INSTRUMENTS;**46,1018,64,1027,68,1033**;NOV 1, 1997
;
; This routine is a continuation of LA7VIN1 and is only called from there.
; It is called to process OBX segments for "CH" subscript tests.
Q
;
OBX ;
;
N LA76241,LA76304,LA7EII,LA7I,LA7LIMIT,LA7OBM,LA7SUBFL,LA7TEST,LA7TREEN,LA7UNITS,LA7VAL,LA7VTYP,LA7X,LA7XFORM,LA7Y
;
K LA7RMK,^TMP("LA7TREE",$J)
;
S LA7SUBFL=63.04
;
; OBX Set ID
S LA7SOBX=$$P^LA7VHLU(.LA7SEG,2,LA7FS)
;
; Value type - type of data from Table 0125
S LA7VTYP=$P($$P^LA7VHLU(.LA7SEG,3,LA7FS),LA7CS)
;
; Determine test result codes - check for primary and alternate codes
; For DoD/CHCS interface - do NOT process test codes using 99LRT as coding system per DoD/July 2002.
S LA7X=$$P^LA7VHLU(.LA7SEG,4,LA7FS),(LA7RNLT,LA7RLNC)=""
S LA7TEST=$P(LA7X,LA7CS)
S LA7TEST(0)=$$UNESC^LA7VHLU3($P(LA7X,LA7CS,2),LA7FS_LA7ECH)
I LA7TEST(0)["^" S LA7TEST(0)=$TR(LA7TEST(0),"^","~")
S LA7TEST(0,1)=$P(LA7X,LA7CS,3)
S LA7TEST(2)=$P(LA7X,LA7CS,4)
S LA7TEST(2,0)=$$UNESC^LA7VHLU3($P(LA7X,LA7CS,5),LA7FS_LA7ECH)
I LA7TEST(2,0)["^" S LA7TEST(2,0)=$TR(LA7TEST(2,0),"^","~")
S LA7TEST(2,1)=$P(LA7X,LA7CS,6)
F I=3,6 D
. S LA7Y=$P(LA7X,LA7CS,I-2)
. I $P(LA7X,LA7CS,I)="LN" D Q
. . I $$GET1^DIQ(95.3,+LA7Y_",",.01)=LA7Y S LA7RLNC=+LA7Y
. I $P(LA7X,LA7CS,I)="99VA64" D Q
. . I $$FIND1^DIC(64,"","OMX",LA7Y) S LA7RNLT=LA7Y
. I $P(LA7X,LA7CS,I)="99LRT" D Q
. . I LA7TEST(0)="",LA7TEST(2,0)'="" S LA7TEST(0)=LA7TEST(2,0)
. . I LA7TEST(2,0)="",LA7TEST(0)'="" S LA7TEST(2,0)=LA7TEST(0)
. . I I=3 S (LA7TEST,LA7TEST(0),LA7TEST(0,1))="" Q
. . I I=6 S (LA7TEST(2),LA7TEST(2,0),LA7TEST(2,1))="" Q
I LA7TEST="",LA7TEST(2)'="" D
. S LA7TEST=LA7TEST(2),LA7TEST(0)=LA7TEST(2,0),LA7TEST(0,1)=LA7TEST(2,1)
. S (LA7TEST(2),LA7TEST(2,0),LA7TEST(2,1))=""
;
; No test code in message
I LA7TEST="",LA7TEST(2)="" D Q
. N LA7OBX
. S LA7OBX=LA7SEG(0)
. D CREATE^LA7LOG(15)
;
; Test code not found in auto inst file, also check alternate codes,
; and log error if none found.
I LA7MTYP="ORU" D Q:LA7TEST=""
. I LA7TEST'="",$D(^LAB(62.4,LA7624,3,"AC",LA7TEST)) Q
. I LA7TEST(2)'="",$D(^LAB(62.4,LA7624,3,"AC",LA7TEST(2))) D Q
. . S LA7TEST=LA7TEST(2),LA7TEST(0)=LA7TEST(2,0),LA7TEST(0,1)=LA7TEST(2,1)
. D CREATE^LA7LOG(16) S LA7TEST=""
;
; Units - trim leading/trailing spaces
S LA7X=$$P^LA7VHLU(.LA7SEG,7,LA7FS),LA7UNITS=""
I LA7X'="" D
. F I=1:1:6 S LA7UNITS(I)=$P(LA7X,LA7CS,I)
. S LA7UNITS=$$TRIM^XLFSTR(LA7UNITS(1),"LR"," ")
. I LA7UNITS["^" D
. . N LA7STR S LA7STR("^")="~U~"
. . S LA7UNITS=$$REPLACE^XLFSTR(LA7UNITS,.LA7STR)
;
; Observation result status - Table 0085
S LA7ORS=$$P^LA7VHLU(.LA7SEG,12,LA7FS)
;
; Responsible observer
S LA7RO=$$XCNTFM^LA7VHLU4($$P^LA7VHLU(.LA7SEG,17,LA7FS),LA7ECH)
;
; Observation method
S LA7X=$$P^LA7VHLU(.LA7SEG,18,LA7FS),LA7OBM=""
I $P(LA7X,LA7CS,3)="99VA64_2" S LA7OBM=$P($P(LA7X,LA7CS,1),".",2)
;
; Equipment instance identifier
S LA7EII=$$P^LA7VHLU(.LA7SEG,19,LA7FS)
I LA7EII'="" D
. S LA7EII=$$UNESC^LA7VHLU3(LA7EII,LA7FS_LA7ECH)
. S LA7EII=$TR(LA7EII,"^",";")
;
; Process ORU message results for all tests which use this test code.
I LA7MTYP="ORU" D Q
. S LA76241=0
. F S LA76241=$O(^LAB(62.4,LA7624,3,"AC",LA7TEST,LA76241)) Q:'LA76241 D PROCESS
;
I LA7MTYP="ORM",$G(LA7696)>0 D ORESULTS^LA7VIN5A
;
Q
;
;
PROCESS ; Process results for a given test code
S LA7VAL=$$P^LA7VHLU(.LA7SEG,6,LA7FS)
I LA7VTYP="CE",$P(LA7VAL,LA7CS,2)'="" S LA7VAL=$P(LA7VAL,LA7CS,2)
E S LA7VAL=$P(LA7VAL,LA7CS)
;
F LA7I=0,1,2 S LA76241(LA7I)=$G(^LAB(62.4,LA7624,3,LA76241,LA7I))
;
; Chem test fields incorrect
I (LA76241(0)="")!(LA76241(1)="") D Q
. D CREATE^LA7LOG(18)
;
; Setup LA7RMK(0) variable in case comments (NTE) sent with test results.
S LA7RMK(0,+LA76241(0))=+$P(LA76241(2),"^",7)_"^"_$P(LA76241(2),"^",8)
;
S LA76304=+$P(LA76241(1),"(",2) ;lab data field
; No dataname for this result
I LA76304'>1 D Q
. D CREATE^LA7LOG(18)
;
; Set flag for new results alert
I LA7ORS'="","CDW"'[LA7ORS S ^TMP("LA7-ORU",$J,LA76248,LA76249)=""
;
; Set flag to send amended results bulletin
I LA7INTYP=10,LA7ORS'="","CDW"[LA7ORS D
. S LA7I=$O(^TMP("LA7 AMENDED RESULTS",$J,""),-1),LA7I=LA7I+1
. S X=LA7LWL_"^"_LA7ISQN_"^"_LA76304_"^"_LA76248_"^"_LA76249_"^"_LA7ORS_"^"_LA7TEST_"^"_$S(LA7TEST(0)'="":LA7TEST(0),1:LA7TEST(2,0))_"^"_$$P^LA7VHLU(.LA7SEG,9,LA7FS)
. S ^TMP("LA7 AMENDED RESULTS",$J,LA7I)=X
. I LA7UID'="" S ^LAH("LA7 AMENDED RESULTS",LA7UID,LA76304,LA7LWL,LA7ISQN)=X
;
; NOTE - this array can be set from inside PARAM 1
K LA7XFORM
; execute PARAM 1 if not a LEDI interface
I LA7INTYP'=10 X $P(LA76241(0),"^",2)
I $P(LA76241(2),"^",3)=0 Q
I $P(LA76241(2),"^",3)=2,"CFUX"'[LA7ORS Q
I LA7ORS="X",LA7VAL="" Q
;
; No value found
I LA7VAL="" D Q
. D CREATE^LA7LOG(17)
;
; Transform result based on fields in file 62.4
D XFORM^LA7VIN5A
Q:LA7VAL=""
;
; Check if result passes input transform on data name
D CHKDIE^LA7VIN5A
Q:LA7VAL=""
;
; Set flag to not store comments if it wasn't explicitly ordered.
I $G(LA7LIMIT)=1 D
. N LA76804
. K LA7LIMIT,LA7TREEN,^TMP("LA7TREE",$J)
. ; Store all tests accessioned in ^TMP
. S LA76804=0
. F S LA76804=$O(^LRO(68,LA7AA,1,LA7AD,1,LA7AN,4,LA76804)) Q:'LA76804 D UNWIND^LA7UTIL(LA76804)
. I '$D(^TMP("LA7TREE",$J,+LA76241(0))) S LA7LIMIT=1 ;wasn't ordered
I $G(LA7LIMIT) D Q
. S $P(LA7RMK(0,+LA76241(0)),"^",1)=0
. K LA7LIMIT,^TMP("LA7TREE",$J)
K ^TMP("LA7TREE",$J)
;
; Check point of care interface for matching specimen type for this test in #62.4
I LA7INTYP>19,LA7INTYP<30 D Q:'LA761
. N LA70070
. S LA761="",LA7X=$P(LA76241(2),"^",13) Q:'LA7X
. S LA70070=$$GET1^DIQ(61,LA7X_",","LEDI HL7:HL7 ABBR")
. I LA70070=LA7SPEC S LA761=LA7X
;
; Set data node=test value
S $P(^LAH(LA7LWL,1,LA7ISQN,LA76304),"^")=LA7VAL
;
; Store reference ranges except for UI (LA7INTYP=1) interfaces
I LA7INTYP'=1 D REFRNG^LA7VIN5A($$P^LA7VHLU(.LA7SEG,8,LA7FS))
;
; Store order/result codes/observation method except for UI (LA7INTYP=1) interfaces
S LA7X=$P(^LAH(LA7LWL,1,LA7ISQN,LA76304),"^",3)
I LA7ONLT S $P(LA7X,"!",1)=LA7ONLT
I LA7RNLT S $P(LA7X,"!",2)=LA7RNLT
I LA7RLNC S $P(LA7X,"!",3)=LA7RLNC
I LA7OBM S $P(LA7X,"!",4)=LA7OBM
I LA7INTYP'=1 S $P(^LAH(LA7LWL,1,LA7ISQN,LA76304),"^",3)=LA7X
;
; Store abnormal flags except for UI (LA7INTYP=1) interfaces.
I LA7INTYP'=1 D ABFLAG^LA7VIN5A($$P^LA7VHLU(.LA7SEG,9,LA7FS))
;
; Store units except for UI (LA7INTYP=1) interfaces which pull values from file #60.
I LA7INTYP'=1,LA7UNITS'="" D
. S LA7X=$P($G(^LAH(LA7LWL,1,LA7ISQN,LA76304)),"^",5)
. S $P(LA7X,"!",7)=LA7UNITS
. S $P(^LAH(LA7LWL,1,LA7ISQN,LA76304),"^",5)=LA7X
;
; Store responsible observer on POC interfaces
I LA7RO'="",LA7INTYP>19,LA7INTYP<30 D
. I $P(LA7RO,"^",2) S $P(^LAH(LA7LWL,1,LA7ISQN,LA76304),"^",4)=$P(LA7RO,"^",2)
;
; Store specimen type except for UI (LA7INTYP=1) interfaces which pull values from the accession.
I LA7INTYP'=1,$G(LA761) D
. S X=$P(^LAH(LA7LWL,1,LA7ISQN,LA76304),"^",5)
. S $P(X,"!")=LA761
. S $P(^LAH(LA7LWL,1,LA7ISQN,LA76304),"^",5)=X
;
; Store where test was performed except for UI (LA7INTYP=1) interfaces.
I LA7INTYP'=1 D
. N LA74,LA7I,LA7X
. S LA7X=$$P^LA7VHLU(.LA7SEG,24,LA7FS),LA74=""
. I $P(LA7X,LA7CS,6)="CLIA" S LA74=$$IDX^XUAF4("CLIA",$P(LA7X,LA7CS,10))
. I LA74 S $P(^LAH(LA7LWL,1,LA7ISQN,LA76304),"^",9)=LA74 Q
. S LA7X=$$P^LA7VHLU(.LA7SEG,16,LA7FS)
. F LA7I=1,4 I $P(LA7X,LA7CS,LA7I+2)?1(1"L-CL",1"CLIA",1"99VACLIA") S LA74=$$IDX^XUAF4("CLIA",$P(LA7X,LA7CS,LA7I))
. I LA74 S $P(^LAH(LA7LWL,1,LA7ISQN,LA76304),"^",9)=LA74 Q
. D PRDID^LA7VIN5A($$P^LA7VHLU(.LA7SEG,16,LA7FS),LA7SFAC,LA7CS)
;
; Store equipment instance identifier
I LA7EII'="" D EII^LA7VIN5A
;
; If results for LEDI interface (LA7INTYP=10) and site keeps file #60
; in sync with reference lab then compare message's units and normals
; with site's to detect changes(LA7FLAG=1) and notify site.
I LA7INTYP=10,$G(LA761),$G(^LAB(60,+$P(LA76241(0),"^"),1,LA761,.1)) D
. N LA760,LA7FLAG,LA7I,LA7Y,LA7X
. S LA760=+$P(LA76241(0),"^"),LA7Y=^LAB(60,LA760,1,LA761,0),LA7FLAG=0
. S LA7X=$P(^LAH(LA7LWL,1,LA7ISQN,LA76304),"^",5)
. I $P(LA7Y,"^",7)'=$P(LA7X,"!",7) S LA7FLAG=1
. I 'LA7FLAG,$P(LA7Y,"^",2)=$P(LA7X,"!",2),$P(LA7Y,"^",3)=$P(LA7X,"!",3) Q
. I 'LA7FLAG D
. . N AGE,DOB,PNM,SEX
. . N LRDPF,LRNG,LRNGS,LRNG2,LRNG3,LRNG4,LRNG5,LRTREA,LRWRD,LRX,LRY
. . I $G(LRDFN) D DEM^LRX,KVAR^VADPT
. . S LRNG=LA7Y D NORM^LRVER5
. . S LA7Y=$TR(LRNG,$C(34),""),LA7X=$TR(LA7X,$C(34),"")
. . I $P(LA7Y,"^",2)=$P(LA7X,"!",2),$P(LA7Y,"^",3)=$P(LA7X,"!",3) Q
. . S LA7FLAG=1
. I 'LA7FLAG Q
. S LA7I=$O(^TMP("LA7 UNITS/NORMALS CHANGED",$J,""),-1),LA7I=LA7I+1
. S X=LA7LWL_"^"_LA7ISQN_"^"_LA76304_"^"_LA76248_"^"_LA76249_"^"_LA7ORS_"^"_LA7TEST_"^"_$S(LA7TEST(0)'="":LA7TEST(0),1:LA7TEST(2,0))_"^"_$$P^LA7VHLU(.LA7SEG,9,LA7FS)_"^"_LA760
. S ^TMP("LA7 UNITS/NORMALS CHANGED",$J,LA7I)=X
;
; If LEDI interface and order status change store which results
; associated with ordered test. Used to determine if order status
; changed bulletin needs to be generated.
I LA7INTYP=10,LA7SAC?1(1"A",1"G") D
. S LA7I=$G(LA7SAC(0)) Q:'LA7I
. S ^TMP("LA7 ORDER STATUS",$J,LA7I,+LA76241(0))=""
Q
LA7VIN5 ;VA/DALOI/JMC - Process Incoming UI Msgs, continued ; 13-Aug-2013 09:09 ; MKK
+1 ;;5.2;AUTOMATED LAB INSTRUMENTS;**46,1018,64,1027,68,1033**;NOV 1, 1997
+2 ;
+3 ; This routine is a continuation of LA7VIN1 and is only called from there.
+4 ; It is called to process OBX segments for "CH" subscript tests.
+5 QUIT
+6 ;
OBX ;
+1 ;
+2 NEW LA76241,LA76304,LA7EII,LA7I,LA7LIMIT,LA7OBM,LA7SUBFL,LA7TEST,LA7TREEN,LA7UNITS,LA7VAL,LA7VTYP,LA7X,LA7XFORM,LA7Y
+3 ;
+4 KILL LA7RMK,^TMP("LA7TREE",$JOB)
+5 ;
+6 SET LA7SUBFL=63.04
+7 ;
+8 ; OBX Set ID
+9 SET LA7SOBX=$$P^LA7VHLU(.LA7SEG,2,LA7FS)
+10 ;
+11 ; Value type - type of data from Table 0125
+12 SET LA7VTYP=$PIECE($$P^LA7VHLU(.LA7SEG,3,LA7FS),LA7CS)
+13 ;
+14 ; Determine test result codes - check for primary and alternate codes
+15 ; For DoD/CHCS interface - do NOT process test codes using 99LRT as coding system per DoD/July 2002.
+16 SET LA7X=$$P^LA7VHLU(.LA7SEG,4,LA7FS)
SET (LA7RNLT,LA7RLNC)=""
+17 SET LA7TEST=$PIECE(LA7X,LA7CS)
+18 SET LA7TEST(0)=$$UNESC^LA7VHLU3($PIECE(LA7X,LA7CS,2),LA7FS_LA7ECH)
+19 IF LA7TEST(0)["^"
SET LA7TEST(0)=$TRANSLATE(LA7TEST(0),"^","~")
+20 SET LA7TEST(0,1)=$PIECE(LA7X,LA7CS,3)
+21 SET LA7TEST(2)=$PIECE(LA7X,LA7CS,4)
+22 SET LA7TEST(2,0)=$$UNESC^LA7VHLU3($PIECE(LA7X,LA7CS,5),LA7FS_LA7ECH)
+23 IF LA7TEST(2,0)["^"
SET LA7TEST(2,0)=$TRANSLATE(LA7TEST(2,0),"^","~")
+24 SET LA7TEST(2,1)=$PIECE(LA7X,LA7CS,6)
+25 FOR I=3,6
Begin DoDot:1
+26 SET LA7Y=$PIECE(LA7X,LA7CS,I-2)
+27 IF $PIECE(LA7X,LA7CS,I)="LN"
Begin DoDot:2
+28 IF $$GET1^DIQ(95.3,+LA7Y_",",.01)=LA7Y
SET LA7RLNC=+LA7Y
End DoDot:2
QUIT
+29 IF $PIECE(LA7X,LA7CS,I)="99VA64"
Begin DoDot:2
+30 IF $$FIND1^DIC(64,"","OMX",LA7Y)
SET LA7RNLT=LA7Y
End DoDot:2
QUIT
+31 IF $PIECE(LA7X,LA7CS,I)="99LRT"
Begin DoDot:2
+32 IF LA7TEST(0)=""
IF LA7TEST(2,0)'=""
SET LA7TEST(0)=LA7TEST(2,0)
+33 IF LA7TEST(2,0)=""
IF LA7TEST(0)'=""
SET LA7TEST(2,0)=LA7TEST(0)
+34 IF I=3
SET (LA7TEST,LA7TEST(0),LA7TEST(0,1))=""
QUIT
+35 IF I=6
SET (LA7TEST(2),LA7TEST(2,0),LA7TEST(2,1))=""
QUIT
End DoDot:2
QUIT
End DoDot:1
+36 IF LA7TEST=""
IF LA7TEST(2)'=""
Begin DoDot:1
+37 SET LA7TEST=LA7TEST(2)
SET LA7TEST(0)=LA7TEST(2,0)
SET LA7TEST(0,1)=LA7TEST(2,1)
+38 SET (LA7TEST(2),LA7TEST(2,0),LA7TEST(2,1))=""
End DoDot:1
+39 ;
+40 ; No test code in message
+41 IF LA7TEST=""
IF LA7TEST(2)=""
Begin DoDot:1
+42 NEW LA7OBX
+43 SET LA7OBX=LA7SEG(0)
+44 DO CREATE^LA7LOG(15)
End DoDot:1
QUIT
+45 ;
+46 ; Test code not found in auto inst file, also check alternate codes,
+47 ; and log error if none found.
+48 IF LA7MTYP="ORU"
Begin DoDot:1
+49 IF LA7TEST'=""
IF $DATA(^LAB(62.4,LA7624,3,"AC",LA7TEST))
QUIT
+50 IF LA7TEST(2)'=""
IF $DATA(^LAB(62.4,LA7624,3,"AC",LA7TEST(2)))
Begin DoDot:2
+51 SET LA7TEST=LA7TEST(2)
SET LA7TEST(0)=LA7TEST(2,0)
SET LA7TEST(0,1)=LA7TEST(2,1)
End DoDot:2
QUIT
+52 DO CREATE^LA7LOG(16)
SET LA7TEST=""
End DoDot:1
IF LA7TEST=""
QUIT
+53 ;
+54 ; Units - trim leading/trailing spaces
+55 SET LA7X=$$P^LA7VHLU(.LA7SEG,7,LA7FS)
SET LA7UNITS=""
+56 IF LA7X'=""
Begin DoDot:1
+57 FOR I=1:1:6
SET LA7UNITS(I)=$PIECE(LA7X,LA7CS,I)
+58 SET LA7UNITS=$$TRIM^XLFSTR(LA7UNITS(1),"LR"," ")
+59 IF LA7UNITS["^"
Begin DoDot:2
+60 NEW LA7STR
SET LA7STR("^")="~U~"
+61 SET LA7UNITS=$$REPLACE^XLFSTR(LA7UNITS,.LA7STR)
End DoDot:2
End DoDot:1
+62 ;
+63 ; Observation result status - Table 0085
+64 SET LA7ORS=$$P^LA7VHLU(.LA7SEG,12,LA7FS)
+65 ;
+66 ; Responsible observer
+67 SET LA7RO=$$XCNTFM^LA7VHLU4($$P^LA7VHLU(.LA7SEG,17,LA7FS),LA7ECH)
+68 ;
+69 ; Observation method
+70 SET LA7X=$$P^LA7VHLU(.LA7SEG,18,LA7FS)
SET LA7OBM=""
+71 IF $PIECE(LA7X,LA7CS,3)="99VA64_2"
SET LA7OBM=$PIECE($PIECE(LA7X,LA7CS,1),".",2)
+72 ;
+73 ; Equipment instance identifier
+74 SET LA7EII=$$P^LA7VHLU(.LA7SEG,19,LA7FS)
+75 IF LA7EII'=""
Begin DoDot:1
+76 SET LA7EII=$$UNESC^LA7VHLU3(LA7EII,LA7FS_LA7ECH)
+77 SET LA7EII=$TRANSLATE(LA7EII,"^",";")
End DoDot:1
+78 ;
+79 ; Process ORU message results for all tests which use this test code.
+80 IF LA7MTYP="ORU"
Begin DoDot:1
+81 SET LA76241=0
+82 FOR
SET LA76241=$ORDER(^LAB(62.4,LA7624,3,"AC",LA7TEST,LA76241))
IF 'LA76241
QUIT
DO PROCESS
End DoDot:1
QUIT
+83 ;
+84 IF LA7MTYP="ORM"
IF $GET(LA7696)>0
DO ORESULTS^LA7VIN5A
+85 ;
+86 QUIT
+87 ;
+88 ;
PROCESS ; Process results for a given test code
+1 SET LA7VAL=$$P^LA7VHLU(.LA7SEG,6,LA7FS)
+2 IF LA7VTYP="CE"
IF $PIECE(LA7VAL,LA7CS,2)'=""
SET LA7VAL=$PIECE(LA7VAL,LA7CS,2)
+3 IF '$TEST
SET LA7VAL=$PIECE(LA7VAL,LA7CS)
+4 ;
+5 FOR LA7I=0,1,2
SET LA76241(LA7I)=$GET(^LAB(62.4,LA7624,3,LA76241,LA7I))
+6 ;
+7 ; Chem test fields incorrect
+8 IF (LA76241(0)="")!(LA76241(1)="")
Begin DoDot:1
+9 DO CREATE^LA7LOG(18)
End DoDot:1
QUIT
+10 ;
+11 ; Setup LA7RMK(0) variable in case comments (NTE) sent with test results.
+12 SET LA7RMK(0,+LA76241(0))=+$PIECE(LA76241(2),"^",7)_"^"_$PIECE(LA76241(2),"^",8)
+13 ;
+14 ;lab data field
SET LA76304=+$PIECE(LA76241(1),"(",2)
+15 ; No dataname for this result
+16 IF LA76304'>1
Begin DoDot:1
+17 DO CREATE^LA7LOG(18)
End DoDot:1
QUIT
+18 ;
+19 ; Set flag for new results alert
+20 IF LA7ORS'=""
IF "CDW"'[LA7ORS
SET ^TMP("LA7-ORU",$JOB,LA76248,LA76249)=""
+21 ;
+22 ; Set flag to send amended results bulletin
+23 IF LA7INTYP=10
IF LA7ORS'=""
IF "CDW"[LA7ORS
Begin DoDot:1
+24 SET LA7I=$ORDER(^TMP("LA7 AMENDED RESULTS",$JOB,""),-1)
SET LA7I=LA7I+1
+25 SET X=LA7LWL_"^"_LA7ISQN_"^"_LA76304_"^"_LA76248_"^"_LA76249_"^"_LA7ORS_"^"_LA7TEST_"^"_$SELECT(LA7TEST(0)'="":LA7TEST(0),1:LA7TEST(2,0))_"^"_$$P^LA7VHLU(.LA7SEG,9,LA7FS)
+26 SET ^TMP("LA7 AMENDED RESULTS",$JOB,LA7I)=X
+27 IF LA7UID'=""
SET ^LAH("LA7 AMENDED RESULTS",LA7UID,LA76304,LA7LWL,LA7ISQN)=X
End DoDot:1
+28 ;
+29 ; NOTE - this array can be set from inside PARAM 1
+30 KILL LA7XFORM
+31 ; execute PARAM 1 if not a LEDI interface
+32 IF LA7INTYP'=10
XECUTE $PIECE(LA76241(0),"^",2)
+33 IF $PIECE(LA76241(2),"^",3)=0
QUIT
+34 IF $PIECE(LA76241(2),"^",3)=2
IF "CFUX"'[LA7ORS
QUIT
+35 IF LA7ORS="X"
IF LA7VAL=""
QUIT
+36 ;
+37 ; No value found
+38 IF LA7VAL=""
Begin DoDot:1
+39 DO CREATE^LA7LOG(17)
End DoDot:1
QUIT
+40 ;
+41 ; Transform result based on fields in file 62.4
+42 DO XFORM^LA7VIN5A
+43 IF LA7VAL=""
QUIT
+44 ;
+45 ; Check if result passes input transform on data name
+46 DO CHKDIE^LA7VIN5A
+47 IF LA7VAL=""
QUIT
+48 ;
+49 ; Set flag to not store comments if it wasn't explicitly ordered.
+50 IF $GET(LA7LIMIT)=1
Begin DoDot:1
+51 NEW LA76804
+52 KILL LA7LIMIT,LA7TREEN,^TMP("LA7TREE",$JOB)
+53 ; Store all tests accessioned in ^TMP
+54 SET LA76804=0
+55 FOR
SET LA76804=$ORDER(^LRO(68,LA7AA,1,LA7AD,1,LA7AN,4,LA76804))
IF 'LA76804
QUIT
DO UNWIND^LA7UTIL(LA76804)
+56 ;wasn't ordered
IF '$DATA(^TMP("LA7TREE",$JOB,+LA76241(0)))
SET LA7LIMIT=1
End DoDot:1
+57 IF $GET(LA7LIMIT)
Begin DoDot:1
+58 SET $PIECE(LA7RMK(0,+LA76241(0)),"^",1)=0
+59 KILL LA7LIMIT,^TMP("LA7TREE",$JOB)
End DoDot:1
QUIT
+60 KILL ^TMP("LA7TREE",$JOB)
+61 ;
+62 ; Check point of care interface for matching specimen type for this test in #62.4
+63 IF LA7INTYP>19
IF LA7INTYP<30
Begin DoDot:1
+64 NEW LA70070
+65 SET LA761=""
SET LA7X=$PIECE(LA76241(2),"^",13)
IF 'LA7X
QUIT
+66 SET LA70070=$$GET1^DIQ(61,LA7X_",","LEDI HL7:HL7 ABBR")
+67 IF LA70070=LA7SPEC
SET LA761=LA7X
End DoDot:1
IF 'LA761
QUIT
+68 ;
+69 ; Set data node=test value
+70 SET $PIECE(^LAH(LA7LWL,1,LA7ISQN,LA76304),"^")=LA7VAL
+71 ;
+72 ; Store reference ranges except for UI (LA7INTYP=1) interfaces
+73 IF LA7INTYP'=1
DO REFRNG^LA7VIN5A($$P^LA7VHLU(.LA7SEG,8,LA7FS))
+74 ;
+75 ; Store order/result codes/observation method except for UI (LA7INTYP=1) interfaces
+76 SET LA7X=$PIECE(^LAH(LA7LWL,1,LA7ISQN,LA76304),"^",3)
+77 IF LA7ONLT
SET $PIECE(LA7X,"!",1)=LA7ONLT
+78 IF LA7RNLT
SET $PIECE(LA7X,"!",2)=LA7RNLT
+79 IF LA7RLNC
SET $PIECE(LA7X,"!",3)=LA7RLNC
+80 IF LA7OBM
SET $PIECE(LA7X,"!",4)=LA7OBM
+81 IF LA7INTYP'=1
SET $PIECE(^LAH(LA7LWL,1,LA7ISQN,LA76304),"^",3)=LA7X
+82 ;
+83 ; Store abnormal flags except for UI (LA7INTYP=1) interfaces.
+84 IF LA7INTYP'=1
DO ABFLAG^LA7VIN5A($$P^LA7VHLU(.LA7SEG,9,LA7FS))
+85 ;
+86 ; Store units except for UI (LA7INTYP=1) interfaces which pull values from file #60.
+87 IF LA7INTYP'=1
IF LA7UNITS'=""
Begin DoDot:1
+88 SET LA7X=$PIECE($GET(^LAH(LA7LWL,1,LA7ISQN,LA76304)),"^",5)
+89 SET $PIECE(LA7X,"!",7)=LA7UNITS
+90 SET $PIECE(^LAH(LA7LWL,1,LA7ISQN,LA76304),"^",5)=LA7X
End DoDot:1
+91 ;
+92 ; Store responsible observer on POC interfaces
+93 IF LA7RO'=""
IF LA7INTYP>19
IF LA7INTYP<30
Begin DoDot:1
+94 IF $PIECE(LA7RO,"^",2)
SET $PIECE(^LAH(LA7LWL,1,LA7ISQN,LA76304),"^",4)=$PIECE(LA7RO,"^",2)
End DoDot:1
+95 ;
+96 ; Store specimen type except for UI (LA7INTYP=1) interfaces which pull values from the accession.
+97 IF LA7INTYP'=1
IF $GET(LA761)
Begin DoDot:1
+98 SET X=$PIECE(^LAH(LA7LWL,1,LA7ISQN,LA76304),"^",5)
+99 SET $PIECE(X,"!")=LA761
+100 SET $PIECE(^LAH(LA7LWL,1,LA7ISQN,LA76304),"^",5)=X
End DoDot:1
+101 ;
+102 ; Store where test was performed except for UI (LA7INTYP=1) interfaces.
+103 IF LA7INTYP'=1
Begin DoDot:1
+104 NEW LA74,LA7I,LA7X
+105 SET LA7X=$$P^LA7VHLU(.LA7SEG,24,LA7FS)
SET LA74=""
+106 IF $PIECE(LA7X,LA7CS,6)="CLIA"
SET LA74=$$IDX^XUAF4("CLIA",$PIECE(LA7X,LA7CS,10))
+107 IF LA74
SET $PIECE(^LAH(LA7LWL,1,LA7ISQN,LA76304),"^",9)=LA74
QUIT
+108 SET LA7X=$$P^LA7VHLU(.LA7SEG,16,LA7FS)
+109 FOR LA7I=1,4
IF $PIECE(LA7X,LA7CS,LA7I+2)?1(1"L-CL",1"CLIA",1"99VACLIA")
SET LA74=$$IDX^XUAF4("CLIA",$PIECE(LA7X,LA7CS,LA7I))
+110 IF LA74
SET $PIECE(^LAH(LA7LWL,1,LA7ISQN,LA76304),"^",9)=LA74
QUIT
+111 DO PRDID^LA7VIN5A($$P^LA7VHLU(.LA7SEG,16,LA7FS),LA7SFAC,LA7CS)
End DoDot:1
+112 ;
+113 ; Store equipment instance identifier
+114 IF LA7EII'=""
DO EII^LA7VIN5A
+115 ;
+116 ; If results for LEDI interface (LA7INTYP=10) and site keeps file #60
+117 ; in sync with reference lab then compare message's units and normals
+118 ; with site's to detect changes(LA7FLAG=1) and notify site.
+119 IF LA7INTYP=10
IF $GET(LA761)
IF $GET(^LAB(60,+$PIECE(LA76241(0),"^"),1,LA761,.1))
Begin DoDot:1
+120 NEW LA760,LA7FLAG,LA7I,LA7Y,LA7X
+121 SET LA760=+$PIECE(LA76241(0),"^")
SET LA7Y=^LAB(60,LA760,1,LA761,0)
SET LA7FLAG=0
+122 SET LA7X=$PIECE(^LAH(LA7LWL,1,LA7ISQN,LA76304),"^",5)
+123 IF $PIECE(LA7Y,"^",7)'=$PIECE(LA7X,"!",7)
SET LA7FLAG=1
+124 IF 'LA7FLAG
IF $PIECE(LA7Y,"^",2)=$PIECE(LA7X,"!",2)
IF $PIECE(LA7Y,"^",3)=$PIECE(LA7X,"!",3)
QUIT
+125 IF 'LA7FLAG
Begin DoDot:2
+126 NEW AGE,DOB,PNM,SEX
+127 NEW LRDPF,LRNG,LRNGS,LRNG2,LRNG3,LRNG4,LRNG5,LRTREA,LRWRD,LRX,LRY
+128 IF $GET(LRDFN)
DO DEM^LRX
DO KVAR^VADPT
+129 SET LRNG=LA7Y
DO NORM^LRVER5
+130 SET LA7Y=$TRANSLATE(LRNG,$CHAR(34),"")
SET LA7X=$TRANSLATE(LA7X,$CHAR(34),"")
+131 IF $PIECE(LA7Y,"^",2)=$PIECE(LA7X,"!",2)
IF $PIECE(LA7Y,"^",3)=$PIECE(LA7X,"!",3)
QUIT
+132 SET LA7FLAG=1
End DoDot:2
+133 IF 'LA7FLAG
QUIT
+134 SET LA7I=$ORDER(^TMP("LA7 UNITS/NORMALS CHANGED",$JOB,""),-1)
SET LA7I=LA7I+1
+135 SET X=LA7LWL_"^"_LA7ISQN_"^"_LA76304_"^"_LA76248_"^"_LA76249_"^"_LA7ORS_"^"_LA7TEST_"^"_$SELECT(LA7TEST(0)'="":LA7TEST(0),1:LA7TEST(2,0))_"^"_$$P^LA7VHLU(.LA7SEG,9,LA7FS)_"^"_LA760
+136 SET ^TMP("LA7 UNITS/NORMALS CHANGED",$JOB,LA7I)=X
End DoDot:1
+137 ;
+138 ; If LEDI interface and order status change store which results
+139 ; associated with ordered test. Used to determine if order status
+140 ; changed bulletin needs to be generated.
+141 IF LA7INTYP=10
IF LA7SAC?1(1"A",1"G")
Begin DoDot:1
+142 SET LA7I=$GET(LA7SAC(0))
IF 'LA7I
QUIT
+143 SET ^TMP("LA7 ORDER STATUS",$JOB,LA7I,+LA76241(0))=""
End DoDot:1
+144 QUIT