source: WorldVistAEHR/trunk/r/ENGINEERING-EN/ENFAACQ.m@ 1271

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

initial load of WorldVistAEHR

File size: 3.5 KB
RevLine 
[613]1ENFAACQ ;WASHINGTON IRMFO/SAB; EQUIPMENT ACQUISITION; 1/3/97
2 ;;7.0;ENGINEERING;**29,39**;Aug 17, 1993
3 ;This routine should not be modified.
4 ;called from routines ENEQ1, ENEQ2, ENEQ3, ENFADEL and ENFAXMTM
5 ; Input
6 ; ENEQ("DA") - equipment entry #
7 ; should already be locked (if appropriate)
8 ; must not already have an active FA Document on file
9 ; ENBAT("SILENT") - (optional) $D true for silent batch processing
10 ; ENBAT("SEL") - (optional) $D true for batch (by CMR or Station)
11 ; Output
12 ; ^TMP($J,"BAD",ENEQ("DA"), - validation problems (if any)
13 ; only returned when $D(ENBAT("SILENT"))
14 D SETUP
15 D:ENDO VALEQ
16 D:ENDO ADDFA
17 K ENAV I ENDO,'$D(ENBAT("SEL")) D I $G(ENUT) S ENDO=0 K ENUT
18 . S ENAV=$$AVP^ENFAAV("6915.2",ENFA("DA"))
19 . I 'ENAV W !,"Adjustment voucher was NOT created."
20 D:'ENDO DEL
21 D:ENDO UPDATE
22 D WRAPUP
23 Q
24SETUP ;
25 S ENDO=1
26 S ENFA("DA")=""
27 S ENFAP("DOC")="FA"
28 F I=0:1:3,8,9 S ENEQ(I)=$G(^ENG(6914,ENEQ("DA"),I))
29 S:'$D(ENFAP("SITE")) ENFAP("SITE")=+^ENG(6915.1,1,0)
30 Q
31VALEQ ; validate equipment
32 K ^TMP($J,"BAD",ENEQ("DA"))
33 D ^ENFAVAL
34 I $D(^TMP($J,"BAD",ENEQ("DA"))) D:'$D(ENBAT("SILENT")) LISTP^ENFAXMTM S ENDO=0 Q
35 Q
36ADDFA ; create entry for FA code sheet
37 S DIC="^ENG(6915.2,",DIC(0)="L",DLAYGO=6915.2
38 S X=ENEQ("DA"),DIC("DR")="1///NOW;1.5////^S X=DUZ"
39 K DD,DO D FILE^DICN K DLAYGO
40 I Y'>0 D S ENDO=0 Q
41 . I $D(ENBAT("SILENT")) D BAD("Can't add to FA DOCUMENT LOG") Q
42 . W !!,"Can't update the FA DOCUMENT LOG file. Better contact IRM."
43 S ENFA("DA")=+Y
44 L +^ENG(6915.2,+Y):0 I '$T D S ENDO=0 Q
45 . I $D(ENBAT("SILENT")) D BAD("Can't lock FA Document") Q
46 . W !!,"The FA document that you just created can not be locked."
47 . W !,"Please notify your ADPAC."
48 S ENFAP(0)=$G(^ENG(6915.2,ENFA("DA"),0))
49 Q
50DEL ;
51 I $G(ENFA("DA"))]"" D
52 . S DA=ENFA("DA"),DIK="^ENG(6915.2," D ^DIK K DIK
53 . W:'$D(ENBAT("SILENT")) !,"FA Document deleted..."
54 I '$D(ENBAT("SILENT")) D
55 . W $C(7),!,"No action taken. Database unchanged."
56 . S DIR(0)="E" D ^DIR K DIR
57 Q
58UPDATE ;
59 ; update equipment file
60 ; populate station number field when blank
61 I $P(ENEQ(9),U,5)="" D
62 . S $P(^ENG(6914,ENEQ("DA"),9),U,5)=ENFAP("SITE")
63 . S $P(ENEQ(9),U,5)=ENFAP("SITE")
64 ; make sure value contains 2 decimals
65 I $P(ENEQ(2),U,3)'?1.12N1"."2N D
66 . S $P(ENEQ(2),U,3)=$$DEC^ENFAUTL($P(ENEQ(2),U,3))
67 . S $P(^ENG(6914,ENEQ("DA"),2),U,3)=$P(ENEQ(2),U,3)
68 ; if acquisition day not specified use 01
69 I $E($P(ENEQ(2),U,4),6,7)="00" D
70 . S $P(ENEQ(2),U,4)=$E($P(ENEQ(2),U,4),1,5)_"01"
71 . S $P(^ENG(6914,ENEQ("DA"),2),U,4)=$P(ENEQ(2),U,4)
72 ; if replacement day not specified use 01
73 I $E($P(ENEQ(2),U,10),6,7)="00" D
74 . S $P(ENEQ(2),U,10)=$E($P(ENEQ(2),U,10),1,5)_"01"
75 . S $P(^ENG(6914,ENEQ("DA"),2),U,10)=$P(ENEQ(2),U,10)
76 ; save current value in adjusted value field on code sheet
77 S ^ENG(6915.2,ENFA("DA"),200)=$P(ENEQ(2),U,3)
78 ; update FAP Balance
79 D ADJBAL^ENFABAL($P(ENEQ(9),U,5),$P(ENEQ(9),U,7),$P(ENEQ(8),U,6),$P($P(ENFAP(0),U,2),"."),$P(ENEQ(2),U,3))
80 ; transmit code sheet
81 W:'$D(ENBAT("SILENT")) !!,"Sending FA document to FAP..."
82 D ^ENFAXMT
83 ; save adjustment voucher
84 I $G(ENAV) D
85 . S DIE="^ENG(6915.2,",DR="301///NOW",DA=ENFA("DA") D ^DIE
86 . W !,"Adjustment Voucher was created.",!
87 Q
88WRAPUP ;
89 I $G(ENFA("DA"))]"" L -^ENG(6915.2,ENFA("DA"))
90 F I=0:1:3,8,9 K ENEQ(I)
91 K ENAV,ENDO,ENFAP,ENFA
92 K DA,DIC,DIE,DR,DIK,DIR,DIROUT,DIRUT,DTOUT,DUOUT,I,X,Y
93 Q
94BAD(X) ; add text to validation problem list
95 N I
96 S I=$P($G(^TMP($J,"BAD",ENEQ("DA"))),U)+1
97 S ^TMP($J,"BAD",ENEQ("DA"),I)=X
98 S ^TMP($J,"BAD",ENEQ("DA"))=I
99 Q
100 ;ENFAACQ
Note: See TracBrowser for help on using the repository browser.