source: WorldVistAEHR/trunk/r/ENGINEERING-EN/ENWOLD.m@ 1800

Last change on this file since 1800 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 2.9 KB
Line 
1ENWOLD ;(WIRMFO)/DH-Delete Old Incomplete PM Work Orders ;12/1/1999
2 ;;7.0;ENGINEERING;**35,64**;Aug 17,1993
3 ;
4 ; Check for old incomplete PM work orders
5 ; If count>500 user may schedule automatic deletion
6 ;
7 ; Sets global node if appropriate
8 ; User prompted for cut-off date and execution time
9 ; Cut-off date may not be more recent than T-365
10EN ;
11 I $P($G(^ENG(6920,0)),U,4)'>300 G EXIT ;Why bother?
12 N DA,SHOP,COUNT,LINE
13 D HOME^%ZIS
14 S Y=$$FMADD^XLFDT(DT,-365) S %DT(0)=-Y X ^DD("DD") S %DT("B")=Y
15 W !!,"NOTE: Creation Dates more recent than "_%DT("B")_" will not be",!," accepted.",!,*7
16 S %DT="AEP" S %DT("A")="Delete Incomplete PM Work Orders created prior to: "
17 D ^%DT I X=U!($D(DTOUT)) G EXIT
18 G:Y'>0 EN ;Shouldn't happen
19 S ENSTART=+Y ;Inverse start date (counting backwards)
20 X ^DD("DD") S ENSTART("E")=Y
21 S DA=$O(^ENG(6920,9999999999),-1),COUNT("TOT")=0,ENX=1
22 W !,"Counting."
23 F S DA=DA-50 Q:DA'>0 S X=$P($G(^ENG(6920,DA,0)),U,2) I X]"",X<ENSTART Q
24 F Q:$P($G(^ENG(6920,DA+1,0)),U,2)>(ENSTART-1) S DA=DA+1
25 S ENDA("START")=DA ;Starting point for 'AINC' x-ref, inverse chronology
26 S SHOP=0 F S SHOP=$O(^ENG(6920,"AINC",SHOP)) Q:'SHOP D
27 . S ENDA=9999999999-ENDA("START"),COUNT(SHOP)=0
28 . F S ENDA=$O(^ENG(6920,"AINC",SHOP,ENDA)) Q:'ENDA D
29 .. S DA=9999999999-ENDA
30 .. I $E($P($G(^ENG(6920,DA,0)),U),1,3)="PM-" S COUNT("TOT")=COUNT("TOT")+1,COUNT(SHOP)=COUNT(SHOP)+1
31 .. I '(DA#100) W "." S ENX=ENX+1 I ENX>IOM W !
32 I COUNT("TOT")>500 D G EXIT
33 . S Y=ENSTART X ^DD("DD")
34 . W @IOF,"There are about "_COUNT("TOT")_" incomplete PM work orders on your system that were"
35 . W !,"created prior to "_ENSTART("E")_". The following is a breakout by shop:"
36 . K X S $P(X,"-",79)="-" W !,X S LINE=4
37 . S SHOP=0 F S SHOP=$O(COUNT(SHOP)) Q:'SHOP D:COUNT(SHOP)>0
38 .. S ENSHOP(SHOP)=COUNT(SHOP)
39 .. I $D(^DIC(6922,SHOP,0)) W !,$P(^(0),U),?30,COUNT(SHOP) S LINE=LINE+1
40 .. I (IOSL-LINE)'>2 R !,"Press <RETURN> to continue...",X:DTIME S LINE=2
41 . K DIR S DIR(0)="Y",DIR("A")="Would you like to schedule a task to delete these work orders",DIR("B")="YES"
42 . D ^DIR K DIR Q:$D(DIRUT)!('Y)
43 . S ZTRTN="DEQUE^ENWOLD",ZTDESC="Delete old incomplete PM work orders"
44 . S ZTSAVE("EN*")="",ZTIO="" D ^%ZTLOAD K ZTSK
45 W !!,"Fewer than 500 existing incomplete PM work orders were created prior to ",!,ENSTART("E")_". No need to continue."
46 R !!,"Press <RETURN> to continue...",X:DTIME
47EXIT K %DT,ENDA,ENSTART,ENSHOP,ENX
48 Q
49 ;
50DEQUE N EN,SHOP,DA,DIK,COUNT S COUNT=0
51 S DIK="^ENG(6920,",SHOP=0
52 F S SHOP=$O(ENSHOP(SHOP)) Q:'SHOP D
53 . S ENDA=9999999999-ENDA("START")
54 . F S ENDA=$O(^ENG(6920,"AINC",SHOP,ENDA)) Q:'ENDA D
55 .. S DA=9999999999-ENDA
56 .. I $E($P($G(^ENG(6920,DA,0)),U),1,3)="PM-" S COUNT=COUNT+1 D ^DIK
57MSG ;
58 S XMY(DUZ)="",XMDUZ=.5,XMSUB="Deletion of Old Incomplete PM Work Orders"
59 S EN(1)=COUNT_" old incomplete PM work orders were just deleted."
60 S XMTEXT="EN("
61 D ^XMD
62 K XMY,XMDUZ,XMTEXT,XMSUB,ENDA,ENSTART,ENSHOP
63 I $D(ZTQUEUED) S ZTREQ="@"
64 Q
65 ;ENWOLD
Note: See TracBrowser for help on using the repository browser.