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

LA7VHLU1.m

Go to the documentation of this file.
  1. LA7VHLU1 ;DALOI/JMC - HL7 segment builder utility ;04/30/10 19:10
  1. ;;5.2;AUTOMATED LAB INSTRUMENTS;**46,61,64,74**;Sep 27, 1994;Build 229
  1. ;
  1. ;
  1. SETID(LA76249,LA7ID,LA7X,LA7TYP) ; Setup identifier's in TMP global for later storing.
  1. ; Call with LA76249 = ien of message in #62.49
  1. ; LA7ID = root of identifier
  1. ; LA7X = value to add to identifier
  1. ; LA7TYP = type - primary(1) or additional(0)
  1. N Y
  1. I $G(LA7X)="" Q
  1. S Y=$O(^TMP("LA7-ID",$J,LA76249,""),-1)+1 ; get next entry
  1. S ^TMP("LA7-ID",$J,LA76249,Y)=LA7ID_LA7X_"^"_+$G(LA7TYP)
  1. Q
  1. ;
  1. ;
  1. UTS(LA7628,LA7UID,LA760) ; Update test status on manifest
  1. ; Call with LA7628 = ien of shipping manifest in #62.8
  1. ; LA7UID = accession's UID
  1. ; LA760 = file # 60 ien of ordered test
  1. ;
  1. ; Sets to status 4 (partial). Will deal with 5 (completed) at later time
  1. ; when lab package has capability of designating an accession as completed.
  1. ;
  1. N LA762801,LA7X
  1. ;
  1. S LA762801=0
  1. F S LA762801=$O(^LAHM(62.8,LA7628,10,"UID",LA7UID,LA762801)) Q:'LA762801 D
  1. . S LA7X=$G(^LAHM(62.8,LA7628,10,LA762801,0))
  1. . I $P(LA7X,"^",2)'=LA760 Q ; Not the test we're looking for.
  1. . I $P(LA7X,"^",8)>2,$P(LA7X,"^",8)<5 D STSUP^LA7SMU(LA7628,LA762801,4)
  1. Q
  1. ;
  1. ;
  1. UPID(LA76249) ; Update identifier's associated with the message in #62.49
  1. ; Call with LA76249 = ien of message in #62.49
  1. ;
  1. N FDA,LA7ERR,LA7I,LA7TYP,LA7X
  1. ;
  1. S LA7I=0
  1. F S LA7I=$O(^TMP("LA7-ID",$J,LA76249,LA7I)) Q:'LA7I D
  1. . S LA7X=^TMP("LA7-ID",$J,LA76249,LA7I),LA7TYP=+$P(LA7X,"^",2)
  1. . I LA7TYP=1,$L($P(LA7X,"^"))<46 D
  1. . . S FDA(1,62.49,LA76249_",",5)=$P(LA7X,"^")
  1. . . D FILE^DIE("","FDA(1)","LA7ERR(1)"),CLEAN^DILF
  1. . I $D(^LAHM(62.49,LA76249,.2,"B",$P(LA7X,"^"))) Q
  1. . S FDA(2,62.49002,"+2,"_LA76249_",",.01)=$P(LA7X,"^")
  1. . D UPDATE^DIE("","FDA(2)","","LA7ERR(2)"),CLEAN^DILF
  1. ;
  1. ; Clean up
  1. D CLEAN^DILF
  1. K ^TMP("LA7-ID",$J,LA76249)
  1. Q
  1. ;
  1. ;
  1. CHKDT(LA7X) ; Check validity of date/time
  1. ; Adjust invalid times to closest valid time - correct for lab problem
  1. ; that generated invalid FileMan date/times.
  1. ; If hours>24 then set to 24 with no minutes/seconds
  1. ; If minutes greater than 59 then set to 59
  1. ; If seconds greater than 59 then set to 59
  1. ;
  1. N I,LA7Y,X
  1. ;
  1. S LA7Y=$P(LA7X,".",2)
  1. ;
  1. ; If time present then check otherwise skip and return input.
  1. I LA7Y'="" D
  1. . F I=1:2:5 D
  1. . . S LA7Y(I)=$E(LA7Y,I,I+1)
  1. . . I $L(LA7Y(I))=1 S LA7Y(I)=LA7Y(I)_"0"
  1. . . I LA7Y(I)>$S(I=1:24,1:59) S LA7Y(I)=$S(I=1:24,1:59)
  1. . . I I=1,LA7Y(1)=24 S LA7Y=24
  1. . S X="."_LA7Y(1)_LA7Y(3)_LA7Y(5),X=+X
  1. . S $P(LA7X,".",2)=$P(X,".",2)
  1. ;
  1. Q LA7X
  1. ;
  1. ;
  1. REFUNIT(LA7SB,LA761) ; Find reference ranges/units from file #60
  1. ; Call with LA7SB = dataname from "CH" subscript
  1. ; LA761 = pointer to topography file #61
  1. ;
  1. ; Returns LA7Y = reference low^reference high^units^critcal low^critcal high^therapeutic low^therapeutic high
  1. ;
  1. ; Finds first entry in file #60 that is associated with this dataname.
  1. N LA760,LA7X,LA7Y
  1. ;
  1. S LA7Y=""
  1. S LA760=+$O(^LAB(60,"C","CH;"_LA7SB_";1",0))
  1. S LA7X=$G(^LAB(60,LA760,1,LA761,0))
  1. S $P(LA7Y,"^")=$P(LA7X,"^",2)
  1. S $P(LA7Y,"^",2)=$P(LA7X,"^",3)
  1. S $P(LA7Y,"^",3)=$P(LA7X,"^",7)
  1. S $P(LA7Y,"^",4)=$P(LA7X,"^",4)
  1. S $P(LA7Y,"^",5)=$P(LA7X,"^",5)
  1. S $P(LA7Y,"^",6)=$P(LA7X,"^",11)
  1. S $P(LA7Y,"^",7)=$P(LA7X,"^",12)
  1. ;
  1. Q LA7Y
  1. ;
  1. ;
  1. OKTOSND(LRSS,LRSB,LA760) ; Check if test ok to send - is (O)utput or (B)oth
  1. ; Call with LRSS = file #63 subscript
  1. ; LRSB = file #63 data name or field reference
  1. ; LA760 = file #60 ien
  1. ;
  1. ; Returns LA7Y = 0-do not send, 1-yes-ok (default)
  1. ;
  1. N LA760,LA7X,LA7Y
  1. S LA7Y=1
  1. ;
  1. ; If "CH" subscript check file #60 test's type that use this dataname
  1. ; and if find one that is type "O" or "B" then set to yes.
  1. I LRSS="CH" D
  1. . I $G(LA760) D Q
  1. . . I "BO"'[$P(^LAB(60,LA760,0),"^",3) S LA7Y=0
  1. . S (LA760,LA7X)=0
  1. . F S LA760=$O(^LAB(60,"C","CH;"_LRSB_";1",LA760)) Q:'LA760 D
  1. . . I "BO"[$P(^LAB(60,LA760,0),"^",3) S LA7X=1
  1. . S LA7Y=LA7X
  1. ;
  1. Q LA7Y
  1. ;
  1. ;
  1. FAMG(LA76248,LA7TYP) ; Find alert mail group for this alert type
  1. ; Call with LA76248 = ien of entry in file #62.48
  1. ; LA7TYP = type of alert
  1. ; (1-new results)
  1. ; (2-error on message)
  1. ; (3-orders received)
  1. ;
  1. ; Returns LA7MG = name of mail group
  1. ;
  1. N LA7MG,X,Y
  1. S (LA7MG,X)=""
  1. F S X=$O(^LAHM(62.48,+$G(LA76248),20,"B",LA7TYP,X)) Q:'X D
  1. . S Y=$G(^LAHM(62.48,LA76248,20,X,0))
  1. . I $P(Y,"^",2)'="" S LA7MG=$P(Y,"^",2) ; Send to mail group.
  1. ;
  1. ; Fail safe mail group when no mail group specified
  1. I LA7MG="" S LA7MG="LAB MESSAGING"
  1. ;
  1. Q LA7MG
  1. ;
  1. ;
  1. GETISO(SUBFL,IENS) ; Retrieve isolate id for micro specimens from file #63
  1. ; Call with SUBFL = FileMan subfile #
  1. ; IENS = FileMan iens of record
  1. ;
  1. ; Returns LA7Y = isolate id as sub-id
  1. ;
  1. N LA7Y
  1. ;
  1. S LA7Y=$$GET1^DIQ(SUBFL,IENS,.1)
  1. I LA7Y="" D
  1. . N FDA,ID,LA74,LA7DIE
  1. . S ID=$S(SUBFL=63.3:3,SUBFL=63.34:6,SUBFL=63.37:9,SUBFL=63.39:12,SUBFL=63.43:17,1:"")
  1. . S ID=ID_"-"_$P(IENS,",")
  1. . S LA74=+$$KSP^XUPARAM("INST")
  1. . S LA7Y=$$MAKEISO^LRVRMI1(LA74,ID)
  1. . S FDA(63,SUBFL,IENS,.1)=LA7Y
  1. . D FILE^DIE("","FDA(63)","LA7DIE(2)")
  1. ;
  1. Q LA7Y
  1. ;
  1. ;
  1. LAHSTAT(LRLL,ISQN,ERR,ERRMSG) ;
  1. ; Determine related file #62.49 message(s) status for results in LAH global.
  1. ; Call with LRLL = ien of loadlist in LAH global
  1. ; ISQN = ien of entry in LAH(LRLL) global
  1. ; ERR = 0 (do not return error messages)
  1. ; = .5 (return status of last message processed)
  1. ; = 1 (return error messages in array ERRMSG)
  1. ;
  1. ; ERRMSG = array to return error messages (pass by reference)
  1. ;
  1. ; Returns STATUS = 0 (no related file #62.49 messages found)
  1. ; = 1 (one or more related file #62.49 messages encountered no errors in processing)
  1. ; = 2 (one or more related file #62.49 messages encountered errors in processing)
  1. ;
  1. ; ERRMSG = array listing related error messages (indexed by FM D/T of error)
  1. ; Example: ERRMSG(3061010.195711)="Msg #1070: No File #62.47 mapping found for OBX-3:0410.3\GRAM STAIN\99LAB"
  1. ;
  1. N I,K,LA7DT,LA7IEN,LA7X,STATUS,X
  1. S (LA7IEN,STATUS)=0
  1. F S LA7IEN=$O(^LAH(LRLL,1,ISQN,.01,LA7IEN)) Q:'LA7IEN D
  1. . I ERR=.5,LA7IEN'=$P(^LAH(LRLL,1,ISQN,0),"^",13) Q
  1. . S LA7X=$G(^LAHM(62.49,LA7IEN,0))
  1. . I $P(LA7X,"^",3)="X",STATUS=0 S STATUS=1 Q
  1. . I $P(LA7X,"^",3)'="E" Q
  1. . S STATUS=2 Q:'ERR
  1. . S LA7DT=$P(LA7X,"^",5),LA7DT(0)=LA7DT\1,LA7DT(1)=LA7DT#1
  1. . S K="LA7ERR^"_(LA7DT(0)-.1)
  1. . F S K=$O(^XTMP(K)) Q:K=""!($P(K,"^")'="LA7ERR") D
  1. . . I LA7DT(0)=$P(K,"^",2) S I=LA7DT(1)-.00000001
  1. . . E S I=0
  1. . . F S I=$O(^XTMP(K,I)) Q:'I D
  1. . . . S X=^XTMP(K,I)
  1. . . . I $P(X,"^",2)=LA7IEN S ERRMSG($P(K,"^",2)_I)=$$DECODEUP^XMCU1($P(X,"^",4))
  1. ;
  1. Q STATUS
  1. ;
  1. ;
  1. LAHSTATP(ERRMSG) ; Print/display error array from LAHSTAT function call.
  1. ; Call with ERRMSG = array of error messages (pass by reference)
  1. ;
  1. N A,LA7IEN,LAJ
  1. ;
  1. S LA7IEN=0,LAJ=1
  1. S A(LAJ)="Errors reported on message(s):",A(LAJ,"F")="!!"
  1. F S LA7IEN=$O(ERRMSG(LA7IEN)) Q:'LA7IEN S LAJ=LAJ+1,A(LAJ)=$$FMTE^XLFDT(LA7IEN,"1M")_" - "_ERRMSG(LA7IEN),A(LAJ,"F")="!?1"
  1. D EN^DDIOL(.A)
  1. Q
  1. ;
  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;;