ENFACTL ;(WCIOFO)/SAB-FAP CAPITALIZATION THRESHOLD LIST ;10/14/1999
;;7.0;ENGINEERING;**63**;Aug 17, 1993
EN ;
; ask device
S %ZIS="QM" D ^%ZIS G:POP EXIT
I $D(IO("Q")) D G EXIT
. S ZTRTN="QEN^ENFACTL"
. S ZTDESC="ENG List Equip to be Expensed"
. D ^%ZTLOAD,HOME^%ZIS K ZTSK
;
QEN ; queued entry
U IO
;
COLLECT ; collect data
S END=0 ; init flag, =true if user stopped job
K ENT ; totals ENT(station,fund,sgl)
; =capitalized count^$^to be expensed count^$
K ^TMP($J)
;
; loop thru equipment in FA DOCUMENT LOG file
S ENDA=0 F S ENDA=$O(^ENG(6915.2,"B",ENDA)) Q:'ENDA D
. Q:+$$CHKFA^ENFAUTL(ENDA)'>0 ; not currently reported to FAP
. ; get equipment data
. S ENSN=$$GET1^DIQ(6914,ENDA_",",60)_" " S:ENSN=" " ENSN="UNK"
. S ENFUND=$$GET1^DIQ(6914,ENDA_",",62)_" " S:ENFUND=" " ENFUND="UNK"
. S ENSGL=$$GET1^DIQ(6914,ENDA_",",38) S:ENSGL="" ENSGL="UNK"
. S ENVAL=$$GET1^DIQ(6914,ENDA_",",12)
. ; update capitalized count and amount
. S $P(ENT(ENSN,ENFUND,ENSGL),U)=$P($G(ENT(ENSN,ENFUND,ENSGL)),U)+1
. S $P(ENT(ENSN,ENFUND,ENSGL),U,2)=$P(ENT(ENSN,ENFUND,ENSGL),U,2)+ENVAL
. ; quit if item should not be expensed
. Q:$P($$CHKEXP^ENFACTU(ENDA),U)'=1
. ; put on sorted list of items that will be expensed and update counts
. S ENSYS=+$$TOPSYS^ENFACTU(ENDA) ; plus value to treat ? as standalone
. S ENSYSV=+$S(ENSYS>0:$$SYSVAL^ENFACTU(ENSYS,"C"),1:ENVAL)
. S ^TMP($J,ENSN,ENSYSV,ENSYS,ENDA)=""
. S $P(ENT(ENSN,ENFUND,ENSGL),U,3)=$P(ENT(ENSN,ENFUND,ENSGL),U,3)+1
. S $P(ENT(ENSN,ENFUND,ENSGL),U,4)=$P(ENT(ENSN,ENFUND,ENSGL),U,4)+ENVAL
;
PRINT ; print results
S ENPG=0 D NOW^%DTC S Y=% D DD^%DT S ENDT=Y
S ENL="",$P(ENL,"-",IOM)=""
I '$D(ENT) S ENSN="" D HD W !!,"Nothing to report."
; loop thru ENT( by station
S ENSN="" F S ENSN=$O(ENT(ENSN)) Q:ENSN="" D Q:END
. D HD Q:END
. I '$D(^TMP($J,ENSN)) W !!,"NO EQUIPMENT WILL BE EXPENSED BY CT TASK FOR THIS STATION."
. ; loop thru system values in ^TMP(
. S ENSYSV="" F S ENSYSV=$O(^TMP($J,ENSN,ENSYSV)) Q:ENSYSV="" D Q:END
. . ; loop thru system # (will be 0 for standalone items)
. . S ENSYS=""
. . F S ENSYS=$O(^TMP($J,ENSN,ENSYSV,ENSYS)) Q:ENSYS="" D Q:END
. . . ; if system then print parent data and system info
. . . I ENSYS>0 D
. . . . W !!,?2,"TOP PARENT SYSTEM ENTRY #: ",ENSYS
. . . . W ?40,"CMR: ",$E($$GET1^DIQ(6914,ENSYS,19),1,5)
. . . . W ?51,"Parent Value: "
. . . . I +$$CHKFA^ENFAUTL(ENSYS) W $FN($$GET1^DIQ(6914,ENSYS,12),",",2)
. . . . E W "not in FAP"
. . . . S ENCSN=$$GET1^DIQ(6914,ENSYS,18)
. . . . W !,?2,"CATEGORY STOCK NUMBER: ",ENCSN
. . . . I ENCSN]"" W " (",$$GET1^DIQ(6914,ENSYS,"18:2"),")"
. . . . W !,?2,"Sum of Capitalized Values in System: "
. . . . W $FN(ENSYSV,",",2)
. . . ; loop thru equipment
. . . S ENDA=0
. . . F S ENDA=$O(^TMP($J,ENSN,ENSYSV,ENSYS,ENDA)) Q:'ENDA D Q:END
. . . . Q:ENDA=ENSYS ; already displayed as parent of system
. . . . I $Y+4>IOSL D HD Q:END W " (continued)"
. . . . S ENCSN=$$GET1^DIQ(6914,ENDA,18)
. . . . ; print format for component of system
. . . . I ENSYS>0 D
. . . . . W !!,?6,"COMPONENT ENTRY #: ",ENDA
. . . . . W ?36,"CMR: ",$E($$GET1^DIQ(6914,ENDA,19),1,5)
. . . . . W ?47,"Component Value: ",$FN($$GET1^DIQ(6914,ENDA,12),",",2)
. . . . . W !,?6,"CATEGORY STOCK NUMBER: ",ENCSN
. . . . . I ENCSN]"" W " (",$$GET1^DIQ(6914,ENDA,"18:2"),")"
. . . . ; print format for standalone equipment
. . . . I ENSYS=0 D
. . . . . W !!,?2,"ENTRY #: ",ENDA
. . . . . W ?22,"CMR: ",$E($$GET1^DIQ(6914,ENDA,19),1,5)
. . . . . W ?33,"Value: ",$FN($$GET1^DIQ(6914,ENDA,12),",",2)
. . . . . W !,?2,"CATEGORY STOCK NUMBER: ",ENCSN
. . . . . I ENCSN]"" W " (",$$GET1^DIQ(6914,ENDA,"18:2"),")"
. Q:END
. ; print station totals
. I $Y+14>IOSL D HD Q:END W " (continued)"
. D HDST
. S ENFUND="" F S ENFUND=$O(ENT(ENSN,ENFUND)) Q:ENFUND="" D Q:END
. . S ENSGL=""
. . F S ENSGL=$O(ENT(ENSN,ENFUND,ENSGL)) Q:ENSGL="" D Q:END
. . . I $Y+6>IOSL D HD Q:END W " (continued)" D HDST
. . . W !,ENFUND,?7,ENSGL
. . . S ENX=$G(ENT(ENSN,ENFUND,ENSGL))
. . . W ?12,$J($FN($P(ENX,U,1),","),5)
. . . W ?18,$J($FN($P(ENX,U,2),",",2),14)
. . . W ?35,$J($FN($P(ENX,U,3),","),5)
. . . W ?41,$J($FN($P(ENX,U,4),",",2),14)
. . . W ?58,$J($FN($P(ENX,U,1)-$P(ENX,U,3),","),5)
. . . W ?64,$J($FN($P(ENX,U,2)-$P(ENX,U,4),",",2),14)
. . . ; add sgl to subtotals for station
. . . S $P(ENT(ENSN),U,1)=$P($G(ENT(ENSN)),U,1)+$P(ENX,U,1)
. . . S $P(ENT(ENSN),U,2)=$P(ENT(ENSN),U,2)+$P(ENX,U,2)
. . . S $P(ENT(ENSN),U,3)=$P(ENT(ENSN),U,3)+$P(ENX,U,3)
. . . S $P(ENT(ENSN),U,4)=$P(ENT(ENSN),U,4)+$P(ENX,U,4)
. W !," ----- -------------- ----- -------------- ----- --------------"
. W !,"Station Tot"
. W ?12,$J($FN($P(ENT(ENSN),U,1),","),5)
. W ?18,$J($FN($P(ENT(ENSN),U,2),",",2),14)
. W ?35,$J($FN($P(ENT(ENSN),U,3),","),5)
. W ?41,$J($FN($P(ENT(ENSN),U,4),",",2),14)
. W ?58,$J($FN($P(ENT(ENSN),U,1)-$P(ENT(ENSN),U,3),","),5)
. W ?64,$J($FN($P(ENT(ENSN),U,2)-$P(ENT(ENSN),U,4),",",2),14)
I END W !!,"REPORT STOPPED BY USER REQUEST"
I 'END,$E(IOST,1,2)="C-" S DIR(0)="E" D ^DIR K DIR
D ^%ZISC
EXIT I $D(ZTQUEUED) S ZTREQ="@"
K ^TMP($J)
K DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y,END,ENDT,ENL,ENPG
K ENCSN,ENDA,ENFUND,ENSGL,ENSN,ENSYS,ENSYSV,ENT,ENVAL,ENX
Q
;
HD ; header
I $D(ZTQUEUED),$$S^%ZTLOAD S ZTSTOP=1,END=1 Q
I $E(IOST,1,2)="C-",ENPG S DIR(0)="E" D ^DIR K DIR I 'Y S END=1 Q
I $E(IOST,1,2)="C-"!ENPG W @IOF
S ENPG=ENPG+1
W !,"EQUIPMENT CT TASK WILL EXPENSE sorted by value"
W ?49,ENDT,?72,"page ",ENPG
W !,ENL
I ENSN]"" W !,"STATION ",ENSN
Q
;
HDST ; header for station totals
W !!," Current Capitalized CT Task Will Expense Remain Capitalized"
W !,"Fund SGL Count $ Amount Count $ Amount Count $ Amount"
W !,"------ ---- ----- -------------- ----- -------------- ----- --------------"
Q
;ENFACTL
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HENFACTL 6019 printed Dec 13, 2024@01:53:24 Page 2
ENFACTL ;(WCIOFO)/SAB-FAP CAPITALIZATION THRESHOLD LIST ;10/14/1999
+1 ;;7.0;ENGINEERING;**63**;Aug 17, 1993
EN ;
+1 ; ask device
+2 SET %ZIS="QM"
DO ^%ZIS
if POP
GOTO EXIT
+3 IF $DATA(IO("Q"))
Begin DoDot:1
+4 SET ZTRTN="QEN^ENFACTL"
+5 SET ZTDESC="ENG List Equip to be Expensed"
+6 DO ^%ZTLOAD
DO HOME^%ZIS
KILL ZTSK
End DoDot:1
GOTO EXIT
+7 ;
QEN ; queued entry
+1 USE IO
+2 ;
COLLECT ; collect data
+1 ; init flag, =true if user stopped job
SET END=0
+2 ; totals ENT(station,fund,sgl)
KILL ENT
+3 ; =capitalized count^$^to be expensed count^$
+4 KILL ^TMP($JOB)
+5 ;
+6 ; loop thru equipment in FA DOCUMENT LOG file
+7 SET ENDA=0
FOR
SET ENDA=$ORDER(^ENG(6915.2,"B",ENDA))
if 'ENDA
QUIT
Begin DoDot:1
+8 ; not currently reported to FAP
if +$$CHKFA^ENFAUTL(ENDA)'>0
QUIT
+9 ; get equipment data
+10 SET ENSN=$$GET1^DIQ(6914,ENDA_",",60)_" "
if ENSN=" "
SET ENSN="UNK"
+11 SET ENFUND=$$GET1^DIQ(6914,ENDA_",",62)_" "
if ENFUND=" "
SET ENFUND="UNK"
+12 SET ENSGL=$$GET1^DIQ(6914,ENDA_",",38)
if ENSGL=""
SET ENSGL="UNK"
+13 SET ENVAL=$$GET1^DIQ(6914,ENDA_",",12)
+14 ; update capitalized count and amount
+15 SET $PIECE(ENT(ENSN,ENFUND,ENSGL),U)=$PIECE($GET(ENT(ENSN,ENFUND,ENSGL)),U)+1
+16 SET $PIECE(ENT(ENSN,ENFUND,ENSGL),U,2)=$PIECE(ENT(ENSN,ENFUND,ENSGL),U,2)+ENVAL
+17 ; quit if item should not be expensed
+18 if $PIECE($$CHKEXP^ENFACTU(ENDA),U)'=1
QUIT
+19 ; put on sorted list of items that will be expensed and update counts
+20 ; plus value to treat ? as standalone
SET ENSYS=+$$TOPSYS^ENFACTU(ENDA)
+21 SET ENSYSV=+$SELECT(ENSYS>0:$$SYSVAL^ENFACTU(ENSYS,"C"),1:ENVAL)
+22 SET ^TMP($JOB,ENSN,ENSYSV,ENSYS,ENDA)=""
+23 SET $PIECE(ENT(ENSN,ENFUND,ENSGL),U,3)=$PIECE(ENT(ENSN,ENFUND,ENSGL),U,3)+1
+24 SET $PIECE(ENT(ENSN,ENFUND,ENSGL),U,4)=$PIECE(ENT(ENSN,ENFUND,ENSGL),U,4)+ENVAL
End DoDot:1
+25 ;
PRINT ; print results
+1 SET ENPG=0
DO NOW^%DTC
SET Y=%
DO DD^%DT
SET ENDT=Y
+2 SET ENL=""
SET $PIECE(ENL,"-",IOM)=""
+3 IF '$DATA(ENT)
SET ENSN=""
DO HD
WRITE !!,"Nothing to report."
+4 ; loop thru ENT( by station
+5 SET ENSN=""
FOR
SET ENSN=$ORDER(ENT(ENSN))
if ENSN=""
QUIT
Begin DoDot:1
+6 DO HD
if END
QUIT
+7 IF '$DATA(^TMP($JOB,ENSN))
WRITE !!,"NO EQUIPMENT WILL BE EXPENSED BY CT TASK FOR THIS STATION."
+8 ; loop thru system values in ^TMP(
+9 SET ENSYSV=""
FOR
SET ENSYSV=$ORDER(^TMP($JOB,ENSN,ENSYSV))
if ENSYSV=""
QUIT
Begin DoDot:2
+10 ; loop thru system # (will be 0 for standalone items)
+11 SET ENSYS=""
+12 FOR
SET ENSYS=$ORDER(^TMP($JOB,ENSN,ENSYSV,ENSYS))
if ENSYS=""
QUIT
Begin DoDot:3
+13 ; if system then print parent data and system info
+14 IF ENSYS>0
Begin DoDot:4
+15 WRITE !!,?2,"TOP PARENT SYSTEM ENTRY #: ",ENSYS
+16 WRITE ?40,"CMR: ",$EXTRACT($$GET1^DIQ(6914,ENSYS,19),1,5)
+17 WRITE ?51,"Parent Value: "
+18 IF +$$CHKFA^ENFAUTL(ENSYS)
WRITE $FNUMBER($$GET1^DIQ(6914,ENSYS,12),",",2)
+19 IF '$TEST
WRITE "not in FAP"
+20 SET ENCSN=$$GET1^DIQ(6914,ENSYS,18)
+21 WRITE !,?2,"CATEGORY STOCK NUMBER: ",ENCSN
+22 IF ENCSN]""
WRITE " (",$$GET1^DIQ(6914,ENSYS,"18:2"),")"
+23 WRITE !,?2,"Sum of Capitalized Values in System: "
+24 WRITE $FNUMBER(ENSYSV,",",2)
End DoDot:4
+25 ; loop thru equipment
+26 SET ENDA=0
+27 FOR
SET ENDA=$ORDER(^TMP($JOB,ENSN,ENSYSV,ENSYS,ENDA))
if 'ENDA
QUIT
Begin DoDot:4
+28 ; already displayed as parent of system
if ENDA=ENSYS
QUIT
+29 IF $Y+4>IOSL
DO HD
if END
QUIT
WRITE " (continued)"
+30 SET ENCSN=$$GET1^DIQ(6914,ENDA,18)
+31 ; print format for component of system
+32 IF ENSYS>0
Begin DoDot:5
+33 WRITE !!,?6,"COMPONENT ENTRY #: ",ENDA
+34 WRITE ?36,"CMR: ",$EXTRACT($$GET1^DIQ(6914,ENDA,19),1,5)
+35 WRITE ?47,"Component Value: ",$FNUMBER($$GET1^DIQ(6914,ENDA,12),",",2)
+36 WRITE !,?6,"CATEGORY STOCK NUMBER: ",ENCSN
+37 IF ENCSN]""
WRITE " (",$$GET1^DIQ(6914,ENDA,"18:2"),")"
End DoDot:5
+38 ; print format for standalone equipment
+39 IF ENSYS=0
Begin DoDot:5
+40 WRITE !!,?2,"ENTRY #: ",ENDA
+41 WRITE ?22,"CMR: ",$EXTRACT($$GET1^DIQ(6914,ENDA,19),1,5)
+42 WRITE ?33,"Value: ",$FNUMBER($$GET1^DIQ(6914,ENDA,12),",",2)
+43 WRITE !,?2,"CATEGORY STOCK NUMBER: ",ENCSN
+44 IF ENCSN]""
WRITE " (",$$GET1^DIQ(6914,ENDA,"18:2"),")"
End DoDot:5
End DoDot:4
if END
QUIT
End DoDot:3
if END
QUIT
End DoDot:2
if END
QUIT
+45 if END
QUIT
+46 ; print station totals
+47 IF $Y+14>IOSL
DO HD
if END
QUIT
WRITE " (continued)"
+48 DO HDST
+49 SET ENFUND=""
FOR
SET ENFUND=$ORDER(ENT(ENSN,ENFUND))
if ENFUND=""
QUIT
Begin DoDot:2
+50 SET ENSGL=""
+51 FOR
SET ENSGL=$ORDER(ENT(ENSN,ENFUND,ENSGL))
if ENSGL=""
QUIT
Begin DoDot:3
+52 IF $Y+6>IOSL
DO HD
if END
QUIT
WRITE " (continued)"
DO HDST
+53 WRITE !,ENFUND,?7,ENSGL
+54 SET ENX=$GET(ENT(ENSN,ENFUND,ENSGL))
+55 WRITE ?12,$JUSTIFY($FNUMBER($PIECE(ENX,U,1),","),5)
+56 WRITE ?18,$JUSTIFY($FNUMBER($PIECE(ENX,U,2),",",2),14)
+57 WRITE ?35,$JUSTIFY($FNUMBER($PIECE(ENX,U,3),","),5)
+58 WRITE ?41,$JUSTIFY($FNUMBER($PIECE(ENX,U,4),",",2),14)
+59 WRITE ?58,$JUSTIFY($FNUMBER($PIECE(ENX,U,1)-$PIECE(ENX,U,3),","),5)
+60 WRITE ?64,$JUSTIFY($FNUMBER($PIECE(ENX,U,2)-$PIECE(ENX,U,4),",",2),14)
+61 ; add sgl to subtotals for station
+62 SET $PIECE(ENT(ENSN),U,1)=$PIECE($GET(ENT(ENSN)),U,1)+$PIECE(ENX,U,1)
+63 SET $PIECE(ENT(ENSN),U,2)=$PIECE(ENT(ENSN),U,2)+$PIECE(ENX,U,2)
+64 SET $PIECE(ENT(ENSN),U,3)=$PIECE(ENT(ENSN),U,3)+$PIECE(ENX,U,3)
+65 SET $PIECE(ENT(ENSN),U,4)=$PIECE(ENT(ENSN),U,4)+$PIECE(ENX,U,4)
End DoDot:3
if END
QUIT
End DoDot:2
if END
QUIT
+66 WRITE !," ----- -------------- ----- -------------- ----- --------------"
+67 WRITE !,"Station Tot"
+68 WRITE ?12,$JUSTIFY($FNUMBER($PIECE(ENT(ENSN),U,1),","),5)
+69 WRITE ?18,$JUSTIFY($FNUMBER($PIECE(ENT(ENSN),U,2),",",2),14)
+70 WRITE ?35,$JUSTIFY($FNUMBER($PIECE(ENT(ENSN),U,3),","),5)
+71 WRITE ?41,$JUSTIFY($FNUMBER($PIECE(ENT(ENSN),U,4),",",2),14)
+72 WRITE ?58,$JUSTIFY($FNUMBER($PIECE(ENT(ENSN),U,1)-$PIECE(ENT(ENSN),U,3),","),5)
+73 WRITE ?64,$JUSTIFY($FNUMBER($PIECE(ENT(ENSN),U,2)-$PIECE(ENT(ENSN),U,4),",",2),14)
End DoDot:1
if END
QUIT
+74 IF END
WRITE !!,"REPORT STOPPED BY USER REQUEST"
+75 IF 'END
IF $EXTRACT(IOST,1,2)="C-"
SET DIR(0)="E"
DO ^DIR
KILL DIR
+76 DO ^%ZISC
EXIT IF $DATA(ZTQUEUED)
SET ZTREQ="@"
+1 KILL ^TMP($JOB)
+2 KILL DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y,END,ENDT,ENL,ENPG
+3 KILL ENCSN,ENDA,ENFUND,ENSGL,ENSN,ENSYS,ENSYSV,ENT,ENVAL,ENX
+4 QUIT
+5 ;
HD ; header
+1 IF $DATA(ZTQUEUED)
IF $$S^%ZTLOAD
SET ZTSTOP=1
SET END=1
QUIT
+2 IF $EXTRACT(IOST,1,2)="C-"
IF ENPG
SET DIR(0)="E"
DO ^DIR
KILL DIR
IF 'Y
SET END=1
QUIT
+3 IF $EXTRACT(IOST,1,2)="C-"!ENPG
WRITE @IOF
+4 SET ENPG=ENPG+1
+5 WRITE !,"EQUIPMENT CT TASK WILL EXPENSE sorted by value"
+6 WRITE ?49,ENDT,?72,"page ",ENPG
+7 WRITE !,ENL
+8 IF ENSN]""
WRITE !,"STATION ",ENSN
+9 QUIT
+10 ;
HDST ; header for station totals
+1 WRITE !!," Current Capitalized CT Task Will Expense Remain Capitalized"
+2 WRITE !,"Fund SGL Count $ Amount Count $ Amount Count $ Amount"
+3 WRITE !,"------ ---- ----- -------------- ----- -------------- ----- --------------"
+4 QUIT
+5 ;ENFACTL