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

APCHS3L.m

Go to the documentation of this file.
APCHS3L ; IHS/TUCSON/LAB - PART 3A OF APCHS -- SUMMARY PRODUCTION COMPONENTS ;  
 ;;2.0;IHS PCC SUITE;**2**;MAY 14, 2009
 ;
MRL ; ******************** MOST RECENT LAB * 9000010.09 *******
 I '$D(^AUPNVLAB("AA",APCHSPAT)) D EKGLAB G MRLX
 X APCHSCKP Q:$D(APCHSQIT)
 X:'APCHSNPG APCHSBRK
 ; <SETUP>
 ; <PROCESS>
 D LBLD,LPRT
 D EKGLAB
 ;now display lab refusals
 S APCHST="LAB",APCHSFN=60 D DISPREF^APCHS3C
 K APCHST,APCHSFN
 ; <CLEANUP>
MRLX K APCHSLT,APCHSLR,APCHSLTX,APCHSLRT,APCHSLL,APCHSLW,APCHSNMX,APCHSDFN,APCHSIVD,APCHSLTD,APCHSN,Y
 K ^TMP($J,"APCHS"),^TMP($J,"APCHS1")
 Q
 ; <BUILD>
LBLD K ^TMP($J,"APCHS","LAB"),^TMP($J,"APCHS1")
 S APCHSLRT="" F APCHSQ=0:0 S APCHSLRT=$O(^AUPNVLAB("AA",APCHSPAT,APCHSLRT)) Q:APCHSLRT=""  D LDATE
 D REORDER
 Q
REORDER ;reorder by accession, parent and child
 S X=0 F  S X=$O(^TMP($J,"APCHS","LAB",X)) Q:X'=+X  D
 .S Y=$P(^TMP($J,"APCHS","LAB",X),U,3)
 .S %=$E($P(^AUPNVLAB(Y,0),U,6),1,2) S:%="" %="ZZ"
 .S %1=$S($P($G(^AUPNVLAB(Y,12)),U,8)]"":$P(^AUPNVLAB(Y,12),U,8),1:Y)
 .S %2=$S($P($G(^AUPNVLAB(Y,12)),U,8)="":0,1:Y)
 .S ^TMP($J,"APCHS1",%,%1,%2,X)=^TMP($J,"APCHS","LAB",X)
 .Q
 K ^TMP($J,"APCHS")
 Q
LDATE S APCHSIVD=$O(^AUPNVLAB("AA",APCHSPAT,APCHSLRT,0))
 S APCHSDFN=0 F  S APCHSDFN=$O(^AUPNVLAB("AA",APCHSPAT,APCHSLRT,APCHSIVD,APCHSDFN)) Q:APCHSDFN'=+APCHSDFN   D:APCHSIVD&(APCHSIVD'>APCHSDLM) LSET
 Q
LSET ;
 S APCHSN=^AUPNVLAB(APCHSDFN,0),APCHSLR=$P(APCHSN,U,4)
 I $P($G(^AUPNVLAB(APCHSDFN,11)),U,9)="R",APCHSLR="",$$VALI^XBDIQ1(60,$P(APCHSN,U),999999901) Q  ;do not display tests that are resulted, result is null and flag says don't display
 I APCHSLR]"",APCHSLR'=" ",$P(APCHSN,U,5)]"" S APCHSLR=APCHSLR_" ("_$P(APCHSN,U,5)_")"
 I APCHSLR="",$P($G(^TMP($J,"APCHS","LAB",APCHSLRT)),U,2)]"" Q
 S ^TMP($J,"APCHS","LAB",APCHSLRT)=(-APCHSIVD\1+9999999)_U_APCHSLR_U_APCHSDFN S APCHSLTX=$P(^LAB(60,APCHSLRT,0),U,1)
 Q
 ; <PRINT>
LPRT ;
 W ?55,"UNITS",?64,"REF RANGE",!
 S APCHSACC="" F  S APCHSACC=$O(^TMP($J,"APCHS1",APCHSACC)) Q:APCHSACC=""!($D(APCHSQIT))  D
 .S APCHSPAR=0 F  S APCHSPAR=$O(^TMP($J,"APCHS1",APCHSACC,APCHSPAR)) Q:APCHSPAR'=+APCHSPAR!($D(APCHSQIT))  D
 ..S APCHCHIL="" F  S APCHCHIL=$O(^TMP($J,"APCHS1",APCHSACC,APCHSPAR,APCHCHIL)) Q:APCHCHIL=""  D
 ...S APCHSLT=$O(^TMP($J,"APCHS1",APCHSACC,APCHSPAR,APCHCHIL,0))
 ...S APCHSDFN=$P(^TMP($J,"APCHS1",APCHSACC,APCHSPAR,APCHCHIL,APCHSLT),U,3)
 ...S Y=$P(^TMP($J,"APCHS1",APCHSACC,APCHSPAR,APCHCHIL,APCHSLT),U,1),APCHSLR=$P(^TMP($J,"APCHS1",APCHSACC,APCHSPAR,APCHCHIL,APCHSLT),U,2) X APCHSCVD S APCHSLTD=Y
 ...D LPRT2
 K APCHCHIL,APCHSPAR,APCHSACC,APCHSLT
 Q
LPRT2 ;
 S APCHSLTX=$P(^LAB(60,APCHSLT,0),U)
 X APCHSCKP Q:$D(APCHSQIT)  I APCHSNPG W ?55,"UNITS",?64,"REF RANGE",!
 W:APCHCHIL "  " W APCHSLTX,?35,APCHSLTD,?45,APCHSLR
 W ?55,$P($G(^AUPNVLAB(APCHSDFN,11)),U)
 I $P($G(^AUPNVLAB(APCHSDFN,11)),U,4)]""!($P($G(^AUPNVLAB(APCHSDFN,11)),U,5)]"") W ?64,$P(^AUPNVLAB(APCHSDFN,11),U,4)_"-"_$P(^AUPNVLAB(APCHSDFN,11),U,5)
 I '$P(^APCHSCTL(APCHSTYP,0),U,7) W ! Q
 ;print out comments per Dorothy
 S APCHSX=0 F  S APCHSX=$O(^AUPNVLAB(APCHSDFN,21,APCHSX)) Q:APCHSX'=+APCHSX!($D(APCHSQIT))  D
 .X APCHSCKP Q:$D(APCHSQIT)
 .W !,?1,^AUPNVLAB(APCHSDFN,21,APCHSX,0)
 F APCHSX=1:1:3 Q:$D(APCHSQIT)  I $P($G(^AUPNVLAB(APCHSDFN,13)),U,APCHSX)]"" D
 .X APCHSCKP Q:$D(APCHSQIT)
 .W !,$P(^AUPNVLAB(APCHSDFN,13),U,APCHSX)
 ;W ?78," ",$P($G(^AUPNVLAB(APCHSDFN,11)),U,9)
 W !
 Q
 ;
EKGLAB ;ENTRY POINT - EKG display in most recent lab panel
 Q:'$D(^AUPNVDXP("AC",APCHSPAT))
 K APCHS
 S APCHSERR=$$START1^APCLDF(APCHSPAT_"^LAST DIAGNOSTIC ECG SUMMARY","APCHS(")
 G:APCHSERR EKGLABX
 ; *array APCHS(1)="DATE^RESULT^DIAG PROC^VDIAG PROCEDURE IEN^AUPNVDXP^VISIT IEN"
 K APCHSERR
 S APCHSIVD=$S($D(APCHS(1)):9999999-$P($P(APCHS(1),U,1),".",1),1:"")
 Q:'APCHSIVD!(APCHSIVD>APCHSDLM)
 S (APCHSLTX,APCHSLT)="EKG"
 S APCHSLRT("EKG")=$P(APCHS(1),U,1)_"^"_$P(APCHS(1),U,2)
 D EKGPRT  ;                           computes/prints ekg info
EKGLABX ;
 K APCHSERR,APCHS(1)
 Q
 ;
EKGPRT ;computers/prints ekg info
 S Y=$P(APCHSLRT(APCHSLT),U,1) X APCHSCVD S APCHSLTD=Y
 S APCHSLR=$P(APCHSLRT(APCHSLT),U,2)
 S APCHSLR=$S(APCHSLR="N":"NORMAL",APCHSLR="A":"ABNORMAL",APCHSLR="B":"BORDERLINE",1:"<none recorded>") ;IHS/CMI/LAB added borderline
 S APCHSLW=$S($G(APCHSLW):APCHSLW,1:28)
 W !,APCHSLTX,?APCHSLW,APCHSLTD,"  ",APCHSLR,!
 Q