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

BLRMLTL.m

Go to the documentation of this file.
BLRMLTL ; IHS/DIR/FJE - SET IHS LAB TRANSACTION LOG - MICRO ; [ 11/18/2002  2:03 PM ]
 ;;5.2;BLR;**1001,1014,1015**;NOV 18, 2002
 ;
 ;S BLRIDT=LRIDT,(BLRTEST,BLRCULT)=$S($D(LRTS):LRTS,1:LRTEST),(BLRRES,BLRTESTN,BLRANTI,BLRANTN,BLRANTP,BLRSTGN,BLRORG,BLRSTG,BLRCMTS)=""
 S BLRIDT=LRIDT,(BLRTEST,BLRCULT)=$S($D(LRTS):LRTS,1:LRTEST),(BLRCMPD,BLRCOLSP,BLRRES,BLRTESTN,BLRANTI,BLRANTN,BLRANTP,BLRSTGN,BLRORG,BLRSTG,BLRCMTS)=""  ;IHS/DIR TUC/AAB 04/08/98
 S BLREXEC=$P(^LAB(60,BLRTEST,0),U,14),BLRGBL=$P($P($P(^LAB(62.07,BLREXEC,.1),"/"),"=",2),"""",2),BLRGBL=$P($P(^DD(63.05,BLRGBL,0),U,4),";",1)
 S BLRVAL=$G(^LR(LRDFN,"MI",BLRIDT,BLRGBL))
 Q:(BLRVAL=""!($P(BLRVAL,U,2)'="F"))
 ;S BLRACCN=$P(^LR(LRDFN,"MI",BLRIDT,0),U,6),BLR60F=1,BLRSETP=0,BLRERFS=""
 S BLRACCN=^LR(LRDFN,"MI",BLRIDT,0),BLRCOLSP=$P(BLRACCN,U,11),BLRACCN=$P(BLRACCN,U,6),BLR60F=1,BLRSETP=0,BLRERFS=""  ;IHS/DIR TUC/AAB 04/09/98
 S:+BLRTEST BLRCMPD=$P($G(^LRO(68,LRAA,1,LRAD,1,LRAN,4,BLRTEST,0)),U,5)  ;IHS/DIR TUC/AAB 04/09/98
 ;D
 I BLRTEST'="",$D(^BLRTXLOG("AAT",BLRACCN,BLRTEST)) D  ;IHS/DIR TUC/AAB 04/09/98
 .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 ;
 S BLRRES="NEGATIVE"
 I $D(^LR(LRDFN,"MI",BLRIDT,25)) D GETRES(25) D BLDMSTR Q
 I $D(^LR(LRDFN,"MI",BLRIDT,2)) D GETRES(2) S BLRTESTN="GRAM STAIN",BLRTEST=$$GETTEST(BLRTESTN) D:BLRCULT=BLRTEST BLDMSTR Q:BLRCULT=BLRTEST  D LOOKTST
 S BLRTESTN="",BLRRES="NEGATIVE",BLRTEST=BLRCULT
 I '$D(^LR(LRDFN,"MI",BLRIDT,3)) D BLDMSTR Q
 I $D(^LR(LRDFN,"MI",BLRIDT,3)),$P(^LR(LRDFN,"MI",BLRIDT,3,0),U,3)="" D BLDMSTR Q
 I $D(^LR(LRDFN,"MI",BLRIDT,3)),$P(^LR(LRDFN,"MI",BLRIDT,3,0),U,4)=0 D BLDMSTR Q  ;organism deleted
 S BLRRES="POSITIVE",BLRTEST=LRTS D BLDMSTR S BLRSPT=3 D ORG Q
 Q
 ;
PARAS ;
 S BLRRES="NEGATIVE"
 I $D(^LR(LRDFN,"MI",BLRIDT,24)) D GETRES(24),BLDMSTR Q
 I '$D(^LR(LRDFN,"MI",BLRIDT,6)) D BLDMSTR Q
 I $D(^LR(LRDFN,"MI",BLRIDT,6)),$P(^LR(LRDFN,"MI",BLRIDT,6,0),U,3)="" D BLDMSTR Q
 S BLRRES="POSITIVE" D BLDMSTR S BLRSPT=6 D PARAS1 Q
 Q
 ;
PARAS1 ;
 S (BLRORGX,BLR60F)=0 F  S BLRORGX=$O(^LR(LRDFN,"MI",BLRIDT,BLRSPT,BLRORGX)) Q:(BLRORGX'?.N!(BLRORGX=""))  S BLRORG=^LR(LRDFN,"MI",BLRIDT,BLRSPT,BLRORGX,0),BLRRES="",BLRORG=+BLRORG D LOOKORG,PARAS2
 Q
PARAS2 ;
 S BLRPAR=$O(^BLRTXLOG("AOG",BLRACCN,BLRORG,""))
 S BLRSTG=0 F  S BLRSTG=$O(^LR(LRDFN,"MI",BLRIDT,BLRSPT,BLRORGX,1,BLRSTG)) Q:(BLRSTG=""!(BLRSTG'?.N))  D
 .S BLRSTGN=^LR(LRDFN,"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 ;
 S BLRRES="NEGATIVE"
 I $D(^LR(LRDFN,"MI",BLRIDT,15)) D GETRES(15) D BLDMSTR Q
 I '$D(^LR(LRDFN,"MI",BLRIDT,9)) D BLDMSTR Q
 I $D(^LR(LRDFN,"MI",BLRIDT,9)),$P(^LR(LRDFN,"MI",BLRIDT,9,0),U,3)="" D BLDMSTR Q
 S BLRRES="POSITIVE" D BLDMSTR S BLRSPT=9 D ORG Q
 Q
 ;
TB ;
 I ($P(BLRVAL,U,3)'=""!($P(BLRVAL,U,4)'="")) D GETFSTAI
 I BLRCULT=BLRTEST,BLRRES'="" Q
 S BLRTEST=BLRCULT,BLRTESTN=""
 I '$D(^LR(LRDFN,"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 ;
 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 ;
 S BLRTESTN="ACID FAST STAIN" S BLRTEST=$$GETTEST(BLRTESTN) I BLRTEST="" S BLRTESTN="AFB SMEAR" S BLRTEST=$$GETTEST(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 ;
 S BLRRES="NEGATIVE"
 I '$D(^LR(LRDFN,"MI",BLRIDT,17)) D BLDMSTR Q
 I $D(^LR(LRDFN,"MI",BLRIDT,17)),$P(^LR(LRDFN,"MI",BLRIDT,17,0),U,3)="" D BLDMSTR Q
 S BLRRES="POSITIVE" D BLDMSTR S BLRSPT=17 D ORG Q
 Q
 ;
ORG ;
 S (BLRORGX,BLR60F)=0 F  S BLRORGX=$O(^LR(LRDFN,"MI",BLRIDT,BLRSPT,BLRORGX)) Q:(BLRORGX'?.N!(BLRORGX=""))  S BLRORG=^LR(LRDFN,"MI",BLRIDT,BLRSPT,BLRORGX,0) S BLRRES=$P(BLRORG,U,2),BLRORG=+BLRORG D LOOKORG D:BLRSPT'=17 ANTIB
 Q
 ;
ANTIB ;
 S BLRPAR=$O(^BLRTXLOG("AOG",BLRACCN,BLRORG,""))
 S BLRANTI=1 F  S BLRANTI=$O(^LR(LRDFN,"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
 S (BLRANTI,BLRANTP)=""
 Q
GETANAME ;
 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 ;
 S BLRSETP=1
 I '$D(^BLRTXLOG("AAT",BLRACCN,BLRTEST)) S BLRPAR=$O(^BLRTXLOG("AAT",BLRACCN,BLRCULT,"")) D ^BLRMLTL1 Q
 D BLDMSTR
 Q
LOOKORG ;
 I '$D(^BLRTXLOG("AOG",BLRACCN,BLRORG)) S BLRPAR=$O(^BLRTXLOG("AAT",BLRACCN,BLRCULT,"")) D ^BLRMLTL1 Q
 D BLDMSTR
 Q
 ;
LOOKDRG ;
 I '$D(^BLRTXLOG("AOD",BLRACCN,BLRORG,BLRANTP)) D ^BLRMLTL1 Q
 D BLDMSTR
 Q
 ;
LOOKSTG ;
 I '$D(^BLRTXLOG("AOS",BLRACCN,BLRORG,BLRSTG)) D ^BLRMLTL1 Q
 D BLDMSTR
 Q
BLDMSTR ;
 S:BLR60F BLRSTR="SEQUENCE NUMBER_$$GETIEN(BLRACCN,BLRTEST)~STATUS FLAG_BLRPHASE~PANEL/TEST POINTER_BLRTEST~PANEL/TEST NAME_BLRTESTN~RESULT_BLRRES" S:BLRCMTS'="" BLRSTR=BLRSTR_"~COMMENTS_BLRCMTS"
 I 'BLR60F D
 .I BLRSPT'=6 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 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 BLRSTR=BLRSTR_"~COLLECTION SAMPLE POINTER_BLRCOLSP" S:+BLRCMPD BLRSTR=BLRSTR_"~COMPLETE DATE_BLRCMPD"  ;IHS/DIR TUC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