VistA-WorldVistAEHR/r/NURSING_SERVICE-NUR/NURA9D2.m

90 lines
5.2 KiB
Mathematica

NURA9D2 ;HIRMFO/YH,MH,MD,RM,FT-FTEE PROFILE BY LOCATION AND SERVICE POSITION ;5/2/97
;;4.0;NURSING SERVICE;**1,13**;Apr 25, 1997
Q:'$D(^DIC(213.9,1,"OFF")) Q:$P(^DIC(213.9,1,"OFF"),"^",1)=1
S (NURPLSW,NURMDSW,NUROUT,NURQUEUE)=0
D EN1^NURSAUTL G QUIT:$G(NUROUT)
D EN9^NURSAGSP
I NURMDSW S DIC(0)="AEMQZ",NURPLSCR=1 D EN5^NURSAGSP K NURPLSCR I $G(NUROUT) G QUIT
I NURMDSW=0,NURPLSW=1 S NURPLSCR=1 D PRD^NURSAGSP K NURPLSCR I $G(NUROUT) G QUIT
W ! D EN1^NURSAGSP G:$G(NUROUT) QUIT
W ! D EN2^NURSAGSP G:$G(NUROUT) QUIT
D EN5^NURSAGP0 W ! G QUIT:$G(NUROUT)
S ZTDESC="Nursing FTEE Profile by Location & Service Position",ZTRTN="START^NURA9D2" D EN7^NURSUT0 G:POP!($D(ZTSK)) QUIT
START ;
K ^TMP($J),^TMP("NURA",$J),^TMP("NURLOC",$J) U IO S (NURPAGE,NTCT,NURSW1,NURQUIT,NCT,NSUBT,NSUBC,PCT,PSUBT,PSUBC,FCT,FSUBT,FSUBC)=0
D SORT G:$G(NUROUT) QUIT D NPRINT S:NURQUIT NCT=NCT+NSUBT I ($Y>(IOSL-6)),'NURQUIT D NHDR
S NURLINE="",$P(NURLINE,"*",7)=""
D EN2^NURAED3 W !!,?20,NURLINE,!,"REPORT TOTAL",?18,$J(NCT,8,3),!!,"COUNT - ASSIGN.",?18,$J(NTCT,8,3) W ?36,"PERSONNEL",?62,$J(NTOT,8,3)
W !!,"MEAN - ASSIGN.",?18,$S(NCT>0&(NTCT>0):$J((NCT/NTCT),8,3),1:" 0.000"),?36,"PERSONNEL",?62,$S(NCT>0&(NTOT>0):$J((NCT/NTOT),8,3),1:" 0.000")
QUIT K ^TMP("NURA",$J),^TMP($J),NTOUR,NUR,NUM D CLOSE^NURSUT1,^NURAKILL
Q
NPRINT S (NURPROG(2),NURFAC(2))="" F S NURFAC(2)=$O(^TMP($J,"L",NURFAC(2))) Q:NURFAC(2)=""!NURQUIT D NM Q:NURQUIT D:NURMDSW FSUB Q:NURQUIT
Q
NM F S NURPROG(2)=$O(^TMP($J,"L",NURFAC(2),NURPROG(2))) Q:NURPROG(2)=""!NURQUIT D NHDR Q:NURQUIT D NN Q:NURQUIT I $G(NURPLSW) D PSUB Q:NURQUIT
Q
NN S NL1="" F S NL1=$O(^TMP($J,"L",NURFAC(2),NURPROG(2),NL1)) Q:NL1=""!NURQUIT D NO Q:NURQUIT D NHDR Q:NURQUIT
Q
NO S NPRI="" F S NPRI=$O(^TMP($J,"L",NURFAC(2),NURPROG(2),NL1,NPRI)) Q:NPRI=""!NURQUIT D NP Q:NURQUIT D NSUB W ! Q:NURQUIT
Q
NP S NSPO="" F S NSPO=$O(^TMP($J,"L",NURFAC(2),NURPROG(2),NL1,NPRI,NSPO)) Q:NSPO=""!NURQUIT S NURSORT=$G(^TMP($J,"L",NURFAC(2),NURPROG(2),NL1,NPRI,NSPO)) I NURSORT D NQ Q:NURQUIT
Q
NQ S NFTEE="" F S NFTEE=$O(^TMP($J,"L1",NURSORT,NFTEE)) Q:NFTEE=""!NURQUIT D NR Q:NURQUIT
Q
NR S N1="" F S N1=$O(^TMP($J,"L1",NURSORT,NFTEE,N1)) Q:N1=""!NURQUIT D NS Q:NURQUIT
Q
NS F DA(1)=0:0 S DA(1)=$O(^TMP($J,"L1",NURSORT,NFTEE,N1,DA(1))) Q:DA(1)'>0!NURQUIT D NT Q:NURQUIT
Q
NT F DA=0:0 S DA=$O(^TMP($J,"L1",NURSORT,NFTEE,N1,DA(1),DA)) Q:DA'>0!NURQUIT D NPPRINT Q:NURQUIT
Q
NPPRINT I ($Y>(IOSL-6)) D NHDR Q:NURQUIT
S NTOUR=DA(1) D S NTOUR=NUR(1)
.N DA S DA=NTOUR D EN9^NURSUT0
S NURSW1=1 S ^TMP("NURA",$J,DA(1),NURSORT)=""
S NSUBT=NSUBT+NFTEE,NSUBC=NSUBC+1,NSUBM=NSUBT/NSUBC
S PSUBT=PSUBT+NFTEE,PSUBC=PSUBC+1,PSUBM=PSUBT/PSUBC
S FSUBT=FSUBT+NFTEE,FSUBC=FSUBC+1,FSUBM=FSUBT/FSUBC
W !,$S(+NFTEE:" ",1:"** ")
W:NSPO'=" BLANK" ?2,NSPO
W:NFTEE'=" BLANK" ?18,$J(NFTEE,8,3)
W:N1'=" BLANK" ?36,$E(N1,1,20)
W:NL1'=" BLANK" ?64,$E(NL1,1,15) W:IOM>120 ?85,NTOUR Q:NURQUIT
Q
NHDR I 'NURQUEUE,NURSW1,$E(IOST)="C" D ENDPG^NURSUT1 S:NUROUT NURQUIT=+NUROUT Q:NURQUIT
S NURPAGE=NURPAGE+1 W:$E(IOST)="C"!(NURPAGE>1) @IOF
I NURMDSW,$G(NWRD)="" W !,?$$CNTR^NURSUT2(NURFAC(2)),$S($G(NURFAC(2))=" BLANK":"NO FACILITY",1:$G(NURFAC(2)))
W !,"FTEE PROFILE BY LOCATION AND SERVICE POSITION" S X="T" D ^%DT D:+Y D^DIQ W ?56,Y,?72,"PAGE: ",NURPAGE
W !!
W !,"SERVICE",?36,"EMPLOYEE"
W !,"POSITION",?22,"FTEE",?36,"NAME",?64,"LOCATION" W:IOM>120 ?85,"TOUR"
W !,$$REPEAT^XLFSTR("-",IOM)
I NURPLSW D NHDR1^NURA9D1
Q
SORT W ! S NRPT=3 D EN4^NURAAGS0
I $O(^TMP($J,""))="",'$D(NURSNLOC) S NUROUT=1 S NURPROG(2)=$S($G(NURPROG)=0:NURPROG(1),1:""),NURFAC(2)=$S($G(NURFAC)=0:NURFAC(1),1:"") D NHDR W !,"THERE IS NO DATA FOR THIS REPORT"
I $O(^TMP($J,""))="",$D(NURSNLOC) S NUROUT=1 S NURPROG(2)=$S($G(NURPROG)=0:NURPROG(1),1:""),NURFAC(2)=$S($G(NURFAC)=0:NURFAC(1),1:"") D NHDR S NL1="" F S NL1=$O(NURSNLOC(NL1)) Q:NL1="" D NODATA^NURSUT1
I $O(^TMP($J,""))'="",$D(NURSNLOC) D I NURSW1=1 D ENDPG^NURSUT1 S NURSW1=0
. S (NURY,NURZ,NURX)="" F S NURY=$O(^TMP($J,"L",NURY)) Q:NURY="" F S NURZ=$O(^TMP($J,"L",NURY,NURZ)) Q:NURZ="" F S NURX=$O(^TMP($J,"L",NURY,NURZ,NURX)) Q:NURX="" S ^TMP("NURLOC",$J,NURX)=""
. S NL1="" F S NL1=$O(NURSNLOC(NL1)) Q:NL1="" I '$D(^TMP("NURLOC",$J,NL1)) D
. . S NURPROG(2)=$S($G(NURPROG)=0:NURPROG(1),1:""),NURFAC(2)=$S($G(NURFAC)=0:NURFAC(1),1:"") D:NURSW1=0 NHDR S NURSW1=1 D NODATA^NURSUT1
. . Q
. Q
Q
NSUB ; SUBTOTAL ROUTINE
D:($Y>(IOSL-6)) NHDR Q:NURQUIT W !?21,"-----"
W !,"SUBTOTAL",?18,$J(NSUBT,8,3),!,"SUBCOUNT",?18,$J(NSUBC,8,3),!,"SUBMEAN" W ?18,$S(NSUBC'=0:$J((NSUBT/NSUBC),8,3),1:" 0.000")
S NCT=NSUBT+NCT,NTCT=NTCT+NSUBC
S (NSUBC,NSUBM,NSUBT)=0
Q
PSUB ; PRODUCT LINE SUBTOTAL ROUTINE
D:($Y>(IOSL-6)) NHDR Q:NURQUIT W !,$S($E(NURPROG(2),1)=" ":$E(NURPROG(2),2,99),1:NURPROG(2))_" TOTALS" W !?20,"******"
W !,"SUBTOTAL",?18,$J(PSUBT,8,3) W:PSUBC'=(0.0) !,"SUBCOUNT",?18,$J(PSUBC,8,3),!,"SUBMEAN" W ?18,$S(PSUBC'=0:$J((PSUBT/PSUBC),8,3),1:" 0.000"),!!
S PCT=PSUBT+PCT
S (PSUBC,PSUBM,PSUBT)=0
Q
FSUB ; FACILITY SUBTOTAL ROUTINE
D:($Y>(IOSL-6)) NHDR Q:NURQUIT W !,NURFAC(2)_" TOTALS" S NURLINE="",$P(NURLINE,"*",7)="" W !?20,NURLINE
W !,"SUBTOTAL",?18,$J(FSUBT,8,3) W:FSUBC'=(0.0) !,"SUBCOUNT",?18,$J(FSUBC,8,3),!,"SUBMEAN" W ?18,$S(FSUBC'=0:$J((FSUBT/FSUBC),8,3),1:" 0>000")
S FCT=FSUBT+FCT
S (FSUBC,FSUBM,FSUBT)=0
Q