ENWOD ;(WIRMFO)/DLM/DH/SAB-Formatted Work Order Display ;5/11/2000
;;7.0;ENGINEERING;**35,43,65,96**;Aug 17, 1993;Build 5
EDIT ; Work order display/edit (screen) option
D WO^ENWOUTL G:Y'>0 EXIT S DA=+Y
D EDIT1
G EDIT
;
EDIT1 ; display/edit one work order
; input DA (ien of work order), DUZ (user number)
N ENBARCD,ENDSTAT,ENEDIT,ENINV,ENJ,ENREOPEN,ENWO,ENWOCLOD,ENX
S ENEDIT=0 ; flag, true if user edited work order
S ENREOPEN=0 ; flag, true if closed work order reopened for edit
D D F D READ Q:ENX="" D ACTION Q:$P($G(^ENG(6920,DA,5)),U,2)]""&ENEDIT
I ENEDIT D
. ; work order edited by user
. N DIE,DR
. S DIE="^ENG(6920,"
. I ENREOPEN,$P($G(^ENG(6920,DA,5)),U,2)']"" S DR="36//^S X=ENWOCLOD" D ^DIE
. I $P($G(^ENG(6920,DA,5)),U,2)]"" D
. . ; work order was closed
. . I "^5^6^"'[(U_$P($G(^ENG(6920,DA,4)),U,3)_U) D
. . . ; status was not set to Completed or Disapproved
. . . S DR="32///^S X=""COMPLETED""" D ^DIE
. . I $E($P($G(^ENG(6920,DA,0)),U),1,3)="PM-" D
. . . ; post PM hours for PM work order
. . . N ENPMDT,PMTOT,X
. . . D PMHRS^ENEQPMR4 Q:'$D(PMTOT)
. . . S X=$P($P(^ENG(6920,DA,0),U),"-",2)
. . . F I=1:1:$L(X) S:$E(X,I)?1N ENPMDT=$G(ENPMDT)_$E(X,I)
. . . S ENPMDT=$E(ENPMDT,1,4)
. . . D COUNT^ENBCPM8
. ; unlock
. L -^ENG(6920,DA)
Q
;
READ ;User interaction
D HOME^%ZIS W !,"ENTER/EDIT (1-33), D(DISPLAY), AC(ACCOUNT), P(PRINT)): EXIT// " R ENX:DTIME
I ENX=10 W !,"Uneditable field.",*7 G READ
I ENX=11 W !,"A transfer option must be used to change SHOP.",*7 G READ
I $E(ENX)="^"!($E(ENX)="E") S ENX=""
Q:ENX="" I ENX?1.2N S ENX=+ENX I ENX<1!(ENX>33) W " ??",*7 G READ
Q:ENX?1.2N S ENX=$TR(ENX,"dap","DAP") I "DAP"'[$E(ENX) W " ??",*7 G READ
Q
;
ACTION ;Edit or display
I ENX'?1.2N N TAG S TAG=$E(ENX) D @TAG Q
; try to prepare work order for editing (if not already done)
I 'ENEDIT D I 'ENEDIT L -^ENG(6920,DA) Q
. L +^ENG(6920,DA):5 I '$T W !,"This work order is being edited by another user. Please try again later." Q
. I $P($G(^ENG(6920,DA,5)),U,2)]"" D I 'ENREOPEN Q
. . W $C(7),!,"NOTE: This work order has been closed."
. . I '$D(^XUSEC("ENEDCLWO",DUZ)) W !,"Security key ENEDCLWO is needed to edit closed work orders." Q
. . S DIR("A")="Are you sure you want to edit this work order",DIR(0)="Y",DIR("B")="NO"
. . D ^DIR K DIR Q:Y'>0
. . I $P($G(^ENG(6920,DA,3)),U,8)>0 D KILLHS^ENEQHS Q:$G(R)="^"
. . S ENWOCLOD=$P(^ENG(6920,DA,5),U,2)
. . S $P(^ENG(6920,DA,5),U,2)="" D TEST^ENWOCOMP
. . I $E($P($G(^ENG(6920,DA,0)),U),1,3)="PM-" D
. . . ; since reopening PM work order we must back out the PM hours
. . . N ENPMDT,PMTOT,X
. . . D PMHRS^ENEQPMR4 Q:'$D(PMTOT)
. . . S X=$P($P(^ENG(6920,DA,0),U),"-",2)
. . . F I=1:1:$L(X) S:$E(X,I)?1N ENPMDT=$G(ENPMDT)_$E(X,I)
. . . S ENPMDT=$E(ENPMDT,1,4)
. . . D UNPOST^ENBCPM8
. . S ENREOPEN=1 ; reopen of closed work order completed
. S ENEDIT=1 ; work order ready for editing
N DIE,DR,ENDA
S DR=$P("16^1^2^3^4^STAT^6^7^8^^9^10^17^18^19^21^EQ53^21.9^22.3^22.5^23^20^31^35^35.5^37^38^37.5^47^16.5^36^39^40",U,ENX) S:DR="STAT" DR=ENDSTAT
I $E(DR,1,2)="EQ" S ENDA=DA D S DA=ENDA Q
. S DIE="^ENG(6914,",DR=$E(DR,3,99),DA=$P($G(^ENG(6920,DA,3)),U,8)
. I DA D
. . L +^ENG(6914,DA):5 I '$T W $C(7),!,"Another user is editing this equipment. Try editing the condition later." Q
. . D ^DIE
. . L -^ENG(6914,DA)
S DIE="^ENG(6920,"
I DR=36 D
. W !!,"Entry of a date will close this work order. Do this last."
. I $D(ENWOCLOD) S DR="36//^S X=ENWOCLOD"
D ^DIE
Q
;
D ;Display WO to CRT
W:$E(IOST,1,2)="C-" @IOF D ST^ENWOD1,TOP^ENWOD2
Q
;
A ;Display Accounting Data
S X="PRCSP13" X ^%ZOSF("TEST") I $T D
. S ENFLG=0 I $D(^ENG(6920,DA,4)),$P(^(4),U,2)]"" D
. . S ENWOACN=$P(^ENG(6920,DA,4),U,2),ENFLG=1
. . I $D(^PRCS(410,ENWOACN,0)) D
. . . S ENWOOR=DA,DA=ENWOACN
. . . D ^PRCSP13
. . . S DA=ENWOOR K ENWOOR
. . K ENWOACN
. W:'ENFLG !,"No procurement request on file for this work order."
. K ENFLG
Q
;
P ;Print work order
I '$D(ENBARCD) S ENBARCD=0 I $D(^ENG(6910.2,"B","PRINT BAR CODES ON W.O.")) S I=$O(^("PRINT BAR CODES ON W.O.",0)) I I>0,$P(^ENG(6910.2,I,0),U,2)="Y" S ENBARCD=1
D DEV^ENLIB Q:POP I $D(IO("Q")) N X S ZTRTN="PRT1^ENWOD",ZTSAVE("EN*")="",ZTSAVE("DA")="",ZTDESC="Print Work Order" D ^%ZTLOAD K ZTSK D HOME^%ZIS Q
PRT1 U IO W:$E(IOST,1,2)="C-" @IOF
D:$E(IOST,1,2)'="C-" PSET^%ZISP
D ST^ENWOD1,TOP^ENWOD2
D:ENBARCD BAR
I $E(IOST,1,2)'="C-" W @IOF D PKILL^%ZISP
N DA ; to protect DA when W.O. printed to P-MESSAGE
; *96 close if the job is not queued in a task
I '$D(ZTQUEUED) D ^%ZISC
Q
;
BAR ; print barcode of w.o. #
I $G(IOBARON)]"",$G(IOBAROFF)]"" W !,@IOBARON W ENWO W @IOBAROFF W !
Q
EXIT ;
Q
;ENWOD
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HENWOD 4809 printed Dec 13, 2024@01:56:13 Page 2
ENWOD ;(WIRMFO)/DLM/DH/SAB-Formatted Work Order Display ;5/11/2000
+1 ;;7.0;ENGINEERING;**35,43,65,96**;Aug 17, 1993;Build 5
EDIT ; Work order display/edit (screen) option
+1 DO WO^ENWOUTL
if Y'>0
GOTO EXIT
SET DA=+Y
+2 DO EDIT1
+3 GOTO EDIT
+4 ;
EDIT1 ; display/edit one work order
+1 ; input DA (ien of work order), DUZ (user number)
+2 NEW ENBARCD,ENDSTAT,ENEDIT,ENINV,ENJ,ENREOPEN,ENWO,ENWOCLOD,ENX
+3 ; flag, true if user edited work order
SET ENEDIT=0
+4 ; flag, true if closed work order reopened for edit
SET ENREOPEN=0
+5 DO D
FOR
DO READ
if ENX=""
QUIT
DO ACTION
if $PIECE($GET(^ENG(6920,DA,5)),U,2)]""&ENEDIT
QUIT
+6 IF ENEDIT
Begin DoDot:1
+7 ; work order edited by user
+8 NEW DIE,DR
+9 SET DIE="^ENG(6920,"
+10 IF ENREOPEN
IF $PIECE($GET(^ENG(6920,DA,5)),U,2)']""
SET DR="36//^S X=ENWOCLOD"
DO ^DIE
+11 IF $PIECE($GET(^ENG(6920,DA,5)),U,2)]""
Begin DoDot:2
+12 ; work order was closed
+13 IF "^5^6^"'[(U_$PIECE($GET(^ENG(6920,DA,4)),U,3)_U)
Begin DoDot:3
+14 ; status was not set to Completed or Disapproved
+15 SET DR="32///^S X=""COMPLETED"""
DO ^DIE
End DoDot:3
+16 IF $EXTRACT($PIECE($GET(^ENG(6920,DA,0)),U),1,3)="PM-"
Begin DoDot:3
+17 ; post PM hours for PM work order
+18 NEW ENPMDT,PMTOT,X
+19 DO PMHRS^ENEQPMR4
if '$DATA(PMTOT)
QUIT
+20 SET X=$PIECE($PIECE(^ENG(6920,DA,0),U),"-",2)
+21 FOR I=1:1:$LENGTH(X)
if $EXTRACT(X,I)?1N
SET ENPMDT=$GET(ENPMDT)_$EXTRACT(X,I)
+22 SET ENPMDT=$EXTRACT(ENPMDT,1,4)
+23 DO COUNT^ENBCPM8
End DoDot:3
End DoDot:2
+24 ; unlock
+25 LOCK -^ENG(6920,DA)
End DoDot:1
+26 QUIT
+27 ;
READ ;User interaction
+1 DO HOME^%ZIS
WRITE !,"ENTER/EDIT (1-33), D(DISPLAY), AC(ACCOUNT), P(PRINT)): EXIT// "
READ ENX:DTIME
+2 IF ENX=10
WRITE !,"Uneditable field.",*7
GOTO READ
+3 IF ENX=11
WRITE !,"A transfer option must be used to change SHOP.",*7
GOTO READ
+4 IF $EXTRACT(ENX)="^"!($EXTRACT(ENX)="E")
SET ENX=""
+5 if ENX=""
QUIT
IF ENX?1.2N
SET ENX=+ENX
IF ENX<1!(ENX>33)
WRITE " ??",*7
GOTO READ
+6 if ENX?1.2N
QUIT
SET ENX=$TRANSLATE(ENX,"dap","DAP")
IF "DAP"'[$EXTRACT(ENX)
WRITE " ??",*7
GOTO READ
+7 QUIT
+8 ;
ACTION ;Edit or display
+1 IF ENX'?1.2N
NEW TAG
SET TAG=$EXTRACT(ENX)
DO @TAG
QUIT
+2 ; try to prepare work order for editing (if not already done)
+3 IF 'ENEDIT
Begin DoDot:1
+4 LOCK +^ENG(6920,DA):5
IF '$TEST
WRITE !,"This work order is being edited by another user. Please try again later."
QUIT
+5 IF $PIECE($GET(^ENG(6920,DA,5)),U,2)]""
Begin DoDot:2
+6 WRITE $CHAR(7),!,"NOTE: This work order has been closed."
+7 IF '$DATA(^XUSEC("ENEDCLWO",DUZ))
WRITE !,"Security key ENEDCLWO is needed to edit closed work orders."
QUIT
+8 SET DIR("A")="Are you sure you want to edit this work order"
SET DIR(0)="Y"
SET DIR("B")="NO"
+9 DO ^DIR
KILL DIR
if Y'>0
QUIT
+10 IF $PIECE($GET(^ENG(6920,DA,3)),U,8)>0
DO KILLHS^ENEQHS
if $GET(R)="^"
QUIT
+11 SET ENWOCLOD=$PIECE(^ENG(6920,DA,5),U,2)
+12 SET $PIECE(^ENG(6920,DA,5),U,2)=""
DO TEST^ENWOCOMP
+13 IF $EXTRACT($PIECE($GET(^ENG(6920,DA,0)),U),1,3)="PM-"
Begin DoDot:3
+14 ; since reopening PM work order we must back out the PM hours
+15 NEW ENPMDT,PMTOT,X
+16 DO PMHRS^ENEQPMR4
if '$DATA(PMTOT)
QUIT
+17 SET X=$PIECE($PIECE(^ENG(6920,DA,0),U),"-",2)
+18 FOR I=1:1:$LENGTH(X)
if $EXTRACT(X,I)?1N
SET ENPMDT=$GET(ENPMDT)_$EXTRACT(X,I)
+19 SET ENPMDT=$EXTRACT(ENPMDT,1,4)
+20 DO UNPOST^ENBCPM8
End DoDot:3
+21 ; reopen of closed work order completed
SET ENREOPEN=1
End DoDot:2
IF 'ENREOPEN
QUIT
+22 ; work order ready for editing
SET ENEDIT=1
End DoDot:1
IF 'ENEDIT
LOCK -^ENG(6920,DA)
QUIT
+23 NEW DIE,DR,ENDA
+24 SET DR=$PIECE("16^1^2^3^4^STAT^6^7^8^^9^10^17^18^19^21^EQ53^21.9^22.3^22.5^23^20^31^35^35.5^37^38^37.5^47^16.5^36^39^40",U,ENX)
if DR="STAT"
SET DR=ENDSTAT
+25 IF $EXTRACT(DR,1,2)="EQ"
SET ENDA=DA
Begin DoDot:1
+26 SET DIE="^ENG(6914,"
SET DR=$EXTRACT(DR,3,99)
SET DA=$PIECE($GET(^ENG(6920,DA,3)),U,8)
+27 IF DA
Begin DoDot:2
+28 LOCK +^ENG(6914,DA):5
IF '$TEST
WRITE $CHAR(7),!,"Another user is editing this equipment. Try editing the condition later."
QUIT
+29 DO ^DIE
+30 LOCK -^ENG(6914,DA)
End DoDot:2
End DoDot:1
SET DA=ENDA
QUIT
+31 SET DIE="^ENG(6920,"
+32 IF DR=36
Begin DoDot:1
+33 WRITE !!,"Entry of a date will close this work order. Do this last."
+34 IF $DATA(ENWOCLOD)
SET DR="36//^S X=ENWOCLOD"
End DoDot:1
+35 DO ^DIE
+36 QUIT
+37 ;
D ;Display WO to CRT
+1 if $EXTRACT(IOST,1,2)="C-"
WRITE @IOF
DO ST^ENWOD1
DO TOP^ENWOD2
+2 QUIT
+3 ;
A ;Display Accounting Data
+1 SET X="PRCSP13"
XECUTE ^%ZOSF("TEST")
IF $TEST
Begin DoDot:1
+2 SET ENFLG=0
IF $DATA(^ENG(6920,DA,4))
IF $PIECE(^(4),U,2)]""
Begin DoDot:2
+3 SET ENWOACN=$PIECE(^ENG(6920,DA,4),U,2)
SET ENFLG=1
+4 IF $DATA(^PRCS(410,ENWOACN,0))
Begin DoDot:3
+5 SET ENWOOR=DA
SET DA=ENWOACN
+6 DO ^PRCSP13
+7 SET DA=ENWOOR
KILL ENWOOR
End DoDot:3
+8 KILL ENWOACN
End DoDot:2
+9 if 'ENFLG
WRITE !,"No procurement request on file for this work order."
+10 KILL ENFLG
End DoDot:1
+11 QUIT
+12 ;
P ;Print work order
+1 IF '$DATA(ENBARCD)
SET ENBARCD=0
IF $DATA(^ENG(6910.2,"B","PRINT BAR CODES ON W.O."))
SET I=$ORDER(^("PRINT BAR CODES ON W.O.",0))
IF I>0
IF $PIECE(^ENG(6910.2,I,0),U,2)="Y"
SET ENBARCD=1
+2 DO DEV^ENLIB
if POP
QUIT
IF $DATA(IO("Q"))
NEW X
SET ZTRTN="PRT1^ENWOD"
SET ZTSAVE("EN*")=""
SET ZTSAVE("DA")=""
SET ZTDESC="Print Work Order"
DO ^%ZTLOAD
KILL ZTSK
DO HOME^%ZIS
QUIT
PRT1 USE IO
if $EXTRACT(IOST,1,2)="C-"
WRITE @IOF
+1 if $EXTRACT(IOST,1,2)'="C-"
DO PSET^%ZISP
+2 DO ST^ENWOD1
DO TOP^ENWOD2
+3 if ENBARCD
DO BAR
+4 IF $EXTRACT(IOST,1,2)'="C-"
WRITE @IOF
DO PKILL^%ZISP
+5 ; to protect DA when W.O. printed to P-MESSAGE
NEW DA
+6 ; *96 close if the job is not queued in a task
+7 IF '$DATA(ZTQUEUED)
DO ^%ZISC
+8 QUIT
+9 ;
BAR ; print barcode of w.o. #
+1 IF $GET(IOBARON)]""
IF $GET(IOBAROFF)]""
WRITE !,@IOBARON
WRITE ENWO
WRITE @IOBAROFF
WRITE !
+2 QUIT
EXIT ;
+1 QUIT
+2 ;ENWOD