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

BEHOVMER.m

Go to the documentation of this file.
BEHOVMER ;MSC/IND/MGH - VITALS ENTERED IN ERROR REPORT ;07-Jun-2010 11:06;MGH
 ;;1.1;BEH COMPONENTS;**001004,001005**;Mar 20, 2007
 ;=================================================================
EN1 ; EP Entry point
 D DEM^VADPT D NOW^%DTC S Y=% X ^DD("DD") S BEHPDT=$P(Y,"@")_" ("_$P($P(Y,"@",2),":",1,2)_")",(BEHOUT,BEHPG)=0,BEH1ST=1,$P(BEHDSH,"-",81)=""
 F BEHVITY=0:0 S BEHVITY=$O(^AUPNVMSR("AE",DFN,BEHVITY)) Q:BEHVITY'>0  F BEHVDT=0:0 S BEHVDT=$O(^AUPNVMSR("AE",DFN,BEHVITY,BEHVDT)) Q:BEHVDT'>0  S BEHVDATE=9999999-BEHVDT I BEHVDATE'<BEHVSDT,BEHVDATE'>BEHVFDT D SORT
 U IO D HDR I $O(^TMP("BEHOERR",$J,0))'>0 W !,"THERE IS NO DATA FOR THIS REPORT" G QT
 F BEHDATE=0:0 S BEHDATE=$O(^TMP("BEHOERR",$J,BEHDATE)) Q:BEHDATE'>0!BEHOUT  D
 .F BEHVITY=0:0 S BEHVITY=$O(^TMP("BEHOERR",$J,BEHDATE,BEHVITY)) Q:BEHVITY'>0!BEHOUT  D
 ..F BEHVDA=0:0 S BEHVDA=$O(^TMP("BEHOERR",$J,BEHDATE,BEHVITY,BEHVDA)) Q:BEHVDA'>0  D WRT Q:BEHOUT
QT ;
 I IOSL'<($Y+8) F X=1:1 W ! Q:IOSL<($Y+8)
 I 'BEHOUT,$E(IOST)'="P" W !!,"Press return to continue ""^"" to escape " R X:DTIME
Q ; KILL VARIBLES
 K ^TMP("BEHOERR",$J),DFN,BEH1ST,BEHDAT,BEHDATE,BEHDSH,BEHOUT,BEHPDT,BEHPG,BEHPR,BEHSITE,BEHVDA,BEHVDATE,BEHVDT,BEHVERR
 K BEHVFDT,BEHVITY,BEHVSDT,BEHVX,POP,DIPGM,BEHP,BEHTYPE,BEHOV,DIPGM,%T,%
 D KVAR^VADPT K VA
 K GREASON,BEHZZ,BEHTAKEN,BEHVARY,GX,BEHQUAL,BEHVPO D ^%ZISC Q
SORT ;
 F BEHVDA=0:0 S BEHVDA=$O(^AUPNVMSR("AE",DFN,BEHVITY,BEHVDT,BEHVDA)) Q:BEHVDA'>0  D
 .I $D(^AUPNVMSR(BEHVDA,2)) D
 ..S BEHVERR=$G(^AUPNVMSR(BEHVDA,0))
 ..;Get the time taken
 ..S BEHTAKEN=$P($G(^AUPNVMSR(BEHVDA,12)),U,1)
 ..S BEHTAKEN=9999999-BEHTAKEN
 ..I BEHTAKEN="" S BEHTAKEN=BEHVDT
 ..S ^TMP("BEHOERR",$J,BEHTAKEN,BEHVITY,BEHVDA)=BEHVERR
 Q
WRT ;
 D:IOSL<($Y+8) HDR Q:BEHOUT  K BEHPR
 S BEHVERR=^TMP("BEHOERR",$J,BEHDATE,BEHVITY,BEHVDA)
 I $D(^AUPNVMSR(BEHVDA,0)) D
 . S BEHDAT("BAD")=$S($D(^AUPNVMSR(+BEHVDA,0)):^(0),1:"")
 . K BEHVX,BEHVX(0),BEHVX(1)
 . S BEHVX=$P(^AUTTMSR(BEHVITY,0),"^",2)
 . S BEHVX(0)=$P(BEHDAT("BAD"),"^",4) D
 ..I BEHVX(0)>0 S BEHVX(0)=$$VALUE(BEHVITY,BEHVX(0)) S BEHVX(1)=""
 . S BEHZZ="" I +$D(^AUPNVMSR(BEHVDA,5)) K BEHVARY S BEHVARY="" D
 ..S BEHZZ=$$QUAL^BEHOVMC2(BEHVDA)
 ..S BEHVX(1)=" ("_BEHZZ_")"
 . S BEHVPO=$P($G(^AUPNVSMR(BEHVDA,0)),"^",10)
 . S $P(BEHDAT("BAD"),"^",4)=BEHVX(0)_BEHVX(1)_$S(BEHVPO'="":" with supplemental O2 "_$S(BEHVPO["l/min":$P(BEHVPO," l/min")_"L/min",1:"")_$S(BEHVPO["l/min":$P(BEHVPO," l/min",2),1:BEHVPO),1:"")_$S(BEHZZ'=""&(BEHVX="O2"):" via ",1:"")
 . S GREASON="" D ERREASON
 S Y=9999999-BEHDATE D D^DIQ S BEHPR("VSDT")=Y
 S EIE=$P($G(^AUPNVMSR(BEHVDA,2)),U,2)
 I EIE'="" S BEHPR("ENUS")=$P($G(^VA(200,EIE,0)),U,1)
 E  S BEHPR("ENUS")=""
 S BEHPR("TYPE")=$S(BEHVITY="":"",$D(^AUTTMSR(BEHVITY,0)):$P(^(0),"^"),1:"")
 W !,BEHPR("VSDT"),?23,BEHPR("TYPE"),?58,BEHPR("ENUS"),!,?3,"Reason: ",GREASON
 I BEHVDA>0 W !,?3,"(Bad data)  ",$P(BEHDAT("BAD"),"^",4)
 W ! Q
HDR ;
 I $E(IOST)'="P",'BEH1ST W !,"Press return to continue ""^"" to escape " R X:DTIME I X="^"!'$T S GMROUT=1 Q
 W:'($E(IOST)'="C"&'BEHPG) @IOF S BEH1ST=0,BEHPG=BEHPG+1
 W !,BEHPDT,?22,"ENTERED IN ERROR VITAL/MEASUREMENT REPORT",?70,"PAGE ",BEHPG
 W !,"Patient: ",VADM(1),?$X+5,$P(VADM(2),"^",2),!!,"Date Vit./Meas. taken",?58,"User who made error",!,BEHDSH,!
 Q
VALUE(TYPE,DATA) ;Get the value for this result
 N TYP,VAL,AGE,BEH,DATAG,DEFAULT,DEFU,ALTU,VALUE
 S TYP=$P(^AUPNVMSR(BEHVDA,0),U)
 S VAL=$P($G(^AUPNVMSR(BEHVDA,0)),U,4)
 S:'$G(DAT) DAT=DT
 S AGE=$$PTAGE^BGOUTL(DFN,$S(X:X,1:DAT))
 S TYP=$P($G(^BEHOVM(90460.01,TYP,0)),U,7)
 S BEH="" S BEH=$O(^BEHOVM(90460.01,"B",TYP,BEH))
 I TYP="" S VALUE=$$RND(VAL)
 E  D
 .S DATAG=$G(^BEHOVM(90460.01,BEH,0))
 .S DEFAULT=$P(DATAG,U,2)
 .I DEFAULT=1 D
 ..S DEFU=$P(DATAG,U,4),ALTU=$P(DATAG,U,3)
 ..I ALTU=""!(DEFU=ALTU) S VALUE=$$RND(VAL)_" "_DEFU
 ..E  S X=VAL I $D(^BEHOVM(90460.01,BEH,2)) X $G(^BEHOVM(90460.01,BEH,2)) D
 ...S VALUE=$$RND(VAL)_" "_DEFU_" ("_$$RND(X)_" "_ALTU_")"
 .I DEFAULT=0 D
 ..S DEFU=$P(DATAG,U,3),ALTU=$P(DATAG,U,4)
 ..I ALTU=""!(DEFU=ALTU) S VALUE=$$RND(VAL)_" "_DEFU
 ..E  S X=VAL I $D(^BEHOVM(90460.01,BEH,1)) X $G(^BEHOVM(90460.01,BEH,1)) D
 ...S VALUE=$$RND(VAL)_" "_DEFU_" ("_$$RND(X)_" "_ALTU_")"
 .I DEFAULT="" S VALUE=$$RND(VAL)
 Q VALUE
ERREASON ;Reason for entered in error
 Q:'$D(^AUPNVMSR(+BEHVDA,2.1))
 S GER=0 F  S GER=$O(^AUPNVMSR(+BEHVDA,2.1,GER)) Q:GER'>0  S GER(1)=$G(^AUPNVMSR(+BEHVDA,2.1,GER,0)) D
 . S GER(2)=$S(GER(1)=1:"incorrect date/time",GER(1)=2:"incorrect reading",GER(1)=3:"incorrect patient",GER(1)=4:"invalid record",1:GER(1))
 . I GER(2)'="" S GREASON=GREASON_$S(GREASON'="":", ",1:"")_GER(2)
 .Q
 K GER Q
RND(X) Q $S(X=+X:+$J(X,0,2),1:X)