APCLVL3 ; IHS/CMI/LAB - NO DESCRIPTION PROVIDED ;
;;2.0;IHS PCC SUITE;;MAY 14, 2009
;LAB added help text to dir call
;
;
TITLE ;EP
Q:"FTCP"[APCLCTYP
K DIR,X,Y S DIR(0)="Y",DIR("A")="Would you like a custom title for this report",DIR("B")="N" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
I $D(DIRUT) S APCLQUIT=1 Q
Q:Y=0
S APCLLENG=$S(APCLTCW:APCLTCW-8,1:60)
I Y=1 K DIR,X,Y S DIR(0)="F^3:"_APCLLENG,DIR("A")="Enter custom title",DIR("?")=" Enter from 3 to "_APCLLENG_" characters" D ^DIR K DIR
G:$D(DIRUT) TITLE
S APCLTITL=Y
S $P(^APCLVRPT(APCLRPT,13),U,3)=APCLTITL
Q
SAVE ;EP
Q:$D(APCLCAND) ;--- don't ask if already a pre-defined rpt
Q:APCLCTYP'="D" ;--- must be a detailed report to be saved
S APCLSAVE=""
K DIR,X,Y S DIR(0)="Y",DIR("A")="Do you wish to SAVE this "_$S('$D(APCLEP1):"SEARCH/",1:"")_"PRINT/SORT logic for future use",DIR("B")="N" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
Q:$D(DIRUT)
Q:'Y
K DIR,X,Y S DIR(0)="9001003.8,.03",DIR("A")="Enter NAME for this REPORT DEFINITION" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
G:$D(DIRUT) SAVE
S APCLNAME=Y
S DIE="^APCLVRPT(",DA=APCLRPT,DR=".02////1;.03///"_APCLNAME_";.06///"_APCLPTVS_";.05///"_APCLCTYP S:$D(APCLEP1) DR=DR_";.09///"_APCLPACK D ^DIE K DIE,DA,DR
Q
COUNT ;EP
W !!
S DIR(0)="S^T:Total Count Only;S:Sub-counts and Total Count;C:Cohort/Template Save;D:Detailed "_$S(APCLPTVS="V":"Visit",1:"Patient")_" Listing"_$S(APCLPTVS="V":";F:Flat file of Area Database formatted records",1:"")
S DIR(0)=DIR(0)_$S(APCLPTVS="V":";P:Unduplicated Patient Cohort/Template",1:"")
S DIR(0)=DIR(0)_";L:Delimited Output File for use in Excel"
S DIR("A")=" Choose Type of Report",DIR("B")="D" D ^DIR K DIR W !!
S:$D(DUOUT) DIRUT=1
I $D(DIRUT) S APCLQUIT=1 Q
S APCLCTYP=Y
I APCLCTYP="F" D FLAT Q:$D(APCLQUIT) S $P(^APCLVRPT(APCLRPT,0),U,5)="F" S:APCLPTVS="V" APCLSORT=19,APCLSORV="Visit Date" Q
I APCLCTYP="T" S $P(^APCLVRPT(APCLRPT,0),U,5)="T" S:APCLPTVS="V" APCLSORT=19,APCLSORV="Visit Date" S:APCLPTVS="P" APCLSORT=1,APCLSORV="Patient Name" Q
I APCLCTYP="D" D PRINT Q:$D(APCLQUIT) D SORT Q
I APCLCTYP="C"&(APCLPTVS="P") D ^APCLSTMP G:$D(APCLQUIT) COUNT D Q
.S $P(^APCLVRPT(APCLRPT,0),U,5)="C"
.S:APCLPTVS="P" APCLSORT=1,APCLSORV="Patient Name"
I APCLCTYP="C"&(APCLPTVS="V") D ^APCLSTMV G:$D(APCLQUIT) COUNT D Q
.S $P(^APCLVRPT(APCLRPT,0),U,5)="C"
.S:APCLPTVS="V" APCLSORT=19,APCLSORV="Visit Date"
I APCLCTYP="P" D ^APCLSTMP G:$D(APCLQUIT) COUNT D Q
.S $P(^APCLVRPT(APCLRPT,0),U,5)="P"
.S APCLSORT=1,APCLSORV="Patient Name"
.Q
I APCLCTYP="L" D Q
.W !!,"You have selected to create a delimited output file, you will be"
.W !,"asked to select the print items, the sort item and then to name the"
.W !,"output file.",!!
.K DIR S DIR(0)="Y",DIR("A")="Do you wish to continue",DIR("B")="Y" KILL DA D ^DIR KILL DIR
.I $D(DIRUT) S APCLQUIT=1 Q
.I 'Y S APCLQUIT=1 Q
.D PRINT Q:$D(APCLQUIT) S $P(^APCLVRPT(APCLRPT,0),U,5)="F" D Q:$D(APCLQUIT)
.D SORT
.D DELIMIT
.I APCLDELT="" S APCLQUIT=1
Q:$G(APCLQUIT)
D SORT
Q
PRINT ;
S APCLCNTL="P"
D ^APCLVL4
Q
SORT ;EP
K APCLSORT,APCLSORV,APCLQUIT
I APCLCTYP="D"!(APCLCTYP="L"),'$D(^APCLVRPT(APCLRPT,12)) W !!,"NO PRINT FIELDS SELECTED!!",$C(7),$C(7) S APCLQUIT=1 Q
S APCLSORT=""
D SHOWR^APCLVLS
S APCLCNTL="R" D ^APCLVL4 K APCLCNTL
I '$D(APCLSORV) S APCLQUIT=1 Q
Q:APCLCTYP'="D"
PAGE ;
K APCLSPAG
Q:APCLCTYP'="D"
S DIR(0)="Y",DIR("A")="Do you want a separate page for each "_APCLSORV,DIR("B")="N" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
I $D(DIRUT) G SORT
S APCLSPAG=Y,DIE="^APCLVRPT(",DA=APCLRPT,DR=".04///"_APCLSPAG D ^DIE K DA,DR,DIE
Q
FLAT ;
S APCLOUTF="APCL"_DUZ_"."
S X2=$E(DT,1,3)_"0101",X1=DT D ^%DTC S APCLJD=X+1
S APCLOUTF=APCLOUTF_APCLJD
W !!,"I am going to create a file called ",APCLOUTF," which will reside in ",!,"the ",$S($P(^AUTTSITE(1,0),U,21)=1:"/usr/spool/uucppublic",1:"C:\EXPORT")," directory.",!
W "Actually, the file will be placed in the same directory that the data export"
W !,"globals are placed. See your site manager for assistance in finding the file",!,"after it is created. PLEASE jot down and remember the following file name:",!?15,"********** ",APCLOUTF," **********",!
W "It may be several hours (or overnight) before your report and flat file are ",!,"finished.",!
W !,"As a reminder, the records that are generated and placed in file ",APCLOUTF,!
W !,"are in a standard, pre-defined record format. For a definition of the format",!,"please see your user manual.",!
S DIR(0)="Y",DIR("A")="Is everything ok? Do you want to continue?",DIR("B")="Y" K DA D ^DIR K DIR
I $D(DIRUT)!(Y'=1) S APCLQUIT=1 Q
S DA=APCLRPT,DR=".12///"_APCLOUTF,DIE="^APCLVRPT(" D ^DIE
K DIE,DA,DR
Q
DELIMIT ;get filename for delimited output
K APCLQUIT
S APCLDELF="",APCLDELT=""
W !!,"You have selected to create a '^' delimited output file. You can have this",!,"output file created as a text file in the pub directory, ",!,"OR you can have the delimited output display on your screen so that"
W !,"you can do a file capture. Keep in mind that if you choose to",!,"do a screen capture you CANNOT Queue your report to run in the background!!",!!
S DIR(0)="S^S:SCREEN - delimited output will display on screen for capture;F:FILE - delimited output will be written to a file in pub",DIR("A")="Select output type",DIR("B")="S" KILL DA D ^DIR KILL DIR
I $D(DIRUT) S APCLDELT="" Q
S APCLDELT=Y
Q:APCLDELT="S"
S DIR(0)="F^1:40" W !,"Enter a filename for the delimited output (no more than 40 characters)"
S DIR("A")="Filename" KILL DA D ^DIR KILL DIR
I $D(DIRUT) G DELIMIT
S APCLDELF=Y
S APCLHDIR=$S($P($G(^AUTTSITE(1,1)),U,2)]"":$P(^AUTTSITE(1,1),U,2),1:$G(^XTV(8989.3,1,"DEV")))
I $G(APCLHDIR)="" S APCLHDIR="/usr/spool/uucppublic/"
W !!,"When the report is finished your delimited output will be found in the",!,APCLHDIR," directory. The filename will be ",APCLDELF,".txt",!
Q
APCLVL3 ; IHS/CMI/LAB - NO DESCRIPTION PROVIDED ;
+1 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
+2 ;LAB added help text to dir call
+3 ;
+4 ;
TITLE ;EP
+1 IF "FTCP"[APCLCTYP
QUIT
+2 KILL DIR,X,Y
SET DIR(0)="Y"
SET DIR("A")="Would you like a custom title for this report"
SET DIR("B")="N"
DO ^DIR
KILL DIR
IF $DATA(DUOUT)
SET DIRUT=1
+3 IF $DATA(DIRUT)
SET APCLQUIT=1
QUIT
+4 IF Y=0
QUIT
+5 SET APCLLENG=$SELECT(APCLTCW:APCLTCW-8,1:60)
+6 IF Y=1
KILL DIR,X,Y
SET DIR(0)="F^3:"_APCLLENG
SET DIR("A")="Enter custom title"
SET DIR("?")=" Enter from 3 to "_APCLLENG_" characters"
DO ^DIR
KILL DIR
+7 IF $DATA(DIRUT)
GOTO TITLE
+8 SET APCLTITL=Y
+9 SET $PIECE(^APCLVRPT(APCLRPT,13),U,3)=APCLTITL
+10 QUIT
SAVE ;EP
+1 ;--- don't ask if already a pre-defined rpt
IF $DATA(APCLCAND)
QUIT
+2 ;--- must be a detailed report to be saved
IF APCLCTYP'="D"
QUIT
+3 SET APCLSAVE=""
+4 KILL DIR,X,Y
SET DIR(0)="Y"
SET DIR("A")="Do you wish to SAVE this "_$SELECT('$DATA(APCLEP1):"SEARCH/",1:"")_"PRINT/SORT logic for future use"
SET DIR("B")="N"
DO ^DIR
KILL DIR
IF $DATA(DUOUT)
SET DIRUT=1
+5 IF $DATA(DIRUT)
QUIT
+6 IF 'Y
QUIT
+7 KILL DIR,X,Y
SET DIR(0)="9001003.8,.03"
SET DIR("A")="Enter NAME for this REPORT DEFINITION"
DO ^DIR
KILL DIR
IF $DATA(DUOUT)
SET DIRUT=1
+8 IF $DATA(DIRUT)
GOTO SAVE
+9 SET APCLNAME=Y
+10 SET DIE="^APCLVRPT("
SET DA=APCLRPT
SET DR=".02////1;.03///"_APCLNAME_";.06///"_APCLPTVS_";.05///"_APCLCTYP
IF $DATA(APCLEP1)
SET DR=DR_";.09///"_APCLPACK
DO ^DIE
KILL DIE,DA,DR
+11 QUIT
COUNT ;EP
+1 WRITE !!
+2 SET DIR(0)="S^T:Total Count Only;S:Sub-counts and Total Count;C:Cohort/Template Save;D:Detailed "_$SELECT(APCLPTVS="V":"Visit",1:"Patient")_" Listing"_$SELECT(APCLPTVS="V":";F:Flat file of Area Database formatted records",1:"")
+3 SET DIR(0)=DIR(0)_$SELECT(APCLPTVS="V":";P:Unduplicated Patient Cohort/Template",1:"")
+4 SET DIR(0)=DIR(0)_";L:Delimited Output File for use in Excel"
+5 SET DIR("A")=" Choose Type of Report"
SET DIR("B")="D"
DO ^DIR
KILL DIR
WRITE !!
+6 IF $DATA(DUOUT)
SET DIRUT=1
+7 IF $DATA(DIRUT)
SET APCLQUIT=1
QUIT
+8 SET APCLCTYP=Y
+9 IF APCLCTYP="F"
DO FLAT
IF $DATA(APCLQUIT)
QUIT
SET $PIECE(^APCLVRPT(APCLRPT,0),U,5)="F"
IF APCLPTVS="V"
SET APCLSORT=19
SET APCLSORV="Visit Date"
QUIT
+10 IF APCLCTYP="T"
SET $PIECE(^APCLVRPT(APCLRPT,0),U,5)="T"
IF APCLPTVS="V"
SET APCLSORT=19
SET APCLSORV="Visit Date"
IF APCLPTVS="P"
SET APCLSORT=1
SET APCLSORV="Patient Name"
QUIT
+11 IF APCLCTYP="D"
DO PRINT
IF $DATA(APCLQUIT)
QUIT
DO SORT
QUIT
+12 IF APCLCTYP="C"&(APCLPTVS="P")
DO ^APCLSTMP
IF $DATA(APCLQUIT)
GOTO COUNT
Begin DoDot:1
+13 SET $PIECE(^APCLVRPT(APCLRPT,0),U,5)="C"
+14 IF APCLPTVS="P"
SET APCLSORT=1
SET APCLSORV="Patient Name"
End DoDot:1
QUIT
+15 IF APCLCTYP="C"&(APCLPTVS="V")
DO ^APCLSTMV
IF $DATA(APCLQUIT)
GOTO COUNT
Begin DoDot:1
+16 SET $PIECE(^APCLVRPT(APCLRPT,0),U,5)="C"
+17 IF APCLPTVS="V"
SET APCLSORT=19
SET APCLSORV="Visit Date"
End DoDot:1
QUIT
+18 IF APCLCTYP="P"
DO ^APCLSTMP
IF $DATA(APCLQUIT)
GOTO COUNT
Begin DoDot:1
+19 SET $PIECE(^APCLVRPT(APCLRPT,0),U,5)="P"
+20 SET APCLSORT=1
SET APCLSORV="Patient Name"
+21 QUIT
End DoDot:1
QUIT
+22 IF APCLCTYP="L"
Begin DoDot:1
+23 WRITE !!,"You have selected to create a delimited output file, you will be"
+24 WRITE !,"asked to select the print items, the sort item and then to name the"
+25 WRITE !,"output file.",!!
+26 KILL DIR
SET DIR(0)="Y"
SET DIR("A")="Do you wish to continue"
SET DIR("B")="Y"
KILL DA
DO ^DIR
KILL DIR
+27 IF $DATA(DIRUT)
SET APCLQUIT=1
QUIT
+28 IF 'Y
SET APCLQUIT=1
QUIT
+29 DO PRINT
IF $DATA(APCLQUIT)
QUIT
SET $PIECE(^APCLVRPT(APCLRPT,0),U,5)="F"
Begin DoDot:2
End DoDot:2
IF $DATA(APCLQUIT)
QUIT
+30 DO SORT
+31 DO DELIMIT
+32 IF APCLDELT=""
SET APCLQUIT=1
End DoDot:1
QUIT
+33 IF $GET(APCLQUIT)
QUIT
+34 DO SORT
+35 QUIT
PRINT ;
+1 SET APCLCNTL="P"
+2 DO ^APCLVL4
+3 QUIT
SORT ;EP
+1 KILL APCLSORT,APCLSORV,APCLQUIT
+2 IF APCLCTYP="D"!(APCLCTYP="L")
IF '$DATA(^APCLVRPT(APCLRPT,12))
WRITE !!,"NO PRINT FIELDS SELECTED!!",$CHAR(7),$CHAR(7)
SET APCLQUIT=1
QUIT
+3 SET APCLSORT=""
+4 DO SHOWR^APCLVLS
+5 SET APCLCNTL="R"
DO ^APCLVL4
KILL APCLCNTL
+6 IF '$DATA(APCLSORV)
SET APCLQUIT=1
QUIT
+7 IF APCLCTYP'="D"
QUIT
PAGE ;
+1 KILL APCLSPAG
+2 IF APCLCTYP'="D"
QUIT
+3 SET DIR(0)="Y"
SET DIR("A")="Do you want a separate page for each "_APCLSORV
SET DIR("B")="N"
DO ^DIR
KILL DIR
IF $DATA(DUOUT)
SET DIRUT=1
+4 IF $DATA(DIRUT)
GOTO SORT
+5 SET APCLSPAG=Y
SET DIE="^APCLVRPT("
SET DA=APCLRPT
SET DR=".04///"_APCLSPAG
DO ^DIE
KILL DA,DR,DIE
+6 QUIT
FLAT ;
+1 SET APCLOUTF="APCL"_DUZ_"."
+2 SET X2=$EXTRACT(DT,1,3)_"0101"
SET X1=DT
DO ^%DTC
SET APCLJD=X+1
+3 SET APCLOUTF=APCLOUTF_APCLJD
+4 WRITE !!,"I am going to create a file called ",APCLOUTF," which will reside in ",!,"the ",$SELECT($PIECE(^AUTTSITE(1,0),U,21)=1:"/usr/spool/uucppublic",1:"C:\EXPORT")," directory.",!
+5 WRITE "Actually, the file will be placed in the same directory that the data export"
+6 WRITE !,"globals are placed. See your site manager for assistance in finding the file",!,"after it is created. PLEASE jot down and remember the following file name:",!?15,"********** ",APCLOUTF," **********",!
+7 WRITE "It may be several hours (or overnight) before your report and flat file are ",!,"finished.",!
+8 WRITE !,"As a reminder, the records that are generated and placed in file ",APCLOUTF,!
+9 WRITE !,"are in a standard, pre-defined record format. For a definition of the format",!,"please see your user manual.",!
+10 SET DIR(0)="Y"
SET DIR("A")="Is everything ok? Do you want to continue?"
SET DIR("B")="Y"
KILL DA
DO ^DIR
KILL DIR
+11 IF $DATA(DIRUT)!(Y'=1)
SET APCLQUIT=1
QUIT
+12 SET DA=APCLRPT
SET DR=".12///"_APCLOUTF
SET DIE="^APCLVRPT("
DO ^DIE
+13 KILL DIE,DA,DR
+14 QUIT
DELIMIT ;get filename for delimited output
+1 KILL APCLQUIT
+2 SET APCLDELF=""
SET APCLDELT=""
+3 WRITE !!,"You have selected to create a '^' delimited output file. You can have this",!,"output file created as a text file in the pub directory, ",!,"OR you can have the delimited output display on your screen so that"
+4 WRITE !,"you can do a file capture. Keep in mind that if you choose to",!,"do a screen capture you CANNOT Queue your report to run in the background!!",!!
+5 SET DIR(0)="S^S:SCREEN - delimited output will display on screen for capture;F:FILE - delimited output will be written to a file in pub"
SET DIR("A")="Select output type"
SET DIR("B")="S"
KILL DA
DO ^DIR
KILL DIR
+6 IF $DATA(DIRUT)
SET APCLDELT=""
QUIT
+7 SET APCLDELT=Y
+8 IF APCLDELT="S"
QUIT
+9 SET DIR(0)="F^1:40"
WRITE !,"Enter a filename for the delimited output (no more than 40 characters)"
+10 SET DIR("A")="Filename"
KILL DA
DO ^DIR
KILL DIR
+11 IF $DATA(DIRUT)
GOTO DELIMIT
+12 SET APCLDELF=Y
+13 SET APCLHDIR=$SELECT($PIECE($GET(^AUTTSITE(1,1)),U,2)]"":$PIECE(^AUTTSITE(1,1),U,2),1:$GET(^XTV(8989.3,1,"DEV")))
+14 IF $GET(APCLHDIR)=""
SET APCLHDIR="/usr/spool/uucppublic/"
+15 WRITE !!,"When the report is finished your delimited output will be found in the",!,APCLHDIR," directory. The filename will be ",APCLDELF,".txt",!
+16 QUIT