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

LA7CORU1.m

Go to the documentation of this file.
  1. LA7CORU1 ;VA/DALOI/JMC - Builder of HL7 Lab Results Microbiology OBR/OBX/NTE ; 22-Oct-2013 09:22 ; MAW
  1. ;;5.2;AUTOMATED LAB INSTRUMENTS;**46,1018,64,1027,68,1033**;NOV 1, 1997
  1. ;
  1. Q
  1. ;
  1. ;
  1. MI ; Build segments for "MI" subscript
  1. ;
  1. N LA7I,LA7ID,LA7IDT,LA7IENS,LA7NLT,LRDFN,LRIDT,LRSB,LRSS
  1. S LA7ORCSN=1
  1. ;
  1. S LRDFN=LA("LRDFN"),LRSS=LA("SUB"),(LA7IENS,LRIDT)=LA("LRIDT")
  1. ;
  1. ; Bacteriology Report
  1. I $D(^LR(LRDFN,LRSS,LRIDT,1)) D
  1. . S LA7IDT=LRIDT,LRSB=11,LA7NLT="87993.0000"
  1. . ;I $G(LA7INPT) D ORC^LA7CORU ;mu2 inpatient
  1. . D OBR^LA7CORU
  1. . D NTE^LA7CORU
  1. . F LRSB=1,11.7,1.5,11 D RPTNTE
  1. . N LRSB
  1. . S LA7OBXSN=0
  1. . ; Report urine/sputum screens
  1. . F LA7I=5,6 I $P(^LR(LRDFN,LRSS,LRIDT,1),"^",LA7I)'="" S LRSB=$S(LA7I=5:11.58,1:11.57) D OBX
  1. . ; Report gram stain
  1. . I $D(^LR(LRDFN,LRSS,LRIDT,2)) D GS
  1. . ; Check for organism id
  1. . I '$D(^LR(LRDFN,LRSS,LRIDT,3)) Q
  1. . S LRSB=12
  1. . D ORG
  1. . D MIC
  1. ;
  1. ; Parasite report
  1. I $D(^LR(LRDFN,LRSS,LRIDT,5)) D
  1. . S LRSB=14,LA7NLT="87505.0000"
  1. . ;I $G(LA7INPT) D ORC^LA7CORU ;mu2 inpatient
  1. . D OBR^LA7CORU
  1. . D NTE^LA7CORU
  1. . F LRSB=16.5,15.51,16.4,14 D RPTNTE
  1. . ; Check for organism id
  1. . I '$D(^LR(LRDFN,LRSS,LRIDT,6)) Q
  1. . N LRSB
  1. . S LA7OBXSN=0,LA7IDT=LRIDT,LRSB=16
  1. . D ORG
  1. ;
  1. ; Mycology report
  1. I $D(^LR(LRDFN,LRSS,LRIDT,8)) D
  1. . S LRSB=18,LA7NLT="87994.0000"
  1. . ;I $G(LA7INPT) D ORC^LA7CORU ;mu2 inpatient
  1. . D OBR^LA7CORU
  1. . D NTE^LA7CORU
  1. . F LRSB=20.5,19.6,20.4,18 D RPTNTE
  1. . ; Check for organism id
  1. . I '$D(^LR(LRDFN,LRSS,LRIDT,9)) Q
  1. . N LRSB
  1. . S LA7OBXSN=0,LA7IDT=LRIDT,LRSB=20
  1. . D ORG
  1. ;
  1. ; Mycobacterium report
  1. I $D(^LR(LRDFN,LRSS,LRIDT,11)) D
  1. . S LRSB=22,LA7NLT="87995.0000"
  1. . ;I $G(LA7INPT) D ORC^LA7CORU ;mu2 inpatient
  1. . D OBR^LA7CORU
  1. . D NTE^LA7CORU
  1. . F LRSB=26.5,26.4,22 D RPTNTE
  1. . N LRSB
  1. . S LA7OBXSN=0,LA7IDT=LRIDT
  1. . ; Report acid fast stain
  1. . I $P(^LR(LRDFN,LRSS,LRIDT,11),"^",3)'="" D
  1. . . S LRSB=24 D OBX
  1. . . S LRSB=25 D OBX
  1. . ; Check for organism id
  1. . I '$D(^LR(LRDFN,LRSS,LRIDT,12)) Q
  1. . S LRSB=26
  1. . D ORG
  1. . D MIC
  1. ;
  1. ; Virology report
  1. I $D(^LR(LRDFN,LRSS,LRIDT,16)) D
  1. . S LRSB=33,LA7NLT="87996.0000"
  1. . ;I $G(LA7INPT) D ORC^LA7CORU ;mu2 inpatient
  1. . D OBR^LA7CORU
  1. . D NTE^LA7CORU
  1. . F LRSB=36.5,36.4,33 D RPTNTE
  1. . ; Check for virus id
  1. . I '$D(^LR(LRDFN,LRSS,LRIDT,17)) Q
  1. . N LRSB
  1. . S LA7OBXSN=0,LA7IDT=LRIDT,LRSB=36
  1. . D ORG
  1. ;
  1. ; Antibiotic Levels
  1. I $D(^LR(LRDFN,LRSS,LRIDT,14)) D
  1. . N LA7SR
  1. . S LRSB=28,LA7NLT="93978.0000",LA7NTESN=0
  1. .; I $G(LA7INPT) D ORC^LA7CORU ;mu2 inpatient
  1. . D OBR^LA7CORU
  1. . S LA7SR=0
  1. . F S LA7SR=$O(^LR(LRDFN,LRSS,LRIDT,14,LA7SR)) Q:'LA7SR S LA7IDT=LRIDT_","_LA7SR D OBX
  1. ;
  1. Q
  1. ;
  1. ;
  1. GS ; Report Gram stain
  1. ;
  1. N LA7GS
  1. ;
  1. S LRSB=11.6,LA7GS=0
  1. F S LA7GS=$O(^LR(LRDFN,LRSS,LRIDT,2,LA7GS)) Q:'LA7GS D
  1. . S LA7IDT=LRIDT_","_LA7GS
  1. . D OBX
  1. Q
  1. ;
  1. ;
  1. RPTNTE ; Send report comments
  1. ;
  1. N LA7CMTYP,LA7FMT,LA7J,LA7ND,LA7SOC,LA7TXT,LA7X
  1. ;
  1. ; Source of comment - handle special codes for other systems, i,e. DOD-CHCS
  1. S LA7SOC=$S($G(LA7NVAF)=1:"AC",1:"L"),LA7ND=0
  1. ;
  1. S LA7FMT=0
  1. ; If HDR interface then send as repetition text.
  1. I $G(LA7INTYP)=30 S LA7FMT=2
  1. ;
  1. D
  1. . ; Bacterial preliminary/report/tests remark
  1. . I LRSB=11 S LA7ND=4,LA7CMTYP="VA-LRMI010" Q
  1. . I LRSB=1 S LA7ND=19,LA7CMTYP="VA-LRMI011" Q
  1. . I LRSB=1.5 S LA7ND=26,LA7CMTYP="VA-LRMI012" Q
  1. . I LRSB=11.7 S LA7ND=25,LA7CMTYP="VA-LRMI013" Q
  1. . ; Parasite preliminary/report/tests remark
  1. . I LRSB=14 S LA7ND=7,LA7CMTYP="VA-LRMI020" Q
  1. . I LRSB=16.5 S LA7ND=21,LA7CMTYP="VA-LRMI021" Q
  1. . I LRSB=16.4 S LA7ND=27,LA7CMTYP="VA-LRMI022" Q
  1. . I LRSB=15.1 S LA7ND=24,LA7CMTYP="VA-LRMI023" Q
  1. . ; Fungal preliminary/report/tests remark
  1. . I LRSB=18 S LA7ND=10,LA7CMTYP="VA-LRMI030" Q
  1. . I LRSB=20.5 S LA7ND=22,LA7CMTYP="VA-LRMI031" Q
  1. . I LRSB=20.4 S LA7ND=28,LA7CMTYP="VA-LRMI032" Q
  1. . I LRSB=19.6 S LA7ND=15,LA7CMTYP="VA-LRMI033" Q
  1. . ; Mycobacteria preliminary/report/tests remark
  1. . I LRSB=22 S LA7ND=13,LA7CMTYP="VA-LRMI040" Q
  1. . I LRSB=26.5 S LA7ND=23,LA7CMTYP="VA-LRMI041" Q
  1. . I LRSB=26.4 S LA7ND=29,LA7CMTYP="VA-LRMI042" Q
  1. . ; Viral preliminary/report/tests remark
  1. . I LRSB=33 S LA7ND=18,LA7CMTYP="VA-LRMI050" Q
  1. . I LRSB=36.5 S LA7ND=20,LA7CMTYP="VA-LRMI051" Q
  1. . I LRSB=36.4 S LA7ND=30,LA7CMTYP="VA-LRMI052" Q
  1. ;
  1. I LA7ND'>0 Q
  1. ;
  1. S LA7J=0
  1. F S LA7J=$O(^LR(LRDFN,LRSS,LRIDT,LA7ND,LA7J)) Q:'LA7J D
  1. . S LA7X=$G(^LR(LRDFN,LRSS,LRIDT,LA7ND,LA7J,0))
  1. . I LA7FMT=0 S LA7TXT=LA7X D NTE^LA7CORU1 Q
  1. . S LA7TXT(LA7J)=LA7X
  1. ;
  1. ; If formatted or repetition format then build comments to a NTE segment.
  1. I LA7FMT,$D(LA7TXT) D NTE^LA7CORU1
  1. ;
  1. Q
  1. ;
  1. ;
  1. ORG ; Build OBR/OBX segments for MI subscript organism id
  1. ;
  1. N LA7ND,LA7ORG
  1. ;
  1. ; Bacterial organism
  1. I LRSB=12 S LA7ND=3
  1. ; Parasite organism
  1. I LRSB=16 S LA7ND=6
  1. ; Fungal organism
  1. I LRSB=20 S LA7ND=9
  1. ; Mycobacteria organism
  1. I LRSB=26 S LA7ND=12
  1. ; Viral agent
  1. I LRSB=36 S LA7ND=17
  1. ;
  1. S LA7ORG=0
  1. F S LA7ORG=$O(^LR(LRDFN,LRSS,LRIDT,LA7ND,LA7ORG)) Q:'LA7ORG D
  1. . S LA7IDT=LRIDT_","_LA7ORG_","
  1. . D OBX
  1. . I LA7ND=17 Q ; no quantity/comments on viruses
  1. . D ORGNTE
  1. . I $P($G(^LR(LRDFN,LRSS,LRIDT,LA7ND,LA7ORG,0)),"^",2)'="" D CC
  1. S SPM(0)=$$SPM^LA7CORU(LA7FS,LA7ECH,LA7UID)
  1. D FILE6249^LA7VHLU(LA76249,.SPM)
  1. D FILESEG^LA7VHLU(GBL,.SPM)
  1. Q
  1. ;
  1. ;
  1. CC ; Send colony count (quantity)
  1. ;
  1. N LRSB
  1. ;
  1. I LA7ND=3 S LRSB="12,1"
  1. I LA7ND=9 S LRSB="20,1"
  1. I LA7ND=12 S LRSB="26,1"
  1. ;
  1. D OBX
  1. ;
  1. Q
  1. ;
  1. ;
  1. ORGNTE ; Send comments on organisms.
  1. ;
  1. N LA7CMTYP,LA7FMT,LA7J,LA7SOC,LA7NTESN,LA7TXT,LA7X
  1. ;
  1. ; Source of comment - handle special codes for other systems, i,e. DOD-CHCS
  1. S LA7SOC=$S($G(LA7NVAF)=1:"RC",1:"L")
  1. ;
  1. S LA7FMT=0,LA7CMTYP=""
  1. ; If HDR interface then send as repetition text.
  1. I $G(LA7INTYP)=30 S LA7FMT=2
  1. ;
  1. S (LA7J,LA7NTESN)=0
  1. F S LA7J=$O(^LR(LRDFN,LRSS,LRIDT,LA7ND,LA7ORG,1,LA7J)) Q:'LA7J D
  1. . S LA7X=$G(^LR(LRDFN,LRSS,LRIDT,LA7ND,LA7ORG,1,LA7J,0))
  1. . I LA7X="" S LA7X=" "
  1. . I LA7FMT=0 S LA7TXT=LA7X D NTE Q
  1. . S LA7TXT(LA7J)=LA7X
  1. ;
  1. ; If formatted or repetition format then build comments to a NTE segment.
  1. I LA7FMT,$D(LA7TXT) D NTE^LA7CORU1
  1. ;
  1. Q
  1. ;
  1. ;
  1. MIC ; Build OBR/OBX segments for MI subscript susceptibilities(MIC)
  1. ;
  1. N LA7ORG,LA7ND,LA7NLT,LA7SB,LA7SB1,LA7SOC,LA7FLAG
  1. S LA7FLAG="" ;MU2 check for existence so SPM can be created
  1. ;
  1. ; Source of comment - handle special codes for other systems, i,e. DOD-CHCS
  1. S LA7SOC=$S($G(LA7NVAF)=1:"RC",1:"L")
  1. ;
  1. S (LA7NLT,LA7NLT(1))=""
  1. I LRSB=12 S LA7ND=3,LA7NLT="87565.0000",LA7NLT(1)="87993.0000"
  1. I LRSB=26 S LA7ND=12,LA7NLT="87899.0000",LA7NLT(1)="87525.0000"
  1. ;
  1. S LA7ORG=0,LA7SB=LRSB
  1. F S LA7ORG=$O(^LR(LRDFN,LRSS,LRIDT,LA7ND,LA7ORG)) Q:'LA7ORG D
  1. . N LA7NTESN,LA7PARNT
  1. . ; Check for susceptibilities for this organism
  1. . S X=$O(^LR(LRDFN,LRSS,LRIDT,LA7ND,LA7ORG,2))
  1. . I X<2!(X>3) Q
  1. . S LA7FLAG=1
  1. . S LA7PARNT=LA7SB_"-"_LA7ORG
  1. . M LA7PARNT=LA7ID(LA7PARNT)
  1. . I $G(LA7INPT) D
  1. . .S LA7ORCSN=LA7ORCSN+1
  1. . .D ORC^LA7CORU ;mu2 inpatient
  1. . D OBR^LA7CORU
  1. . S LA7OBXSN=0,LA7SB1=2
  1. . F S LA7SB1=$O(^LR(LRDFN,LRSS,LRIDT,LA7ND,LA7ORG,LA7SB1)) Q:'LA7SB1!(LA7SB1>2.99) D
  1. . . N LA7CMTYP,LA7FMT,LA7TXT,LRSB
  1. . . S LA7IDT=LRIDT_","_LA7ORG_","_LA7SB1,LRSB=LA7SB_","_LA7SB1
  1. . . D OBX
  1. . . S X=$O(^LAB(62.06,"AD",LA7SB1,0)) Q:'X
  1. . . S LA7TXT=$P($G(^LAB(62.06,X,0)),"^",3)
  1. . . I LA7TXT'="" S (LA7NTESN,LA7FMT)=0,LA7CMTYP="" D NTE
  1. . I LA7ND'=3 Q ; no free text antibiotics on AFB
  1. . S LA7SB1=0
  1. . F S LA7SB1=$O(^LR(LRDFN,LRSS,LRIDT,LA7ND,LA7ORG,3,LA7SB1)) Q:'LA7SB1 D
  1. . . N LRSB
  1. . . S LA7IDT=LRIDT_","_LA7ORG_","_LA7SB1
  1. . . S LRSB=LA7SB_",3,1" D OBX
  1. . . S LRSB=LA7SB_",3,2" D OBX
  1. I $G(LA7FLAG) D
  1. . N LROSPEC,LRISPEC
  1. . S LROSPEC=LRSPEC
  1. . S LRISPEC=$S($P($G(LA7CODE),"!"):$O(^LAM("E",$P(LA7CODE,"!"),0)),1:"")
  1. . I LRISPEC S LRSPEC=$S($O(^LAM(LRISPEC,5,"B",0)):$O(^LAM(LRISPEC,5,"B",0)),1:LRSPEC)
  1. . I '$G(LA7INPT) D
  1. . .S SPM(0)=$$SPM^LA7CORU(LA7FS,LA7ECH,LA7UID)
  1. . .D FILE6249^LA7VHLU(LA76249,.SPM)
  1. . .D FILESEG^LA7VHLU(GBL,.SPM)
  1. . S LRSPEC=LROSPEC
  1. ;
  1. Q
  1. ;
  1. ;
  1. OBX ; Build OBX segments for MI subscript
  1. ; Also called by AP^LA7VORU2 to build AP OBX segments.
  1. ;
  1. N LA7DATA
  1. D OBX^LA7COBX(LRDFN,LRSS,LA7IDT,LRSB,.LA7DATA,.LA7OBXSN,LA7FS,LA7ECH,LA7NVAF)
  1. ;
  1. ; If OBX failed to build then don't store
  1. I '$D(LA7DATA) Q
  1. ;
  1. D FILESEG^LA7VHLU(GBL,.LA7DATA)
  1. ;
  1. ; Check for flag to only build meesage but do not file
  1. I '$G(LA7NOMSG) D FILE6249^LA7VHLU(LA76249,.LA7DATA)
  1. Q
  1. ;
  1. ;
  1. NTE ; Build NTE segment with comment
  1. ;
  1. N LA7DATA
  1. ;
  1. D NTE^LA7CHLU3(.LA7DATA,.LA7TXT,$G(LA7SOC),LA7FS,LA7ECH,.LA7NTESN,$G(LA7CMTYP),$G(LA7FMT))
  1. D FILESEG^LA7VHLU(GBL,.LA7DATA)
  1. ;
  1. ; Check for flag to only build meesage but do not file
  1. I '$G(LA7NOMSG) D FILE6249^LA7VHLU(LA76249,.LA7DATA)
  1. ;
  1. Q