INHMSR1 ;KN; 31 Jan 96 09:56; Statistical Report Definition Screen.
;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
;COPYRIGHT 1991-2000 SAIC
;
; MODULE NAME: Statistical Report Definition Screen (INHMSR1).
;
; PURPOSE:
; The purpose of the Statistic Report Definition Module (INHMSR1)
; is to display statistic definition screen, and accept user's
; selected criteria.
;
; DESCRIPTION:
; The processing of this routine will use List Processor (DWL)
; to display the definition screen for the user to select sort
; criteria, range for the items selected and the total option.
; Predefined selectable fields are stored in global
; ^UTILITY("INHSR"). The routine will call function GATHER
; to construct INA array. It calls function GVL to validate user's
; input entry as maximum of five items can be selected and the
; range should be valid depends on item selected. It calls function
; INACHK to verify field .01 range. It calls function INHELP to get
; help for range input. The hot key will allow the user select from
; the following options:
; . Run to calculate statistic and display report on the screen
; or send it to the printer.
; . Header/Footer to add optional header/footer to the statistic
; report.
; . Abort to exit the screen.
;
Q
;
EN(INIEN,INNM) ; Entry point for Statistic Report Definition Module
;
; Return: none
; Parameters:
; INIEN = File ien
; INNM = Name of file for statistic report
; Code begins
N INX,INHEAD,IN,INCNT,INA,INQ,INFLD,INRB,SEL,HEADER,INF1,HD,FT,INFLG,ZTSK
S (INCNT,INFLG)=0
; Check if file selected has pre-defined field in global.
S INFLG=$D(^UTILITY($J,"INHSR",INIEN))#10
; Search ^DD cross reference for field ien (infld=field name)
S INFLD=0 F S INFLD=$O(^DD(INIEN,INFLD)) Q:'INFLD D
.S INX=$P(^DD(INIEN,INFLD,0),U,1)
.; only display selectable fields predefined in global
.I $$ISTHERE^INHMSR10(INIEN,INFLD,INFLG) D
..; Initialize incnt=number of selection user made
..S INCNT=$G(INCNT)+1
..; IN(col,row), ex:col=2 is field name i.e. INX
..S IN(1,INCNT)="",IN(2,INCNT)=INX,IN(3,INCNT)="",IN(4,INCNT)="",IN(5,INCNT)="",IN(6,INCNT)=INFLD
..S:INFLD=.01 INF1=INX
..; ListMan, make column 1,3,4,5 selectable.
..S IN(1,INCNT,0)="",IN(3,INCNT,0)="",IN(4,INCNT,0)="",IN(5,INCNT,0)=""
..; 1.Make col 1 editable, 2. width=1, 3. input validation
..S IN(1,INCNT,"DQ")="",IN(1,INCNT,"DQ",0)=1,IN(1,INCNT,"DQ",1)="K:X'?1N!(X>5)!(X<1) X"
..S IN(1,INCNT,"DQ","?")="D POP^DWLR2(4,1) W ""Enter a number from 1 to 5. The number is used to indicate the sort order."" I $$CR^UTSRD"
..S (IN(3,INCNT,"DQ"),IN(4,INCNT,"DQ"))="",(IN(3,INCNT,"DQ",0),IN(4,INCNT,"DQ",0))=20,(IN(3,INCNT,"DQ","?"),IN(4,INCNT,"DQ","?"))="D INHELP^INHMSR10("_INIEN_","_INFLD_")",(IN(3,INCNT,"DQ",1),IN(4,INCNT,"DQ",1))=$$GVL^INHMSR10(INIEN,INFLD)
..S IN(5,INCNT,"DQ")="",IN(5,INCNT,"DQ",0)=1,YN="YNyn",IN(5,INCNT,"DQ",1)="K:X'?1A!(YN'[X) X",IN(5,INCNT,"DQ","?")="D POP^DWLR2(4,1) W ""Enter Y or N to indicate whether a count for this field is desired."" I $$CR^UTSRD"
; Set hot key for selection - Graph not used - DWLHOT(2)="Graph^GRAPH
S DWLHOT(1)="FILE/EXIT^R",DWLHOT(3)="Hd/Ft^HDFT",DWLHOT(4)="Exit^A"
S INHEAD="D HEADER^INHMSR1(INNM)"
D HOTSET^DWL
W @IOF
;Setup for list processor
S INRB=0,INQ=0,DWLRF="IN",DWLB="0^3^15^2^25^20^20^2",DWL="KCHQ2FZWXXA5",DWL("TITLE")=INHEAD
; Processing loop
F Q:INQ=1 D
.; Rebuild in array if error
.D:INRB RBIN(.INA)
.S INRB=0
.D ^DWL
.I (DWLR="R") D Q
..; If press run, then rebuild INA array, SEL=0
..S SEL=$$GATHER^INHMSR11(.INA,INCNT)
..I SEL=0 S INQ=0,INRB=1
..E D R(INIEN,SEL,.INA) S INQ=1
.;I DWLR="GRAPH" D GRAPH S SEL=$$GATHER^INHMSR11(.INA,INCNT),INQ=0,INRB=1
.I DWLR="HDFT" D HDFT S SEL=$$GATHER^INHMSR11(.INA,INCNT),INQ=0,INRB=1 Q
.I DWLR="A" S INQ=1 W @IOF Q
.; Abort and File/Exit key
.I DWLR="^" S INQ=1 W @IOF Q
.I DWLR="^^" S INQ=1 W @IOF Q
.;Ignore if user hit enter key
.I +DWLR>0 W *7 S SEL=$$GATHER^INHMSR11(.INA,INCNT),INQ=0,INRB=1
Q
;
RBIN(INA) ; Rebuild IN array.
;
; Description: The function RBIN is used to rebuild IN display
; array if error occurs.
; Return: none
; Parameter:
; INA = Name of statistical report criteria array.
; Code begins:
N INX
; Loop thru ina array, inx=order, i=row where selection is at
S INX=0 F S INX=$O(INA(INX)) Q:INX="" D
.S I=$G(INA(INX,5))
.; Rebuild column 1 and 5 (order and total)
.S IN(1,I,"DQ")=INX
.S IN(5,I,"DQ")=$G(INA(INX,7))
.; ina(order,6) contains type of the field
.S IN(3,I,"DQ")=$G(INA(INX,3)),IN(4,I,"DQ")=$G(INA(INX,4))
Q
;
R(INFL,SEL,INA) ; Entry point for Hotkey run
;
; Description: The function R is used to pass the INA array
; to module INHMSR2 for calculate statistic and display.
; Return: none
; Parameters:
; INFL = File ien (internal entry number)
; SEL = Number of selection that user made.
; INA = Array of user selected criteria.
; Code begins:
W @IOF
N P1
S INA("INHD")=$G(INHD),INA("INFT")=$G(INFT)
D STAT^INHMSR2(INFL,.INA,SEL)
Q
;
HDFT ;Header and footer
;
; Description: The function HDFT is used to ask user to
; enter text used for the report Header or Footer.
; Return: none
; Parameter: none
; Code begins:
W @IOF
; NOTE: 2 - required input or timed out; 30 = wait 30 seconds
S P1="Please Enter Header: ;;2,10;;;;;2;;INHD;;30;;IN"
W ! D ^UTSRD(P1,"","",1)
S P1="Please Enter Footer: ;;2,20;;;;;2;;INFT;;30;;IN"
W ! D ^UTSRD(P1,"","",1)
Q
;
;
; Description: The function HEADER is used to display DWL
; header, and hot key selection.
; Return: None
; Parameters:
; INNM = Name of the current selected file.
; Code begins:
; Call function to display the header's name
S INTXT="STATISTICAL REPORT DEFINITION" W ?(IOM-$L(INTXT))/2,INTXT,!
; Call function to display the DWL screen for user select
W ?(IOM-$L(INNM))/2,INNM,!,"Order ","Field Name",?33,"From",?55,"To",?73,"Count"
; Display Hotkey for information.
W $$SETXY^%ZTF(0,19),DWLMSG
Q
INHMSR1 ;KN; 31 Jan 96 09:56; Statistical Report Definition Screen.
+1 ;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
+2 ;COPYRIGHT 1991-2000 SAIC
+3 ;
+4 ; MODULE NAME: Statistical Report Definition Screen (INHMSR1).
+5 ;
+6 ; PURPOSE:
+7 ; The purpose of the Statistic Report Definition Module (INHMSR1)
+8 ; is to display statistic definition screen, and accept user's
+9 ; selected criteria.
+10 ;
+11 ; DESCRIPTION:
+12 ; The processing of this routine will use List Processor (DWL)
+13 ; to display the definition screen for the user to select sort
+14 ; criteria, range for the items selected and the total option.
+15 ; Predefined selectable fields are stored in global
+16 ; ^UTILITY("INHSR"). The routine will call function GATHER
+17 ; to construct INA array. It calls function GVL to validate user's
+18 ; input entry as maximum of five items can be selected and the
+19 ; range should be valid depends on item selected. It calls function
+20 ; INACHK to verify field .01 range. It calls function INHELP to get
+21 ; help for range input. The hot key will allow the user select from
+22 ; the following options:
+23 ; . Run to calculate statistic and display report on the screen
+24 ; or send it to the printer.
+25 ; . Header/Footer to add optional header/footer to the statistic
+26 ; report.
+27 ; . Abort to exit the screen.
+28 ;
+29 QUIT
+30 ;
EN(INIEN,INNM) ; Entry point for Statistic Report Definition Module
+1 ;
+2 ; Return: none
+3 ; Parameters:
+4 ; INIEN = File ien
+5 ; INNM = Name of file for statistic report
+6 ; Code begins
+7 NEW INX,INHEAD,IN,INCNT,INA,INQ,INFLD,INRB,SEL,HEADER,INF1,HD,FT,INFLG,ZTSK
+8 SET (INCNT,INFLG)=0
+9 ; Check if file selected has pre-defined field in global.
+10 SET INFLG=$DATA(^UTILITY($JOB,"INHSR",INIEN))#10
+11 ; Search ^DD cross reference for field ien (infld=field name)
+12 SET INFLD=0
FOR
SET INFLD=$ORDER(^DD(INIEN,INFLD))
IF 'INFLD
QUIT
Begin DoDot:1
+13 SET INX=$PIECE(^DD(INIEN,INFLD,0),U,1)
+14 ; only display selectable fields predefined in global
+15 IF $$ISTHERE^INHMSR10(INIEN,INFLD,INFLG)
Begin DoDot:2
+16 ; Initialize incnt=number of selection user made
+17 SET INCNT=$GET(INCNT)+1
+18 ; IN(col,row), ex:col=2 is field name i.e. INX
+19 SET IN(1,INCNT)=""
SET IN(2,INCNT)=INX
SET IN(3,INCNT)=""
SET IN(4,INCNT)=""
SET IN(5,INCNT)=""
SET IN(6,INCNT)=INFLD
+20 IF INFLD=.01
SET INF1=INX
+21 ; ListMan, make column 1,3,4,5 selectable.
+22 SET IN(1,INCNT,0)=""
SET IN(3,INCNT,0)=""
SET IN(4,INCNT,0)=""
SET IN(5,INCNT,0)=""
+23 ; 1.Make col 1 editable, 2. width=1, 3. input validation
+24 SET IN(1,INCNT,"DQ")=""
SET IN(1,INCNT,"DQ",0)=1
SET IN(1,INCNT,"DQ",1)="K:X'?1N!(X>5)!(X<1) X"
+25 SET IN(1,INCNT,"DQ","?")="D POP^DWLR2(4,1) W ""Enter a number from 1 to 5. The number is used to indicate the sort order."" I $$CR^UTSRD"
+26 SET (IN(3,INCNT,"DQ"),IN(4,INCNT,"DQ"))=""
SET (IN(3,INCNT,"DQ",0),IN(4,INCNT,"DQ",0))=20
SET (IN(3,INCNT,"DQ","?"),IN(4,INCNT,"DQ","?"))="D INHELP^INHMSR10("_INIEN_","_INFLD_")"
SET (IN(3,INCNT,"DQ",1),IN(4,INCNT,"DQ",1))=$$GVL^INHMSR10(INIEN,INFLD)
+27 SET IN(5,INCNT,"DQ")=""
SET IN(5,INCNT,"DQ",0)=1
SET YN="YNyn"
SET IN(5,INCNT,"DQ",1)="K:X'?1A!(YN'[X) X"
SET IN(5,INCNT,"DQ","?")="D POP^DWLR2(4,1) W ""Enter Y or N to indicate whether a count for this field is desired."" I $$CR^UTSRD"
End DoDot:2
End DoDot:1
+28 ; Set hot key for selection - Graph not used - DWLHOT(2)="Graph^GRAPH
+29 SET DWLHOT(1)="FILE/EXIT^R"
SET DWLHOT(3)="Hd/Ft^HDFT"
SET DWLHOT(4)="Exit^A"
+30 SET INHEAD="D HEADER^INHMSR1(INNM)"
+31 DO HOTSET^DWL
+32 WRITE @IOF
+33 ;Setup for list processor
+34 SET INRB=0
SET INQ=0
SET DWLRF="IN"
SET DWLB="0^3^15^2^25^20^20^2"
SET DWL="KCHQ2FZWXXA5"
SET DWL("TITLE")=INHEAD
+35 ; Processing loop
+36 FOR
IF INQ=1
QUIT
Begin DoDot:1
+37 ; Rebuild in array if error
+38 IF INRB
DO RBIN(.INA)
+39 SET INRB=0
+40 DO ^DWL
+41 IF (DWLR="R")
Begin DoDot:2
+42 ; If press run, then rebuild INA array, SEL=0
+43 SET SEL=$$GATHER^INHMSR11(.INA,INCNT)
+44 IF SEL=0
SET INQ=0
SET INRB=1
+45 IF '$TEST
DO R(INIEN,SEL,.INA)
SET INQ=1
End DoDot:2
QUIT
+46 ;I DWLR="GRAPH" D GRAPH S SEL=$$GATHER^INHMSR11(.INA,INCNT),INQ=0,INRB=1
+47 IF DWLR="HDFT"
DO HDFT
SET SEL=$$GATHER^INHMSR11(.INA,INCNT)
SET INQ=0
SET INRB=1
QUIT
+48 IF DWLR="A"
SET INQ=1
WRITE @IOF
QUIT
+49 ; Abort and File/Exit key
+50 IF DWLR="^"
SET INQ=1
WRITE @IOF
QUIT
+51 IF DWLR="^^"
SET INQ=1
WRITE @IOF
QUIT
+52 ;Ignore if user hit enter key
+53 IF +DWLR>0
WRITE *7
SET SEL=$$GATHER^INHMSR11(.INA,INCNT)
SET INQ=0
SET INRB=1
End DoDot:1
+54 QUIT
+55 ;
RBIN(INA) ; Rebuild IN array.
+1 ;
+2 ; Description: The function RBIN is used to rebuild IN display
+3 ; array if error occurs.
+4 ; Return: none
+5 ; Parameter:
+6 ; INA = Name of statistical report criteria array.
+7 ; Code begins:
+8 NEW INX
+9 ; Loop thru ina array, inx=order, i=row where selection is at
+10 SET INX=0
FOR
SET INX=$ORDER(INA(INX))
IF INX=""
QUIT
Begin DoDot:1
+11 SET I=$GET(INA(INX,5))
+12 ; Rebuild column 1 and 5 (order and total)
+13 SET IN(1,I,"DQ")=INX
+14 SET IN(5,I,"DQ")=$GET(INA(INX,7))
+15 ; ina(order,6) contains type of the field
+16 SET IN(3,I,"DQ")=$GET(INA(INX,3))
SET IN(4,I,"DQ")=$GET(INA(INX,4))
End DoDot:1
+17 QUIT
+18 ;
R(INFL,SEL,INA) ; Entry point for Hotkey run
+1 ;
+2 ; Description: The function R is used to pass the INA array
+3 ; to module INHMSR2 for calculate statistic and display.
+4 ; Return: none
+5 ; Parameters:
+6 ; INFL = File ien (internal entry number)
+7 ; SEL = Number of selection that user made.
+8 ; INA = Array of user selected criteria.
+9 ; Code begins:
+10 WRITE @IOF
+11 NEW P1
+12 SET INA("INHD")=$GET(INHD)
SET INA("INFT")=$GET(INFT)
+13 DO STAT^INHMSR2(INFL,.INA,SEL)
+14 QUIT
+15 ;
HDFT ;Header and footer
+1 ;
+2 ; Description: The function HDFT is used to ask user to
+3 ; enter text used for the report Header or Footer.
+4 ; Return: none
+5 ; Parameter: none
+6 ; Code begins:
+7 WRITE @IOF
+8 ; NOTE: 2 - required input or timed out; 30 = wait 30 seconds
+9 SET P1="Please Enter Header: ;;2,10;;;;;2;;INHD;;30;;IN"
+10 WRITE !
DO ^UTSRD(P1,"","",1)
+11 SET P1="Please Enter Footer: ;;2,20;;;;;2;;INFT;;30;;IN"
+12 WRITE !
DO ^UTSRD(P1,"","",1)
+13 QUIT
+14 ;
+1 ;
+2 ; Description: The function HEADER is used to display DWL
+3 ; header, and hot key selection.
+4 ; Return: None
+5 ; Parameters:
+6 ; INNM = Name of the current selected file.
+7 ; Code begins:
+8 ; Call function to display the header's name
+9 SET INTXT="STATISTICAL REPORT DEFINITION"
WRITE ?(IOM-$LENGTH(INTXT))/2,INTXT,!
+10 ; Call function to display the DWL screen for user select
+11 WRITE ?(IOM-$LENGTH(INNM))/2,INNM,!,"Order ","Field Name",?33,"From",?55,"To",?73,"Count"
+12 ; Display Hotkey for information.
+13 WRITE $$SETXY^%ZTF(0,19),DWLMSG
+14 QUIT