APCLYV42 ; IHS/CMI/LAB - CLINIC VISIT COUNTS PRINT ;
;;2.0;IHS PCC SUITE;;MAY 14, 2009
;
INIT ;initialize variables
I APCLBD=APCLED,(APCLCL="A") G ^APCLYV43 ;print rtn for one date & all clinics
I '$D(^XTMP("APCLYV4",APCLJOB,APCLBT)) S APCLPAGE=0,APCLSTOP="" D HEAD0
S APCLPAGE=0,APCLSTOP="",APCLTOT=0 ;total count
;
SET ;set up print fields
S APCLCLP=0
SET0 S APCLCLP=$O(^XTMP("APCLYV4",APCLJOB,APCLBT,APCLCLP)) G FINAL:APCLCLP=""
S APCLCLX=0
SET1 S APCLCLX=$O(^XTMP("APCLYV4",APCLJOB,APCLBT,APCLCLP,APCLCLX)) G SET0:APCLCLX=""
S (APCLVDT,APCLCTOT)=0 D HEAD
SET2 S APCLVDT=$O(^XTMP("APCLYV4",APCLJOB,APCLBT,APCLCLP,APCLCLX,APCLVDT))
I APCLVDT="" D TOTALS G END:APCLSTOP="^",SET1
S APCLCNT=^XTMP("APCLYV4",APCLJOB,APCLBT,APCLCLP,APCLCLX,APCLVDT),APCLCTOT=APCLCTOT+APCLCNT
I $Y>(IOSL-5) D PAGE G:APCLSTOP="^" END
W !?21,$E(APCLVDT,4,5),"/",$E(APCLVDT,6,7),"/",$E(APCLVDT,2,3)
W ?45,$J(APCLCNT,5) G SET2
;
FINAL ;print grand totals
G END:APCLCL'="A"
I $Y>(IOSL-5) D PAGE G:APCLSTOP="^" END
W !!?30,"TOTAL VISITS: ",$J(APCLTOT,5),!!
END ;
D DONE^APCLOSUT
K APCLCTOT,APCLTOT,APCLCLX,APCLVDT,APCLPAGE,APCLSTOP,APCLCNT,APCLCLP
W:IOST'?1"C-".E @IOF
K ^XTMP("APCLYV4",APCLJOB,APCLBT)
Q
;
TOTALS ;print totals
I $Y>(IOSL-5) D PAGE G:APCLSTOP="^" END
W !!?21,"TOTAL VISITS FOR CLINIC:",?45,$J(APCLCTOT,5)
S APCLTOT=APCLTOT+APCLCTOT
;
I $E(IOST)="C",IO=IO(0) W ! S DIR(0)="E" D ^DIR K DIR I Y=0!(Y="^")!($D(DTOUT)) S APCLSTOP="^" Q
Q
;
HEAD W:$D(IOF) @IOF S X=$P(^DIC(4,DUZ(2),0),"^"),APCLPAGE=APCLPAGE+1
W !!,$P(^VA(200,DUZ,0),"^",2),?(80-$L(X)/2),X,?70,"Page ",APCLPAGE
S X=$P($H,",",2) D TIME W !,Y
S Y="" I $G(APCLCLX)]"" S Y=$S($D(^DIC(40.7,APCLCLX,0)):$P(^(0),"^",2),1:"??") ;clinic code
S X="VISIT COUNTS FOR "_APCLCLP_" ("_Y_") "_"CLINIC"
W ?(80-$L(X)/2),X
S Y=DT X ^DD("DD") W !,Y
W ?28,"for ",$E(APCLBD,4,5),"/",$E(APCLBD,6,7),"/",$E(APCLBD,2,3)
W " to ",$E(APCLED,4,5),"/",$E(APCLED,6,7),"/",$E(APCLED,2,3)
W !!?20,"VISIT DATES",?41,"NUMBER OF VISITS"
Q
;
HEAD0 ;EP
W:$D(IOF) @IOF S X=$P(^DIC(4,DUZ(2),0),"^"),APCLPAGE=APCLPAGE+1
W !!,$P(^VA(200,DUZ,0),"^",2),?(80-$L(X)/2),X,?70,"Page ",APCLPAGE
S X=$P($H,",",2) D TIME W !,Y
S Y="" I $G(APCLCLX)]"" S Y=$S($D(^DIC(40.7,APCLCLX,0)):$P(^(0),"^",2),1:"??") ;clinic code
S Y=DT X ^DD("DD") W !,Y
W ?28,"for ",$E(APCLBD,4,5),"/",$E(APCLBD,6,7),"/",$E(APCLBD,2,3)
W " to ",$E(APCLED,4,5),"/",$E(APCLED,6,7),"/",$E(APCLED,2,3)
W !!!!,"NUMBER OF VISITS: ","No visits to report." G END
PAGE ;form feed to new page
I IOST'?1"C-".E D HEAD Q
;
I $E(IOST)="C",IO=IO(0) W ! S DIR(0)="E" D ^DIR K DIR I Y=0!(Y="^")!($D(DTOUT)) S APCLSTOP="^" Q
I APCLSTOP'="^" D HEAD
Q
TIME S Y="" Q:'$D(X) Q:X<0!(X>86400)
S %A=X\60,%B=%A\60 S:%B>12 %B=%B-12 S:%B=0 %B=12 S:%B<10 %B=" "_%B
S %C=$S(%A=0:"M ",%A=720:"N ",%A=1440:"M ",%A<720:"am",1:"pm")
S Y=%B_":"_$E(%A#60+100,2,3)_" "_%C K %A,%B,%C Q
APCLYV42 ; IHS/CMI/LAB - CLINIC VISIT COUNTS PRINT ;
+1 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
+2 ;
INIT ;initialize variables
+1 ;print rtn for one date & all clinics
IF APCLBD=APCLED
IF (APCLCL="A")
GOTO ^APCLYV43
+2 IF '$DATA(^XTMP("APCLYV4",APCLJOB,APCLBT))
SET APCLPAGE=0
SET APCLSTOP=""
DO HEAD0
+3 ;total count
SET APCLPAGE=0
SET APCLSTOP=""
SET APCLTOT=0
+4 ;
SET ;set up print fields
+1 SET APCLCLP=0
SET0 SET APCLCLP=$ORDER(^XTMP("APCLYV4",APCLJOB,APCLBT,APCLCLP))
IF APCLCLP=""
GOTO FINAL
+1 SET APCLCLX=0
SET1 SET APCLCLX=$ORDER(^XTMP("APCLYV4",APCLJOB,APCLBT,APCLCLP,APCLCLX))
IF APCLCLX=""
GOTO SET0
+1 SET (APCLVDT,APCLCTOT)=0
DO HEAD
SET2 SET APCLVDT=$ORDER(^XTMP("APCLYV4",APCLJOB,APCLBT,APCLCLP,APCLCLX,APCLVDT))
+1 IF APCLVDT=""
DO TOTALS
IF APCLSTOP="^"
GOTO END
GOTO SET1
+2 SET APCLCNT=^XTMP("APCLYV4",APCLJOB,APCLBT,APCLCLP,APCLCLX,APCLVDT)
SET APCLCTOT=APCLCTOT+APCLCNT
+3 IF $Y>(IOSL-5)
DO PAGE
IF APCLSTOP="^"
GOTO END
+4 WRITE !?21,$EXTRACT(APCLVDT,4,5),"/",$EXTRACT(APCLVDT,6,7),"/",$EXTRACT(APCLVDT,2,3)
+5 WRITE ?45,$JUSTIFY(APCLCNT,5)
GOTO SET2
+6 ;
FINAL ;print grand totals
+1 IF APCLCL'="A"
GOTO END
+2 IF $Y>(IOSL-5)
DO PAGE
IF APCLSTOP="^"
GOTO END
+3 WRITE !!?30,"TOTAL VISITS: ",$JUSTIFY(APCLTOT,5),!!
END ;
+1 DO DONE^APCLOSUT
+2 KILL APCLCTOT,APCLTOT,APCLCLX,APCLVDT,APCLPAGE,APCLSTOP,APCLCNT,APCLCLP
+3 IF IOST'?1"C-".E
WRITE @IOF
+4 KILL ^XTMP("APCLYV4",APCLJOB,APCLBT)
+5 QUIT
+6 ;
TOTALS ;print totals
+1 IF $Y>(IOSL-5)
DO PAGE
IF APCLSTOP="^"
GOTO END
+2 WRITE !!?21,"TOTAL VISITS FOR CLINIC:",?45,$JUSTIFY(APCLCTOT,5)
+3 SET APCLTOT=APCLTOT+APCLCTOT
+4 ;
+5 IF $EXTRACT(IOST)="C"
IF IO=IO(0)
WRITE !
SET DIR(0)="E"
DO ^DIR
KILL DIR
IF Y=0!(Y="^")!($DATA(DTOUT))
SET APCLSTOP="^"
QUIT
+6 QUIT
+7 ;
HEAD IF $DATA(IOF)
WRITE @IOF
SET X=$PIECE(^DIC(4,DUZ(2),0),"^")
SET APCLPAGE=APCLPAGE+1
+1 WRITE !!,$PIECE(^VA(200,DUZ,0),"^",2),?(80-$LENGTH(X)/2),X,?70,"Page ",APCLPAGE
+2 SET X=$PIECE($HOROLOG,",",2)
DO TIME
WRITE !,Y
+3 ;clinic code
SET Y=""
IF $GET(APCLCLX)]""
SET Y=$SELECT($DATA(^DIC(40.7,APCLCLX,0)):$PIECE(^(0),"^",2),1:"??")
+4 SET X="VISIT COUNTS FOR "_APCLCLP_" ("_Y_") "_"CLINIC"
+5 WRITE ?(80-$LENGTH(X)/2),X
+6 SET Y=DT
XECUTE ^DD("DD")
WRITE !,Y
+7 WRITE ?28,"for ",$EXTRACT(APCLBD,4,5),"/",$EXTRACT(APCLBD,6,7),"/",$EXTRACT(APCLBD,2,3)
+8 WRITE " to ",$EXTRACT(APCLED,4,5),"/",$EXTRACT(APCLED,6,7),"/",$EXTRACT(APCLED,2,3)
+9 WRITE !!?20,"VISIT DATES",?41,"NUMBER OF VISITS"
+10 QUIT
+11 ;
HEAD0 ;EP
+1 IF $DATA(IOF)
WRITE @IOF
SET X=$PIECE(^DIC(4,DUZ(2),0),"^")
SET APCLPAGE=APCLPAGE+1
+2 WRITE !!,$PIECE(^VA(200,DUZ,0),"^",2),?(80-$LENGTH(X)/2),X,?70,"Page ",APCLPAGE
+3 SET X=$PIECE($HOROLOG,",",2)
DO TIME
WRITE !,Y
+4 ;clinic code
SET Y=""
IF $GET(APCLCLX)]""
SET Y=$SELECT($DATA(^DIC(40.7,APCLCLX,0)):$PIECE(^(0),"^",2),1:"??")
+5 SET Y=DT
XECUTE ^DD("DD")
WRITE !,Y
+6 WRITE ?28,"for ",$EXTRACT(APCLBD,4,5),"/",$EXTRACT(APCLBD,6,7),"/",$EXTRACT(APCLBD,2,3)
+7 WRITE " to ",$EXTRACT(APCLED,4,5),"/",$EXTRACT(APCLED,6,7),"/",$EXTRACT(APCLED,2,3)
+8 WRITE !!!!,"NUMBER OF VISITS: ","No visits to report."
GOTO END
PAGE ;form feed to new page
+1 IF IOST'?1"C-".E
DO HEAD
QUIT
+2 ;
+3 IF $EXTRACT(IOST)="C"
IF IO=IO(0)
WRITE !
SET DIR(0)="E"
DO ^DIR
KILL DIR
IF Y=0!(Y="^")!($DATA(DTOUT))
SET APCLSTOP="^"
QUIT
+4 IF APCLSTOP'="^"
DO HEAD
+5 QUIT
TIME SET Y=""
IF '$DATA(X)
QUIT
IF X<0!(X>86400)
QUIT
+1 SET %A=X\60
SET %B=%A\60
IF %B>12
SET %B=%B-12
IF %B=0
SET %B=12
IF %B<10
SET %B=" "_%B
+2 SET %C=$SELECT(%A=0:"M ",%A=720:"N ",%A=1440:"M ",%A<720:"am",1:"pm")
+3 SET Y=%B_":"_$EXTRACT(%A#60+100,2,3)_" "_%C
KILL %A,%B,%C
QUIT