- AMHRL3 ; IHS/CMI/LAB - LISTER ;
- ;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
- ;
- ;
- COUNT ;EP
- W !! S DIR(0)="S^T:Total Count Only;S:Sub-counts and Total Count;D:Detailed Listing"_$S(AMHPTVS="V":";F:Flat ASCII file (pre-defined record format)",1:"")
- S DIR("A")="Choose Type of Report",DIR("B")="D" D ^DIR K DIR W !!
- S:$D(DUOUT) DIRUT=1
- I $D(DIRUT) S AMHQUIT=1 Q
- S AMHCTYP=Y
- I AMHCTYP="T" S $P(^AMHTRPT(AMHRPT,0),U,5)=1 S:AMHPTVS="V" AMHSORT=19,AMHSORV="Encounter Date" S:AMHPTVS="P" AMHSORT=70,AMHSORV="Patient Name" S:AMHPTVS="S" AMHSORT=129,AMHSORV="Date of Suicide Act" Q
- I AMHCTYP="D" D PRINT Q:$D(AMHQUIT) D SORT Q
- I AMHCTYP="F" D FLAT S:AMHPTVS="S" AMHSORT=129,AMHSORV="Date of Suicide Act" Q:$D(AMHQUIT) S $P(^AMHTRPT(AMHRPT,0),U,5)=1 S:AMHPTVS="V" AMHSORT=19,AMHSORV="Encounter Date" S:AMHPTVS="P" AMHSORT=70,AMHSORV="Patient Name" Q
- D SORT
- Q
- PRINT ;
- S AMHCNTL="P" D ^AMHRL4
- Q
- SORT ;
- K AMHSORT,AMHSORV,AMHQUIT
- I AMHCTYP="D",'$D(^AMHTRPT(AMHRPT,12)) W !!,"NO PRINT FIELDS SELECTED!!",$C(7),$C(7) S AMHQUIT=1 Q
- S AMHSORT=""
- D SHOWR^AMHRLS
- S AMHCNTL="R" D ^AMHRL4 K AMHCNTL
- I '$D(AMHSORV) S AMHQUIT=1 Q
- Q:AMHCTYP'="D"
- PAGE ;
- K AMHSPAG
- Q:AMHCTYP'="D"
- S DIR(0)="Y",DIR("A")="Do you want a separate page for each "_AMHSORV,DIR("B")="N" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
- I $D(DIRUT) G SORT
- S AMHSPAG=Y,DIE="^AMHTRPT(",DA=AMHRPT,DR=".04///"_AMHSPAG D CALLDIE^AMHLEIN
- Q
- FLAT ;
- S AMHFILE="AMH"_DUZ_"."
- S X2=$E(DT,1,3)_"0101",X1=DT D ^%DTC S AMHJD=X+1
- S AMHFILE=AMHFILE_AMHJD
- W !!,"I am going to create a file called ",AMHFILE," 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,"********** ",AMHFILE," **********",!
- 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 ",AMHFILE,!
- 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 AMHQUIT=1 Q
- S DA=AMHRPT,DR=".12///"_AMHFILE,DIE="^AMHTRPT(" D ^DIE
- K DIE,DA,DR
- Q
- AMHRL3 ; IHS/CMI/LAB - LISTER ;
- +1 ;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
- +2 ;
- +3 ;
- COUNT ;EP
- +1 WRITE !!
- SET DIR(0)="S^T:Total Count Only;S:Sub-counts and Total Count;D:Detailed Listing"_$SELECT(AMHPTVS="V":";F:Flat ASCII file (pre-defined record format)",1:"")
- +2 SET DIR("A")="Choose Type of Report"
- SET DIR("B")="D"
- DO ^DIR
- KILL DIR
- WRITE !!
- +3 IF $DATA(DUOUT)
- SET DIRUT=1
- +4 IF $DATA(DIRUT)
- SET AMHQUIT=1
- QUIT
- +5 SET AMHCTYP=Y
- +6 IF AMHCTYP="T"
- SET $PIECE(^AMHTRPT(AMHRPT,0),U,5)=1
- IF AMHPTVS="V"
- SET AMHSORT=19
- SET AMHSORV="Encounter Date"
- IF AMHPTVS="P"
- SET AMHSORT=70
- SET AMHSORV="Patient Name"
- IF AMHPTVS="S"
- SET AMHSORT=129
- SET AMHSORV="Date of Suicide Act"
- QUIT
- +7 IF AMHCTYP="D"
- DO PRINT
- IF $DATA(AMHQUIT)
- QUIT
- DO SORT
- QUIT
- +8 IF AMHCTYP="F"
- DO FLAT
- IF AMHPTVS="S"
- SET AMHSORT=129
- SET AMHSORV="Date of Suicide Act"
- IF $DATA(AMHQUIT)
- QUIT
- SET $PIECE(^AMHTRPT(AMHRPT,0),U,5)=1
- IF AMHPTVS="V"
- SET AMHSORT=19
- SET AMHSORV="Encounter Date"
- IF AMHPTVS="P"
- SET AMHSORT=70
- SET AMHSORV="Patient Name"
- QUIT
- +9 DO SORT
- +10 QUIT
- PRINT ;
- +1 SET AMHCNTL="P"
- DO ^AMHRL4
- +2 QUIT
- SORT ;
- +1 KILL AMHSORT,AMHSORV,AMHQUIT
- +2 IF AMHCTYP="D"
- IF '$DATA(^AMHTRPT(AMHRPT,12))
- WRITE !!,"NO PRINT FIELDS SELECTED!!",$CHAR(7),$CHAR(7)
- SET AMHQUIT=1
- QUIT
- +3 SET AMHSORT=""
- +4 DO SHOWR^AMHRLS
- +5 SET AMHCNTL="R"
- DO ^AMHRL4
- KILL AMHCNTL
- +6 IF '$DATA(AMHSORV)
- SET AMHQUIT=1
- QUIT
- +7 IF AMHCTYP'="D"
- QUIT
- PAGE ;
- +1 KILL AMHSPAG
- +2 IF AMHCTYP'="D"
- QUIT
- +3 SET DIR(0)="Y"
- SET DIR("A")="Do you want a separate page for each "_AMHSORV
- SET DIR("B")="N"
- DO ^DIR
- KILL DIR
- IF $DATA(DUOUT)
- SET DIRUT=1
- +4 IF $DATA(DIRUT)
- GOTO SORT
- +5 SET AMHSPAG=Y
- SET DIE="^AMHTRPT("
- SET DA=AMHRPT
- SET DR=".04///"_AMHSPAG
- DO CALLDIE^AMHLEIN
- +6 QUIT
- FLAT ;
- +1 SET AMHFILE="AMH"_DUZ_"."
- +2 SET X2=$EXTRACT(DT,1,3)_"0101"
- SET X1=DT
- DO ^%DTC
- SET AMHJD=X+1
- +3 SET AMHFILE=AMHFILE_AMHJD
- +4 WRITE !!,"I am going to create a file called ",AMHFILE," 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,"********** ",AMHFILE," **********",!
- +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 ",AMHFILE,!
- +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 AMHQUIT=1
- QUIT
- +12 SET DA=AMHRPT
- SET DR=".12///"_AMHFILE
- SET DIE="^AMHTRPT("
- DO ^DIE
- +13 KILL DIE,DA,DR
- +14 QUIT