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

DGPTAPA.m

Go to the documentation of this file.
  1. DGPTAPA ;MTC/ALB - PTF Archive Utilities; 10-14-92
  1. ;;5.3;Registration;;Aug 13, 1993
  1. ;
  1. ARC ;-- entry point to Archive PTF records
  1. N DGTMP,REGEN
  1. ;
  1. ;-- set re-generation flag to yes
  1. S REGEN=1
  1. ;-- get template to archive
  1. D SEL^VALM2 I '$D(VALMY) G ARCQ
  1. S DGTMP=$O(^TMP("ARCPTF",$J,"AP LIST","REC",+$O(VALMY(0)),0))
  1. ;
  1. ;-- if data is already purged then exit
  1. I $P(^DGP(45.62,DGTMP,0),U,7) W !,">>> PTF Archived Data Already Purged..." H 2 G ARCQ
  1. ;-- find out if archive data exist
  1. I $$MKARC(DGTMP,.REGEN) D
  1. .;-- do archive to device
  1. . I $$WR(DGTMP,REGEN) D
  1. ..;-- update history file
  1. .. D ADDARC(DGTMP)
  1. ;
  1. ARCQ Q
  1. ;
  1. ADDARC(TEMP) ;-- This function will add archive date, user and status
  1. ;
  1. ; INPUT : TEMP - IFN of the History File to update
  1. ;
  1. N SRTMP
  1. ;-- if no A/P template exit
  1. I '$D(^DGP(45.62,TEMP,0)) G ADDARCQ
  1. ;-- new/revise archive data A/P template archive data
  1. W !,">>> Adding Archive data to PTF Archive/Purge History entry."
  1. S DA=TEMP,DIE="^DGP(45.62,",DR=".02////^S X=DUZ;.03///NOW;.04///1"
  1. D ^DIE
  1. ADDARCQ ;
  1. Q
  1. ;
  1. ARCEX ;-- exit point from protocol
  1. D TMPINT^DGPTLMU2
  1. S VALMBCK="R"
  1. Q
  1. ;
  1. MKARC(DGTMP,REGEN) ;-- this function will create the word process field that contains the
  1. ; archive data if one does not exists. If a field already exist then
  1. ; the data will be deleted and the new field will be created.
  1. ;
  1. ; INPUT : DGTMP - A/P Template
  1. ; REGEN - flag to indicate if re-gen of data is required
  1. ; OUTPUT : 1 - ok continue
  1. ; 0 - don't continue
  1. ;
  1. N DATE,EXIST
  1. S EXIST=1
  1. ;--if data has been purged, if so exit
  1. G:$P($G(^DGP(45.62,DGTMP,0)),U,7) MKARCQ
  1. ;--check if archive data already exists
  1. I $G(^DGP(45.62,DGTMP,100,0))'="" S EXIST=$$CHDATA G:EXIST<0 MKARCQ
  1. ;-- if regenerate delete old data, set flag
  1. I EXIST D
  1. . S DR="100///@",DA=DGTMP,DIE="^DGP(45.62," D ^DIE K DA,DR,DIE
  1. . S REGEN=1
  1. ;-- set flag NOT to regenerate
  1. I 'EXIST S REGEN=0
  1. S EXIST=1
  1. MKARCQ Q EXIST
  1. ;
  1. CHDATA() ;-- if data already exists in WP field ask if should be purged
  1. ; OUTPUT : 1 - ok continue
  1. ; 0 - don't continue
  1. ; -1 - user enters a "^"
  1. N EXIST
  1. S DIR(0)="Y",DIR("A")="Archive Data already exists. Should I re-generate the Archive data",DIR("B")="NO" D ^DIR
  1. S EXIST=$S($D(DIRUT):-1,Y:1,1:0)
  1. K DIR
  1. Q EXIST
  1. CHECK ;
  1. S Y=$$STATUS^DGPTLMU2(DGTMP)
  1. Q
  1. ;
  1. WR(DGTMP,REGEN) ;-- this function will write the archived data out to a sequential
  1. ; device.
  1. ; INPUT : DGTMP - Active PTF A/P template
  1. ; REGEN - regeneration flag
  1. ; OUTPUT : 1 - ok continue
  1. ; 0 - don't continue
  1. ;
  1. N RESULT
  1. S RESULT=1
  1. W !!,*7,">>> Select Device for Archiving PTF Data."
  1. S %ZIS="Q" D ^%ZIS I POP S RESULT=0 G WRQ
  1. I $D(IO("Q")) D G WRQ
  1. . S ZTRTN="WRITEM^DGPTAPA",ZTDESC="PTF A/P Archive",ZTSAVE("DGTMP")="",ZTSAVE("REGEN")=""
  1. . D ^%ZTLOAD D HOME^%ZIS K IO("Q")
  1. D WRITEM
  1. WRQ ;
  1. Q RESULT
  1. ;
  1. WRITEM ;-- loop thru write archive data
  1. N I,X,DGPTF
  1. U IO
  1. ;-- check if archive data should be built
  1. I REGEN D BLDAD(DGTMP)
  1. ;-- write archived data to a device
  1. S I=0 F S I=$O(^DGP(45.62,DGTMP,100,I)) Q:'I D
  1. . S X=$G(^DGP(45.62,DGTMP,100,I,0))
  1. . W:X]"" X,!
  1. D ^%ZISC
  1. WRITEMQ ;
  1. Q
  1. ;
  1. BLDAD(DGTMP) ;-- This function will load the Archive data into the wp
  1. ; field in the A/P template.
  1. ;
  1. ; INPUT : DGTMP - A/P Template
  1. ;
  1. N SRTMP,DGPTF,DATE
  1. ;-- delete any data in wp field
  1. I $D(DGP(45.62,DGTMP,100)) D
  1. . S DR="100///@",DA=DGTMP,DIE="^DGP(45.62," D ^DIE K DA,DR,DIE
  1. ;-- load header
  1. 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))_"."
  1. S DR="100///^S X=DATE",DA=DGTMP,DIE="^DGP(45.62," D ^DIE K DA,DR,DIE
  1. ;-- add generic header to wp field
  1. D MKHEAD^DGPTAPA4
  1. ;-- archive selected records
  1. S SRTMP=$P(^DGP(45.62,DGTMP,0),U,8),DGPTF=""
  1. F S DGPTF=$O(^DIBT(SRTMP,1,DGPTF)) Q:'DGPTF D ARINT^DGPTAPA1
  1. Q
  1. ;