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

APCHS3E.m

Go to the documentation of this file.
APCHS3E ; IHS/CMI/LAB - PART 3 OF APCHS -- SUMMARY PRODUCTION COMPONENTS ;
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
 ;
MIC ; ******************** MIC DATA * 9000010.09 *******
 I '$D(^AUPNVMIC("AE",APCHSPAT)) G MICX
 W !?3,"See the Lab Package for More Complete Microbiology Information than ",!,"contained below."
 X APCHSCKP Q:$D(APCHSQIT)  I APCHSNPG W ?34,"RESULT",?58,"COLL DATE",?68,"COMP DATE",!
 X:'APCHSNPG APCHSBRK
 ; <SETUP>
 K ^TMP($J,"APCHSMICP"),^TMP($J,"APCHMICA")
 ; <PROCESS>
 D LBLD,LPRT
 ; <CLEANUP>
MICX K X,Y,C,D,T,O,P,A,N
 K APCHSIVD,APCHSLT,APCHSIEN,APCHSACC,APCHS01,APCHSORG,APCHSANT,APCHSVL
 K ^TMP($J,"APCHSMICP"),^TMP($J,"APCHMICA")
 Q
 ; <BUILD>
LBLD ;
 S APCHSIVD="" F   S APCHSIVD=$O(^AUPNVMIC("AE",APCHSPAT,APCHSIVD)) Q:'APCHSIVD!(APCHSIVD>APCHSDLM)  D LDATE
 Q
LDATE S APCHSLT="" F  S APCHSLT=$O(^AUPNVMIC("AE",APCHSPAT,APCHSIVD,APCHSLT)) Q:APCHSLT'=+APCHSLT  D
 .S APCHSIEN=0 F  S APCHSIEN=$O(^AUPNVMIC("AE",APCHSPAT,APCHSIVD,APCHSLT,APCHSIEN)) Q:APCHSIEN'=+APCHSIEN  D LSET
 Q
LSET ;
 S N=$G(^AUPNVMIC(APCHSIEN,0))
 S D=$P($P($G(^AUPNVMIC(APCHSIEN,12)),U),".") I D]"" S D=9999999-D
 S P=$P($G(^AUPNVMIC(APCHSIEN,12)),U,8)
 S O=$P(N,U,4),A=$P(N,U,5),C=$P(N,U,6),T=$P(N,U,1)
 S:O="" O=0 S:A="" A=0 S:C="" C=0
 Q:T=""
 I P="" S ^TMP($J,"APCHSMICP",$S(D]"":D,1:APCHSIVD),C,T,APCHSIEN)=""
 S ^TMP($J,"APCHMICA",C,T,O,A,APCHSIEN)=""
 Q
 ; <PRINT>
LPRT ;
 Q:'$D(^TMP($J,"APCHSMICP"))
 W ?34,"RESULT",?58,"COLL DATE",?68,"COMP DATE",!
 S APCHSIVD="" F  S APCHSIVD=$O(^TMP($J,"APCHSMICP",APCHSIVD)) Q:APCHSIVD'=+APCHSIVD!($D(APCHSQIT))  D
 .S APCHSACC="" F  S APCHSACC=$O(^TMP($J,"APCHSMICP",APCHSIVD,APCHSACC)) Q:APCHSACC=""!($D(APCHSQIT))  D
 ..S APCHS01=0 F  S APCHS01=$O(^TMP($J,"APCHSMICP",APCHSIVD,APCHSACC,APCHS01)) Q:APCHS01'=+APCHS01!($D(APCHSQIT))  D
 ...S APCHSIEN=0 F  S APCHSIEN=$O(^TMP($J,"APCHSMICP",APCHSIVD,APCHSACC,APCHS01,APCHSIEN)) Q:APCHSIEN'=+APCHSIEN!($D(APCHSQIT))  D LPRT2
 ...Q
 ..Q
 .Q
 Q
LPRT2 ;
 ;print all from this acc,.01
 S APCHSORG="" F  S APCHSORG=$O(^TMP($J,"APCHMICA",APCHSACC,APCHS01,APCHSORG)) Q:APCHSORG=""!($D(APCHSQIT))  D
 .S APCHSANT="" F  S APCHSANT=$O(^TMP($J,"APCHMICA",APCHSACC,APCHS01,APCHSORG,APCHSANT)) Q:APCHSANT=""!($D(APCHSQIT))  D
 ..S APCHSVL=0 F  S APCHSVL=$O(^TMP($J,"APCHMICA",APCHSACC,APCHS01,APCHSORG,APCHSANT,APCHSVL)) Q:APCHSVL'=+APCHSVL!($D(APCHSQIT))  D LPRT3
 Q
LPRT3 ;write out line
 S APCHSN=^AUPNVMIC(APCHSVL,0)
 X APCHSCKP Q:$D(APCHSQIT)  I APCHSNPG W ?34,"RESULT",?58,"COLL DATE",?68,"COMP DATE",!
 ;write name
 K ^TMP($J,"APCHMICA",APCHSACC,APCHS01,APCHSORG,APCHSANT,APCHSVL)
 ;I APCHSANT=0,APCHSORG'=0 W !?3,$$VAL^XBDIQ1(9000010.25,APCHSVL,.04),"  ",$$ORGR(APCHSPAT,APCHSACC,$P($G(^AUPNVMIC(APCHSVL,12)),U),APCHSVL) S Y=$P(APCHSN,U,9) X APCHSCVD W ?68,Y,?79,$E($P($G(^AUPNVMIC(APCHSVL,11)),U,9)),! Q
 I APCHSANT=0,APCHSORG'=0 W !?2,$$VAL^XBDIQ1(9000010.25,APCHSVL,.04),"  ",?34,$$ORGR(APCHSPAT,APCHSACC,$P($G(^AUPNVMIC(APCHSVL,12)),U),APCHSVL) S Y=$P(APCHSN,U,9) X APCHSCVD W ?68,Y,! Q
 ;I APCHSANT>0 W ?3,$$VAL^XBDIQ1(9000010.25,APCHSVL,.05),?34,$P(APCHSN,U,7) S Y=$P(APCHSN,U,9) X APCHSCVD W ?68,Y,?79,$E($P($G(^AUPNVMIC(APCHSVL,11)),U,9)),! Q
 I APCHSANT>0 W ?3,$$VAL^XBDIQ1(9000010.25,APCHSVL,.05),?34,$P(APCHSN,U,7) S Y=$P(APCHSN,U,9) X APCHSCVD W ?68,Y,! Q
 ;W:'APCHSNPG ! W $P(^LAB(60,$P(APCHSN,U),0),U) S Y=(9999999-APCHSIVD) X APCHSCVD W ?58,Y,?47,$P(APCHSN,U,7) S Y=$P(APCHSN,U,9) X APCHSCVD W ?68,Y,?79,$E($P($G(^AUPNVMIC(APCHSVL,11)),U,9)),! D
 W:'APCHSNPG ! W $P(^LAB(60,$P(APCHSN,U),0),U) S Y=(9999999-APCHSIVD) X APCHSCVD D
 .W:$P(^LAB(60,$P(APCHSN,U),0),U)["GRAM " ?34,$$GSR(APCHSPAT,APCHSACC,$P($G(^AUPNVMIC(APCHSVL,12)),U),APCHSVL)
 .W ?58,Y S Y=$P(APCHSN,U,9) X APCHSCVD W ?68,Y,! D
 ..W ?2,"Site/Specimen: ",$$SITE(APCHSPAT,APCHSACC,$P($G(^AUPNVMIC(APCHSVL,12)),U),APCHSVL),!?2,"Collection Sample: ",$$COL(APCHSPAT,APCHSACC,$P($G(^AUPNVMIC(APCHSVL,12)),U),APCHSVL),!
 Q
SITE(P,A,D,V) ;return site/specimen
 I $G(P)="" Q ""
 I $G(A)="" Q ""
 I $G(D)="" Q ""
 I $G(V)="" Q ""
 I $P($G(^AUPNVMIC(V,11)),U,3)]"" Q $$VAL^XBDIQ1(9000010.25,V,1103)
 NEW APCHLRDF,APCHIVD,X
 S APCHLRDF=$P($G(^DPT(P,"LR")),U)
 I APCHLRDF="" Q ""
 S APCHIVD=9999999-D
 I '$D(^LR(APCHLRDF,"MI",APCHIVD,0)) Q ""
 I $P(^LR(APCHLRDF,"MI",APCHIVD,0),U,6)'=A Q ""
 S X=$P(^LR(APCHLRDF,"MI",APCHIVD,0),U,5)
 I 'X Q ""
 I '$D(^LAB(61,X,0)) Q ""
 Q $P(^LAB(61,X,0),U)
 ;
COL(P,A,D,V) ;
 I $G(P)="" Q ""
 I $G(A)="" Q ""
 I $G(D)="" Q ""
 I $G(V)="" Q ""
 I $P($G(^AUPNVMIC(V,0)),U,8)]"" Q $$VAL^XBDIQ1(9000010.25,V,.08)
 NEW APCHLRDF,APCHIVD,X
 S APCHLRDF=$P($G(^DPT(P,"LR")),U)
 I APCHLRDF="" Q ""
 S APCHIVD=9999999-D
 I '$D(^LR(APCHLRDF,"MI",APCHIVD,0)) Q ""
 I $P(^LR(APCHLRDF,"MI",APCHIVD,0),U,6)'=A Q ""
 S X=$P(^LR(APCHLRDF,"MI",APCHIVD,0),U,11)
 I 'X Q ""
 I '$D(^LAB(62,X,0)) Q ""
 Q $P(^LAB(62,X,0),U)
 ;
GSR(P,A,D,V) ;
 I $G(P)="" Q ""
 I $G(A)="" Q ""
 I $G(D)="" Q ""
 I $G(V)="" Q ""
 NEW APCHLRDF,APCHIVD,X,R
 S R=$$VAL^XBDIQ1(9000010.25,V,.07)
 S APCHLRDF=$P($G(^DPT(P,"LR")),U)
 I APCHLRDF="" Q ""
 S APCHIVD=9999999-D
 I '$D(^LR(APCHLRDF,"MI",APCHIVD,0)) Q ""
 I $P(^LR(APCHLRDF,"MI",APCHIVD,0),U,6)'=A Q ""
 S X=$G(^LR(APCHLRDF,"MI",APCHIVD,2,1,0))
 I X="" Q ""
 ;
 Q X
ORGR(P,A,D,V) ;
 I $G(P)="" Q ""
 I $G(A)="" Q ""
 I $G(D)="" Q ""
 I $G(V)="" Q ""
 NEW APCHLRDF,APCHIVD,X,R
 S R=$$VAL^XBDIQ1(9000010.25,V,.07)
 S APCHLRDF=$P($G(^DPT(P,"LR")),U)
 I APCHLRDF="" Q ""
 S APCHIVD=9999999-D
 I '$D(^LR(APCHLRDF,"MI",APCHIVD,0)) Q ""
 I $P(^LR(APCHLRDF,"MI",APCHIVD,0),U,6)'=A Q ""
 S X=$P($G(^LR(APCHLRDF,"MI",APCHIVD,3,1,0)),U,2)
 I X="" Q ""
 ;
 Q X