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