AZXRBUG6 ;BUGDRUG2 Report PROGRAM [ 09/23/94 9:52 AM ]
;Version 1
;"Cultured Organisms by Source"
;09/04/92 JOHN H. LYNCH
;
;ALLOWS THE DATA ENTRY PERSON TO RUN A REPORT
;GIVING INFORMATION ON THE TOTAL NUMBER OF ENTRIES
;IN THE DATABASE FOR A GIVEN FACILITY AND DATE
;RANGE, BY SPECIMEN, ORGANISM AND THE COUNT FOR
;EACH SET.
;THE ROUTINES THAT CALL AZXRBUG6:
;AZXRBUG3, Reports
;THE ROUTINES THAT AZXRBUG6 CALLS:
;AZXRBUG7, Reports Input
;%ZIS, Fileman Device Handler
;DD^%DT, Fileman Date Conversion
;^DIC, Fileman Lookup
;Variable List
;PG= Current page count.
;LN= Current line count.
;COUNT= Organism count.
;TCOUNT= Total Organism count.
;FACBKUP= Flag returned from AZXRBUG7 with data on
; whether user wants to quit.
;BORDER= Special border for report.
;HEADER= Special header for report.
;%ZIS(B)= Don't use HOME as default device.
;LDATE= Current date used in print loop (REPORT SUB-
; ROUTINE).
;FCLTY= Current Facility in START LOOP.
;FDATE= Users starting date input; this value is
; exported from AZXRBUG7.
;TDATE= Users ending date input; this value is
; exported from AZXRBUG7.
;SPEC= Current Specimen in START LOOP.
;ORG= Current Organism in START LOOP.
;DA= Current Internal Entry Number in START LOOP.
;Y= Date used for date conversion.
;RFDATE= Starting report date in external format.
;RTDATE= Ending report date in external format.
;SPECCHK= Holds current Specimen Name.
;DIC(0)=
;DIC= Holds the file used during lookup.
;X= Lookup value for Specimen.
;ORGCHK= Holds current Organism Name.
;YN= Users input of whether to printer another report.
MAIN ;AZXRBUG6 PROGRAM CONTROL
;SET LOCAL VARIABLES
S PG=0 ;INITIALIZE PAGE NUMBER
S LN=0 ;INITIALIZE LINE COUNTER
S COUNT=0 ;INITIALIZE COUNT
S TCOUNT=0 ;INITIALIZE TCOUNT
D ^AZXRBUG7 ;CALL INPUT ROUTINE
;FOR FACILITY & DATE RANGE
I FACBKUP="Y" Q ;FACBKUP= RETURNED FROM
; ^AZXRBUG7;USER WANTS
; TO QUIT
D REPORT
D CONT
D KILL
Q
REPORT ;SETUP VALUES TO PREPARE FOR REPORT PRINT
;SET LOCAL VARIABLES
S BORDER="_______________________________________________________________________________________________"
S HEADER="Specimen Organism Count"
S %ZIS("B")="" ;DON'T USE HOME AS DEFAULT
;DEVICE
D ^%ZIS U IO ;OPEN DEVICE
I IO="" Q ;USER WANTS OUT
I IO(0)=IO W !,*7,"This report must be printed.",! G REPORT
D DTCNVRT,HEADING ;PRINT OUT FIRST PAGE HEADING
S SPEC="" ;INITIALIZE SPECIMEN
;START START LOOP
;SPECPRT= FLAG CHECK TO SEE
; IF SPECIMEN HAS
; ALREADY BEEN PRINTED
;GET SPECIMEN, ORGANISM
;GET ALL VALID DATES
;PRINT OUT ALL WHEN ALL
;DATES ARE EXHAUSTED FOR THIS
;FCLTY,SPEC,ORG,LDATE COMB.
;INCREMENT THE COUNT & TCOUNT
D
.F S SPEC=$O(^DIZ(1991020,"FSOD",FCLTY,SPEC)) Q:'SPEC S CONT="N",SPECPRT=1 D
..S ORG="" F S ORG=$O(^DIZ(1991020,"FSOD",FCLTY,SPEC,ORG)) D:('ORG)&(CONT="N") NXTSPEC Q:'ORG D
...S LDATE=FDATE-1 F S LDATE=$O(^DIZ(1991020,"FSOD",FCLTY,SPEC,ORG,LDATE)) D:(('LDATE)!(LDATE>TDATE))&COUNT PRTALL Q:('LDATE)!(LDATE>TDATE) D
....S DA="" F S DA=$O(^DIZ(1991020,"FSOD",FCLTY,SPEC,ORG,LDATE,DA)) Q:'DA D INCRMNT
I LN>(IOSL-4) D HEADING ;PRINT TCOUNT ON NEXT PAGE
W "Total Count",?90,$J(TCOUNT,5,0),!,BORDER,!
X ^%ZIS("C") ;CLOSE DEVICE
Q
NXTSPEC ;PREPARE FOR NEXT SPECIMEN
W BORDER,!!
S LN=LN+2
Q
PRTALL ;PRINT OUT THE CURRENT SPECIMEN, ORGANISM
;AND CURRENT COUNT
I SPECPRT S SPECPRT=0 D EXTSPEC ;CHECK SPECPRT TO SEE IF
;SPECIMEN HAS ALREADY BEEN
;PRINTED
D EXTORG ;PRINT OUT ORGANISM
W ?90,$J(COUNT,5,0),! ;PRINT COUNT
S LN=LN+1 ;INCREMENT LINE COUNT
S COUNT=0 ;INITIALIZE COUNT
D NEWPAGE ;CHECK IF NEW PAGE NEEDED
Q
DTCNVRT ;CONVERT TDATE & FDATE TO EXTERNAL FORMAT (RTDATE, RFDATE)
S Y=FDATE ;CONVERT TO EXTERNAL DATE
D DD^%DT ;VALUE RETURNED IN Y
S RFDATE=Y ;RFDATE= REPORT DATE
S Y=TDATE ;CONVERT TO EXTERNAL DATE
D DD^%DT ;VALUE RETURNED IN Y
S RTDATE=Y ;RTDATE= REPORT DATE
Q
NEWPAGE ;CHECK FOR WHETHER A NEW PAGE IS NEEDED
I LN>(IOSL-2) S LN=0 D HEADING S CONT="Y"
;RESET LINE COUNT
;PRINT HEADING
;INCRMNT LINE COUNT
;RE-WRITE SPECIMEN
Q
EXTSPEC ;CONVERT Specimen_Name TO EXTERNAL FORMAT
S SPECCHK=SPEC ;SPECCHK= HOLDS CURRENT
; Specimen_Name
S DIC(0)="NXZ" ;N= INTERNAL NUMBER LOOKUP
;X= EXACT MATCH REQUIRED
;Z= VALUES RETURNED IN Y=N^S
; N= INTERNAL ENTRY NUMBER
; S= VALUE OF .01 FIELD
S DIC="^DIZ(1991019," ;DIC= ORGANISM FILE
S X=SPECCHK ;X= LOOKUP VALUE (SPEC)
D ^DIC ;DO FILEMAN LOOKUP
S SPECCHK=$P(^DIZ(1991019,$P(Y,U,1),0),U,1)
;SPECCHK= Specimen_Name
W SPECCHK ;PRINT Specimen_Name
Q
EXTORG ;CONVERT Organism_Name TO EXTERNAL FORMAT
I CONT="Y" W SPECCHK,?41,"**Continued**",! S LN=LN+3,CONT="N"
;CONT
S ORGCHK=ORG ;ORGCHK= HOLDS CURRENT
; Organism_Name
S DIC(0)="NXZ" ;N= INTERNAL NUMBER LOOKUP
;X= EXACT MATCH REQUIRED
;Z= VALUES RETURNED IN Y=N^S
; N= INTERNAL ENTRY NUMBER
; S= VALUE OF .01 FIELD
S DIC="^DIZ(1991018," ;DIC= ORGANISM FILE
S X=ORGCHK ;X= LOOKUP VALUE (ORG)
D ^DIC ;DO FILEMAN LOOKUP
S ORGCHK=$P(^DIZ(1991018,$P(Y,U,1),0),U,1)
;ORGCHK= Organism_Name
W ?41,ORGCHK ;PRINT OUT ORGANISM AND COUNT
Q
INCRMNT ;INCREMENT COUNT VARIABLE
S TCOUNT=TCOUNT+1 ;INCREMENT TOTAL COUNT
S COUNT=COUNT+1 ;INCREMENT CURR. ORG COUNT
Q
HEADING ;PRINT OUT THE HEADING FOR EACH NEW PAGE
I PG>0 W # ;SEND FORMFEED
S PG=PG+1 ;INCREMENT PAGE COUNTER
W !,BORDER,!
W !,"BugDrug2 Cultured Organisms by Source"
W ?41,"From Date: ",RFDATE,?68,"--",?74,"To Date: ",RTDATE
W !!,"Facility: ",FAC,?77,"Page: ",PG
W !,BORDER
W !!,HEADER
W !,BORDER,!!
S LN=10 ;INITIALIZE LINE COUNTER
;HEADER USES 10 LINES
Q
CONT ;ASK USER WHETHER TO CONTINUE WITH REPORT PRINT
;SET LOCAL VARIABLES
S PG=0 ;INITIALIZE PAGE COUNTER
S LN=0 ;INITIALIZE LINE COUNTER
S COUNT=0 ;INITIALIZE COUNT
S TCOUNT=0 ;INITIALIZE TCOUNT
W !!!!!!!,"Do you want to print another"
R " 'Cultured Organisms by Source' report? N//",YN
;ASK USER WHETHER TO CONTINUE?
I YN?1.3"?" W !!,"Answer with: Y= Yes, N= No" G CONT
;USER WANTS HELP
I (YN?1"Y")!(YN?1"y")!(YN?1"YES")!(YN?1"yes") D ^AZXRBUG7 I FACBKUP="N" D REPORT G CONT
;FACBKUP= RETURNED FROM
; ^AZXRBUG7;USER WANTS
; TO BACK UP A PROMPT
Q
KILL ;KILL LOCAL VARIABLES AND EXIT ROUTINE AZXRBUG6
K PG,LN,COUNT,TCOUNT,FACBKUP,BORDER,HEADER,%ZIS
K LDATE,FCLTY,SPEC,ORG,DA,FDATE,TDATE,Y,RFDATE,RTDATE
K FAC,SPECCHK,DIC,X,CONT,ORGCHK,YN
Q
AZXRBUG6 ;BUGDRUG2 Report PROGRAM [ 09/23/94 9:52 AM ]
+1 ;Version 1
+2 ;"Cultured Organisms by Source"
+3 ;09/04/92 JOHN H. LYNCH
+4 ;
+5 ;ALLOWS THE DATA ENTRY PERSON TO RUN A REPORT
+6 ;GIVING INFORMATION ON THE TOTAL NUMBER OF ENTRIES
+7 ;IN THE DATABASE FOR A GIVEN FACILITY AND DATE
+8 ;RANGE, BY SPECIMEN, ORGANISM AND THE COUNT FOR
+9 ;EACH SET.
+10 +11 ;THE ROUTINES THAT CALL AZXRBUG6:
+12 ;AZXRBUG3, Reports
+13 +14 ;THE ROUTINES THAT AZXRBUG6 CALLS:
+15 ;AZXRBUG7, Reports Input
+16 ;%ZIS, Fileman Device Handler
+17 ;DD^%DT, Fileman Date Conversion
+18 ;^DIC, Fileman Lookup
+19 +20 ;Variable List
+21 ;PG= Current page count.
+22 ;LN= Current line count.
+23 ;COUNT= Organism count.
+24 ;TCOUNT= Total Organism count.
+25 ;FACBKUP= Flag returned from AZXRBUG7 with data on
+26 ; whether user wants to quit.
+27 ;BORDER= Special border for report.
+28 ;HEADER= Special header for report.
+29 ;%ZIS(B)= Don't use HOME as default device.
+30 ;LDATE= Current date used in print loop (REPORT SUB-
+31 ; ROUTINE).
+32 ;FCLTY= Current Facility in START LOOP.
+33 ;FDATE= Users starting date input; this value is
+34 ; exported from AZXRBUG7.
+35 ;TDATE= Users ending date input; this value is
+36 ; exported from AZXRBUG7.
+37 ;SPEC= Current Specimen in START LOOP.
+38 ;ORG= Current Organism in START LOOP.
+39 ;DA= Current Internal Entry Number in START LOOP.
+40 ;Y= Date used for date conversion.
+41 ;RFDATE= Starting report date in external format.
+42 ;RTDATE= Ending report date in external format.
+43 ;SPECCHK= Holds current Specimen Name.
+44 ;DIC(0)=
+45 ;DIC= Holds the file used during lookup.
+46 ;X= Lookup value for Specimen.
+47 ;ORGCHK= Holds current Organism Name.
+48 ;YN= Users input of whether to printer another report.
+49 MAIN ;AZXRBUG6 PROGRAM CONTROL
+1 ;SET LOCAL VARIABLES
+2 ;INITIALIZE PAGE NUMBER
SET PG=0
+3 ;INITIALIZE LINE COUNTER
SET LN=0
+4 ;INITIALIZE COUNT
SET COUNT=0
+5 ;INITIALIZE TCOUNT
SET TCOUNT=0
+6 +7 ;CALL INPUT ROUTINE
DO ^AZXRBUG7
+8 ;FOR FACILITY & DATE RANGE
+9 +10 ;FACBKUP= RETURNED FROM
IF FACBKUP="Y"
QUIT
+11 ; ^AZXRBUG7;USER WANTS
+12 ; TO QUIT
+13 +14 DO REPORT
+15 DO CONT
+16 DO KILL
+17 QUIT
+18 REPORT ;SETUP VALUES TO PREPARE FOR REPORT PRINT
+1 ;SET LOCAL VARIABLES
+2 SET BORDER="_______________________________________________________________________________________________"
+3 SET HEADER="Specimen Organism Count"
+4 ;DON'T USE HOME AS DEFAULT
SET %ZIS("B")=""
+5 ;DEVICE
+6 +7 ;OPEN DEVICE
DO ^%ZIS
USE IO
+8 +9 ;USER WANTS OUT
IF IO=""
QUIT
+10 IF IO(0)=IO
WRITE !,*7,"This report must be printed.",!
GOTO REPORT
+11 ;PRINT OUT FIRST PAGE HEADING
DO DTCNVRT
DO HEADING
+12 +13 ;INITIALIZE SPECIMEN
SET SPEC=""
+14 +15 ;START START LOOP
+16 ;SPECPRT= FLAG CHECK TO SEE
+17 ; IF SPECIMEN HAS
+18 ; ALREADY BEEN PRINTED
+19 ;GET SPECIMEN, ORGANISM
+20 ;GET ALL VALID DATES
+21 ;PRINT OUT ALL WHEN ALL
+22 ;DATES ARE EXHAUSTED FOR THIS
+23 ;FCLTY,SPEC,ORG,LDATE COMB.
+24 ;INCREMENT THE COUNT & TCOUNT
+25 Begin DoDot:1
+26 FOR
SET SPEC=$ORDER(^DIZ(1991020,"FSOD",FCLTY,SPEC))
IF 'SPEC
QUIT
SET CONT="N"
SET SPECPRT=1
Begin DoDot:2
+27 SET ORG=""
FOR
SET ORG=$ORDER(^DIZ(1991020,"FSOD",FCLTY,SPEC,ORG))
IF ('ORG)&(CONT="N")
DO NXTSPEC
IF 'ORG
QUIT
Begin DoDot:3
+28 SET LDATE=FDATE-1
FOR
SET LDATE=$ORDER(^DIZ(1991020,"FSOD",FCLTY,SPEC,ORG,LDATE))
IF (('LDATE)!(LDATE>TDATE))&COUNT
DO PRTALL
IF ('LDATE)!(LDATE>TDATE)
QUIT
Begin DoDot:4
+29 SET DA=""
FOR
SET DA=$ORDER(^DIZ(1991020,"FSOD",FCLTY,SPEC,ORG,LDATE,DA))
IF 'DA
QUIT
DO INCRMNT
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+30 ;PRINT TCOUNT ON NEXT PAGE
IF LN>(IOSL-4)
DO HEADING
+31 WRITE "Total Count",?90,$JUSTIFY(TCOUNT,5,0),!,BORDER,!
+32 +33 +34 ;CLOSE DEVICE
XECUTE ^%ZIS("C")
+35 QUIT
+36 NXTSPEC ;PREPARE FOR NEXT SPECIMEN
+1 WRITE BORDER,!!
+2 SET LN=LN+2
+3 QUIT
+4 PRTALL ;PRINT OUT THE CURRENT SPECIMEN, ORGANISM
+1 ;AND CURRENT COUNT
+2 ;CHECK SPECPRT TO SEE IF
IF SPECPRT
SET SPECPRT=0
DO EXTSPEC
+3 ;SPECIMEN HAS ALREADY BEEN
+4 ;PRINTED
+5 ;PRINT OUT ORGANISM
DO EXTORG
+6 ;PRINT COUNT
WRITE ?90,$JUSTIFY(COUNT,5,0),!
+7 ;INCREMENT LINE COUNT
SET LN=LN+1
+8 ;INITIALIZE COUNT
SET COUNT=0
+9 ;CHECK IF NEW PAGE NEEDED
DO NEWPAGE
+10 QUIT
+11 DTCNVRT ;CONVERT TDATE & FDATE TO EXTERNAL FORMAT (RTDATE, RFDATE)
+1 ;CONVERT TO EXTERNAL DATE
SET Y=FDATE
+2 ;VALUE RETURNED IN Y
DO DD^%DT
+3 ;RFDATE= REPORT DATE
SET RFDATE=Y
+4 +5 ;CONVERT TO EXTERNAL DATE
SET Y=TDATE
+6 ;VALUE RETURNED IN Y
DO DD^%DT
+7 ;RTDATE= REPORT DATE
SET RTDATE=Y
+8 QUIT
+9 NEWPAGE ;CHECK FOR WHETHER A NEW PAGE IS NEEDED
+1 IF LN>(IOSL-2)
SET LN=0
DO HEADING
SET CONT="Y"
+2 ;RESET LINE COUNT
+3 ;PRINT HEADING
+4 ;INCRMNT LINE COUNT
+5 ;RE-WRITE SPECIMEN
+6 QUIT
+7 EXTSPEC ;CONVERT Specimen_Name TO EXTERNAL FORMAT
+1 ;SPECCHK= HOLDS CURRENT
SET SPECCHK=SPEC
+2 ; Specimen_Name
+3 ;N= INTERNAL NUMBER LOOKUP
SET DIC(0)="NXZ"
+4 ;X= EXACT MATCH REQUIRED
+5 ;Z= VALUES RETURNED IN Y=N^S
+6 ; N= INTERNAL ENTRY NUMBER
+7 ; S= VALUE OF .01 FIELD
+8 +9 ;DIC= ORGANISM FILE
SET DIC="^DIZ(1991019,"
+10 ;X= LOOKUP VALUE (SPEC)
SET X=SPECCHK
+11 ;DO FILEMAN LOOKUP
DO ^DIC
+12 SET SPECCHK=$PIECE(^DIZ(1991019,$PIECE(Y,U,1),0),U,1)
+13 ;SPECCHK= Specimen_Name
+14 +15 ;PRINT Specimen_Name
WRITE SPECCHK
+16 QUIT
+17 EXTORG ;CONVERT Organism_Name TO EXTERNAL FORMAT
+1 IF CONT="Y"
WRITE SPECCHK,?41,"**Continued**",!
SET LN=LN+3
SET CONT="N"
+2 ;CONT
+3 +4 ;ORGCHK= HOLDS CURRENT
SET ORGCHK=ORG
+5 ; Organism_Name
+6 ;N= INTERNAL NUMBER LOOKUP
SET DIC(0)="NXZ"
+7 ;X= EXACT MATCH REQUIRED
+8 ;Z= VALUES RETURNED IN Y=N^S
+9 ; N= INTERNAL ENTRY NUMBER
+10 ; S= VALUE OF .01 FIELD
+11 +12 ;DIC= ORGANISM FILE
SET DIC="^DIZ(1991018,"
+13 ;X= LOOKUP VALUE (ORG)
SET X=ORGCHK
+14 ;DO FILEMAN LOOKUP
DO ^DIC
+15 SET ORGCHK=$PIECE(^DIZ(1991018,$PIECE(Y,U,1),0),U,1)
+16 ;ORGCHK= Organism_Name
+17 +18 ;PRINT OUT ORGANISM AND COUNT
WRITE ?41,ORGCHK
+19 QUIT
+20 INCRMNT ;INCREMENT COUNT VARIABLE
+1 ;INCREMENT TOTAL COUNT
SET TCOUNT=TCOUNT+1
+2 ;INCREMENT CURR. ORG COUNT
SET COUNT=COUNT+1
+3 QUIT
+4 HEADING ;PRINT OUT THE HEADING FOR EACH NEW PAGE
+1 +2 ;SEND FORMFEED
IF PG>0
WRITE #
+3 ;INCREMENT PAGE COUNTER
SET PG=PG+1
+4 +5 WRITE !,BORDER,!
+6 WRITE !,"BugDrug2 Cultured Organisms by Source"
+7 WRITE ?41,"From Date: ",RFDATE,?68,"--",?74,"To Date: ",RTDATE
+8 WRITE !!,"Facility: ",FAC,?77,"Page: ",PG
+9 WRITE !,BORDER
+10 WRITE !!,HEADER
+11 WRITE !,BORDER,!!
+12 +13 ;INITIALIZE LINE COUNTER
SET LN=10
+14 ;HEADER USES 10 LINES
+15 QUIT
+16 CONT ;ASK USER WHETHER TO CONTINUE WITH REPORT PRINT
+1 ;SET LOCAL VARIABLES
+2 ;INITIALIZE PAGE COUNTER
SET PG=0
+3 ;INITIALIZE LINE COUNTER
SET LN=0
+4 ;INITIALIZE COUNT
SET COUNT=0
+5 ;INITIALIZE TCOUNT
SET TCOUNT=0
+6 +7 WRITE !!!!!!!,"Do you want to print another"
+8 READ " 'Cultured Organisms by Source' report? N//",YN
+9 ;ASK USER WHETHER TO CONTINUE?
+10 +11 IF YN?1.3"?"
WRITE !!,"Answer with: Y= Yes, N= No"
GOTO CONT
+12 ;USER WANTS HELP
+13 IF (YN?1"Y")!(YN?1"y")!(YN?1"YES")!(YN?1"yes")
DO ^AZXRBUG7
IF FACBKUP="N"
DO REPORT
GOTO CONT
+14 ;FACBKUP= RETURNED FROM
+15 ; ^AZXRBUG7;USER WANTS
+16 ; TO BACK UP A PROMPT
+17 QUIT
+18 KILL ;KILL LOCAL VARIABLES AND EXIT ROUTINE AZXRBUG6
+1 KILL PG,LN,COUNT,TCOUNT,FACBKUP,BORDER,HEADER,%ZIS
+2 KILL LDATE,FCLTY,SPEC,ORG,DA,FDATE,TDATE,Y,RFDATE,RTDATE
+3 KILL FAC,SPECCHK,DIC,X,CONT,ORGCHK,YN
+4 QUIT