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

BLRTNM.m

Go to the documentation of this file.
BLRTNM ; IHS/HQT/MJL - SET IHS LAB TRANSACTION LOG - MICRO ;MAY 06, 2009 9:58 AM
 ;;5.2;IHS LABORATORY;**1011,1014,1015,1025,1026,1030**;NOV 01, 1997
 ;
 D:$G(SNAPSHOT) ENTRYAUD^BLRUTIL("ENTER ^BLRTNM")
 S BLRLRDFN=$G(^BLRSITE(BLRQSITE,20,BLRQDH,1,BLRLTP,"LRDFN"))
 S BLRIDT=$G(^BLRSITE(BLRQSITE,20,BLRQDH,1,BLRLTP,"LRIDT"))
 S (BLRTEST,BLRCULT)=$G(^BLRSITE(BLRQSITE,20,BLRQDH,1,BLRLTP,"BLRTEST"))
 S (BLRCMPD,BLRCOLSP,BLRRES,BLRTESTN,BLRANTI,BLRANTN,BLRANTP,BLRSTGN,BLRORG,BLRSTG,BLRCMTS)=""
 ;
 I 'BLRTEST D KILL Q
 ;
 ;
 S BLREXEC=$P($G(^LAB(60,BLRTEST,0)),U,14)  ;'EDIT CODE'
 ;
 ; ----- BEGIN IHS/OIT/MKK LR*5.2*1025 MODIFICATIONS
 ;            Check to make sure Edit code exists.
 ;            If not, set error message and quit because it's
 ;            not possible to process the transaction.
 I +$G(BLREXEC)<1  D  Q
 . S BLRERR=1
 . S BLRERROR(1)="Null/Zero Edit code for Lab Test IEN:"_BLRTEST_".  Invalid."
 ; ----- END ISH/OIT/MKK LR*5.2*1025 MODICATIONS
 ;
 ;GET FIRST FIELD # IN THE EXECUTE CODE???
 ; S BLRGBL=$P($P($P($G(^LAB(62.07,BLREXEC,.1)),"/"),"=",2),"""",2)
 S BLRGBL=+$P($P($P($G(^LAB(62.07,BLREXEC,.1)),"/"),"=",2),"""",2)   ; IHS/OIT/MKK - LR*5.2*1030 -- Cow Creek Correction
 ;
 ;LOOK AT 'MICROBIOLOGY SUB-FIELD'
 ; S BLRGBL=$P($P($G(^DD(63.05,BLRGBL,0)),U,4),";",1)  ;GET THE SUBSCRIPT
 S BLRGBL=+$P($P($G(^DD(63.05,BLRGBL,0)),U,4),";",1)  ;GET THE SUBSCRIPT  ; IHS/OIT/MKK - LR*5.2*1030 -- Cow Creek Correction
 ;GET THAT SUBSCRIPT LEVEL'S VALUE
 S BLRVAL=$G(^LR(BLRLRDFN,"MI",BLRIDT,BLRGBL))
 S BLRACCN=$G(^LR(BLRLRDFN,"MI",BLRIDT,0))
 Q:$G(BLRACCN)=""  ;IHS/ITSC/TPF 06/06/02 CAN'T PROCESS IF NO ACCESSION
 ;                  DUE TO A DELETION
 S BLRCOLSP=$P(BLRACCN,U,11),BLRACCN=$P(BLRACCN,U,6),BLR60F=1,BLRSETP=0,BLRERFS=""
 Q:(BLRVAL=""!($P(BLRVAL,U,2)'="F"))
 S BLRAA=$G(^BLRSITE(BLRQSITE,20,BLRQDH,1,BLRLTP,"LRAA")),BLRAD=$G(^("LRAD")),BLRAN=$G(^("LRAN")),BLRSS=$G(^("LRSS")),BLRODT=$G(^("LRODT")),BLRSEQ=$G(^("LRSN")),BLRSPEC=$G(^("LRSPEC"))
 S:+BLRTEST BLRCMPD=$P($G(^LRO(68,BLRAA,1,BLRAD,1,BLRAN,4,BLRTEST,0)),U,5)
 I BLRTEST'="",$D(^BLRTXLOG("AAT",BLRACCN,BLRTEST)) D
 .I BLRGBL=1 D BACT Q
 .I BLRGBL=5 D PARAS Q
 .I BLRGBL=8 D MYCOL Q
 .I BLRGBL=11 D TB Q
 .I BLRGBL=16 D VIROL Q
 D KILL
 Q
 ;
BACT ;
 D:$G(SNAPSHOT) ENTRYAUD^BLRUTIL("ENTER BACT^BLRTNM")
 S BLRRES="NEGATIVE"
 I $D(^LR(BLRLRDFN,"MI",BLRIDT,25)) D GETRES(25) D BLDMSTR Q
 I $D(^LR(BLRLRDFN,"MI",BLRIDT,2)) D GETRES(2) S BLRTESTN="GRAM STAIN",BLRTEST=$O(^LAB(60,"B",BLRTESTN,"")) D:BLRCULT=BLRTEST BLDMSTR Q:BLRCULT=BLRTEST  D LOOKTST
 S BLRTESTN="",BLRRES="NEGATIVE",BLRTEST=BLRCULT
 I '$D(^LR(BLRLRDFN,"MI",BLRIDT,3)) D BLDMSTR Q
 I $D(^LR(BLRLRDFN,"MI",BLRIDT,3)),$P(^LR(BLRLRDFN,"MI",BLRIDT,3,0),U,3)="" D BLDMSTR Q
 I $D(^LR(BLRLRDFN,"MI",BLRIDT,3)),$P(^LR(BLRLRDFN,"MI",BLRIDT,3,0),U,4)=0 D BLDMSTR Q  ;organism deleted
 S BLRRES="POSITIVE",BLRTEST=^BLRSITE(BLRQSITE,20,BLRQDH,1,BLRLTP,"BLRTEST") D BLDMSTR S BLRSPT=3 D ORG Q
 Q
 ;
PARAS ;
 D:$G(SNAPSHOT) ENTRYAUD^BLRUTIL("ENTER PARAS^BLRTNM")
 S BLRRES="NEGATIVE"
 I $D(^LR(BLRLRDFN,"MI",BLRIDT,24)) D GETRES(24),BLDMSTR Q
 I '$D(^LR(BLRLRDFN,"MI",BLRIDT,6)) D BLDMSTR Q
 I $D(^LR(BLRLRDFN,"MI",BLRIDT,6)),$P(^LR(BLRLRDFN,"MI",BLRIDT,6,0),U,3)="" D BLDMSTR Q
 S BLRRES="POSITIVE" D BLDMSTR S BLRSPT=6 D PARAS1 Q
 Q
 ;
PARAS1 ;
 D:$G(SNAPSHOT) ENTRYAUD^BLRUTIL("ENTER PARAS1^BLRTNM")
 S (BLRORGX,BLR60F)=0 F  S BLRORGX=$O(^LR(BLRLRDFN,"MI",BLRIDT,BLRSPT,BLRORGX)) Q:(BLRORGX'?.N!(BLRORGX=""))  S BLRORG=^LR(BLRLRDFN,"MI",BLRIDT,BLRSPT,BLRORGX,0),BLRRES="",BLRORG=+BLRORG D LOOKORG,PARAS2
 Q
PARAS2 ;
 D:$G(SNAPSHOT) ENTRYAUD^BLRUTIL("ENTER PARAS2^BLRTNM")
 S BLRPAR=$O(^BLRTXLOG("AOG",BLRACCN,BLRORG,""))
 S BLRSTG=0 F  S BLRSTG=$O(^LR(BLRLRDFN,"MI",BLRIDT,BLRSPT,BLRORGX,1,BLRSTG)) Q:(BLRSTG=""!(BLRSTG'?.N))  D
 .S BLRSTGN=^LR(BLRLRDFN,"MI",BLRIDT,BLRSPT,BLRORGX,1,BLRSTG,0)
 .S BLRRES=$P(BLRSTGN,U,2),BLRSTGN=$P(BLRSTGN,U,1)
 .D LOOKSTG S BLRSTGN="" Q
 S BLRSTG=""
 Q
 ;
MYCOL ;
 D:$G(SNAPSHOT) ENTRYAUD^BLRUTIL("ENTER MYCOL^BLRTNM")
 S BLRRES="NEGATIVE"
 I $D(^LR(BLRLRDFN,"MI",BLRIDT,15)) D GETRES(15) D BLDMSTR Q
 I '$D(^LR(BLRLRDFN,"MI",BLRIDT,9)) D BLDMSTR Q
 I $D(^LR(BLRLRDFN,"MI",BLRIDT,9)),$P(^LR(BLRLRDFN,"MI",BLRIDT,9,0),U,3)="" D BLDMSTR Q
 S BLRRES="POSITIVE" D BLDMSTR S BLRSPT=9 D ORG Q
 Q
 ;
TB ;
 D:$G(SNAPSHOT) ENTRYAUD^BLRUTIL("ENTER TB^BLRTNM")
 I ($P(BLRVAL,U,3)'=""!($P(BLRVAL,U,4)'="")) D GETFSTAI
 I BLRCULT=BLRTEST,BLRRES'="" Q
 S BLRTEST=BLRCULT,BLRTESTN=""
 I '$D(^LR(BLRLRDFN,"MI",BLRIDT,12)) S BLRRES="NEGATIVE" D BLDMSTR Q
 D:'$D(^UTILITY("TB",$J)) BLDTB
 S BLRRES="POSITIVE" D BLDMSTR S BLRSPT=12 D ORG Q
 Q
 ;
BLDTB ;
 D:$G(SNAPSHOT) ENTRYAUD^BLRUTIL("ENTER BLDTB^BLRTNM")
 S BLRPX=1 F  S BLRPX=$O(^DD(63.39,"GL",BLRPX)) Q:BLRPX=""  S BLRFLD=$O(^DD(63.39,"GL",BLRPX,1,"")),^UTILITY("TB",$J,BLRPX)=$P(^DD(63.39,BLRFLD,0),U,1)
 K BLRFLD,BLRPX
 Q
GETFSTAI ;
 D:$G(SNAPSHOT) ENTRYAUD^BLRUTIL("ENTER GETFSTAI^BLRTNM")
 S BLRTESTN="ACID FAST STAIN" S BLRTEST=$O(^LAB(60,"B",BLRTESTN,"")) I BLRTEST="" S BLRTESTN="AFB SMEAR" S BLRTEST=$O(^LAB(60,"B",BLRTESTN,""))
 S BLRRES=$P(BLRVAL,U,3) I BLRRES'="",$P(BLRVAL,U,4)'="" S BLRRES=BLRRES_";"_$P(BLRVAL,U,4)
 S:BLRRES="" BLRRES=$P(BLRVAL,U,4)
 D LOOKTST
 Q
VIROL ;
 D:$G(SNAPSHOT) ENTRYAUD^BLRUTIL("ENTER VIROL^BLRTNM")
 S BLRRES="NEGATIVE"
 I '$D(^LR(BLRLRDFN,"MI",BLRIDT,17)) D BLDMSTR Q
 I $D(^LR(BLRLRDFN,"MI",BLRIDT,17)),$P(^LR(BLRLRDFN,"MI",BLRIDT,17,0),U,3)="" D BLDMSTR Q
 S BLRRES="POSITIVE" D BLDMSTR S BLRSPT=17 D ORG Q
 Q
 ;
ORG ;
 D:$G(SNAPSHOT) ENTRYAUD^BLRUTIL("ENTER ORG^BLRTNM")
 S (BLRORGX,BLR60F)=0 F  S BLRORGX=$O(^LR(BLRLRDFN,"MI",BLRIDT,BLRSPT,BLRORGX)) Q:(BLRORGX'?.N!(BLRORGX=""))  S BLRORG=^LR(BLRLRDFN,"MI",BLRIDT,BLRSPT,BLRORGX,0) S BLRRES=$P(BLRORG,U,2),BLRORG=+BLRORG D LOOKORG D:BLRSPT'=17 ANTIB
 Q
 ;
ANTIB ;
 D:$G(SNAPSHOT) ENTRYAUD^BLRUTIL("ENTER ANTIB^BLRTNM")
 S BLRPAR=$O(^BLRTXLOG("AOG",BLRACCN,BLRORG,""))
 ; S BLRANTI=1 F  S BLRANTI=$O(^LR(BLRLRDFN,"MI",BLRIDT,BLRSPT,BLRORGX,BLRANTI)) Q:(BLRANTI=""!($L(BLRANTI)=1))  S BLRRES=$P(^(BLRANTI),U,1) S:BLRGBL'=11 BLRANTP=$O(^LAB(62.06,"AD",BLRANTI,"")) D:BLRGBL=11 GETANAME D LOOKDRG S BLRERFS="" K BLRERF
 ; ----- BEGIN IHS/OIT/MKK LR*5.2*1025 -- Need to bypass non-existent Drug Nodes in the ANTIMICROBIAL SUSCEPTIBILITY dictionary
 S BLRANTI=1
 F  S BLRANTI=$O(^LR(BLRLRDFN,"MI",BLRIDT,BLRSPT,BLRORGX,BLRANTI)) Q:(BLRANTI=""!($L(BLRANTI)=1))  D
 . S BLRRES=$P($G(^LR(BLRLRDFN,"MI",BLRIDT,BLRSPT,BLRORGX,BLRANTI)),U,1)
 . S:BLRGBL'=11 BLRANTP=$O(^LAB(62.06,"AD",BLRANTI,""))
 . D:BLRGBL=11 GETANAME
 . D:$G(BLRANTP)'="" LOOKDRG
 . S BLRERFS=""
 . K BLRERF
 ; ----- END IHS/OIT/MKK LR*5.2*1025 -- Need to bypass non-existent Antibiotics
 S (BLRANTI,BLRANTP)=""
 Q
GETANAME ;
 D:$G(SNAPSHOT) ENTRYAUD^BLRUTIL("ENTER GETANAME^BLRTNM")
 S BLRANTP=BLRANTI
 S BLRANTN=^UTILITY("TB",$J,BLRANTP)
 S X=BLRANTN,DIC=62.06,DIC(0)="MX" D ^DIC
 I Y'=-1 S BLRANTP=$P(Y,U,1) Q
 S BLRERFS="Field 1302 of file 9009022 not a valid antibiotic ien",BLRERF=1
 Q
 ;
LOOKTST ;
 ; ----- BEGIN IHS/OIT/MKK LR*5.2*1026 - Make sure BLRTEST variable exists
 I +$G(BLRTEST)<1  Q
 ; ----- BEGIN IHS/OIT/MKK LR*5.2*1026 MODIFICATIONS 
 D:$G(SNAPSHOT) ENTRYAUD^BLRUTIL("ENTER LOOKTST^BLRTNM")
 S BLRSETP=1
 I '$D(^BLRTXLOG("AAT",BLRACCN,BLRTEST)) S BLRPAR=$O(^BLRTXLOG("AAT",BLRACCN,BLRCULT,"")) D ^BLRTNM1 Q
 D BLDMSTR
 Q
LOOKORG ;
 D:$G(SNAPSHOT) ENTRYAUD^BLRUTIL("ENTER LOOKORG^BLRTNM")
 I '$D(^BLRTXLOG("AOG",BLRACCN,BLRORG)) S BLRPAR=$O(^BLRTXLOG("AAT",BLRACCN,BLRCULT,"")) D ^BLRTNM1 Q
 D BLDMSTR
 Q
 ;
LOOKDRG ;
 D:$G(SNAPSHOT) ENTRYAUD^BLRUTIL("ENTER LOOKDRG^BLRTNM")
 I '$D(^BLRTXLOG("AOD",BLRACCN,BLRORG,BLRANTP)) D ^BLRTNM1 Q
 D BLDMSTR
 Q
 ;
LOOKSTG ;
 D:$G(SNAPSHOT) ENTRYAUD^BLRUTIL("ENTER LOOKSTG^BLRTNM")
 I '$D(^BLRTXLOG("AOS",BLRACCN,BLRORG,BLRSTG)) D ^BLRTNM1 Q
 D BLDMSTR
 Q
BLDMSTR ;
 D:$G(SNAPSHOT) ENTRYAUD^BLRUTIL("ENTER BLDMSTR^BLRTNM")
 S BLRCMF="M"
 I BLR60F S BLRCRSBS="""AAT"",BLRACCN,BLRTEST",BLRDIR=-1,BLROKCK="",BLRBADCK="",BLR("PANEL/TEST POINTER")=BLRTEST,BLR("PANEL/TEST NAME")=BLRTESTN,BLR("RESULT")=BLRRES S:BLRCMTS'="" BLR("COMMENTS")=BLRCMTS
 I 'BLR60F D
 .I BLRSPT'=6 D  Q
 ..;S BLRSTR="SEQUENCE NUMBER_$$GETOGIEN(BLRACCN,BLRORG"_$S(BLRANTI="":")",1:",BLRANTP)~ANTIBIOTIC_BLRANTP")_"~STATUS FLAG_BLRPHASE~RESULT_BLRRES~ORGANISM_BLRORG~ANTIBIOTIC NAME_BLRANTN~PCC ERROR FLAG_BLRERFS" Q
  ..S BLRCRSBS=""""_$S(BLRANTP'="":"AOD",1:"AOG")_""",BLRACCN,BLRORG",BLRDIR=-1,BLROKCK="CHKDT",BLRBADCK=""
 ..S BLR("RESULT")=BLRRES,BLR("ORGANISM")=BLRORG,BLR("ANTIBIOTIC NAME")=BLRANTN,BLR("PCC ERROR FLAG")=BLRERFS
 ..S:BLRANTP'="" BLRCRSBS=BLRCRSBS_",BLRANTP",BLR("ANTIBIOTIC")=BLRANTP
 .;S BLRSTR="SEQUENCE NUMBER_$$GETOSIEN(BLRACCN,BLRORG"_$S(BLRSTG="":")",1:",BLRSTG)~STAGE COUNTER_BLRSTG")_"~STATUS FLAG_BLRPHASE~RESULT_BLRRES~ORGANISM_BLRORG" S:BLRSTGN'="" BLRSTR=BLRSTR_"~STAGE NAME_BLRSTGN" Q
 .S BLRCRSBS=""""_$S(BLRSTG'="":"AOS",1:"AOG")_""",BLRACCN,BLRORG",BLRDIR=-1,BLROKCK="CHKDT",BLRBADCK=""
 .S BLR("RESULT")=BLRRES,BLR("ORGANISM")=BLRORG S:BLRSTGN'="" BLR("STAGE NAME")=BLRSTGN Q
 .S:BLRSTG'="" BLRCRSBS=BLRCRSBS_",BLRSTG",BLR("STAGE COUNTER")=BLRSTG
 S BLR("COLLECTION SAMPLE POINTER")=BLRCOLSP S:+BLRCMPD BLR("COMPLETE DATE")=BLRCMPD
 S BLR("SEQUENCE NUMBER")=$$GETIEN D:'BLRERR ^BLRNFLTL
 S BLRCMTS=""
 K BLR
 Q
 ;
GETRES(BLRRSUB) ;
 ;
 D:$G(SNAPSHOT) ENTRYAUD^BLRUTIL("ENTER GETRES^BLRTNM")
 S BLRYY=0 F BLRI=1:1 S BLRYY=$O(^LR(BLRLRDFN,"MI",BLRIDT,BLRRSUB,BLRYY)) Q:BLRYY=""  S:BLRI>1 BLRCMTS=BLRCMTS_$C(20) S BLRCMTS=BLRCMTS_^LR(BLRLRDFN,"MI",BLRIDT,BLRRSUB,BLRYY,0)
 I BLRCMTS'="" S BLRRES="POSITIVE"
 K BLRI
 Q
 ;
GETIEN() ;
 D:$G(SNAPSHOT) ENTRYAUD^BLRUTIL("ENTER GETIEN^BLRTNM")
 S BLRERR=0 I BLRCMF="C" D GETNEW Q BLRENT
 D
 .S BLRCRGL="^BLRTXLOG("_BLRCRSBS_")",BLRENT=$O(@BLRCRGL@(""),BLRDIR)
 .S:'BLRENT BLRERR=1
 .I BLRENT,BLROKCK'="" D @BLROKCK
 .I 'BLRERR,BLRBADCK'="" D @BLRBADCK
 .I BLRERR D EMSG Q
 .S BLRIEN=BLRENT_"," Q
 Q BLRENT
 ;
GETNEW ;
 D:$G(SNAPSHOT) ENTRYAUD^BLRUTIL("ENTER GETNEW^BLRTNM")
 S BLRENT=$G(^BLRTXLOG("SEQ"))
 I 'BLRENT S BLRENT=$O(^BLRTXLOG("@"),-1) I BLRENT,'$D(^BLRTXLOG(1)) S BLRENT=0
 F BLRENT=BLRENT+1:1 Q:'$D(^BLRTXLOG(BLRENT))
 S BLRENTS="BLRENTS",BLRENTS(1)=BLRENT,^BLRTXLOG("SEQ")=BLRENT,BLRIEN="+1,"
 Q
 ;
CHKDT ;
 D:$G(SNAPSHOT) ENTRYAUD^BLRUTIL("ENTER CHKDT^BLRTNM")
 S BLRCDT=$P(^BLRTXLOG(BLRENT,12),U)
 Q:$E(BLRCDT,1,3)=$E(DT,1,3)
 I ($E(BLRCDT,1,3)+1)'=$E(DT,1,3) S BLRERR=1,BLRDTER=1 Q  ;MORE THAN 1 YEAR AHEAD
 I $E(BLRCDT,4,5)<11 S BLRERR=1,BLRDTER=1 Q
 Q
 ;
EMSG ;
 ; Log an error because the crossreference isn't set.
 I 'BLRENT D
 .S BLRERR=1,BLRERROR(1)="Something wrong -- problem with IHS Lab Transaction Log Cross Reference: "_BLRCRGL
 Q
 ;
 ;
KILL ;
 K BLR60F,BLRANTI,BLRANTP,BLRATOM,BLRCAT,BLRCLNC,BLRCMTS,BLRCPTC,BLRCPTF,BLRCPTP,BLRCPTS,BLRCST,BLRCULT,BLRLRDFN,BLRDTC,BLRDUZ,BLRDUZ2,BLRDUZN,BLRENT,BLREXEC,BLRFID,BLRFILE,BLRFOUND,BLRANTN,BLRERFS,BLRERF
 K BLRGBL,BLRIDT,BLRL60,BLRLOC,BLRLOCN,BLRLOGDA,BLRLRDFN,BLRODT,BLRODTM,BLRORG,BLRORGX,BLRPAR,BLRPROV,BLRPROVN,BLRRES,BLRSEQ,BLRSETP,BLRSPEC,BLRSPT,BLRSTG,BLRSTGN,BLRSTR,BLRSTR1,BLRTEST
 K BLRTEST1,BLRTESTN,BLRUNITS,BLRVAL,BLRXII,BLRYY,BLRZ,BLRCMPD,BLRCOLSP
 Q