source: FOIAVistA/trunk/r/REGISTRATION-DGQE-DG-DPT-GRPX-VAD-VAF-VAS-VAT-VAU--VA-VIC--DGBT--DGJ--DGYA--VALM/DGPTAPA.m@ 1169

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

initial load of FOIAVistA 6/30/08 version

File size: 3.8 KB
Line 
1DGPTAPA ;MTC/ALB - PTF Archive Utilities; 10-14-92
2 ;;5.3;Registration;;Aug 13, 1993
3 ;
4ARC ;-- entry point to Archive PTF records
5 N DGTMP,REGEN
6 ;
7 ;-- set re-generation flag to yes
8 S REGEN=1
9 ;-- get template to archive
10 D SEL^VALM2 I '$D(VALMY) G ARCQ
11 S DGTMP=$O(^TMP("ARCPTF",$J,"AP LIST","REC",+$O(VALMY(0)),0))
12 ;
13 ;-- if data is already purged then exit
14 I $P(^DGP(45.62,DGTMP,0),U,7) W !,">>> PTF Archived Data Already Purged..." H 2 G ARCQ
15 ;-- find out if archive data exist
16 I $$MKARC(DGTMP,.REGEN) D
17 .;-- do archive to device
18 . I $$WR(DGTMP,REGEN) D
19 ..;-- update history file
20 .. D ADDARC(DGTMP)
21 ;
22ARCQ Q
23 ;
24ADDARC(TEMP) ;-- This function will add archive date, user and status
25 ;
26 ; INPUT : TEMP - IFN of the History File to update
27 ;
28 N SRTMP
29 ;-- if no A/P template exit
30 I '$D(^DGP(45.62,TEMP,0)) G ADDARCQ
31 ;-- new/revise archive data A/P template archive data
32 W !,">>> Adding Archive data to PTF Archive/Purge History entry."
33 S DA=TEMP,DIE="^DGP(45.62,",DR=".02////^S X=DUZ;.03///NOW;.04///1"
34 D ^DIE
35ADDARCQ ;
36 Q
37 ;
38ARCEX ;-- exit point from protocol
39 D TMPINT^DGPTLMU2
40 S VALMBCK="R"
41 Q
42 ;
43MKARC(DGTMP,REGEN) ;-- this function will create the word process field that contains the
44 ; archive data if one does not exists. If a field already exist then
45 ; the data will be deleted and the new field will be created.
46 ;
47 ; INPUT : DGTMP - A/P Template
48 ; REGEN - flag to indicate if re-gen of data is required
49 ; OUTPUT : 1 - ok continue
50 ; 0 - don't continue
51 ;
52 N DATE,EXIST
53 S EXIST=1
54 ;--if data has been purged, if so exit
55 G:$P($G(^DGP(45.62,DGTMP,0)),U,7) MKARCQ
56 ;--check if archive data already exists
57 I $G(^DGP(45.62,DGTMP,100,0))'="" S EXIST=$$CHDATA G:EXIST<0 MKARCQ
58 ;-- if regenerate delete old data, set flag
59 I EXIST D
60 . S DR="100///@",DA=DGTMP,DIE="^DGP(45.62," D ^DIE K DA,DR,DIE
61 . S REGEN=1
62 ;-- set flag NOT to regenerate
63 I 'EXIST S REGEN=0
64 S EXIST=1
65MKARCQ Q EXIST
66 ;
67CHDATA() ;-- if data already exists in WP field ask if should be purged
68 ; OUTPUT : 1 - ok continue
69 ; 0 - don't continue
70 ; -1 - user enters a "^"
71 N EXIST
72 S DIR(0)="Y",DIR("A")="Archive Data already exists. Should I re-generate the Archive data",DIR("B")="NO" D ^DIR
73 S EXIST=$S($D(DIRUT):-1,Y:1,1:0)
74 K DIR
75 Q EXIST
76CHECK ;
77 S Y=$$STATUS^DGPTLMU2(DGTMP)
78 Q
79 ;
80WR(DGTMP,REGEN) ;-- this function will write the archived data out to a sequential
81 ; device.
82 ; INPUT : DGTMP - Active PTF A/P template
83 ; REGEN - regeneration flag
84 ; OUTPUT : 1 - ok continue
85 ; 0 - don't continue
86 ;
87 N RESULT
88 S RESULT=1
89 W !!,*7,">>> Select Device for Archiving PTF Data."
90 S %ZIS="Q" D ^%ZIS I POP S RESULT=0 G WRQ
91 I $D(IO("Q")) D G WRQ
92 . S ZTRTN="WRITEM^DGPTAPA",ZTDESC="PTF A/P Archive",ZTSAVE("DGTMP")="",ZTSAVE("REGEN")=""
93 . D ^%ZTLOAD D HOME^%ZIS K IO("Q")
94 D WRITEM
95WRQ ;
96 Q RESULT
97 ;
98WRITEM ;-- loop thru write archive data
99 N I,X,DGPTF
100 U IO
101 ;-- check if archive data should be built
102 I REGEN D BLDAD(DGTMP)
103 ;-- write archived data to a device
104 S I=0 F S I=$O(^DGP(45.62,DGTMP,100,I)) Q:'I D
105 . S X=$G(^DGP(45.62,DGTMP,100,I,0))
106 . W:X]"" X,!
107 D ^%ZISC
108WRITEMQ ;
109 Q
110 ;
111BLDAD(DGTMP) ;-- This function will load the Archive data into the wp
112 ; field in the A/P template.
113 ;
114 ; INPUT : DGTMP - A/P Template
115 ;
116 N SRTMP,DGPTF,DATE
117 ;-- delete any data in wp field
118 I $D(DGP(45.62,DGTMP,100)) D
119 . S DR="100///@",DA=DGTMP,DIE="^DGP(45.62," D ^DIE K DA,DR,DIE
120 ;-- load header
121 S DATE="$PTF Records Selected from "_$$FTIME^VALM1($P(^DGP(45.62,DGTMP,0),U,10))_" thru "_$$FTIME^VALM1($P(^DGP(45.62,DGTMP,0),U,11))_"."
122 S DR="100///^S X=DATE",DA=DGTMP,DIE="^DGP(45.62," D ^DIE K DA,DR,DIE
123 ;-- add generic header to wp field
124 D MKHEAD^DGPTAPA4
125 ;-- archive selected records
126 S SRTMP=$P(^DGP(45.62,DGTMP,0),U,8),DGPTF=""
127 F S DGPTF=$O(^DIBT(SRTMP,1,DGPTF)) Q:'DGPTF D ARINT^DGPTAPA1
128 Q
129 ;
Note: See TracBrowser for help on using the repository browser.