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

BCHRC9.m

Go to the documentation of this file.
BCHRC9 ; IHS/CMI/LAB - CHR Report 2 ; 
 ;;2.0;IHS RPMS CHR SYSTEM;;OCT 23, 2012;Build 27
 ;IHS/CMI/LAB - PATCH 6 fixed logic on total services
 ;
 I '$G(DUZ(2)) W $C(7),$C(7),!!,"SITE NOT SET IN DUZ(2) - NOTIFY SITE MANAGER!!",!! Q
 S BCHJOB=$J,BCHBTH=$H
 D INFORM
GETDATES ;
BD ;get beginning date
 W ! S DIR(0)="D^:DT:EP",DIR("A")="Enter BEGINNING Date of Service for Report" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
 I $D(DIRUT) G XIT
 S BCHBD=Y
ED ;get ending date
 W ! S DIR(0)="D^"_BCHBD_":DT:EP",DIR("A")="Enter ENDING Date of Service for Report" S Y=BCHBD D DD^%DT S DIR("B")=Y,Y="" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
 I $D(DIRUT) G BD
 S BCHED=Y
 S X1=BCHBD,X2=-1 D C^%DTC S BCHSD=X
 ;
PROG ;IHS/CMI/LAB - added program screen
 S BCHPRG=""
 S DIR(0)="Y",DIR("A")="Include data from ALL CHR Programs",DIR("B")="N",DIR("?")="If you wish to include visits from ALL programs answer Yes.  If you wish to tabulate for only one program enter NO." D ^DIR K DIR
 G:$D(DIRUT) BD
 I Y=1 S BCHPRG="" G REG
PROG1 ;enter program
 K X,DIC,DA,DD,DR,Y S DIC("A")="Which CHR Program: ",DIC="^BCHTPROG(",DIC(0)="AEMQ" D ^DIC K DIC,DA G:Y<0 PROG
 S BCHPRG=+Y
REG ;
 S BCHREG="",BCHREGN=""
 S DIR(0)="S^R:Registered Patients;N:Non-Registered Patients;B:Both Registered and Non-Registered Patients",DIR("A")="Include which Patients",DIR("B")="B" KILL DA D ^DIR KILL DIR
 I $D(DIRUT) G PROG
 S BCHREG=Y,BCHREGN=Y(0)
ZIS ;CALL TO XBDBQUE
 S XBRP="^BCHRC9P",XBRC="PROC^BCHRC9",XBRX="XIT^BCHRC9",XBNS="BCH"
 D ^XBDBQUE
 D XIT
 Q
ERR W $C(7),$C(7),!,"Must be a valid date and be Today or earlier. Time not allowed!" Q
XIT ;
 K V,BCHSD,BCHBD,BCHBDD,BCHED,BCHEDD,BCHODAT,BCHR,BCHR0,X,P,S,N,BCHQUIT,BCHBTH,BCHDT,BCHNAME,BCHPRG,BCHBT,BCHJOB
 K X,Y
 Q
 ;
INFORM ;
 W:$D(IOF) @IOF
 W !?20,"**********  CHR REPORT NO. 9  **********"
 W !!?28,"DATA SUMMARY BY PROVIDER",!!,"You must enter the time frame for the report.",!
 Q
 ;
 ;
PROC ;EP - PROCESS REFERRAL REPORT
 D XTMP^BCHUTIL("BCHRC9","CHR CHR REPORT")
 S (BCHBT,BCHBTH)=$H,BCHJOB=$J
 S ^XTMP("BCHRC9",BCHJOB,BCHBT,"TOTAL")=0
 D D,EOJ
 Q
 ;
EOJ ;
 S BCHET=$H
 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
 ;
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 PROCESS
 Q
PROCESS ;
 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 C=$P(BCHR0,U,3),BCHNAME=$P(^VA(200,C,0),U)
 I '$D(^XTMP("BCHRC9",BCHJOB,BCHBT,"PROV",BCHNAME)) S ^XTMP("BCHRC9",BCHJOB,BCHBT,"PROV",BCHNAME)=0
 S (X,C)=0 F  S X=$O(^BCHRPROB("AD",BCHR,X)) Q:X'=+X  S C=C+1 D
 .Q:$P(^BCHRPROB(X,0),U,4)=""  ;no service entered
 .S $P(^XTMP("BCHRC9",BCHJOB,BCHBT,"PROV",BCHNAME),U)=$P(^XTMP("BCHRC9",BCHJOB,BCHBT,"PROV",BCHNAME),U)+1,$P(^XTMP("BCHRC9",BCHJOB,BCHBT,"TOTAL"),U)=$P(^XTMP("BCHRC9",BCHJOB,BCHBT,"TOTAL"),U)+1
 .S S=$P(^BCHRPROB(X,0),U,4),Y=$P(^BCHTSERV(S,0),U,3)
 .I Y="LT"!(Y="AM")!(Y="OT") D
 ..S $P(^XTMP("BCHRC9",BCHJOB,BCHBT,"PROV",BCHNAME),U,5)=$P(^XTMP("BCHRC9",BCHJOB,BCHBT,"PROV",BCHNAME),U,5)+$P(^BCHRPROB(X,0),U,5),$P(^XTMP("BCHRC9",BCHJOB,BCHBT,"TOTAL"),U,5)=$P(^XTMP("BCHRC9",BCHJOB,BCHBT,"TOTAL"),U,5)+$P(^BCHRPROB(X,0),U,5)
 ..;IHS/CMI/LAB - modified line below patch 6
 ..I C=1 S $P(^XTMP("BCHRC9",BCHJOB,BCHBT,"PROV",BCHNAME),U,5)=$P(^XTMP("BCHRC9",BCHJOB,BCHBT,"PROV",BCHNAME),U,5)+$P(BCHR0,U,11),$P(^XTMP("BCHRC9",BCHJOB,BCHBT,"TOTAL"),U,5)=$P(^XTMP("BCHRC9",BCHJOB,BCHBT,"TOTAL"),U,5)+$P(BCHR0,U,11)
 .E  D
 ..S $P(^XTMP("BCHRC9",BCHJOB,BCHBT,"PROV",BCHNAME),U,4)=$P(^XTMP("BCHRC9",BCHJOB,BCHBT,"PROV",BCHNAME),U,4)+$P(^BCHRPROB(X,0),U,5),$P(^XTMP("BCHRC9",BCHJOB,BCHBT,"TOTAL"),U,4)=$P(^XTMP("BCHRC9",BCHJOB,BCHBT,"TOTAL"),U,4)+$P(^BCHRPROB(X,0),U,5)
 ..;IHS/CMI/LAB - patch 6 modified line below
 ..I C=1 S $P(^XTMP("BCHRC9",BCHJOB,BCHBT,"PROV",BCHNAME),U,4)=$P(^XTMP("BCHRC9",BCHJOB,BCHBT,"PROV",BCHNAME),U,4)+$P(BCHR0,U,11),$P(^XTMP("BCHRC9",BCHJOB,BCHBT,"TOTAL"),U,4)=$P(^XTMP("BCHRC9",BCHJOB,BCHBT,"TOTAL"),U,4)+$P(BCHR0,U,11)
 .Q
 S $P(^XTMP("BCHRC9",BCHJOB,BCHBT,"PROV",BCHNAME),U,2)=$P(^XTMP("BCHRC9",BCHJOB,BCHBT,"PROV",BCHNAME),U,2)+$P(BCHR0,U,12)
 S $P(^XTMP("BCHRC9",BCHJOB,BCHBT,"TOTAL"),U,2)=$P(^XTMP("BCHRC9",BCHJOB,BCHBT,"TOTAL"),U,2)+$P(BCHR0,U,12)
 S N=$P(BCHR0,U,27)+$P(BCHR0,U,11)
 S $P(^XTMP("BCHRC9",BCHJOB,BCHBT,"PROV",BCHNAME),U,3)=$P(^XTMP("BCHRC9",BCHJOB,BCHBT,"PROV",BCHNAME),U,3)+N,$P(^XTMP("BCHRC9",BCHJOB,BCHBT,"TOTAL"),U,3)=$P(^XTMP("BCHRC9",BCHJOB,BCHBT,"TOTAL"),U,3)+N
 Q