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

BLRSLTL1.m

Go to the documentation of this file.
BLRSLTL1 ; IHS/DIR/MJL - SET IHS LAB TRANSACTION LOG ; [ 08/01/2002  7:59 AM ]
 ;;5.2T9;LR;**1018**;Nov 17, 2004
 ;;5.2;BLR;**1001,1009**;Mar 7, 2001
SET ;
 I BLROPT1="ADDCOL" D MODSET Q
 I BLRPHASE="A",BLROPT1="ADDACC" S BLRTEST=+LRTS,BLRACCN=^LRO(68,LRAA,1,LRAD,1,LRAN,.2)
 S BLRVAL=^LRO(69,BLRODT,1,BLRSEQ,0),BLRLRDFN=$P(BLRVAL,U,1),BLRODTM=$P(BLRVAL,U,5),BLRDTC=$P($G(^LRO(69,BLRODT,1,BLRSEQ,1)),U)
 S BLRLRDFN=$P(BLRVAL,U,1),BLRODTM=$P(BLRVAL,U,5),BLRDTC=$P($G(^LRO(69,BLRODT,1,BLRSEQ,1)),U)
 S BLRLOCN=$P(BLRVAL,U,7) S:BLRDTC="" BLRDTC=$P(BLRVAL,U,8)
 S BLRDUZ=$P(BLRVAL,U,2),BLRDUZ2=DUZ(2)
 I BLRDUZ="" S BLRDUZ=.5
 S BLRDUZN=$S($D(^VA(200,BLRDUZ,0)):$P(^(0),U,1),1:"UNK"_BLRDUZ)
 S BLRDFN=$P(^LR(BLRLRDFN,0),U,3),BLRFILE=$P(^LR(BLRLRDFN,0),U,2),BLRODTM=$G(BLRODTM)
 S BLRLOC="" I BLRLOCN'="" S BLRLOC=$O(^SC("B",BLRLOCN,"")) S:BLRLOC="" BLRLOC=$O(^SC("C",BLRLOCN,"")) I BLRLOC="" S X=BLRLOCN,DIC=44,DIC(0)="MX" D ^DIC S BLRLOC=+Y I Y=-1 S BLRLOC=""
 ;S BLRCAT="A" I $L($G(^DPT(BLRDFN,.1))) S BLRCAT="I"
 ;----- BEGIN IHS MODIFICATIONS LR*5.2*1018
  S BLRCAT="A" S X=$$GET1^DIQ(2,BLRLRDFN,.103) I X]"",X'["OBSERVATION" S BLRCAT="I"
 ;----- END IHS MODIFICATIONS
 S BLRCLNC="",BLRPCC1=0
 I BLRLOC'="" S BLRCLNC=^SC(BLRLOC,0),BLRIST=$P(BLRCLNC,U,4),BLRCLNC=$P(BLRCLNC,U,7) S:BLRIST="" BLRIST=$G(DUZ(2)) I BLRPCC S BLRPCCC=$P($G(^APCCCTRL(BLRIST,11,BLRLPKG,0)),U,3) I BLRPCCC'="" S BLRPCC1=$S(BLRPCCC:1,1:BLRCAT'="I")
 S BLRPROVN="",BLRPROV=$P(BLRVAL,U,6) S:+BLRPROV>0 BLRPROVN=$P(^VA(200,$P(BLRVAL,U,6),0),U,1) S:BLRPROVN="" BLRPROVN="Unknown Provider"
 S BLRSTR="SEQUENCE NUMBER_$$GETIEN(BLRODTM,BLRSEQ,BLRTEST1)~STATUS FLAG_BLRPHASE~"
 I BLRCMF="C" D
 .S BLRSTR=BLRSTR_"LRFILE_BLRFILE~LRDFN_BLRLRDFN~PATIENT POINTER VALUE_BLRDFN~ORDERING PROVIDER POINTER_BLRPROV~VERIFIER POINTER_BLRDUZ~"
 .S BLRSTR=BLRSTR_"ORDER DATE_$P(BLRVAL,U,5)~ORDER SEQUENCE NUMBER_BLRSEQ~ORDERING PROVIDER NAME_BLRPROVN~ORDER NUMBER_^LRO(69,BLRODT,1,BLRSEQ,.1)~"
 .S BLRSTR=BLRSTR_"COLLECTION DATE/TIME_BLRDTC~VERIFIER NAME_BLRDUZN~ORDERING LOCATION NAME_BLRLOCN~ENTRY DATE/TIME_BLR(""ORDER DATE"")~CLINIC STOP CODE POINTER_BLRCLNC~ORDERING LOCATION POINTER_BLRLOC~DUZ(2)_BLRDUZ2~I/O CATEGORY_BLRCAT~"
 I BLRPHASE="A",BLROPT1="ADDACC" D SET1 Q
 I BLRPHASE="R" S:$G(LRACC)'="" BLRACCN=LRACC S BLRPHASE="A" D SET1 Q
 S BLRTST=0 F  S BLRTST=$O(^LRO(69,BLRODT,1,BLRSEQ,2,BLRTST)) Q:'BLRTST  D
 .S BLRX=^LRO(69,BLRODT,1,BLRSEQ,2,BLRTST,0),BLRTEST=+BLRX I BLRPHASE="O",BLROPT1="ADDORD",'$D(BLRTSTS(BLRTEST)) Q
 .;I BLRPHASE="A" S BLRACCN="" S:$D(LRACC)'=0 BLRACCN=LRACC 
 .I BLRPHASE="A" D  ;IHS/DIR TUC/AAB 04/17/98
 ..I BLROPT1="RECCOL"!(BLROPT1="ITMCOL") S BLRACCN=^LRO(68,LRAA,1,LRAD,1,LRAN,.2),BLRSPEC=$P(^LRO(68,LRAA,1,LRAD,1,LRAN,5,1,0),U) Q
 ..S BLRACCN="" S:$D(LRACC)'=0 BLRACCN=LRACC
 .I $G(LRSS)'="MI",BLRPHASE'="A" D SET1 Q
 .I LRAA=$P(BLRX,U,4),LRAN=$P(BLRX,U,5) D SET1
 Q
 ;
MODSET ;  ;IHS/DIR TUC/AAB 04/01/98
 S BLROAOT=$P(^LRO(69,BLRODT,1,LRPSN,0),U,5)
 S BLRCTST=0 F  S BLRCTST=$O(^BLRTXLOG("AOT",BLRODTM,BLRSEQ,BLRCTST)) Q:'BLRCTST  D
 .I $D(^BLRTXLOG("AOT",BLROAOT,LRPSN,BLRCTST)) S BLRPHASE="D"
 .S BLRSTR="SEQUENCE NUMBER_$$GETIEN(BLRODTM,BLRSEQ,BLRCTST)~STATUS FLAG_BLRPHASE~"  ;FROM AOT
 .S BLRSTR=BLRSTR_"ORDER DATE_$P(^LRO(69,BLRODT,1,LRPSN,0),U,5)~ORDER SEQUENCE NUMBER_LRPSN~ORDER NUMBER_^LRO(69,BLRODT,1,LRPSN,.1)"  ;TO AOT
 .D ^BLRFLTL(BLRCMF,BLRSTR)
 .S BLRPHASE="O"
 K BLRCTST,BLROAOT
 Q
SET1 ;
 S:BLRPHASE'="O" BLRSTR=BLRSTR_"ACCESSION NUMBER_BLRACCN~"
 S BLRLEV=1,BLRCPTL=10000,BLRTEST1=BLRTEST,BLRLEV(1)=BLRTEST,BLRLEV(1,1)="",BLRPAR="",BLRATOM=0 D SET3
 F  D SET2 Q:'BLRLEV
 K BLRLEV,BLRPAR
 Q
 ;
SET2 ;
 S BLRATOM=$O(^LAB(60,BLRLEV(BLRLEV),2,0))="" I BLRATOM,BLRLEV=1 S BLRLEV=0 Q
 S:'BLRATOM BLRLEV=BLRLEV+1 S BLRLEV(BLRLEV,0)=$O(^LAB(60,BLRLEV(BLRLEV-1),2,$G(BLRLEV(BLRLEV,0),0)))
 I BLRLEV(BLRLEV,0) S BLRTEST1=+^LAB(60,BLRLEV(BLRLEV-1),2,$G(BLRLEV(BLRLEV,0),0),0),BLRLEV(BLRLEV)=BLRTEST1 D SET3 Q
 S BLRLEV(BLRLEV,0)=0,BLRLEV=BLRLEV-2
 Q
 ;
SET3 ;
 S BLRATOM=$O(^LAB(60,BLRTEST1,2,0))="",BLRL60=^LAB(60,BLRTEST1,0),BLRCST=$P(BLRL60,U,11),BLRMOD=$P(BLRL60,U,4)
 S BLRCPTS="" I BLRLEV=1 D CPTCODE
 S BLRSTR1="",BLRSPEC=$G(LRSPEC)
 I BLROPT1="RECCOL"!(BLROPT1="ITMCOL") S BLRSPEC=$P(^LRO(68,LRAA,1,LRAD,1,LRAN,5,1,0),U)  ;IHS/DIR TUC/AAB 04/05/98 
 I BLRSPEC'="" D SET4
 S BLRSTR1=BLRSTR1_"CPT LAB CODE POINTER_BLRCPTP~BILLING CPT STRING_BLRCPTS~PANEL/TEST POINTER_BLRTEST1~LAB TEST LIST COST_BLRCST~LAB MODULE_BLRMOD"
 S:BLRDTC'="" BLRSTR1=BLRSTR1_"~COLLECTION DATE/TIME_BLRDTC"
 I BLRCMF="C" S:BLRLEV(BLRLEV,1)'="" BLRPAR=BLRLEV(BLRLEV,1),BLRSTR1=BLRSTR1_"~PARENT POINTER_BLRPAR" S:'BLRATOM BLRLPAR=BLRPAR,BLRSTR1=BLRSTR1_"~@BLRPAR_BLR(""SEQUENCE NUMBER"")"
 S BLRPREV=$O(^BLRTXLOG("AOT",BLRODTM,BLRSEQ,BLRTEST1,""),-1) I BLRPREV'="",$P(^BLRTXLOG(BLRPREV,1),"^",2)'="D",BLRCMF="C" Q
 D ^BLRFLTL(BLRCMF,BLRSTR_BLRSTR1)
 I 'BLRATOM,BLRCMF="C" S BLRLEV(BLRLEV+1,1)=BLRPAR
 Q
 ;
SET4 ;
 I $D(^LAB(60,BLRTEST1,1,BLRSPEC)) S BLRZ=$G(^LAB(60,BLRTEST1,1,BLRSPEC,0)),BLRUNITS=$P($P(BLRZ,U,7)," ",1),BLRSTR1="SITE/SPECIMEN POINTER_BLRSPEC~UNITS_BLRUNITS~" Q
 S BLRSTR1="SITE/SPECIMEN POINTER_BLRSPEC~"
 Q
 ;
CPTCODE ; Entry point
 S BLRFOUND=0,(BLRXII,BLRCPTS,BLRCPTP)="" F  S BLRXII=$O(^BLRCPT("C",BLRTEST1,BLRXII)) Q:(BLRXII="")  I '$P(^BLRCPT(BLRXII,1),U,2) D GETCPT Q:BLRFOUND
 Q
 ;
GETCPT ;
 Q:BLRODTM<$P(^BLRCPT(BLRXII,0),U,3)
 S BLRFOUND=1,BLRCPTP=BLRXII
 S BLRCPTN=0 F BLRNN=1:1 S BLRCPTN=$O(^BLRCPT(BLRXII,11,BLRCPTN)) Q:'BLRCPTN  S BLRCPDAT=^BLRCPT(BLRXII,11,BLRCPTN,0),BLRCPCD=$P(BLRCPDAT,U),BLRCPCST=$P(BLRCPDAT,U,2),BLRCPRC=$P(BLRCPDAT,U,3),BLRCPACT=$P(BLRCPDAT,U,4) D
 .S (BLRCPTM,BLRCPTQ)=""
 .S BLRCPMN=0 F BLRNN1=1:1 S BLRCPMN=$O(^BLRCPT(BLRXII,11,BLRCPTN,1,BLRCPMN)) Q:'BLRCPMN  S:BLRNN1>1 BLRCPTM=BLRCPTM_"," S BLRCPTM=BLRCPTM_^BLRCPT(BLRXII,11,BLRCPTN,1,BLRCPMN,0)
 .S BLRCPQN=0 F BLRNN1=1:1 S BLRCPQN=$O(^BLRCPT(BLRXII,11,BLRCPTN,2,BLRCPQN)) Q:'BLRCPQN  S:BLRNN1>1 BLRCPTQ=BLRCPTQ_"," S BLRCPTQ=BLRCPTQ_^BLRCPT(BLRXII,11,BLRCPTN,2,BLRCPQN,0)
 .S:BLRNN>1 BLRCPTS=BLRCPTS_";" S BLRCPTS=BLRCPTS_BLRCPCD_"|"_BLRCPCST_"|"_BLRCPRC_"|"_BLRCPACT_"|"_BLRCPTM_"|"_BLRCPTQ
 K BLRCPCD,BLRCPCST,BLRCPRC,BLRCPACT,BLRCPTN,BLRCPDAT,BLRCPTM,BLRCPMN,BLRCPTQ,BLRCPQN,BLRNN,BLRNN1
 Q