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

ACDVIMP.m

Go to the documentation of this file.
  1. ACDVIMP ;IHS/ADC/EDE/KML - UNIX OR DOS IMPORT; [ 11/03/1999 12:09 PM ]
  1. ;;4.1;CHEMICAL DEPENDENCY MIS;**3**;MAY 11, 1998
  1. ;;
  1. ;***************************************************************
  1. ;Read files to reconstruct the ^ACDVTMP global onto
  1. ;the area/hq machines.
  1. ;This globals holds/transmits cdmis visit data and the associated
  1. ;data from the link files
  1. ;*************************************************************
  1. EN ;EP
  1. ;//[ACD SUPER0]
  1. ;
  1. ;Check for black box
  1. I '$L($T(OPEN^%ZISH)) W !,"But you need to first install patch 25 of Kernel 7" Q
  1. ;
  1. DIR ;Ask user for directory
  1. S DIR("B")=$S($P($G(^AUTTSITE(1,0)),U,21)=1:"/usr/spool/uucppublic",1:"C:\EXPORT")
  1. S DIR(0)="F^1:100",DIR("A")="Directory to import from "
  1. W !
  1. D ^DIR K DIR
  1. I $D(DIRUT) D K Q
  1. S ACDIR=X
  1. ;
  1. ;
  1. ;Stop user if facility
  1. I $E(ACD6DIG)'=9,$E(ACD6DIG,3,4)'="00" W !!,*7,*7,"Facilities have no need to import data." D K Q
  1. ;
  1. ;Check for unfinished import
  1. I $D(^ACDV1TMP) W !!,*7,*7,"But an incomplete import exists due to a corrupt location table.",!,"I will try again to complete the import..." D EN^ACDVIMP1,K Q
  1. ;
  1. ;Initialize ^ACDVTMP to reconstruct on area/hq machine
  1. I $D(^ACDVTMP) W !!,*7,*7,"It appears an import is presently running." D K Q
  1. K ^ACDVTMP ; kill of scratch global SAC EXEMPTION (2.3.2.3 KILLING of unsubscripted globals is prohibited)
  1. ;
  1. W @IOF,!!,*7,*7,"Please note that I will not allow you to import your own",!,"extract and will automatically delete the file for you...",!!
  1. W !!,"It is advisable to capture the upcomming terminal screens to a printer.",!,"Please open a log file or turn on 'PRINT SCREEN'."
  1. F W !!,"Ok to Continue: " S %=2 D YN^DICN W:%=0 " Answer Yes or No" G:%'=1&(%'=0) K Q:%=1
  1. ;
  1. F ;File import from
  1. ;Gather all files into a list for display/selection
  1. K ACDF
  1. S Y=$$LIST^%ZISH(ACDIR,"ACDV*",.ACDF) D ERROR^ACDWUTL
  1. I '$O(ACDF(0)) W !!,*7,*7,"No CDMIS import files found in ",ACDIR
  1. I W !,"Job terminated....." D K Q
  1. ;
  1. ;
  1. ;Display files available for the user to import
  1. S ACDN=0 F I=0:0 S I=$O(ACDF(I)) Q:'I S ACDN=ACDN+1 W !,I," ",ACDF(I)
  1. S DIR(0)="L^1:"_ACDN,DIR("A")="Select the FILE to IMPORT"
  1. W !
  1. D ^DIR
  1. I $D(DIRUT) D K Q
  1. S ACDLIST=Y
  1. ;
  1. ;Process imported files one at a time
  1. K ACDFILES
  1. S ACDIFC=0
  1. F ACDI=1:1 K ACDOWN S ACDFNA=$P(ACDLIST,",",ACDI) Q:ACDFNA="" S ACDFNA=ACDF(ACDFNA) D L1
  1. I 'ACDIFC W !!,"No data to update",! Q
  1. W !!,"Now updating CDMIS files with imported data....." D EN^ACDVIMP1
  1. W !!,"Now purging files and setting audit trail",!
  1. K ACDOWN
  1. S ACDFNA=""
  1. F S ACDFNA=$O(ACDFILES(ACDFNA)) Q:ACDFNA="" D D PASS2
  1. . F I=1:1:4 S ACDHEAD(I)=ACDFILES(ACDFNA,I)
  1. . Q
  1. W !!!?20,"Finished........."
  1. D K Q
  1. ;
  1. ;
  1. L1 ;Open file to read from
  1. S Y=$$OPEN^%ZISH(ACDIR,ACDFNA,"R") I Y W !,"Error code: ",Y," detected." D K Q
  1. ;
  1. IN ;Read in from the imported file to build ^ACDVTMP
  1. U IO(0) W !!,"Now importing data from file: ",ACDFNA
  1. F I=1:1:4 U IO R ACDHEAD(I):DTIME
  1. ;Start of Patch *3* IHS/DSD/HJT ACD*4.1*3 10/20/1999
  1. ; The following code checks record 4 to see if created by NT machine
  1. ; and makes the proper adjustment if so.
  1. S XACDLN=$L(ACDHEAD(4))
  1. I $A($E(ACDHEAD(4),XACDLN))=13 S ACDHEAD(4)=$E(ACDHEAD(4),1,XACDLN-1)
  1. ;End of Patch *3*
  1. ;
  1. I $P(ACDHEAD(4),U,20)'="IMPORT FILE" U IO(0) W !,"Not a Import file...I will skip it" D ^%ZISC Q
  1. U IO(0) W !,"FACILITY: ",ACDHEAD(2)
  1. S ACDNODE=ACDHEAD(2)_","_$P(ACDHEAD(4),U)_","_$P(ACDHEAD(4),U,2)
  1. I $D(^ACDVTMP4(ACDNODE)) U IO(0) W !!,"It appears that the data from this file has already been imported once.",! S ACDOWN=1 G PASS
  1. I $P(^DIC(4,DUZ(2),0),U)=$E(ACDHEAD(2),2,9999),$E(ACD6DIG)'=9 U IO(0) W !!,*7,*7,*7,*7,"** You are trying to import your own extract. NOT ALLOWED **." S ACDOWN=1 G PASS
  1. I $P(^DIC(4,DUZ(2),0),U)=$E(ACDHEAD(2),2,9999),$E(ACD6DIG)=9 W !!,"OK,Headquarters is importing an archive created at Headquarters.",!!
  1. S ACDIFC=ACDIFC+1
  1. ;Start of Patch *3* IHS/DSD/HJT ACD*4.1*3 10/20/1999
  1. S ^ACDVTMP4(ACDNODE)=""
  1. N ACDQUIT S ACDQUIT=0
  1. F I=1:1 U IO R ACD(1):DTIME,ACD(2):DTIME D Q:ACDQUIT
  1. .I ACD(1)="**" S ACDQUIT=1 Q
  1. .I ACD(1)["**"&($A($E(ACD(1),$L(ACD(1))))=13) S ACDQUIT=1 Q
  1. .; If source is NT, a CR [$A(...)=13] is inserted at end of each line
  1. .; The following code removes it
  1. .F IJ=1,2 S XACDLN=$L(ACD(IJ)) I $A($E(ACD(IJ),XACDLN))=13 S ACD(IJ)=$E(ACD(IJ),1,XACDLN-1) ;HJT
  1. .;End of Patch *3*
  1. .S @ACD(1)=ACD(2)
  1. .I '(I#50) U IO(0) W "."
  1. .Q
  1. S ACDFILES(ACDFNA)=""
  1. F I=1:1:4 S ACDFILES(ACDFNA,I)=ACDHEAD(I)
  1. D ^%ZISC
  1. Q
  1. PASS ;Skip when user tries to import their own extract
  1. ;Skip when data to import is a duplicate
  1. D ^%ZISC
  1. PASS2 ; FOR PURGING FILES AFTER DATA INSTALLED
  1. W !,"Deleting ",ACDFNA," from your system now..."
  1. S Y=$$DEL^%ZISH(ACDIR,ACDFNA) D ERROR^ACDWUTL
  1. I $D(ACDOWN) U IO(0) W !,"No Updating has occurred for this file."
  1. ;
  1. XMD ;Audit trail
  1. D EN^ACDVXMD(ACDFNA,.ACDHEAD)
  1. Q
  1. ;
  1. K ;kill variables
  1. K ACDFILES,ACDIFC
  1. K ACD,ACDF,ACDIOP,DIR,XMY,ACDLINE,ACDBWP,ACDCS,ACDDA,ACDDUZ,ACDFNA,ACDHEAD,ACDI,ACDIIF,ACDLIST,ACDN,ACDPG,ACDRNG,ACDRUG,ACDTDC,ACDUSER,ACDV,ACDNODE,XACDLN
  1. Q