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

BCHRCH1.m

Go to the documentation of this file.
BCHRCH1 ; IHS/CMI/LAB - PROCESS REPORT ; 
 ;;2.0;IHS RPMS CHR SYSTEM;;OCT 23, 2012;Build 27
 ;IHS/CMI/LAB - tmp to xtmp
 ;
 ;
 ;
 ;
START ;
 D XTMP^BCHUTIL("BCHRCH","CHR CHR REPORT")
 S BCHTT=0
 S (BCHBT,BCHBTH)=$H,BCHJOB=$J
 D D
 D SETTMP
 D END
 Q
 ;
D ; Run by date of service
 S X1=BCHBD,X2=-1 D C^%DTC S BCHSD=X
 S BCHODAT=BCHSD_".9999" F  S BCHODAT=$O(^BCHR("B",BCHODAT)) Q:BCHODAT=""!((BCHODAT\1)>BCHED)  D D1
 Q
 ;
END ;
 S BCHET=$H
 D EOJ
 Q
EOJ ;
 Q
D1 ;
 S (BCHR,BCHRCNT)=0 F  S BCHR=$O(^BCHR("B",BCHODAT,BCHR)) Q:BCHR'=+BCHR  I $D(^BCHR(BCHR,0)),$P(^(0),U,2)]"",$P(^(0),U,3)]"" S BCHR0=^(0) D PROC
 Q
PROC ;
 S BCHPAT=$P(BCHR0,U,4)
 S BCHNRPAT=$P($G(^BCHR(BCHR,11)),U,12)
 ;I 'BCHPAT,'BCHNRPAT Q   ;no patient
 I BCHREG="R",BCHPAT="" Q
 I BCHREG="N",BCHNRPAT="" Q
 I BCHPAT,BCHNRPAT S BCHNRPAT=""
 I BCHPAT Q:'$D(^DPT(BCHPAT,0))
 S BCHPROG=$P(BCHR0,U,2)
 I BCHPRG,BCHPRG'=BCHPROG Q
 S BCHPROV=$P(BCHR0,U,3)
 I BCHPROVT="O",BCHCHR1'=BCHPROV Q
 S (BCHX,BCHC)=0 F  S BCHX=$O(^BCHRPROB("AD",BCHR,BCHX)) Q:BCHX'=+BCHX  S BCHC=BCHC+1 D
 .Q:$P(^BCHRPROB(BCHX,0),U,4)=""
 .S P=$P(^BCHRPROB(BCHX,0),U),A=$P(^BCHRPROB(BCHX,0),U,4),S=$P(^BCHRPROB(BCHX,0),U,5)
 .S BCHTT=BCHTT+S I BCHC=1 S BCHTT=BCHTT+$P(BCHR0,U,11)
 .S ^(P)=$S($D(^XTMP("BCHRCH",BCHJOB,BCHBT,"PROBLEM",P)):^(P)+S,1:S) I BCHC=1 S ^(P)=^(P)+$P(BCHR0,U,11)
 .S ^(A)=$S($D(^XTMP("BCHRCH",BCHJOB,BCHBT,"ACTIVITY",A)):^(A)+S,1:S) I BCHC=1 S ^(A)=^(A)+$P(BCHR0,U,11)
 Q
 ;
SETTMP ;
 S X=0 F  S X=$O(^XTMP("BCHRCH",BCHJOB,BCHBT,"ACTIVITY",X)) Q:X'=+X  S ^XTMP("BCHRCH",BCHJOB,BCHBT,"TOP ACTS",9999999-^(X),X)=X_U_^(X)_U_(^(X)/BCHTT)
 S X=0 F  S X=$O(^XTMP("BCHRCH",BCHJOB,BCHBT,"PROBLEM",X)) Q:X'=+X  S ^XTMP("BCHRCH",BCHJOB,BCHBT,"TOP PROBS",9999999-^(X),X)=X_U_^(X)_U_(^(X)/BCHTT)
 Q