Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: BLRRIIN2

BLRRIIN2.m

Go to the documentation of this file.
  1. BLRRIIN2 ;VA/DALOI/JRR - Process Incoming UI Msgs, continued ;JUL 06, 2010 3:14 PM
  1. ;;5.2;IHS LABORATORY;**1027**;NOV 01, 1997
  1. ;;5.2;AUTOMATED LAB INSTRUMENTS;**17,23,27,46**;Sep 27, 1994
  1. ;This routine is a continuation of LA7UIIN1 and is only called from there.
  1. ;It is called to begin processing the NTE & OBX segments.
  1. QUIT
  1. ;
  1. NTE ; Process NTE segments that follow the OBR and OBX segments
  1. ; These NTE segments contain comments from instruments or other facilities.
  1. ; NTE segments following OBR's contain comments which refer to the entire test battery.
  1. ; NTE segments following OBX's contain comments which are test specific.
  1. ; Test specific comments can be prefaced with a site defined prefix -
  1. ; see field REMARK PREFIX (#19) in CHEM TEST multiple of AUTOMATED INSTRUMENT (#62.4 file.
  1. ; NTE segments are not allowed anywhere except after the OBR or OBX segments.
  1. ; There can be more than one NTE, each will be stored as a comment in ^LAH.
  1. ;
  1. F LA762495=LA762495:0 S LA762495=$O(^LAHM(62.49,LA76249,150,LA762495)) Q:'LA762495 S LA7NTE=$G(^(LA762495,0)) Q:$E(LA7NTE,1,3)'="NTE" D
  1. . N LA7,LA7I
  1. . S LA7RMK=$P(LA7NTE,LA7FS,4)
  1. . S LA7=$RE(LA7RMK)
  1. . F LA7I=1:1:$L(LA7) Q:$E(LA7,LA7I)'=" " ; Find start of trailing spaces.
  1. . S LA7RMK=$E(LA7RMK,1,($L(LA7RMK)-LA7I+1)) ; Truncate trailing spaces.
  1. . I LA7RMK=$TR($P($G(^LRO(68,LA7AA,1,LA7AD,1,LA7AN,3)),"^",6),"~") Q ; Don't store remark if same as specimen comment (without "~").
  1. . I LA7RMK=$G(^LR(+$G(^LRO(68,LA7AA,1,LA7AD,1,LA7AN,0)),.091)) Q ; or patient info (#.091 in file 63) - info previously downloaded
  1. . I LA7RMK="" Q ; No remark to store.
  1. . I $O(LA7RMK(0,0)) D Q ; If test specific, store test name with comments (see below)
  1. . . N LA7I
  1. . . S LA7I=0
  1. . . F S LA7I=$O(LA7RMK(0,LA7I)) Q:'LA7I I $P(LA7RMK(0,LA7I),"^") D RMKSET^LASET(LA7LWL,LA7ISQN,LA7RMK,$P(LA7RMK(0,LA7I),"^",2))
  1. . I $P(LA7INST,"^",17) D RMKSET^LASET(LA7LWL,LA7ISQN,LA7RMK,"") ;store comment in 1 node of ^LAH global
  1. K LA7RMK
  1. Q:LA762495="" ;no more segments to process
  1. ;
  1. OBX F LA762495=LA762495-1:0 S LA762495=$O(^LAHM(62.49,LA76249,150,LA762495)) Q:'LA762495 K LA7OBX S LA7OBX=^(LA762495,0) Q:$E(LA7OBX,1,3)'="OBX" D
  1. . K LA7RMK
  1. . S LA7TEST=$P($P(LA7OBX,LA7FS,4),LA7CS,1)
  1. . I LA7TEST="" D QUIT
  1. . . D CREATE^LA7LOG(15)
  1. . I '$D(^LAB(62.4,LA7624,3,"AC",LA7TEST)) D QUIT ;test code not found in auto inst file
  1. . . D CREATE^LA7LOG(16)
  1. . S LA76241=0 ; Process results for all tests which use this test code.
  1. . F S LA76241=$O(^LAB(62.4,LA7624,3,"AC",LA7TEST,LA76241)) Q:'LA76241 D
  1. . . S LA7VAL=$P(LA7OBX,LA7FS,6)
  1. . . Q:$G(LA7VAL)="DNR" ;cmi/anch/maw 8/16/2007 don't process DNR's
  1. . . F LA7I=0,1,2 S LA76241(LA7I)=$G(^LAB(62.4,LA7624,3,LA76241,LA7I))
  1. . . I (LA76241(0)="")!(LA76241(1)="") D QUIT ;chem test fields incorrect
  1. . . . D CREATE^LA7LOG(18)
  1. . . ; Setup LA7RMK(0) variable in case comments (NTE) sent with test results.
  1. . . S LA7RMK(0,+LA76241(0))=+$P(LA76241(2),"^",7)_"^"_$P(LA76241(2),"^",8)
  1. . . K LA7XFORM ;this array can be set from inside PARAM 1
  1. . . X $P(LA76241(0),"^",2) ;execute PARAM 1
  1. . . I LA7VAL="" D QUIT ;no value
  1. . . . D CREATE^LA7LOG(17)
  1. . . D XFORM ;transform result based on fields in file 62.4
  1. . . Q:LA7VAL=""
  1. . . I $G(LA7LIMIT)=1 D ;flag to not store if wasn't explicitly ordered
  1. . . . K LA7LIMIT,LA7TREEN,^TMP("LA7TREE",$J)
  1. . . . F LA76804=0:0 S LA76804=$O(^LRO(68,LA7AA,1,LA7AD,1,LA7AN,4,LA76804)) Q:'LA76804 D UNWIND^LA7UTIL(LA76804) ;store all tests accessioned in ^TMP
  1. . . . I '$D(^TMP("LA7TREE",$J,+LA76241(0))) S LA7LIMIT=1 ;wasn't ordered
  1. . . I $G(LA7LIMIT) D QUIT ;don't store
  1. . . . S $P(LA7RMK(0,+LA76241(0)),"^",1)=0 ; Set flag to not store comments if any.
  1. . . . K LA7LIMIT,^TMP("LA7TREE",$J)
  1. . . K ^TMP("LA7TREE",$J)
  1. . . S LA76304=+$P(LA76241(1),"(",2) ;lab data field
  1. . . I LA76304'>1 D Q ; No dataname for this result
  1. . . . D CREATE^LA7LOG(18)
  1. . . S ^LAH(LA7LWL,1,LA7ISQN,LA76304)=LA7VAL ;set data node=test value
  1. . . D REFRNG($P(LA7OBX,LA7FS,8)) ; Store reference ranges
  1. . . D ABFLAG($P(LA7OBX,LA7FS,9)) ; Store abnormal flags
  1. . . D UNITS($P(LA7OBX,LA7FS,7)) ;Store Units cmi/maw 2/29/2008
  1. . . D PRDID($P(LA7OBX,LA7FS,16),LA7CS) ; Store where test was performed.
  1. I $E(LA7OBX,1,3)="NTE" S LA762495=LA762495-1 G NTE
  1. K LA7RMK
  1. Q
  1. ;
  1. XFORM ; Transform the result based on fields 12,13,14,16,17 in the Chem Test
  1. ; multiple in the Auto Instrument file (62.4), or set on the fly
  1. ; from PARAM 1
  1. N LA7I
  1. S LA7XFORM=LA76241(2)
  1. ; get PARAM 1 overides
  1. I $D(LA7XFORM(1)),LA7XFORM(1)?1.N S $P(LA7XFORM,"^")=LA7XFORM(1)
  1. F LA7I=2,3,5,6 I $D(LA7XFORM(LA7I)) S $P(LA7XFORM,"^",LA7I)=LA7XFORM(LA7I)
  1. ; set up defaults if field was not answered
  1. ;
  1. ; accept results,yes
  1. I $P(LA7XFORM,"^",3)="" S $P(LA7XFORM,"^",3)=1
  1. ; strip spaces,yes
  1. I $P(LA7XFORM,"^",6)="" S $P(LA7XFORM,"^",6)=1
  1. ;
  1. ; now transform
  1. ; don't accept results
  1. I '$P(LA7XFORM,"^",3) S LA7VAL="" Q
  1. ; accept ordered tests only
  1. I $P(LA7XFORM,"^",5) S LA7LIMIT=1
  1. ; decimal places if result start with number or decimal point
  1. ; skip results i.e. ">100".
  1. I $P(LA7XFORM,"^")?1.N,LA7VAL?1(1N.E,1".".E) D
  1. . S LA7VAL=$FN(LA7VAL,"",+LA7XFORM)
  1. ; strip spaces
  1. I $P(LA7XFORM,"^",6) S LA7VAL=$TR(LA7VAL," ","")
  1. ; make result a comment, store comment in ^LAH global
  1. ; set value to null after making into remark, don't store twice.
  1. I $P(LA7XFORM,"^",2) D
  1. . D RMKSET^LASET(LA7LWL,LA7ISQN,LA7VAL,"")
  1. . S LA7VAL=""
  1. Q
  1. ;
  1. ;
  1. PRDID(LA7PRDID,LA7CS) ; Process/Store Producer's ID
  1. ; Store where test was performed.
  1. ; Call with LA7PRDID = Producer's ID field
  1. ; LA7CS = component encoding character
  1. N LA7X,LA7Y
  1. S LA7PRDID=$G(LA7PRDID),LA7CS=$G(LA7CS)
  1. ; Don't store producer's id.
  1. I LA7PRDID=""!('$P(LA76241(2),"^",9))!(LA7CS="") Q
  1. ;
  1. S LA7X=$P(LA7PRDID,LA7CS,2)
  1. I $L($P(LA7PRDID,LA7CS)) S LA7X=LA7X_$S($L(LA7X):" ",1:"")_"["_$P(LA7PRDID,LA7CS)_"]"
  1. I LA7X="" Q
  1. S LA7X="results from "_LA7X
  1. S LA7Y=$P(LA7RMK(0,+LA76241(0)),"^",2)
  1. ; If no prefix, use test name.
  1. I '$L(LA7Y) S LA7Y=$P($G(^LAB(60,+LA76241(0),0)),"^")_": "
  1. D RMKSET^LASET(LA7LWL,LA7ISQN,LA7X,LA7Y)
  1. Q
  1. ;
  1. ;
  1. REFRNG(LA7X) ; Process/Store References Range.
  1. ; Call with LA7X = reference range to store.
  1. N LA7Y
  1. S LA7X=$G(LA7X)
  1. ; No ref range or don't store ref range.
  1. I LA7X=""!('$P(LA76241(2),"^",10)) Q
  1. S LA7X="ref range - "_LA7X
  1. S LA7Y=$P(LA7RMK(0,+LA76241(0)),"^",2)
  1. ; If no prefix, use test name.
  1. I '$L(LA7Y) S LA7Y=$P($G(^LAB(60,+LA76241(0),0)),"^")_": "
  1. D RMKSET^LASET(LA7LWL,LA7ISQN,LA7X,LA7Y)
  1. Q
  1. ;
  1. UNITS(LA7X) ;Process/Store Units cmi/maw 2/29/2008 store units if parameter set to yes
  1. N LA7Y
  1. S LA7X=$G(LA7X) ;units
  1. I LA7X=""!('$P(LA76241(2),"^",15)) Q ;quit if units blank or p15 of 2 array in AUTO INSTRUMENT CHEM TEST multiple set to NO
  1. S LA7X="Units - "_LA7X
  1. S LA7Y=$P(LA7RMK(0,+LA76241(0)),"^",2) ;test prefix
  1. ; If no prefix, use test name.
  1. I '$L(LA7Y) S LA7Y=$P($G(^LAB(60,+LA76241(0),0)),"^")_": " ;use test name if no prefix
  1. D RMKSET^LASET(LA7LWL,LA7ISQN,LA7X,LA7Y)
  1. Q
  1. ;
  1. ;
  1. ABFLAG(LA7X) ; Process/Store Abnormal Flags.
  1. ; Call with LA7X = abnormal flags to store.
  1. ; Converts flag to interpretation based on HL7 Table 0078.
  1. ; If no match store code instead of interpretation
  1. ;
  1. N I,LA7Y,LA7Z
  1. ;
  1. S LA7X=$G(LA7X)
  1. ; No flag or don't store abnormal flags.
  1. I LA7X=""!('$P(LA76241(2),"^",11)) Q
  1. F I=1:1:18 I LA7X=$P("L^H^LL^HH^<^>^N^A^AA^U^D^B^W^S^R^I^MS^VS","^",I) S LA7X=$P($T(ABFLAGS+I),";;",2) Q
  1. S LA7X="normalcy status - "_LA7X
  1. S LA7Y=$P(LA7RMK(0,+LA76241(0)),"^",2)
  1. ;
  1. ; If no prefix, use test name.
  1. I '$L(LA7Y) S LA7Y=$P($G(^LAB(60,+LA76241(0),0)),"^")_": "
  1. ;
  1. D RMKSET^LASET(LA7LWL,LA7ISQN,LA7X,LA7Y)
  1. Q
  1. ;
  1. ABFLAGS ;; HL7 Table 0078 Abnormal flags
  1. ;;Below low normal;;
  1. ;;Above high normal;;
  1. ;;Below lower panic limits;;
  1. ;;Above upper panic limits;;
  1. ;;Below absolute low-off instrument scale;;
  1. ;;Above absolute high-off instrument scale;;
  1. ;;Normal;;
  1. ;;Abnormal;;
  1. ;;Very abnormal;;
  1. ;;Significant change up;;
  1. ;;Significant change down;;
  1. ;;Better;;
  1. ;;Worse;;
  1. ;;Susceptible;;
  1. ;;Resistant;;
  1. ;;Intermediate;;
  1. ;;Moderately susceptible;;
  1. ;;Very susceptible;;