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

BMCRR16.m

Go to the documentation of this file.
BMCRR16 ; IHS/PHXAO/TMJ - IN HOUSE REFERRALS BY PROVIDER ;   
 ;;4.0;REFERRED CARE INFO SYSTEM;;JAN 09, 2006
 ;4.0 IHS/OIT/FCJ ADDED BROWSE FUNCTION AND TOTALS
 ;
START ;
 S BMCJOB=$J,BMCBTH=$H
 W !!,"This report will tally all in-house referrals by clinic referred to.",!
 W "Report will include both Primary and Secondary Referrals.",!!
D ;DATE RANGE
BD ;get beginning date
 W ! S DIR(0)="D^::EP",DIR("A")="Enter beginning Referral Date" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
 I $D(DIRUT) G XIT
 S BMCBD=Y
ED ;get ending date
 W ! S DIR(0)="D^"_BMCBD_"::EP",DIR("A")="Enter ending Referral Date"  D ^DIR K DIR S:$D(DUOUT) DIRUT=1
 I $D(DIRUT) G BD
 S BMCED=Y
 S X1=BMCBD,X2=-1 D C^%DTC S BMCSD=X
 ;
CLIN ;
 S BMCCLIN="" S DIR(0)="S^A:ALL Clinics;O:ONE Clinic",DIR("A")="Report should tally referrals for ",DIR("B")="A" K DA D ^DIR K DIR
 G:$D(DIRUT) D
 I Y="O" D GETCLIN G:BMCCLIN="" CLIN
ZIS ;call to XBDBQUE
 D ZIS^BMCRUTL
 I $D(DIRUT) S BMCQUIT="" G XIT
 G:$G(BMCQUIT) XIT
 I $G(BMCOPT)="B" D BROWSE,XIT Q
 S XBRP="PRINT^BMCRR16",XBRC="PROC^BMCRR16",XBRX="XIT^BMCRR16",XBNS="BMC"
 D ^XBDBQUE
 D XIT
 Q
BROWSE ;
 S XBRP="VIEWR^XBLM(""PRINT^BMCRR16"")"
 S XBRC="PROC^BMCRR16",XBRX="XIT^BMCRR16",XBIOP=0,XBNS="BMC" D ^XBDBQUE
 Q
XIT ;EP
 K BMCPROV,BMCREF,BMCODAT,BMCBD,BMCED,BMCSD,BMCQUIT,BMCPG,BMCCLIN,BMCBT,BMCBTH,BMCET,BMCJOB,BMCRREC,BMCSTOT,D,DFN,DIC,DIRUT,DTOUT,DUOUT,P,X1,X2
 K BMCSRTOT,BMCPRTOT
 D KILL^AUPNPAT
 Q
GETCLIN ;
 S DIC="^DIC(40.7,",DIC(0)="AEMQ" D ^DIC K DIC
 Q:Y=-1
 S BMCCLIN=+Y
 Q
PROC ;EP called from xbdbque
 S BMCBT=$H
 S BMCODAT=$O(^BMCREF("B",BMCSD)) I BMCODAT="" S BMCET=$H Q
 S BMCODAT=BMCSD_".9999" F  S BMCODAT=$O(^BMCREF("B",BMCODAT)) Q:BMCODAT=""!((BMCODAT\1)>BMCED)  D R1
END ;
 S BMCET=$H
 Q
R1 ;
 S BMCREF="" F  S BMCREF=$O(^BMCREF("B",BMCODAT,BMCREF)) Q:BMCREF'=+BMCREF  I $P(^BMCREF(BMCREF,0),U,4)="N" S BMCRREC=^BMCREF(BMCREF,0),DFN=$P(BMCRREC,U,3) D PROCR
 Q
PROCR ;
 I BMCCLIN,$P(BMCRREC,U,23)'=BMCCLIN Q
 S C=$P(BMCRREC,U,23),P=$P(BMCRREC,U,6)
 S C=$S(C:$P(^DIC(40.7,C,0),U),1:"<UNKNOWN>")
 S P=$S(P:$P(^VA(200,P,0),U),1:"<UNKNOWN>")
 S R=$S($P($G(^BMCREF(BMCREF,1)),U)'="":"S",1:"P") ;IHS/OIT/FCJ
 S ^(P)=$S($D(^XTMP("BMCRR16",BMCJOB,BMCBTH,"CLIN",C,P)):^(P)+1,1:1)
 S ^(R)=$S($D(^XTMP("BMCRR16",BMCJOB,BMCBTH,"CLIN",C,0,R)):^(R)+1,1:1) ;IHS/OIT/FCJ
 Q
PRINT ;EP called from xbdbque
 S BMCPG=0 D @("HEAD"_(2-($E(IOST,1,2)="C-")))
 S BMCQUIT=0
 I '$D(^XTMP("BMCRR16",BMCJOB,BMCBTH)) W !!,"No IN-HOUSE REFERRALS",! G DONE
 S BMCCLIN="" F  S BMCCLIN=$O(^XTMP("BMCRR16",BMCJOB,BMCBTH,"CLIN",BMCCLIN)) Q:BMCCLIN=""!(BMCQUIT)  D PROVIDER
DONE ;
 K ^XTMP("BMCRR16",BMCJOB,BMCBTH)
 D DONE^BMCRLP2
 Q
PROVIDER ;
 I $Y>(IOSL-5) D HEAD Q:BMCQUIT
 W !!,BMCCLIN S (BMCSTOT,BMCPRTOT,BMCSRTOT)=0
 S BMCPROV=0 F  S BMCPROV=$O(^XTMP("BMCRR16",BMCJOB,BMCBTH,"CLIN",BMCCLIN,BMCPROV)) Q:BMCPROV=""!(BMCQUIT)  D
 .I $Y>(IOSL-5) D HEAD Q:BMCQUIT
 .W !?20,BMCPROV,?50,$J(^XTMP("BMCRR16",BMCJOB,BMCBTH,"CLIN",BMCCLIN,BMCPROV),5) S BMCSTOT=BMCSTOT+^(BMCPROV)
 S BMCSRTOT=$G(^XTMP("BMCRR16",BMCJOB,BMCBTH,"CLIN",BMCCLIN,0,"S")) ;IHS/OIT/FCJ
 S BMCPRTOT=$G(^XTMP("BMCRR16",BMCJOB,BMCBTH,"CLIN",BMCCLIN,0,"P")) ;IHS/OIT/FCJ
 I $Y>(IOSL-5) D HEAD Q:BMCQUIT
 W !!,"Total Secondary Referrals = ",$S(BMCSRTOT="":0,1:BMCSRTOT) ;IHS/OIT/FCJ
 W !,"Total Primary Referrals = ",$S(BMCPRTOT="":0,1:BMCPRTOT) ;IHS/OIT/FCJ
 W !,"Total for ",BMCCLIN,?50,$J(BMCSTOT,5),!
 Q
 I $E(IOST)="C",IO=IO(0) W ! S DIR(0)="EO" D ^DIR K DIR I Y=0!(Y="^")!($D(DTOUT)) S BMCQUIT=1 Q
HEAD1 ;
 W:$D(IOF) @IOF
HEAD2 ;
 S BMCPG=BMCPG+1
 W !?55,$$FMTE^XLFDT(DT),?72,"Page ",BMCPG,!
 W ?20,"IN-HOUSE REFERRALS BY CLINIC",!
 W ?14,"REFERRAL DATE RANGE: ",$$FMTE^XLFDT(BMCBD)," to ",$$FMTE^XLFDT(BMCED)
 W !!,"CLINIC REFERRED TO",?20,"PROVIDER REFERRED FROM",?50,"NUMBER"
 W !,$TR($J(" ",80)," ","-")
 Q