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

BCHRC11.m

Go to the documentation of this file.
BCHRC11 ; IHS/CMI/LAB - PROCESS REPORT ; 
 ;;2.0;IHS RPMS CHR SYSTEM;;OCT 23, 2012;Build 27
 ;IHS/CMI/LAB - tmp to xtmp
 ;
 ;
 ;
 ;
START ;
 S (BCHBT,BCHBTH)=$H,BCHJOB=$J
 D XTMP^BCHUTIL("BCHRC1","CHR CHR REPORT")
 D 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  D
 .S BCHC=BCHC+1
 .I BCHLEAVE="D" I $P(^BCHRPROB(BCHX,0),U,4),$P(^BCHTSERV($P(^BCHRPROB(BCHX,0),U,4),0),U,3)="LT" Q
 .D @BCHRPT
 .D
 ..;BY 1ST LEVEL
 ..S $P(^(BCHPROBN),U)=$S($D(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA",BCHPROBN)):$P(^(BCHPROBN),U)+1,1:1)
 ..S $P(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA",BCHPROBN),U,2)=$P(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA",BCHPROBN),U,2)+$P(^BCHRPROB(BCHX,0),U,5)
 ..I BCHC=1 S $P(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA",BCHPROBN),U,3)=$P(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA",BCHPROBN),U,3)+$P(BCHR0,U,11)
 ..I BCHRPT=3,BCHC=1 D
 ...S $P(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA",BCHPROBN),U,4)=$P(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA",BCHPROBN),U,4)+$P(BCHR0,U,12)
 ..I BCHRPT'=3 D
 ...S $P(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA",BCHPROBN),U,4)=$P(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA",BCHPROBN),U,4)+$P(BCHR0,U,12)
 ..;SUBTOTALS
 ..S $P(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA",BCHPROBN,BCHSUB1),U)=$S($D(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA",BCHPROBN,BCHSUB1)):$P(^(BCHSUB1),U)+1,1:1)
 ..S $P(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA",BCHPROBN,BCHSUB1),U,2)=$P(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA",BCHPROBN,BCHSUB1),U,2)+$P(^BCHRPROB(BCHX,0),U,5)
 ..I BCHC=1 S $P(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA",BCHPROBN,BCHSUB1),U,3)=$P(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA",BCHPROBN,BCHSUB1),U,3)+$P(BCHR0,U,11)
 ..I BCHRPT=3,BCHC=1 D
 ...S $P(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA",BCHPROBN,BCHSUB1),U,4)=$P(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA",BCHPROBN,BCHSUB1),U,4)+$P(BCHR0,U,12)
 ..I BCHRPT'=3 D
 ...S $P(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA",BCHPROBN,BCHSUB1),U,4)=$P(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA",BCHPROBN,BCHSUB1),U,4)+$P(BCHR0,U,12)
 ..;TOTALS
 ..S $P(^("*TOTAL*"),U)=$S($D(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA","*TOTAL*")):$P(^("*TOTAL*"),U)+1,1:1)
 ..S $P(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA","*TOTAL*"),U,2)=$P(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA","*TOTAL*"),U,2)+$P(^BCHRPROB(BCHX,0),U,5)
 ..I BCHC=1 S $P(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA","*TOTAL*"),U,3)=$P(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA","*TOTAL*"),U,3)+$P(BCHR0,U,11)
 ..I BCHRPT=3,BCHC=1 S $P(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA","*TOTAL*"),U,4)=$P(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA","*TOTAL*"),U,4)+$P(BCHR0,U,12)
 ..I BCHRPT'=3 S $P(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA","*TOTAL*"),U,4)=$P(^XTMP("BCHRC1",BCHJOB,BCHBT,"DATA","*TOTAL*"),U,4)+$P(BCHR0,U,12)
 Q
1 ;health area
 S BCHPROB=$P(^BCHRPROB(BCHX,0),U)
 S BCHPROBN=$P(^BCHTPROB(BCHPROB,0),U)_"|"_$P(^BCHTPROB(BCHPROB,0),U,2)
 S BCHSUB1=$P(^BCHRPROB(BCHX,0),U,4)
 I BCHSUB1="" S BCHSUB1="NO ACTIVITY ENTERED|**" Q
 S BCHSUB1=$P(^BCHTSERV(BCHSUB1,0),U)_"|"_$P(^BCHTSERV(BCHSUB1,0),U,3)
 Q
2 ;activity
 S BCHPROB=$P(^BCHRPROB(BCHX,0),U,4)
 I BCHPROB="" S BCHPROBN="NO SERVICE ENTERED|**"
 I BCHPROB]"" S BCHPROBN=$P(^BCHTSERV(BCHPROB,0),U)_"|"_$P(^BCHTSERV(BCHPROB,0),U,3)
 S BCHSUB1=$P(^BCHRPROB(BCHX,0),U)
 I BCHSUB1="" S BCHSUB1="NO PROBLEM ENTERED|**" Q
 S BCHSUB1=$P(^BCHTPROB(BCHSUB1,0),U)_"|"_$P(^BCHTPROB(BCHSUB1,0),U,2)
 Q
3 ;setting
 S BCHPROB=$P(BCHR0,U,6)
 I BCHPROB="" S BCHPROBN="NO SETTING ENTERED|**" Q
 S BCHPROBN=$P(^BCHTACTL(BCHPROB,0),U)_"|"_$P(^(0),U,5)
 S BCHSUB1=$$VAL^XBDIQ1(90002,BCHR,.03)
 I BCHSUB1="" S BCHSUB1="UNKNOWN"
 Q