AMHRPT0 ; IHS/CMI/LAB - MENUS FOR REPORT DRIVER ;
;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
;
K AMHDISP,AMHSEL,AMHHIGH
W:$D(IOF) @IOF
S AMHLHDR="PRINT DATA ITEMS Menu" W ?((80-$L(AMHLHDR))/2),AMHLHDR,!
W "The following data items can be printed. You can use up to 132 characters.",!,"Choose the data items in the order you want them printed.",!
W ?15,"Total Report width (including column margins - 2 spaces): ",AMHTCW
S AMHHIGH=0,X=0 F S X=$O(^AMHSORT("C",X)) Q:X'=+X S Y=$O(^AMHSORT("C",X,"")) I $P(^AMHSORT(Y,0),U,5)["P",$P(^(0),U,11)["V" S AMHHIGH=AMHHIGH+1,AMHSEL(AMHHIGH)=Y
S AMHCUT=((AMHHIGH/2)+.5)\1
S I=0,J=1 F S I=$O(AMHSEL(I)) Q:I'=+I I '$D(AMHDISP(I)) D
.W !?2,I,") ",$P(^AMHSORT(AMHSEL(I),0),U) S AMHDISP(I)="",J=I+AMHCUT I $D(AMHSEL(J)),'$D(AMHDISP(J)) W ?40,J,") ",$P(^AMHSORT(AMHSEL(J),0),U) S AMHDISP(J)=""
W !?7,"<Enter a list or a range. E.g. 1-4,5,20 or 10,12,20,30>"
W !?7,"<<PRESS ENTER to conclude selections or '^' to exit>>"
Q
K AMHDISP,AMHSEL,AMHHIGH
I $Y>(IOSL-4) W:$D(IOF) @IOF
W !,"The records displayed can be selected based on any of the following criteria:",!
S AMHHIGH=0,X=0 F S X=$O(^AMHSORT(AMHXREF,X)) Q:X'=+X S Y=$O(^AMHSORT(AMHXREF,X,"")) I $P(^AMHSORT(Y,0),U,5)["S",$P(^(0),U,11)[AMHPTVS S AMHHIGH=AMHHIGH+1,AMHSEL(AMHHIGH)=Y
S AMHCUT=((AMHHIGH/3)+1)\1
S I=0,J=1,K=1 F S I=$O(AMHSEL(I)) Q:I'=+I!($D(AMHDISP(I))) D
.W !,I,") ",$E($P(^AMHSORT(AMHSEL(I),0),U),1,23) S AMHDISP(I)=""
.S J=I+AMHCUT I $D(AMHSEL(J)),'$D(AMHDISP(J)) W ?27,J,") ",$E($P(^AMHSORT(AMHSEL(J),0),U),1,22) S AMHDISP(J)=""
.S K=J+AMHCUT I $D(AMHSEL(K)),'$D(AMHDISP(K)) W ?53,K,") ",$E($P(^AMHSORT(AMHSEL(K),0),U),1,22) S AMHDISP(K)=""
W !?9,"<Enter a list or a range. E.g. 1-4,5,20 or 10,12,20,30>"
W !?9,"<<PRESS ENTER to conclude selections or bypass screens>>"
Q
K AMHDISP,AMHSEL,AMHHIGH
I $Y>(IOSL-4) W:$D(IOF) @IOF
W !!,"The records displayed can be sorted by any one of the following:",!
S AMHHIGH=0,X=0 F S X=$O(^AMHSORT("C",X)) Q:X'=+X S Y=$O(^AMHSORT("C",X,"")) I $P(^AMHSORT(Y,0),U,5)["R",$P(^(0),U,11)["V" S AMHHIGH=AMHHIGH+1,AMHSEL(AMHHIGH)=Y
S AMHCUT=((AMHHIGH/2)+.5)\1
S I=0,J=1,K=1 F S I=$O(AMHSEL(I)) Q:I'=+I I '$D(AMHDISP(I)) W !?5,I,") ",$P(^AMHSORT(AMHSEL(I),0),U) S AMHDISP(I)="",J=I+AMHCUT I $D(AMHSEL(J)),'$D(AMHDISP(J)) W ?40,J,") ",$P(^AMHSORT(AMHSEL(J),0),U) S AMHDISP(J)=""
W !!,"<<If you don't select a sort criteria the report will be sorted by Visit date>>"
Q
;
N ;EP
K ^AMHTRPT(AMHRPT,11,AMHCRIT),^AMHTRPT(AMHRPT,11,"B",AMHCRIT)
S DIR(0)="FO^1:7",DIR("A")="Enter a Range for "_$P(^AMHSORT(AMHCRIT,0),U)_", (e.g. 5-12)" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
I Y="" W !!,"No number range entered. All numbers will be included." Q
I Y'?.N1"-".N W !!,$C(7),$C(7),"Enter an number range in the format nnn-nnn. E.g. 0-5, 0-99, 5-20." G N
S ^AMHTRPT(AMHRPT,11,AMHCRIT,0)=AMHCRIT,^AMHTRPT(AMHRPT,11,"B",AMHCRIT,AMHCRIT)=""
S AMHCNT=0,^AMHTRPT(AMHRPT,11,AMHCRIT,11,AMHCNT,0)="^9002013.8110101A^1^1" F X=$P(Y,"-"):1:$P(Y,"-",2) S AMHCNT=AMHCNT+1,^AMHTRPT(AMHRPT,11,AMHCRIT,11,1,0)=X,^AMHTRPT(AMHRPT,11,AMHCRIT,11,"B",X,AMHCNT)=""
Q
Y ;EP
S DIR(0)="S^1:"_AMHTEXT_";0:NO "_AMHTEXT_"",DIR("A")="Choose one",DIR("B")="1" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
Q:$D(DIRUT)
Q:Y=""
S ^AMHTRPT(AMHRPT,11,AMHCRIT,0)=AMHCRIT,^AMHTRPT(AMHRPT,11,"B",AMHCRIT,AMHCRIT)=""
S ^AMHTRPT(AMHRPT,11,AMHCRIT,11,1,0)=Y,^AMHTRPT(AMHRPT,11,AMHCRIT,11,"B",Y,1)="",^AMHTRPT(AMHRPT,11,AMHCRIT,11,0)="^9001003.8110101A^"_1_"^"_1
Q
AMHRPT0 ; IHS/CMI/LAB - MENUS FOR REPORT DRIVER ;
+1 ;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
+2 ;
+1 KILL AMHDISP,AMHSEL,AMHHIGH
+2 IF $DATA(IOF)
WRITE @IOF
+3 SET AMHLHDR="PRINT DATA ITEMS Menu"
WRITE ?((80-$LENGTH(AMHLHDR))/2),AMHLHDR,!
+4 WRITE "The following data items can be printed. You can use up to 132 characters.",!,"Choose the data items in the order you want them printed.",!
+5 WRITE ?15,"Total Report width (including column margins - 2 spaces): ",AMHTCW
+6 SET AMHHIGH=0
SET X=0
FOR
SET X=$ORDER(^AMHSORT("C",X))
IF X'=+X
QUIT
SET Y=$ORDER(^AMHSORT("C",X,""))
IF $PIECE(^AMHSORT(Y,0),U,5)["P"
IF $PIECE(^(0),U,11)["V"
SET AMHHIGH=AMHHIGH+1
SET AMHSEL(AMHHIGH)=Y
+7 SET AMHCUT=((AMHHIGH/2)+.5)\1
+8 SET I=0
SET J=1
FOR
SET I=$ORDER(AMHSEL(I))
IF I'=+I
QUIT
IF '$DATA(AMHDISP(I))
Begin DoDot:1
+9 WRITE !?2,I,") ",$PIECE(^AMHSORT(AMHSEL(I),0),U)
SET AMHDISP(I)=""
SET J=I+AMHCUT
IF $DATA(AMHSEL(J))
IF '$DATA(AMHDISP(J))
WRITE ?40,J,") ",$PIECE(^AMHSORT(AMHSEL(J),0),U)
SET AMHDISP(J)=""
End DoDot:1
+10 WRITE !?7,"<Enter a list or a range. E.g. 1-4,5,20 or 10,12,20,30>"
+11 WRITE !?7,"<<PRESS ENTER to conclude selections or '^' to exit>>"
+12 QUIT
+1 KILL AMHDISP,AMHSEL,AMHHIGH
+2 IF $Y>(IOSL-4)
IF $DATA(IOF)
WRITE @IOF
+3 WRITE !,"The records displayed can be selected based on any of the following criteria:",!
+4 SET AMHHIGH=0
SET X=0
FOR
SET X=$ORDER(^AMHSORT(AMHXREF,X))
IF X'=+X
QUIT
SET Y=$ORDER(^AMHSORT(AMHXREF,X,""))
IF $PIECE(^AMHSORT(Y,0),U,5)["S"
IF $PIECE(^(0),U,11)[AMHPTVS
SET AMHHIGH=AMHHIGH+1
SET AMHSEL(AMHHIGH)=Y
+5 SET AMHCUT=((AMHHIGH/3)+1)\1
+6 SET I=0
SET J=1
SET K=1
FOR
SET I=$ORDER(AMHSEL(I))
IF I'=+I!($DATA(AMHDISP(I)))
QUIT
Begin DoDot:1
+7 WRITE !,I,") ",$EXTRACT($PIECE(^AMHSORT(AMHSEL(I),0),U),1,23)
SET AMHDISP(I)=""
+8 SET J=I+AMHCUT
IF $DATA(AMHSEL(J))
IF '$DATA(AMHDISP(J))
WRITE ?27,J,") ",$EXTRACT($PIECE(^AMHSORT(AMHSEL(J),0),U),1,22)
SET AMHDISP(J)=""
+9 SET K=J+AMHCUT
IF $DATA(AMHSEL(K))
IF '$DATA(AMHDISP(K))
WRITE ?53,K,") ",$EXTRACT($PIECE(^AMHSORT(AMHSEL(K),0),U),1,22)
SET AMHDISP(K)=""
End DoDot:1
+10 WRITE !?9,"<Enter a list or a range. E.g. 1-4,5,20 or 10,12,20,30>"
+11 WRITE !?9,"<<PRESS ENTER to conclude selections or bypass screens>>"
+12 QUIT
+1 KILL AMHDISP,AMHSEL,AMHHIGH
+2 IF $Y>(IOSL-4)
IF $DATA(IOF)
WRITE @IOF
+3 WRITE !!,"The records displayed can be sorted by any one of the following:",!
+4 SET AMHHIGH=0
SET X=0
FOR
SET X=$ORDER(^AMHSORT("C",X))
IF X'=+X
QUIT
SET Y=$ORDER(^AMHSORT("C",X,""))
IF $PIECE(^AMHSORT(Y,0),U,5)["R"
IF $PIECE(^(0),U,11)["V"
SET AMHHIGH=AMHHIGH+1
SET AMHSEL(AMHHIGH)=Y
+5 SET AMHCUT=((AMHHIGH/2)+.5)\1
+6 SET I=0
SET J=1
SET K=1
FOR
SET I=$ORDER(AMHSEL(I))
IF I'=+I
QUIT
IF '$DATA(AMHDISP(I))
WRITE !?5,I,") ",$PIECE(^AMHSORT(AMHSEL(I),0),U)
SET AMHDISP(I)=""
SET J=I+AMHCUT
IF $DATA(AMHSEL(J))
IF '$DATA(AMHDISP(J))
WRITE ?40,J,") ",$PIECE(^AMHSORT(AMHSEL(J),0),U)
SET AMHDISP(J)=""
+7 WRITE !!,"<<If you don't select a sort criteria the report will be sorted by Visit date>>"
+8 QUIT
+9 ;
N ;EP
+1 KILL ^AMHTRPT(AMHRPT,11,AMHCRIT),^AMHTRPT(AMHRPT,11,"B",AMHCRIT)
+2 SET DIR(0)="FO^1:7"
SET DIR("A")="Enter a Range for "_$PIECE(^AMHSORT(AMHCRIT,0),U)_", (e.g. 5-12)"
DO ^DIR
KILL DIR
IF $DATA(DUOUT)
SET DIRUT=1
+3 IF Y=""
WRITE !!,"No number range entered. All numbers will be included."
QUIT
+4 IF Y'?.N1"-".N
WRITE !!,$CHAR(7),$CHAR(7),"Enter an number range in the format nnn-nnn. E.g. 0-5, 0-99, 5-20."
GOTO N
+5 SET ^AMHTRPT(AMHRPT,11,AMHCRIT,0)=AMHCRIT
SET ^AMHTRPT(AMHRPT,11,"B",AMHCRIT,AMHCRIT)=""
+6 SET AMHCNT=0
SET ^AMHTRPT(AMHRPT,11,AMHCRIT,11,AMHCNT,0)="^9002013.8110101A^1^1"
FOR X=$PIECE(Y,"-"):1:$PIECE(Y,"-",2)
SET AMHCNT=AMHCNT+1
SET ^AMHTRPT(AMHRPT,11,AMHCRIT,11,1,0)=X
SET ^AMHTRPT(AMHRPT,11,AMHCRIT,11,"B",X,AMHCNT)=""
+7 QUIT
Y ;EP
+1 SET DIR(0)="S^1:"_AMHTEXT_";0:NO "_AMHTEXT_""
SET DIR("A")="Choose one"
SET DIR("B")="1"
DO ^DIR
KILL DIR
IF $DATA(DUOUT)
SET DIRUT=1
+2 IF $DATA(DIRUT)
QUIT
+3 IF Y=""
QUIT
+4 SET ^AMHTRPT(AMHRPT,11,AMHCRIT,0)=AMHCRIT
SET ^AMHTRPT(AMHRPT,11,"B",AMHCRIT,AMHCRIT)=""
+5 SET ^AMHTRPT(AMHRPT,11,AMHCRIT,11,1,0)=Y
SET ^AMHTRPT(AMHRPT,11,AMHCRIT,11,"B",Y,1)=""
SET ^AMHTRPT(AMHRPT,11,AMHCRIT,11,0)="^9001003.8110101A^"_1_"^"_1
+6 QUIT