ACDPIMP ;IHS/ADC/EDE/KML - UNIX or DOS IMPORT 10:08;
;;4.1;CHEMICAL DEPENDENCY MIS;;MAY 11, 1998
;;
;***************************************************************
;Read files to reconstruct the ^ACDPTMP global onto
;the area/hq machines.
;This global hold/transmits cdmis program data from the file
;^ACDQAN
;*************************************************************
EN ;EP
;//[ACD SUPER8]
;
;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(^ACDP1TMP) W !!,*7,*7,"But an incomplete import exists due to a corrupt location table.",!,"I will try again to complete the import..." D EN^ACDPIMP1,K Q
;
;Initialize ^ACDPTMP to reconstruct on area/hq machine
I $D(^ACDPTMP) W !!,*7,*7,"It appears an import is presently running." D K Q
K ^ACDPTMP ; kill of scratch global SAC EXEMPTION (2.3.2.3 KILL of unsubscripted globals is prohibited)
;
W @IOF
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,"ACDP*",.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
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 for update",! Q
W !!!!,"Now updating CDMIS files with imported data....." D EN^ACDPIMP1
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 ^ACDPTMP
U IO(0) W !!!,"Now importing data from file: ",ACDFNA
F I=1:1:4 U IO R ACDHEAD(I):DTIME
I $P(ACDHEAD(4),U,20)'="IMPORT FILE" U IO(0) W !,"Not an 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)
S ACDIFC=ACDIFC+1
F U IO R ACD(1):DTIME,ACD(2):DTIME Q:ACD(1)="**" D
.S @ACD(1)=ACD(2)
.U IO(0) W "."
.Q
PASS ;Skip when user tries to import their own extract
;Skip when data to import is a duplicate
D ^%ZISC
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^ACDPXMD(ACDFNA,.ACDHEAD)
Q
;
K ;kill variables
K 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
K ACDA,%X,%Y,ACDIR,DIK,DIC,ACDMSG,XMZ,XMDUZ
ACDPIMP ;IHS/ADC/EDE/KML - UNIX or DOS IMPORT 10:08;
+1 ;;4.1;CHEMICAL DEPENDENCY MIS;;MAY 11, 1998
+2 ;;
+3 ;***************************************************************
+4 ;Read files to reconstruct the ^ACDPTMP global onto
+5 ;the area/hq machines.
+6 ;This global hold/transmits cdmis program data from the file
+7 ;^ACDQAN
+8 ;*************************************************************
EN ;EP
+1 ;//[ACD SUPER8]
+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(^ACDP1TMP)
WRITE !!,*7,*7,"But an incomplete import exists due to a corrupt location table.",!,"I will try again to complete the import..."
DO EN^ACDPIMP1
DO K
QUIT
+14 ;
+15 ;Initialize ^ACDPTMP to reconstruct on area/hq machine
+16 IF $DATA(^ACDPTMP)
WRITE !!,*7,*7,"It appears an import is presently running."
DO K
QUIT
+17 ; kill of scratch global SAC EXEMPTION (2.3.2.3 KILL of unsubscripted globals is prohibited)
KILL ^ACDPTMP
+18 ;
+19 WRITE @IOF
+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,"ACDP*",.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 SET ACDIFC=0
+18 FOR ACDI=1:1
KILL ACDOWN
SET ACDFNA=$PIECE(ACDLIST,",",ACDI)
IF ACDFNA=""
QUIT
SET ACDFNA=ACDF(ACDFNA)
DO L1
+19 IF 'ACDIFC
WRITE !!,"No data for update",!
QUIT
+20 WRITE !!!!,"Now updating CDMIS files with imported data....."
DO EN^ACDPIMP1
+21 WRITE !!!!?20,"Finished........."
+22 DO K
QUIT
+23 ;
+24 ;
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 ^ACDPTMP
+1 USE IO(0)
WRITE !!!,"Now importing data from file: ",ACDFNA
+2 FOR I=1:1:4
USE IO
READ ACDHEAD(I):DTIME
+3 IF $PIECE(ACDHEAD(4),U,20)'="IMPORT FILE"
USE IO(0)
WRITE !,"Not an Import file...I will skip it"
DO ^%ZISC
QUIT
+4 USE IO(0)
WRITE !,"FACILITY: ",ACDHEAD(2)
+5 SET ACDNODE=ACDHEAD(2)_","_$PIECE(ACDHEAD(4),U)_","_$PIECE(ACDHEAD(4),U,2)
+6 SET ACDIFC=ACDIFC+1
+7 FOR
USE IO
READ ACD(1):DTIME,ACD(2):DTIME
IF ACD(1)="**"
QUIT
Begin DoDot:1
+8 SET @ACD(1)=ACD(2)
+9 USE IO(0)
WRITE "."
+10 QUIT
End DoDot:1
PASS ;Skip when user tries to import their own extract
+1 ;Skip when data to import is a duplicate
+2 DO ^%ZISC
+3 WRITE !,"Deleting ",ACDFNA," from your system now..."
+4 SET Y=$$DEL^%ZISH(ACDIR,ACDFNA)
DO ERROR^ACDWUTL
+5 IF $DATA(ACDOWN)
USE IO(0)
WRITE !,"No Updating has occurred for this file."
+6 ;
XMD ;Audit trail
+1 DO EN^ACDPXMD(ACDFNA,.ACDHEAD)
+2 QUIT
+3 ;
K ;kill variables
+1 KILL 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
+3 KILL ACDA,%X,%Y,ACDIR,DIK,DIC,ACDMSG,XMZ,XMDUZ