BATRPT5 ; IHS/CMI/LAB - master list of all active patients ;
;;1.0;IHS ASTHMA REGISTER;;FEB 19, 2003
;
;
START ;
D EXIT
W:$D(IOF) @IOF
W !!,$$CTR^BATU("PERSISTENT PATIENTS WITH LESS THAN n REFILLS"),!,$$CTR^BATU("OF CONTROLLER MEDS IN A USER DEFINED RANGE"),!
W !,"This report will list all persistent patients who have had N number of",!,"refills of controller medication in a user defined date range.",!,"The patients reviewed are those on the Asthma Register.",!
STAT ;
S BATS=""
S DIR(0)="90181.01,.02",DIR("A")="Review Patients with which Register Status",DIR("B")="A" KILL DA D ^DIR KILL DIR
I $D(DIRUT) D EXIT Q
I Y="" D EXIT Q
S BATS=Y,BATSF=Y(0)
DATES ;
S (BATBD,BATED)=""
BD ;get beginning date
W ! S DIR(0)="D^::EP",DIR("A")="Enter Beginning Date to Search for Controller Meds" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
I $D(DIRUT) G STAT
S BATBD=Y
ED ;get ending date
W ! S DIR(0)="DA^::EP",DIR("A")="Enter Ending Date to search for Controller Meds: " S Y=BATBD D DD^%DT S Y="" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
I $D(DIRUT) G BD
I Y<BATBD W !!,"Ending date cannot be less than beginning date." G DATES
S BATED=Y
S X1=BATBD,X2=-1 D C^%DTC S BATSD=X
NUM ;how many
S BATNR=0
S DIR(0)="N^0:99:",DIR("A")="How many refills" KILL DA D ^DIR KILL DIR
I $D(DIRUT) G DATES
I Y="" G DATES
S BATNR=Y
AGE ;Age Screening
K BATAGE,BATAGET
W ! S DIR(0)="YO",DIR("A")="Would you like to restrict the report by Patient age range",DIR("B")="YES"
S DIR("?")="If you wish to include visits from ALL age ranges, anwser No. If you wish to include visits for only patients within a particular age range, enter Yes."
D ^DIR K DIR
G:$D(DIRUT) DATES
I 'Y G SORT
;
AGER ;Age Screening
W !
S DIR(0)="FO^1:7",DIR("A")="Enter an Age Range (e.g. 5-12,1-1)" D ^DIR
I Y="" W !!,"No age range entered." G AGE
I Y'?1.3N1"-"1.3N W !!,$C(7),$C(7),"Enter a numeric range in the format nnn-nnn. e.g. 0-5, 0-99, 5-20." G AGER
S BATAGET=Y
;
;
SORT ;
S BATSORT=""
S DIR(0)="S^N:Patient Name;D:Patient AGE;V:Patient's Next Asthma Visit Due Date;A:Last Asthma Severity;L:Last Asthma Visit",DIR("A")="Sort List by",DIR("B")="N" KILL DA D ^DIR KILL DIR
I $D(DIRUT) D EXIT Q
S BATSORT=Y
ZIS ;
W ! S DIR(0)="S^P:PRINT Output;B:BROWSE Output on Screen",DIR("A")="Do you wish to",DIR("B")="P" K DA D ^DIR K DIR
I $D(DIRUT) D EXIT Q
S BATOPT=Y
I Y="B" D BROWSE,EXIT Q
S XBRP="PRINT^BATRPT5",XBRC="PROC^BATRPT5",XBRX="EXIT^BATRPT5",XBNS="BAT"
D ^XBDBQUE
D EXIT
Q
BROWSE ;
S XBRP="VIEWR^XBLM(""PRINT^BATRPT5"")"
S XBRC="PROC^BATRPT5",XBRX="EXIT^BATRPT5",XBIOP=0 D ^XBDBQUE
Q
EXIT ;
D EN^XBVK("BAT")
Q
PROC ;
S BATJ=$J,BATH=$H
D XTMP^BATU("BATRPT5","ASTHMA REGISTER DUE LIST")
S BATX=0 F S BATX=$O(^BATREG(BATX)) Q:BATX'=+BATX D
.I $$DOD^AUPNPAT(BATX)]"" Q ;DECEASED
.S BATAGE=$$AGE^AUPNPAT(BATX,BATBD)
.I $D(BATAGET),BATAGE>$P(BATAGET,"-",2) Q
.I $D(BATAGET),BATAGE<$P(BATAGET,"-") Q
.;only 2,3,4
.S X=$$LASTSEVD^BATU(BATX,1,BATED)
.I X=""!(X=1) Q
.S BATCNT=$$GETMED(BATX,BATBD,BATED)
.I BATCNT>BATNR Q ;didn't have 4 or more
.I BATCNT=BATNR Q
.D GETSORT
.S ^XTMP("BATRPT5",BATJ,BATH,"PATIENTS",BATSRTV,BATX)=BATCNT
.Q
Q
GETSORT ;
S BATSRTV=""
I BATSORT="N" S BATSRTV=$P(^DPT(BATX,0),U) Q
I BATSORT="D" S BATSRTV=$$AGE^AUPNPAT(BATX) I BATSRTV="" S BATSRTV="--" Q
I BATSORT="A" S BATSRTV=$$LASTSEVD^BATU(BATX,1,BATED) I BATSRTV="" S BATSRTV="--" Q
I BATSORT="V" S BATSRTV=$P(^BATREG(BATX,0),U,7) I BATSRTV="" S BATSRTV="--"
I BATSORT="L" S BATSRTV=$P(^BATREG(BATX,0),U,6) I BATSRTV="" S BATSRTV="--"
Q
GETMED(P,BDATE,EDATE) ;all reliever meds count up
NEW X,BATL,E,C
K BATL
S X=P_"^ALL MEDS [BAT ASTHMA CONTROLLER MEDS"_";DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE) S E=$$START1^APCLDF(X,"BATL(")
S (X,C)=0 F S X=$O(BATL(X)) Q:X'=+X S C=C+1
K BATL
S X=P_"^ALL MEDS [BAT ASTHMA INHALED STEROIDS"_";DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE) S E=$$START1^APCLDF(X,"BATL(")
S X=0 F S X=$O(BATL(X)) Q:X'=+X S C=C+1
Q C
;
PRINT ;EP
S BATQUIT=0,BATPG=0
D HEADER
I '$D(^XTMP("BATRPT5",BATJ,BATH,"PATIENTS")) W !!,"No patients to list" G EOJ
S BATST="" F S BATST=$O(^XTMP("BATRPT5",BATJ,BATH,"PATIENTS",BATST)) Q:BATST=""!(BATQUIT) D
.S BATX=0 F S BATX=$O(^XTMP("BATRPT5",BATJ,BATH,"PATIENTS",BATST,BATX)) Q:BATX'=+BATX!(BATQUIT) D
..I $Y>(IOSL-4) D HEADER Q:BATQUIT
..S BATCNT=^XTMP("BATRPT5",BATJ,BATH,"PATIENTS",BATST,BATX)
..W !,$E($P(^DPT(BATX,0),U),1,22),?23,$$HRN^AUPNPAT(BATX,DUZ(2)),?30,$$AGE^AUPNPAT(BATX,DT,"R")
..W ?37,$E($$LASTSEVD^BATU(BATX,5,BATED),1,17),?55,$$FMTE^XLFDT($P($P(^BATREG(BATX,0),U,6),".")),?68,$$FMTE^XLFDT($P($P(^BATREG(BATX,0),U,7),"."))
..W !?5,"Number of Controller Refills: ",BATCNT
..Q
.Q
EOJ ;
I BATOPT'="B",$E(IOST)="C",IO=IO(0) S DIR(0)="EO",DIR("A")="End of report. Press ENTER" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
K ^XTMP("BATRPT5",BATJ,BATH),BATX
W:$D(IOF) @IOF
Q
G:'BATPG HEADER1
K DIR I $E(IOST)="C",IO=IO(0),'$D(ZTQUEUED) W ! S DIR(0)="EO" D ^DIR K DIR I Y=0!(Y="^")!($D(DTOUT)) S BATQUIT=1 Q
W:$D(IOF) @IOF S BATPG=BATPG+1
W !,$P(^VA(200,DUZ,0),U,2),?35,$$FMTE^XLFDT(DT),?70,"Page ",BATPG,!
W $$CTR^BATU($$LOC^BATU),!
W !,$$CTR^BATU("*** ASTHMA REGISTER PERSISTENT PATIENTS ***",80),!
W $$CTR^BATU("*** WITH LESS THAN "_BATNR_" REFILLS OF CONTROLLER MEDS ***",80),!
S X="Due Dates: "_$$FMTE^XLFDT(BATBD)_" to "_$$FMTE^XLFDT(BATED) W $$CTR^BATU(X,80),!
S X="Register Status: "_BATSF W $$CTR^BATU(X,80),!
I $D(BATAGET) S X="Ages: "_BATAGET W $$CTR^BATU(X,80),!
W !,"PATIENT NAME",?24,"HRN",?31,"AGE",?37,"LAST SEVERITY",?55,"LAST VISIT",?68,"NEXT DUE"
W !,$TR($J("",80)," ","-")
Q
BATRPT5 ; IHS/CMI/LAB - master list of all active patients ;
+1 ;;1.0;IHS ASTHMA REGISTER;;FEB 19, 2003
+2 ;
+3 ;
START ;
+1 DO EXIT
+2 IF $DATA(IOF)
WRITE @IOF
+3 WRITE !!,$$CTR^BATU("PERSISTENT PATIENTS WITH LESS THAN n REFILLS"),!,$$CTR^BATU("OF CONTROLLER MEDS IN A USER DEFINED RANGE"),!
+4 WRITE !,"This report will list all persistent patients who have had N number of",!,"refills of controller medication in a user defined date range.",!,"The patients reviewed are those on the Asthma Register.",!
STAT ;
+1 SET BATS=""
+2 SET DIR(0)="90181.01,.02"
SET DIR("A")="Review Patients with which Register Status"
SET DIR("B")="A"
KILL DA
DO ^DIR
KILL DIR
+3 IF $DATA(DIRUT)
DO EXIT
QUIT
+4 IF Y=""
DO EXIT
QUIT
+5 SET BATS=Y
SET BATSF=Y(0)
DATES ;
+1 SET (BATBD,BATED)=""
BD ;get beginning date
+1 WRITE !
SET DIR(0)="D^::EP"
SET DIR("A")="Enter Beginning Date to Search for Controller Meds"
DO ^DIR
KILL DIR
IF $DATA(DUOUT)
SET DIRUT=1
+2 IF $DATA(DIRUT)
GOTO STAT
+3 SET BATBD=Y
ED ;get ending date
+1 WRITE !
SET DIR(0)="DA^::EP"
SET DIR("A")="Enter Ending Date to search for Controller Meds: "
SET Y=BATBD
DO DD^%DT
SET Y=""
DO ^DIR
KILL DIR
IF $DATA(DUOUT)
SET DIRUT=1
+2 IF $DATA(DIRUT)
GOTO BD
+3 IF Y<BATBD
WRITE !!,"Ending date cannot be less than beginning date."
GOTO DATES
+4 SET BATED=Y
+5 SET X1=BATBD
SET X2=-1
DO C^%DTC
SET BATSD=X
NUM ;how many
+1 SET BATNR=0
+2 SET DIR(0)="N^0:99:"
SET DIR("A")="How many refills"
KILL DA
DO ^DIR
KILL DIR
+3 IF $DATA(DIRUT)
GOTO DATES
+4 IF Y=""
GOTO DATES
+5 SET BATNR=Y
AGE ;Age Screening
+1 KILL BATAGE,BATAGET
+2 WRITE !
SET DIR(0)="YO"
SET DIR("A")="Would you like to restrict the report by Patient age range"
SET DIR("B")="YES"
+3 SET DIR("?")="If you wish to include visits from ALL age ranges, anwser No. If you wish to include visits for only patients within a particular age range, enter Yes."
+4 DO ^DIR
KILL DIR
+5 IF $DATA(DIRUT)
GOTO DATES
+6 IF 'Y
GOTO SORT
+7 ;
AGER ;Age Screening
+1 WRITE !
+2 SET DIR(0)="FO^1:7"
SET DIR("A")="Enter an Age Range (e.g. 5-12,1-1)"
DO ^DIR
+3 IF Y=""
WRITE !!,"No age range entered."
GOTO AGE
+4 IF Y'?1.3N1"-"1.3N
WRITE !!,$CHAR(7),$CHAR(7),"Enter a numeric range in the format nnn-nnn. e.g. 0-5, 0-99, 5-20."
GOTO AGER
+5 SET BATAGET=Y
+6 ;
+7 ;
SORT ;
+1 SET BATSORT=""
+2 SET DIR(0)="S^N:Patient Name;D:Patient AGE;V:Patient's Next Asthma Visit Due Date;A:Last Asthma Severity;L:Last Asthma Visit"
SET DIR("A")="Sort List by"
SET DIR("B")="N"
KILL DA
DO ^DIR
KILL DIR
+3 IF $DATA(DIRUT)
DO EXIT
QUIT
+4 SET BATSORT=Y
ZIS ;
+1 WRITE !
SET DIR(0)="S^P:PRINT Output;B:BROWSE Output on Screen"
SET DIR("A")="Do you wish to"
SET DIR("B")="P"
KILL DA
DO ^DIR
KILL DIR
+2 IF $DATA(DIRUT)
DO EXIT
QUIT
+3 SET BATOPT=Y
+4 IF Y="B"
DO BROWSE
DO EXIT
QUIT
+5 SET XBRP="PRINT^BATRPT5"
SET XBRC="PROC^BATRPT5"
SET XBRX="EXIT^BATRPT5"
SET XBNS="BAT"
+6 DO ^XBDBQUE
+7 DO EXIT
+8 QUIT
BROWSE ;
+1 SET XBRP="VIEWR^XBLM(""PRINT^BATRPT5"")"
+2 SET XBRC="PROC^BATRPT5"
SET XBRX="EXIT^BATRPT5"
SET XBIOP=0
DO ^XBDBQUE
+3 QUIT
EXIT ;
+1 DO EN^XBVK("BAT")
+2 QUIT
PROC ;
+1 SET BATJ=$JOB
SET BATH=$HOROLOG
+2 DO XTMP^BATU("BATRPT5","ASTHMA REGISTER DUE LIST")
+3 SET BATX=0
FOR
SET BATX=$ORDER(^BATREG(BATX))
IF BATX'=+BATX
QUIT
Begin DoDot:1
+4 ;DECEASED
IF $$DOD^AUPNPAT(BATX)]""
QUIT
+5 SET BATAGE=$$AGE^AUPNPAT(BATX,BATBD)
+6 IF $DATA(BATAGET)
IF BATAGE>$PIECE(BATAGET,"-",2)
QUIT
+7 IF $DATA(BATAGET)
IF BATAGE<$PIECE(BATAGET,"-")
QUIT
+8 ;only 2,3,4
+9 SET X=$$LASTSEVD^BATU(BATX,1,BATED)
+10 IF X=""!(X=1)
QUIT
+11 SET BATCNT=$$GETMED(BATX,BATBD,BATED)
+12 ;didn't have 4 or more
IF BATCNT>BATNR
QUIT
+13 IF BATCNT=BATNR
QUIT
+14 DO GETSORT
+15 SET ^XTMP("BATRPT5",BATJ,BATH,"PATIENTS",BATSRTV,BATX)=BATCNT
+16 QUIT
End DoDot:1
+17 QUIT
GETSORT ;
+1 SET BATSRTV=""
+2 IF BATSORT="N"
SET BATSRTV=$PIECE(^DPT(BATX,0),U)
QUIT
+3 IF BATSORT="D"
SET BATSRTV=$$AGE^AUPNPAT(BATX)
IF BATSRTV=""
SET BATSRTV="--"
QUIT
+4 IF BATSORT="A"
SET BATSRTV=$$LASTSEVD^BATU(BATX,1,BATED)
IF BATSRTV=""
SET BATSRTV="--"
QUIT
+5 IF BATSORT="V"
SET BATSRTV=$PIECE(^BATREG(BATX,0),U,7)
IF BATSRTV=""
SET BATSRTV="--"
+6 IF BATSORT="L"
SET BATSRTV=$PIECE(^BATREG(BATX,0),U,6)
IF BATSRTV=""
SET BATSRTV="--"
+7 QUIT
GETMED(P,BDATE,EDATE) ;all reliever meds count up
+1 NEW X,BATL,E,C
+2 KILL BATL
+3 SET X=P_"^ALL MEDS [BAT ASTHMA CONTROLLER MEDS"_";DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE)
SET E=$$START1^APCLDF(X,"BATL(")
+4 SET (X,C)=0
FOR
SET X=$ORDER(BATL(X))
IF X'=+X
QUIT
SET C=C+1
+5 KILL BATL
+6 SET X=P_"^ALL MEDS [BAT ASTHMA INHALED STEROIDS"_";DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE)
SET E=$$START1^APCLDF(X,"BATL(")
+7 SET X=0
FOR
SET X=$ORDER(BATL(X))
IF X'=+X
QUIT
SET C=C+1
+8 QUIT C
+9 ;
PRINT ;EP
+1 SET BATQUIT=0
SET BATPG=0
+2 DO HEADER
+3 IF '$DATA(^XTMP("BATRPT5",BATJ,BATH,"PATIENTS"))
WRITE !!,"No patients to list"
GOTO EOJ
+4 SET BATST=""
FOR
SET BATST=$ORDER(^XTMP("BATRPT5",BATJ,BATH,"PATIENTS",BATST))
IF BATST=""!(BATQUIT)
QUIT
Begin DoDot:1
+5 SET BATX=0
FOR
SET BATX=$ORDER(^XTMP("BATRPT5",BATJ,BATH,"PATIENTS",BATST,BATX))
IF BATX'=+BATX!(BATQUIT)
QUIT
Begin DoDot:2
+6 IF $Y>(IOSL-4)
DO HEADER
IF BATQUIT
QUIT
+7 SET BATCNT=^XTMP("BATRPT5",BATJ,BATH,"PATIENTS",BATST,BATX)
+8 WRITE !,$EXTRACT($PIECE(^DPT(BATX,0),U),1,22),?23,$$HRN^AUPNPAT(BATX,DUZ(2)),?30,$$AGE^AUPNPAT(BATX,DT,"R")
+9 WRITE ?37,$EXTRACT($$LASTSEVD^BATU(BATX,5,BATED),1,17),?55,$$FMTE^XLFDT($PIECE($PIECE(^BATREG(BATX,0),U,6),".")),?68,$$FMTE^XLFDT($PIECE($PIECE(^BATREG(BATX,0),U,7),"."))
+10 WRITE !?5,"Number of Controller Refills: ",BATCNT
+11 QUIT
End DoDot:2
+12 QUIT
End DoDot:1
EOJ ;
+1 IF BATOPT'="B"
IF $EXTRACT(IOST)="C"
IF IO=IO(0)
SET DIR(0)="EO"
SET DIR("A")="End of report. Press ENTER"
DO ^DIR
KILL DIR
IF $DATA(DUOUT)
SET DIRUT=1
+2 KILL ^XTMP("BATRPT5",BATJ,BATH),BATX
+3 IF $DATA(IOF)
WRITE @IOF
+4 QUIT
+1 IF 'BATPG
GOTO HEADER1
+2 KILL DIR
IF $EXTRACT(IOST)="C"
IF IO=IO(0)
IF '$DATA(ZTQUEUED)
WRITE !
SET DIR(0)="EO"
DO ^DIR
KILL DIR
IF Y=0!(Y="^")!($DATA(DTOUT))
SET BATQUIT=1
QUIT
+1 IF $DATA(IOF)
WRITE @IOF
SET BATPG=BATPG+1
+2 WRITE !,$PIECE(^VA(200,DUZ,0),U,2),?35,$$FMTE^XLFDT(DT),?70,"Page ",BATPG,!
+3 WRITE $$CTR^BATU($$LOC^BATU),!
+4 WRITE !,$$CTR^BATU("*** ASTHMA REGISTER PERSISTENT PATIENTS ***",80),!
+5 WRITE $$CTR^BATU("*** WITH LESS THAN "_BATNR_" REFILLS OF CONTROLLER MEDS ***",80),!
+6 SET X="Due Dates: "_$$FMTE^XLFDT(BATBD)_" to "_$$FMTE^XLFDT(BATED)
WRITE $$CTR^BATU(X,80),!
+7 SET X="Register Status: "_BATSF
WRITE $$CTR^BATU(X,80),!
+8 IF $DATA(BATAGET)
SET X="Ages: "_BATAGET
WRITE $$CTR^BATU(X,80),!
+9 WRITE !,"PATIENT NAME",?24,"HRN",?31,"AGE",?37,"LAST SEVERITY",?55,"LAST VISIT",?68,"NEXT DUE"
+10 WRITE !,$TRANSLATE($JUSTIFY("",80)," ","-")
+11 QUIT