SCRPW58 ;RENO/KEITH - Most Frequent 20 Practitioner Types (OP8) or (IP8); 15 Jul 98 8:28 PM
;;5.3;Scheduling;**144,466,1015**;AUG 13, 1993;Build 21
;Most Frequent 20 Practitioner Types (OP8) or (IP8)
S SDSTA=$G(SDSTA,2)
D RQUE^SCRPW50("START^SCRPW58","Most Frequent 20 Practitioner Types "_$S(SDSTA=2:"(OP8)",1:"(IP8)"),1) Q
;
START ;Print report
K ^TMP("SCRPW",$J) S (SDSTOP,SDOUT)=0,SDT=SD("FYD")
F S SDT=$O(^SCE("B",SDT)) Q:'SDT!SDOUT!(SDT>SD("EDT")) S SDOE=0 F S SDOE=$O(^SCE("B",SDT,SDOE)) Q:'SDOE!SDOUT S SDOE0=$$GETOE^SDOE(SDOE),SDIV=$P(SDOE0,U,11) I $$VALID() D SET(SDIV) D:SDMD SET(0)
G:SDOUT EXIT S (SDVCT,SDIV)=""
F S SDIV=$O(^TMP("SCRPW",$J,SDIV)) Q:SDIV=""!SDOUT D STOP,DLIST S SDX="" F S SDX=$O(^TMP("SCRPW",$J,SDIV,0,SDX)) Q:SDX=""!SDOUT S SDI=^TMP("SCRPW",$J,SDIV,0,SDX),^TMP("SCRPW",$J,SDIV,1,SDI,SDX)=""
G:SDOUT EXIT S SDLINE="",$P(SDLINE,"-",(IOM+1))="" D NOW^%DTC S Y=% X ^DD("DD") S SDPNOW=$P(Y,":",1,2),SDTIT(1)="<*> MOST FREQUENT 20 PRACTITIONER TYPES "_$S(SDSTA=2:"(OP8)",1:"(IP8)")_" <*>",SDPG=0 D:$E(IOST)="C" DISP0^SCRPW23
I '$D(^TMP("SCRPW",$J)) S SDPAGE=1,SDX="No activity found within report parameters." D HDR G:SDOUT EXIT W !!?(IOM-$L(SDX)\2),SDX G EXIT
G:SDOUT EXIT S SDIVN="" F S SDIVN=$O(SDIV(SDIVN)) Q:SDIVN=""!SDOUT D DPRT(SDIV(SDIVN))
G:SDOUT EXIT D:SDVCT>1 DPRT(0)
EXIT I $E(IOST)="C",'SDOUT N DIR S DIR(0)="E" D ^DIR
K ^TMP("SCRPW",$J),%,%H,%I,DIR,SD,SDARY,SDCD,SDDIV,SDI,SDII,SDIV,SDIVN,SDLINE,SDMD,SDOE,SDOE0,SDOUT,SDPAGE,SDPC,SDPG,SDPNOW,SDSPE,SDSTOP,SDSUB,SDT,SDTIT,SDV,SDVCT,SDX,X,Y,SDSTA Q
;
DPRT(SDV) ;Print division
;Required input: SDV=division ifn or '0' for combined divisions
I SDV S SDTIT(2)="For "_$S(SDDIV["DIVISIONS":"division",1:"facility")_": "_SDIVN
I 'SDV S SDTIT(2)="Report for: "_$P(SDDIV,U,2) D
.S SDI=2,SDIVN="" F S SDIVN=$O(SDIV(SDIVN)) Q:SDIVN="" S SDI=SDI+1,SDTIT(SDI)=$J("Division: ",$L(SDIVN))_SDIVN
.Q
S SDPAGE=1 D HDR,HD1 Q:SDOUT S (SDI,SDII)="" F S SDI=$O(^TMP("SCRPW",$J,SDV,1,SDI),-1) Q:SDI=""!SDOUT!(SDII>19) S SDX="" F S SDX=$O(^TMP("SCRPW",$J,SDV,1,SDI,SDX)) Q:SDX=""!SDOUT!(SDII>19) D PLINE
Q
;
PLINE ;Print output line
D:$Y>(IOSL-4) HDR,HD1 Q:SDOUT
S SDPC=$$CODE2TXT^XUA4A72(SDX) Q:'$L(SDPC)
S SDCD=+$P(SDX,"V",2),SDSPE=$P(SDPC,U,2),SDSUB=$P(SDPC,U,3),SDII=SDII+1
W !,$J(SDII,3,0),?6,$J(SDCD,7,0),?15,$E(SDSPE,1,51),?68,$E(SDSUB,1,52),?122,$J(SDI,10,0)
Q
;
HDR ;Print header
I $E(IOST)="C",SDPG N DIR S DIR(0)="E" W ! D ^DIR S SDOUT=Y'=1 Q:SDOUT
D STOP Q:SDOUT W:SDPG!($E(IOST)="C") $$XY^SCRPW50(IOF,1,0) W:$X $$XY^SCRPW50("",0,0)
N SDI S SDI=0 W SDLINE F S SDI=$O(SDTIT(SDI)) Q:'SDI W !?(IOM-$L(SDTIT(SDI))\2),SDTIT(SDI)
W !,SDLINE,!,"For Fiscal Year activity through ",SD("PEDT"),!,"Date printed: ",SDPNOW,?(IOM-6-$L(SDPAGE)),"Page: ",SDPAGE,!,SDLINE S SDPAGE=SDPAGE+1,SDPG=1 Q
;
HD1 ;Print subheader
Q:SDOUT W !,"Rank",?6,"VA Code",?15,"Specialty",?68,"Subspecialty",?123,"Frequency",!,"---- ------- ",$E(SDLINE,1,51),?68,$E(SDLINE,1,52),?122,"----------" Q
;
DLIST ;Create alphabetic list of divisions found
Q:'SDIV S SDX=$P($G(^DG(40.8,SDIV,0)),U) S:'$L(SDX) SDX="*** UNKNOWN ***" S SDIV(SDX)=SDIV,SDVCT=SDVCT+1 Q
;
VALID() ;Check encounter record
I $P(SDOE0,U,4),$P($G(^SC($P(SDOE0,U,4),0)),U,17)="Y" Q 0
I SDIV,$$DIV(),$P(SDOE0,U,2),'$P(SDOE0,U,6),$P(SDOE0,U,7),$P(SDOE0,U,12)=SDSTA Q 1
Q 0
;
DIV() ;Check division
Q:'SDDIV 1 Q $D(SDDIV(SDIV))
;
STOP ;Check for stop task request
S:$D(ZTQUEUED) (SDOUT,ZTSTOP)=$S($$S^%ZTLOAD:1,1:0) Q
;
SET(SDIV) ;Set division lists
;Required input: SDIV=division ifn or '0' for summary
S SDSTOP=SDSTOP+1 I SDSTOP#2000=0 D STOP^SCRPW40 Q:SDOUT
N SDARY,SDI,SDX
D PROV^SCRPW50(SDOE,.SDARY)
S SDI=0 F S SDI=$O(SDARY(SDI)) Q:'SDI S SDX=SDARY(SDI) I $L(SDX) D
.S ^TMP("SCRPW",$J,SDIV,0,SDX)=$G(^TMP("SCRPW",$J,SDIV,0,SDX))+1
.Q
Q
SCRPW58 ;RENO/KEITH - Most Frequent 20 Practitioner Types (OP8) or (IP8); 15 Jul 98 8:28 PM
+1 ;;5.3;Scheduling;**144,466,1015**;AUG 13, 1993;Build 21
+2 ;Most Frequent 20 Practitioner Types (OP8) or (IP8)
+3 SET SDSTA=$GET(SDSTA,2)
+4 DO RQUE^SCRPW50("START^SCRPW58","Most Frequent 20 Practitioner Types "_$SELECT(SDSTA=2:"(OP8)",1:"(IP8)"),1)
QUIT
+5 ;
START ;Print report
+1 KILL ^TMP("SCRPW",$JOB)
SET (SDSTOP,SDOUT)=0
SET SDT=SD("FYD")
+2 FOR
SET SDT=$ORDER(^SCE("B",SDT))
IF 'SDT!SDOUT!(SDT>SD("EDT"))
QUIT
SET SDOE=0
FOR
SET SDOE=$ORDER(^SCE("B",SDT,SDOE))
IF 'SDOE!SDOUT
QUIT
SET SDOE0=$$GETOE^SDOE(SDOE)
SET SDIV=$PIECE(SDOE0,U,11)
IF $$VALID()
DO SET(SDIV)
IF SDMD
DO SET(0)
+3 IF SDOUT
GOTO EXIT
SET (SDVCT,SDIV)=""
+4 FOR
SET SDIV=$ORDER(^TMP("SCRPW",$JOB,SDIV))
IF SDIV=""!SDOUT
QUIT
DO STOP
DO DLIST
SET SDX=""
FOR
SET SDX=$ORDER(^TMP("SCRPW",$JOB,SDIV,0,SDX))
IF SDX=""!SDOUT
QUIT
SET SDI=^TMP("SCRPW",$JOB,SDIV,0,SDX)
SET ^TMP("SCRPW",$JOB,SDIV,1,SDI,SDX)=""
+5 IF SDOUT
GOTO EXIT
SET SDLINE=""
SET $PIECE(SDLINE,"-",(IOM+1))=""
DO NOW^%DTC
SET Y=%
XECUTE ^DD("DD")
SET SDPNOW=$PIECE(Y,":",1,2)
SET SDTIT(1)="<*> MOST FREQUENT 20 PRACTITIONER TYPES "_$SELECT(SDSTA=2:"(OP8)",1:"(IP8)")_" <*>"
SET SDPG=0
IF $EXTRACT(IOST)="C"
DO DISP0^SCRPW23
+6 IF '$DATA(^TMP("SCRPW",$JOB))
SET SDPAGE=1
SET SDX="No activity found within report parameters."
DO HDR
IF SDOUT
GOTO EXIT
WRITE !!?(IOM-$LENGTH(SDX)\2),SDX
GOTO EXIT
+7 IF SDOUT
GOTO EXIT
SET SDIVN=""
FOR
SET SDIVN=$ORDER(SDIV(SDIVN))
IF SDIVN=""!SDOUT
QUIT
DO DPRT(SDIV(SDIVN))
+8 IF SDOUT
GOTO EXIT
IF SDVCT>1
DO DPRT(0)
EXIT IF $EXTRACT(IOST)="C"
IF 'SDOUT
NEW DIR
SET DIR(0)="E"
DO ^DIR
+1 KILL ^TMP("SCRPW",$JOB),%,%H,%I,DIR,SD,SDARY,SDCD,SDDIV,SDI,SDII,SDIV,SDIVN,SDLINE,SDMD,SDOE,SDOE0,SDOUT,SDPAGE,SDPC,SDPG,SDPNOW,SDSPE,SDSTOP,SDSUB,SDT,SDTIT,SDV,SDVCT,SDX,X,Y,SDSTA
QUIT
+2 ;
DPRT(SDV) ;Print division
+1 ;Required input: SDV=division ifn or '0' for combined divisions
+2 IF SDV
SET SDTIT(2)="For "_$SELECT(SDDIV["DIVISIONS":"division",1:"facility")_": "_SDIVN
+3 IF 'SDV
SET SDTIT(2)="Report for: "_$PIECE(SDDIV,U,2)
Begin DoDot:1
+4 SET SDI=2
SET SDIVN=""
FOR
SET SDIVN=$ORDER(SDIV(SDIVN))
IF SDIVN=""
QUIT
SET SDI=SDI+1
SET SDTIT(SDI)=$JUSTIFY("Division: ",$LENGTH(SDIVN))_SDIVN
+5 QUIT
End DoDot:1
+6 SET SDPAGE=1
DO HDR
DO HD1
IF SDOUT
QUIT
SET (SDI,SDII)=""
FOR
SET SDI=$ORDER(^TMP("SCRPW",$JOB,SDV,1,SDI),-1)
IF SDI=""!SDOUT!(SDII>19)
QUIT
SET SDX=""
FOR
SET SDX=$ORDER(^TMP("SCRPW",$JOB,SDV,1,SDI,SDX))
IF SDX=""!SDOUT!(SDII>19)
QUIT
DO PLINE
+7 QUIT
+8 ;
PLINE ;Print output line
+1 IF $Y>(IOSL-4)
DO HDR
DO HD1
IF SDOUT
QUIT
+2 SET SDPC=$$CODE2TXT^XUA4A72(SDX)
IF '$LENGTH(SDPC)
QUIT
+3 SET SDCD=+$PIECE(SDX,"V",2)
SET SDSPE=$PIECE(SDPC,U,2)
SET SDSUB=$PIECE(SDPC,U,3)
SET SDII=SDII+1
+4 WRITE !,$JUSTIFY(SDII,3,0),?6,$JUSTIFY(SDCD,7,0),?15,$EXTRACT(SDSPE,1,51),?68,$EXTRACT(SDSUB,1,52),?122,$JUSTIFY(SDI,10,0)
+5 QUIT
+6 ;
HDR ;Print header
+1 IF $EXTRACT(IOST)="C"
IF SDPG
NEW DIR
SET DIR(0)="E"
WRITE !
DO ^DIR
SET SDOUT=Y'=1
IF SDOUT
QUIT
+2 DO STOP
IF SDOUT
QUIT
IF SDPG!($EXTRACT(IOST)="C")
WRITE $$XY^SCRPW50(IOF,1,0)
IF $X
WRITE $$XY^SCRPW50("",0,0)
+3 NEW SDI
SET SDI=0
WRITE SDLINE
FOR
SET SDI=$ORDER(SDTIT(SDI))
IF 'SDI
QUIT
WRITE !?(IOM-$LENGTH(SDTIT(SDI))\2),SDTIT(SDI)
+4 WRITE !,SDLINE,!,"For Fiscal Year activity through ",SD("PEDT"),!,"Date printed: ",SDPNOW,?(IOM-6-$LENGTH(SDPAGE)),"Page: ",SDPAGE,!,SDLINE
SET SDPAGE=SDPAGE+1
SET SDPG=1
QUIT
+5 ;
HD1 ;Print subheader
+1 IF SDOUT
QUIT
WRITE !,"Rank",?6,"VA Code",?15,"Specialty",?68,"Subspecialty",?123,"Frequency",!,"---- ------- ",$EXTRACT(SDLINE,1,51),?68,$EXTRACT(SDLINE,1,52),?122,"----------"
QUIT
+2 ;
DLIST ;Create alphabetic list of divisions found
+1 IF 'SDIV
QUIT
SET SDX=$PIECE($GET(^DG(40.8,SDIV,0)),U)
IF '$LENGTH(SDX)
SET SDX="*** UNKNOWN ***"
SET SDIV(SDX)=SDIV
SET SDVCT=SDVCT+1
QUIT
+2 ;
VALID() ;Check encounter record
+1 IF $PIECE(SDOE0,U,4)
IF $PIECE($GET(^SC($PIECE(SDOE0,U,4),0)),U,17)="Y"
QUIT 0
+2 IF SDIV
IF $$DIV()
IF $PIECE(SDOE0,U,2)
IF '$PIECE(SDOE0,U,6)
IF $PIECE(SDOE0,U,7)
IF $PIECE(SDOE0,U,12)=SDSTA
QUIT 1
+3 QUIT 0
+4 ;
DIV() ;Check division
+1 IF 'SDDIV
QUIT 1
QUIT $DATA(SDDIV(SDIV))
+2 ;
STOP ;Check for stop task request
+1 IF $DATA(ZTQUEUED)
SET (SDOUT,ZTSTOP)=$SELECT($$S^%ZTLOAD:1,1:0)
QUIT
+2 ;
SET(SDIV) ;Set division lists
+1 ;Required input: SDIV=division ifn or '0' for summary
+2 SET SDSTOP=SDSTOP+1
IF SDSTOP#2000=0
DO STOP^SCRPW40
IF SDOUT
QUIT
+3 NEW SDARY,SDI,SDX
+4 DO PROV^SCRPW50(SDOE,.SDARY)
+5 SET SDI=0
FOR
SET SDI=$ORDER(SDARY(SDI))
IF 'SDI
QUIT
SET SDX=SDARY(SDI)
IF $LENGTH(SDX)
Begin DoDot:1
+6 SET ^TMP("SCRPW",$JOB,SDIV,0,SDX)=$GET(^TMP("SCRPW",$JOB,SDIV,0,SDX))+1
+7 QUIT
End DoDot:1
+8 QUIT