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

BHSLABA.m

Go to the documentation of this file.
BHSLABA ;IHS/CIA/MGH - Health Summary for V lab file ;04-Aug-2009 15:43;MGH
 ;;1.0;HEALTH SUMMARY COMPONENTS;**1,2,3**;March 17, 2006
 ;===================================================================
 ;Taken from APCHS3A
 ; IHS/TUCSON/LAB - PART 3A OF APCHS -- SUMMARY PRODUCTION COMPONENTS ;  [ 07/08/02  3:25 PM ]
 ;;2.0;IHS RPMS/PCC Health Summary;**3,9**;JUN 24, 1997
 ;Patch 1 includes changes for patch 13
 ;Patch 2 for changes in patch 16
 ;Patch 3 for addition of date/time of result
MRL ; ******************** MOST RECENT LAB * 9000010.09 *******
 N BHSPAT,BHSQ
 S BHSPAT=DFN
 I '$D(^AUPNVLAB("AA",BHSPAT)) D EKGLAB S BHST="LAB",BHSFN=60 D DISPREF^BHSRAD G MRLX
 D CKP^GMTSUP Q:$D(GMTSQIT)
 ; <SETUP>
 ; <PROCESS>
 D LBLD,LPRT
 D EKGLAB
 ;Patch 2, lab refusals
 S BHST="LAB",BHSFN=60 D DISPREF^BHSRAD
 K BHST,BHSFN
 ; <CLEANUP>
MRLX K BHSLT,BHSX,BHSLR,BHSLTX,BHSLRT,BHSLL,BHSLW,BHSNMX,BHSDFN,BHSIVD,BHSLTD,BHSN,Y,BHSRDT,BHSLTX
 K ^TMP($J,"BHS"),^TMP($J,"BHS1")
 Q
 ; <BUILD>
LBLD K ^TMP($J,"BHS","LAB"),^TMP($J,"BHS1")
 S BHSLRT="" F BHSQ=0:0 S BHSLRT=$O(^AUPNVLAB("AA",BHSPAT,BHSLRT)) Q:BHSLRT=""  D LDATE
 D REORDER
 Q
REORDER ;reorder by accession, parent and child
 N %,%1,%2,X
 S X=0 F  S X=$O(^TMP($J,"BHS","LAB",X)) Q:X'=+X  D
 .S Y=$P(^TMP($J,"BHS","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,"BHS1",%,%1,%2,X)=^TMP($J,"BHS","LAB",X)
 .Q
 K ^TMP($J,"BHS")
 Q
LDATE S BHSIVD=$O(^AUPNVLAB("AA",BHSPAT,BHSLRT,0))
 S BHSDFN=0 F  S BHSDFN=$O(^AUPNVLAB("AA",BHSPAT,BHSLRT,BHSIVD,BHSDFN)) Q:BHSDFN'=+BHSDFN   D:BHSIVD&(BHSIVD'>GMTSDLM) LSET
 Q
LSET ;
 S BHSN=^AUPNVLAB(BHSDFN,0),BHSLR=$P(BHSN,U,4)
 I $P($G(^AUPNVLAB(BHSDFN,11)),U,9)="R",BHSLR="",$$VALI^XBDIQ1(60,$P(BHSN,U),999999901) Q  ;do not display tests that are resulted, result is null and flag says don't display
 I BHSLR]"",$P(BHSN,U,5)]"" S BHSLR=BHSLR_" ("_$P(BHSN,U,5)_")"
 I BHSLR="",$P($G(^TMP($J,"BHS","LAB",BHSLRT)),U,2)]"" Q
 S ^TMP($J,"BHS","LAB",BHSLRT)=(-BHSIVD\1+9999999)_U_BHSLR_U_BHSDFN S BHSLTX=$P(^LAB(60,BHSLRT,0),U,1)
 Q
 ; <PRINT>
LPRT ;
 W ?2,"TEST",?23,"RESULT DT/TIME",?39,"VISIT",?50,"RESULT",?60,"UNITS",?70,"REF RANGE",!
 S BHSACC="" F  S BHSACC=$O(^TMP($J,"BHS1",BHSACC)) Q:BHSACC=""!($D(GMTSQIT))  D
 .S BHSPAR=0 F  S BHSPAR=$O(^TMP($J,"BHS1",BHSACC,BHSPAR)) Q:BHSPAR'=+BHSPAR!($D(GMTSQIT))  D
 ..S APCHCHIL="" F  S APCHCHIL=$O(^TMP($J,"BHS1",BHSACC,BHSPAR,APCHCHIL)) Q:APCHCHIL=""  D
 ...S BHSLT=$O(^TMP($J,"BHS1",BHSACC,BHSPAR,APCHCHIL,0))
 ...S BHSDFN=$P(^TMP($J,"BHS1",BHSACC,BHSPAR,APCHCHIL,BHSLT),U,3)
 ...S X=$P(^TMP($J,"BHS1",BHSACC,BHSPAR,APCHCHIL,BHSLT),U,1),BHSLR=$P(^TMP($J,"BHS1",BHSACC,BHSPAR,APCHCHIL,BHSLT),U,2) D REGDT4^GMTSU S BHSLTD=X
 ...D LPRT2
 K APCHCHIL,BHSPAR,BHSACC,BHSLT
 Q
LPRT2 ;
 S BHSLTX=$P(^LAB(60,BHSLT,0),U)
 S BHSRDT=$P($G(^AUPNVLAB(BHSDFN,12)),U,12) I BHSRDT]"" S BHSRDT=$$DATE^APCHSMU($P(BHSRDT,"."))_"@"_$P($P($$FMTE^XLFDT(BHSRDT),"@",2),":",1,2)
 D CKP^GMTSUP Q:$D(GMTSQIT)  I GMTSNPG W ?2,"TEST",?23,"RESULT DT/TIME",?39,"VISIT",?47,"RESULT",?60,"UNITS",?70,"REF RANGE",!
 W:APCHCHIL " " W $E(BHSLTX,1,20),?23,BHSRDT,?38,BHSLTD,?50,BHSLR
 W ?60,$P($G(^AUPNVLAB(BHSDFN,11)),U)
 I $P($G(^AUPNVLAB(BHSDFN,11)),U,4)]""!($P($G(^AUPNVLAB(BHSDFN,11)),U,5)]"") W ?70,$P(^AUPNVLAB(BHSDFN,11),U,4)_"-"_$P(^AUPNVLAB(BHSDFN,11),U,5)
 ;I '$P(^APCHSCTL(APCHSTYP,0),U,7) W ! Q
 ;print out comments per Dorothy
 S BHSX=0 F  S BHSX=$O(^AUPNVLAB(BHSDFN,21,BHSX)) Q:BHSX'=+BHSX!($D(GMTSQIT))  D
 .D CKP^GMTSUP Q:$D(GMTSQIT)
 .W !,?1,^AUPNVLAB(BHSDFN,21,BHSX,0)
 F BHSX=1:1:3 Q:$D(GMTSQIT)  I $P($G(^AUPNVLAB(BHSDFN,13)),U,BHSX)]"" D
 .D CKP^GMTSUP Q:$D(GMTSQIT)
 .W !,$P(^AUPNVLAB(BHSDFN,13),U,BHSX)
 ;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",BHSPAT))
 K BHS
 S BHSERR=$$START1^APCLDF(BHSPAT_"^LAST DIAGNOSTIC ECG SUMMARY","BHS(")
 G:BHSERR EKGLABX
 ; *array BHS(1)="DATE^RESULT^DIAG PROC^VDIAG PROCEDURE IEN^AUPNVDXP^VISIT IEN"
 K BHSERR
 S BHSIVD=$S($D(BHS(1)):9999999-$P($P(BHS(1),U,1),".",1),1:"")
 Q:'BHSIVD!(BHSIVD>GMTSDLM)
 S (BHSLTX,BHSLT)="EKG"
 S BHSLRT("EKG")=$P(BHS(1),U,1)_"^"_$P(BHS(1),U,2)
 D EKGPRT  ;                           computes/prints ekg info
EKGLABX ;
 K BHSERR,BHS(1)
 Q
 ;
EKGPRT ;computers/prints ekg info
 S X=$P(BHSLRT(BHSLT),U,1) D REGDT4^GMTSU S BHSLTD=X
 S BHSLR=$P(BHSLRT(BHSLT),U,2)
 S BHSLR=$S(BHSLR="N":"NORMAL",BHSLR="A":"ABNORMAL",BHSLR="B":"BORDERLINE",1:"<none recorded>") ;IHS/CMI/LAB added borderline
 S BHSLW=$S($G(BHSLW):BHSLW,1:28)
 W !,BHSLTX,?BHSLW,BHSLTD,"  ",BHSLR,!
 Q
 ;