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

BCHRP4.m

Go to the documentation of this file.
  1. BCHRP4 ; IHS/CMI/LAB - All visit report driver 26 Apr 2007 10:51 AM ;
  1. ;;2.0;IHS RPMS CHR SYSTEM;;OCT 23, 2012;Build 27
  1. ;
  1. START ;
  1. I '$G(DUZ(2)) W $C(7),$C(7),!!,"SITE NOT SET IN DUZ(2) - NOTIFY SITE MANAGER!!",!! K BCHSITE Q
  1. S BCHJOB=$J,BCHBTH=$H
  1. D INFORM
  1. GETDATES ;
  1. BD ;get beginning date
  1. W ! S DIR(0)="D^:DT:EP",DIR("A")="Enter beginning Date of Service" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
  1. I $D(DIRUT) G XIT
  1. S BCHBD=Y
  1. ED ;get ending date
  1. W ! S DIR(0)="D^"_BCHBD_":DT:EP",DIR("A")="Enter ending Date of Service" S Y=BCHBD D DD^%DT S DIR("B")=Y,Y="" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
  1. I $D(DIRUT) G BD
  1. S BCHED=Y
  1. S X1=BCHBD,X2=-1 D C^%DTC S BCHSD=X
  1. ;
  1. PROG ;IHS/CMI/LAB - added program screen
  1. S BCHPRG=""
  1. 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
  1. G:$D(DIRUT) BD
  1. I Y=1 S BCHPRG="" G REG
  1. PROG1 ;enter program
  1. 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
  1. S BCHPRG=+Y
  1. REG ;
  1. S BCHREG="",BCHREGN=""
  1. 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
  1. I $D(DIRUT) G PROG
  1. S BCHREG=Y,BCHREGN=Y(0)
  1. ZIS ;CALL TO XBDBQUE
  1. S XBRP="PRINT^BCHRP4",XBRC="PROC^BCHRP4",XBRX="XIT^BCHRP4",XBNS="BCH"
  1. D ^XBDBQUE
  1. D XIT
  1. Q
  1. ERR W $C(7),$C(7),!,"Must be a valid date and be Today or earlier. Time not allowed!" Q
  1. XIT ;
  1. D EN^XBVK("BCH")
  1. K ^TMP($J)
  1. Q
  1. ;
  1. INFORM ;
  1. W:$D(IOF) @IOF
  1. W !,"****** REPORT OF # OF CHR PCCs/PATIENTS BY TRIBE ******",!
  1. W !,"This report will tally records and patients seen by Tribe",!
  1. Q
  1. ;
  1. ;
  1. PROC ;EP - called from xbdbque
  1. VD ; Run by visit date
  1. S X1=BCHBD,X2=-1 D C^%DTC S BCHSD=X
  1. K BCHTOT K ^TMP($J)
  1. S (BCHTOTR,BCHTOTP)=0
  1. S BCHODAT=BCHSD_".9999" F S BCHODAT=$O(^BCHR("B",BCHODAT)) Q:BCHODAT=""!((BCHODAT\1)>BCHED) D V1
  1. Q
  1. ;
  1. V1 ;
  1. S BCHR="" 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=^BCHR(BCHR,0),DFN=$P(BCHR0,U,4) D PROC1
  1. Q
  1. PROC1 ;
  1. S BCHPAT=$P(BCHR0,U,4)
  1. S BCHNRPAT=$P($G(^BCHR(BCHR,11)),U,12)
  1. I 'BCHPAT,'BCHNRPAT Q ;no patient
  1. I BCHREG="R",BCHPAT="" Q
  1. I BCHREG="N",BCHNRPAT="" Q
  1. I BCHPAT,BCHNRPAT S BCHNRPAT=""
  1. I BCHPAT Q:'$D(^DPT(BCHPAT,0))
  1. S BCHPROG=$P(BCHR0,U,2)
  1. I BCHPRG,BCHPRG'=BCHPROG Q ;not correct program
  1. I BCHPAT S T=$$VAL^XBDIQ1(9000001,BCHPAT,1108)
  1. I BCHNRPAT S T=$$VAL^XBDIQ1(90002.11,BCHNRPAT,.05)
  1. I T="" S T="UNKNOWN TRIBE"
  1. S $P(BCHTOT(T),U,1)=$P($G(BCHTOT(T)),U,1)+1,BCHTOTR=BCHTOTR+1
  1. I BCHPAT D
  1. .I $D(^TMP($J,"DFN",DFN)) Q ;already counted this patient
  1. .S ^TMP($J,"DFN",DFN)="" S $P(BCHTOT(T),U,2)=$P($G(BCHTOT(T)),U,2)+1,BCHTOTP=BCHTOTP+1
  1. I BCHNRPAT D
  1. .Q:$D(^TMP($J,"NRDFN",BCHNRPAT))
  1. .S ^TMP($J,"NRDFN",BCHNRPAT)="" S $P(BCHTOT(T),U,2)=$P($G(BCHTOT(T)),U,2)+1,BCHTOTP=BCHTOTP+1
  1. Q
  1. PRINT ;EP
  1. S BCHPG=0 S BCHQUIT=0
  1. I '$D(BCHTOT) D HEAD W !!,"NO DATA TO REPORT",!! Q
  1. D HEAD
  1. S BCHT="" F S BCHT=$O(BCHTOT(BCHT)) Q:BCHT=""!(BCHQUIT) D
  1. .I $Y>(IOSL-4) D HEAD Q:BCHQUIT
  1. .W !?3,BCHT,?50,$$C($P(BCHTOT(BCHT),U,1),0,8),?65,$$C($P(BCHTOT(BCHT),U,2),0,8)
  1. .Q
  1. I $Y>(IOSL-3) D HEAD
  1. I BCHQUIT G DONE
  1. W !!?3,"ALL TRIBES/TOTAL",?50,$$C(BCHTOTR,0,8),?65,$$C(BCHTOTP,0,8)
  1. DONE ;
  1. K BCHET
  1. D DONE^BCHUTIL1
  1. Q
  1. C(X,X2,X3) ;
  1. D COMMA^%DTC
  1. Q $$STRIP^XLFSTR(X," ")
  1. I 'BCHPG G HEAD1
  1. I $E(IOST)="C",IO=IO(0) W ! S DIR(0)="EO" D ^DIR K DIR I Y=0!(Y="^")!($D(DTOUT)) S BCHQUIT=1 Q
  1. HEAD1 ; if terminal
  1. W:$D(IOF) @IOF
  1. HEAD2 ; if printer
  1. S BCHPG=BCHPG+1
  1. W !?13,"********** CONFIDENTIAL PATIENT INFORMATION **********"
  1. W !,$P(^VA(200,DUZ,0),U,2),?33,$$FMTE^XLFDT(DT),?70,"Page ",BCHPG,!
  1. W $$CTR^BCHRLU($$LOC^BCHRLU),!
  1. S X="TALLY OF CHR PCCs AND PATIENTS BY TRIBE" W $$CTR^BCHRLU(X,80),!
  1. S BCHPROGN=$S(BCHPRG:$P(^BCHTPROG(BCHPRG,0),U)_" ("_$P(^(0),U,5)_")",1:"ALL"),X=$L(BCHPROGN)+10
  1. W ?((80-X)/2),"PROGRAM: ",BCHPROGN,!
  1. S X=$L("PATIENTS: "_BCHREGN)
  1. W ?((80-X)/2),"PATIENTS: ",BCHREGN,!
  1. W ?17,"REPORT DATES: ",$$FMTE^XLFDT(BCHBD)," TO ",$$FMTE^XLFDT(BCHED),!
  1. W !?50,"# CHR PCCs",?65,"# PATIENTS",!
  1. W !,$TR($J(" ",80)," ","-")
  1. Q