Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: ENWONEW3

ENWONEW3.m

Go to the documentation of this file.
  1. ENWONEW3 ;WIRMFO/SAB-Incoming Inspection Work Order ;12.18.97
  1. ;;7.0;ENGINEERING;**35,47**;Aug 17, 1993
  1. ;
  1. IIWO(ENEQ) ; Generate Incoming Inspection Work Order
  1. ; called from ENEQ1, ENEQ3
  1. ; In
  1. ; ENEQ - equipment entry #
  1. ; ENMA("IIWO") - (optional) flag; true when multi equip entry
  1. ; ENMA("IIWO","DA") - (optional) w.o. ien generated for 1st equip
  1. ; ENMA("IIWO","ION") - (optional) device ion used with 1st equip w.o.
  1. ; ENMA("IIWO","QDT") - (optional) queued date/time of 1st w.o. print
  1. ; Out
  1. ; ENDA - work order ien
  1. ; ENWO - work order number
  1. ; also when $G(ENMA("IIWO")) true and device selected for output
  1. ; ENION - device ion used for (auto)print
  1. ; ENQDT - queued date/time when output queued
  1. ;
  1. N AUTOPRT,DA,DIC,DIE,DR,ENEDPM,ENI,ENJ,ENTEC,ENX
  1. N NUMBER,SHOPDEV,SHOPKEY,WARD
  1. K ENION,ENQDT S (ENDA,ENWO)=""
  1. ; determine user privileges
  1. S ENEDPM=$D(^XUSEC("ENEDPM",DUZ))
  1. ; determine shop of work order
  1. I $G(ENMA("IIWO","DA")) S SHOPKEY=$P($G(^ENG(6920,ENMA("IIWO","DA"),2)),U)
  1. E D
  1. . S SHOPKEY=$P(^DIC(6910,1,0),U,13) ; incoming inspection section
  1. . I SHOPKEY="" D ; or responsible shop
  1. . . S ENI=$O(^ENG(6914,ENEQ,4,0))
  1. . . I ENI S SHOPKEY=$P(^ENG(6914,ENEQ,4,ENI,0),U)
  1. . I SHOPKEY="" S SHOPKEY=$P(^DIC(6910,1,0),U,6) ; or temp w.o. section
  1. . ; ask shop if blank or user holds key
  1. . I SHOPKEY=""!ENEDPM F D Q:SHOPKEY]""
  1. . . S DIC="^DIC(6922,",DIC(0)="AQEM"
  1. . . I SHOPKEY S DIC("B")=$P($G(^DIC(6922,SHOPKEY,0)),U)
  1. . . I 'ENEDPM S DIC("S")="I Y#100>89" ; restrict to receiving areas
  1. . . D ^DIC K DIC
  1. . . I $D(DTOUT)!$D(DUOUT) S SHOPKEY="^" Q
  1. . . I Y>0 S SHOPKEY=+Y Q
  1. . . W !,"Shop required. Enter '^' if you don't want to create a W.O.",!
  1. I SHOPKEY'>0 W !,"Unspecified Shop. Work Order was NOT created." G EXIT
  1. ;
  1. ; create work order
  1. D WONUM^ENWONEW I NUMBER="" D G EXIT
  1. . W $C(7),!,"Can't seem to add to Work Order File."
  1. . W !,"You will need to manually create the incoming inspection W.O."
  1. S ENDA=DA,ENWO=NUMBER
  1. W !,"WORK ORDER #: ",NUMBER
  1. ; lock work order
  1. L +^ENG(6920,DA):5 I '$T D G EXIT
  1. . W $C(7),!,"Can't lock the new work order. Please contact IRM."
  1. ; populate work order
  1. ; with standard data for an electronic work order
  1. S WARD=1 D WOFILL^ENWONEW S WARD=0
  1. ; with data for an incoming inspection work order
  1. S DIE="^ENG(6920,"
  1. S DR="6///Incoming Inspection"
  1. S DR=DR_";17///AVERAGE"
  1. S DR=DR_";32///"_$S(SHOPKEY#100>89:"PENDING",1:"IN PROGRESS")
  1. I SHOPKEY#100>89 S DR=DR_";10///TODAY"
  1. D ^DIE
  1. K ENFDA S ENFDA(6920.035,"+2,"_DA_",",.01)="I1"
  1. D UPDATE^DIE("E","ENFDA")
  1. ; with equipment related data
  1. S DIE="^ENG(6920,"
  1. S DR="18///"_ENEQ
  1. S ENX=$$GET1^DIQ(6914,ENEQ,24) I ENX]"" S DR=DR_";3///"_ENX
  1. D ^DIE
  1. ; with user specified data
  1. S DIE="^ENG(6920,",DR=""
  1. I $G(ENMA("IIWO","DA")) D
  1. . ; copy comments from 1st work order
  1. . I $D(^ENG(6920,ENMA("IIWO","DA"),6)) D
  1. . . D WP^DIE(6920,DA_",",40,"","^ENG(6920,ENMA(""IIWO"",""DA""),6)")
  1. . ; copy other user editable fields from 1st work order into DR
  1. . S ENX=$P($G(^ENG(6920,ENMA("IIWO","DA"),2)),U,2) ; tech
  1. . I ENX]"" S DR=DR_";16////"_ENX
  1. . S ENX=$P($G(^ENG(6920,ENMA("IIWO","DA"),1)),U,3) ; contact
  1. . I ENX]"" S DR=DR_";7////"_ENX
  1. . S ENX=$P($G(^ENG(6920,ENMA("IIWO","DA"),1)),U,4) ; phone
  1. . I ENX]"" S DR=DR_";8////"_ENX
  1. I '$G(ENMA("IIWO","DA")) D
  1. . ; build DR string for user editable fields
  1. . ; determine responsible technician (if any)
  1. . S ENI=$O(^ENG(6914,ENEQ,4,0))
  1. . S ENJ=$S(ENI:$P(^ENG(6914,ENEQ,4,ENI,0),U,2),1:"")
  1. . S ENTEC=$S(ENJ:$P($G(^ENG("EMP",ENJ,0)),U),1:"")
  1. . I ENTEC]""!ENEDPM D
  1. . . S DR=DR_";16"
  1. . . I ENTEC]"" S DR=DR_"//"_$S(ENEDPM:"",1:"/")_ENTEC ; resp. tech
  1. . S DR=DR_";7;8;40"
  1. I $E(DR)=";" S DR=$E(DR,2,245)
  1. D ^DIE
  1. PRT ; print work order?
  1. S ENI=$O(^ENG(6910.2,"B","AUTO PRINT NEW W.O.",0))
  1. S AUTOPRT=$S(ENI:$P(^ENG(6910.2,ENI,0),U,2),1:"")
  1. S SHOPDEV=$$GET1^DIQ(6922,SHOPKEY,2)
  1. ; if no user interaction required then call woprnt
  1. I "^L^S^"[(U_AUTOPRT_U),SHOPDEV]"" S WARD=0 D WOPRNT^ENWONEW G PRTX
  1. ; if not autoprinted and shop is receiving area then skip
  1. I SHOPKEY#100>89 G PRTX
  1. ; if subsequent equipment of multiple then use previous device (if any)
  1. I $G(ENMA("IIWO","DA")) D G PRTX
  1. . S IOP=$G(ENMA("IIWO","ION"))
  1. . I IOP]"" S %ZIS="Q" D ^%ZIS Q:POP D PRTL
  1. ; if not autoprinted, not receiving area, and not subsequent then ask
  1. S DIR(0)="Y",DIR("A")="Print this work order",DIR("B")="YES"
  1. D ^DIR K DIR Q:Y'>0
  1. D DEV^ENLIB I POP D HOME^%ZIS G PRTX
  1. I $G(ENMA("IIWO")) S ENION=$S($D(IO("Q")):"Q;"_ION,1:ION)
  1. D PRTL
  1. PRTX ;
  1. ; unlock work order
  1. L -^ENG(6920,DA)
  1. EXIT ;
  1. Q
  1. ;
  1. PRTL ; Print W.O. Long Format
  1. ; determine required variables
  1. N ENBARCD,ENWO
  1. S ENBARCD=0
  1. S ENI=$O(^ENG(6910.2,"B","PRINT BAR CODES ON W.O."))
  1. I ENI,$P(^ENG(6910.2,ENI,0),U,2)="Y" S ENBARCD=1
  1. S ENWO=$P(^ENG(6920,DA,0),U)
  1. ;
  1. I $D(IO("Q")) D Q
  1. . S ZTRTN="PRT1^ENWOD",ZTDESC="Enginering Work Order"
  1. . S ZTIO=ION
  1. . ; when subsequent entry during multiple use date/time of 1st for task
  1. . I +$G(ENMA("IIWO","QDT")) S ZTDTH=ENMA("IIWO","QDT")
  1. . F ENX="DA","ENBARCD","ENWO" S ZTSAVE(ENX)=""
  1. . D ^%ZTLOAD
  1. . ; when 1st of multiple entry return date/time queued
  1. . I $G(ENMA("IIWO")),$G(ENION)]"" S ENQDT=$G(ZTSK("D"))
  1. . D HOME^%ZIS K ZTSK
  1. ;
  1. D PRT1^ENWOD
  1. I $E(IOST,1,2)="C-" D HOLD^ENWOD2
  1. K ENDSTAT,ENX,ENINV
  1. Q
  1. ;
  1. ;ENWONEW3