BWUPLD ;IHS/ANMC/MWR - UPLOAD: UPLOAD LAB FILES;11-Feb-2003 18:09;PLS
;;2.0;WOMEN'S HEALTH;**8**;MAY 16, 1996
;;* MICHAEL REMILLARD, DDS * ALASKA NATIVE MEDICAL CENTER *
;; CALLED BY OPTION: "BW UPLD LOAD LAB FILES" TO UPLOAD FROM HFS
;; COMMERCIAL LAB ABBREVIATION TABLES AND RESULTS.
;
;---> THIS ROUTINE UPLOADS THE SELECTED HOST FILE: EITHER A
;---> TABLE OF RESULTS ABBREVIATIONS FROM A COMMERCIAL LAB,
;---> OR A FILE OF LAB TEST RESULTS FROM A COMMERCIAL.
;---> THE HOST FILE IS FIRST READ INTO A TEMPORARY "HOLDING" FILE,
;---> CONVERTED FROM FIXED LENGTH IF NECESSARY DURING THE READ.
;---> THEN A SECOND ROUTINE IS CALLED TO MOVE DATA FROM THE
;---> TEMPORARY FILE INTO THE APPROPRIATE PERMANENT FILE.
;
START ;EP
N BWHNDL
S BWHNDL="WHEALTH"
D SETVARS^BWUTL5
D TITLE^BWUTL5("UTILITY TO IMPORT LAB RESULTS")
W !!?3,"NOTE: THIS UTILITY IS FOR USE ONLY WITH CORNING CLINICAL"
W " LABORATORIES."
S BWHFS=$P(^BWSITE(DUZ(2),0),U,14)
I BWHFS']"" D Q
.W !!?5,"No Host File Path has been specified in the Site Parameters."
.W !?5,"Edit the Site Parameters or contact your site manager.",!
.D DIRZ^BWUTL3
;
;---> CHOOSE FILE TO UPLOAD.
N DIR,DIRUT,Y
W !!!?3,"Choose lab name and type of file to upload."
W !?3,"(Note: The Corning Table must be loaded before the Corning "
W "Results.)"
S DIR("A")=" Select file name and type"
S DIR(0)="SMO^CT:Corning Table;CR:Corning Results"
D HELP1
D ^DIR
I Y=-1!($D(DIRUT)) S BWPOP=1 G EXIT
S BWA=Y
;---> BELOW, BWGBL IDENTIFIES THE TEMPORARY FILE, BWRTN IDENTIFIES
;---> THE ROUTINE FOR CONVERTING THE DATA (FROM FIXED LENGTH, ETC.)
;---> AND FOR TRANSFERING THE DATA FROM THE TEMPORARY FILE TO THE
;---> PERMANENT FILE.
D
.I BWA="CT" S BWRTN="^BWUPTNI",BWGBL="^BWTNI(" Q
.I BWA="CR" S BWRTN="^BWUPRNI",BWGBL="^BWRNI(" Q
I '$D(@(BWGBL_"0)")) W !,"Receiving global does not exist." Q
S BWGBLN=$P(@(BWGBL_"0)"),U)
;
;---> ASK FOR HOST FILE NAME.
K DIR
W !!?5,"Enter the name of the file you wish to import."
W !?5,"Do not include any slashes in the filename.",!
S DIR(0)="FOA",DIR("A")=" Enter filename: "
S DIR("?")=" Enter the filename without any path "
S DIR("?")=DIR("?")_"--just the filename itself."
D ^DIR
I $D(DIRUT) S BWPOP=1 Q
S BWFLNM=Y
;
;---> KILL OFF EXISTING TEMPORARY FILE GLOBAL.
D ZGBL^BWUTL8(BWGBL)
;
READ ;EP
;---> READ LINES OF HOST FILE TEXT AND STUFF AS NODES IN ^BWTNI
S Y=$$OPEN^%ZISH(BWHNDL,BWHFS,BWFLNM,"R")
I Y D Q
.W !?10,"* FAILURE TO OPEN HOST FILE: ",BWHFS,BWFLNM," (",Y,")"
.W !?10," CHECK FILENAME AND PATH IN SITE PARAMETERS.",!
.D DIRZ^BWUTL3
;
W !!?5,"Uploading Host File to ",BWGBLN," file..."
U IO
F BWI=1:1 R BWLINE:DTIME Q:'$L(BWLINE) D
.Q:$P(BWLINE,U)?1C.C
.;---> CONVERT FIXED LENGTH FIELDS TO VARIABLE, DELIMITED BY "^", ETC.
.N Y
.D @("CVT"_BWRTN_"(.BWLINE,.Y)")
.Q:BWLINE=""
.I 'Y S @(BWGBL_BWI_",0)")=BWLINE Q
.S @(BWGBL_BWI_",0)")=$P(BWLINE,U,1,12)
.S @(BWGBL_BWI_",1)")=$P(BWLINE,U,13,18)
.S @(BWGBL_BWI_",2)")=$P(BWLINE,U,19,25)
D ^%ZISC
;
INDEX ;EP
;---> NOW INDEX THE FILE.
W !?5,"Indexing ",BWGBLN," file..."
S DIK=BWGBL D IXALL^DIK
;
TRANSFER ;EP
;---> TRANSFER TEMPORARY TABLE ENTRIES TO PERMANENT FILE.
D @("TRANS"_BWRTN)
;
W !?5,"Deleting ",BWGBLN," data..."
;---> CLEANUP: KILL OFF EXISTING TEMPORARY FILE GLOBAL.
D ZGBL^BWUTL8(BWGBL)
W !?5,"Complete.",! D DIRZ^BWUTL3
;
EXIT ;EP
D KILLALL^BWUTL8
Q
;
HELPTX ;EP
N I,T,X S T="" F I=1:1:BWTAB S T=T_" "
F I=1:1 S X=$T(@BWLINL+I) Q:X'[";;" S DIR("?",I)=T_$P(X,";;",2)
S DIR("?")=DIR("?",I-1) K DIR("?",I-1)
Q
;
HELP1 ;EP
;;Table files contain the Abbreviations Table for the selected lab.
;;Results files contain the coded results of patients' tests for
;;the selected lab.
S BWTAB=5,BWLINL="HELP1" D HELPTX
Q
BWUPLD ;IHS/ANMC/MWR - UPLOAD: UPLOAD LAB FILES;11-Feb-2003 18:09;PLS
+1 ;;2.0;WOMEN'S HEALTH;**8**;MAY 16, 1996
+2 ;;* MICHAEL REMILLARD, DDS * ALASKA NATIVE MEDICAL CENTER *
+3 ;; CALLED BY OPTION: "BW UPLD LOAD LAB FILES" TO UPLOAD FROM HFS
+4 ;; COMMERCIAL LAB ABBREVIATION TABLES AND RESULTS.
+5 ;
+6 ;---> THIS ROUTINE UPLOADS THE SELECTED HOST FILE: EITHER A
+7 ;---> TABLE OF RESULTS ABBREVIATIONS FROM A COMMERCIAL LAB,
+8 ;---> OR A FILE OF LAB TEST RESULTS FROM A COMMERCIAL.
+9 ;---> THE HOST FILE IS FIRST READ INTO A TEMPORARY "HOLDING" FILE,
+10 ;---> CONVERTED FROM FIXED LENGTH IF NECESSARY DURING THE READ.
+11 ;---> THEN A SECOND ROUTINE IS CALLED TO MOVE DATA FROM THE
+12 ;---> TEMPORARY FILE INTO THE APPROPRIATE PERMANENT FILE.
+13 ;
START ;EP
+1 NEW BWHNDL
+2 SET BWHNDL="WHEALTH"
+3 DO SETVARS^BWUTL5
+4 DO TITLE^BWUTL5("UTILITY TO IMPORT LAB RESULTS")
+5 WRITE !!?3,"NOTE: THIS UTILITY IS FOR USE ONLY WITH CORNING CLINICAL"
+6 WRITE " LABORATORIES."
+7 SET BWHFS=$PIECE(^BWSITE(DUZ(2),0),U,14)
+8 IF BWHFS']""
Begin DoDot:1
+9 WRITE !!?5,"No Host File Path has been specified in the Site Parameters."
+10 WRITE !?5,"Edit the Site Parameters or contact your site manager.",!
+11 DO DIRZ^BWUTL3
End DoDot:1
QUIT
+12 ;
+1 ;---> CHOOSE FILE TO UPLOAD.
+2 NEW DIR,DIRUT,Y
+3 WRITE !!!?3,"Choose lab name and type of file to upload."
+4 WRITE !?3,"(Note: The Corning Table must be loaded before the Corning "
+5 WRITE "Results.)"
+6 SET DIR("A")=" Select file name and type"
+7 SET DIR(0)="SMO^CT:Corning Table;CR:Corning Results"
+8 DO HELP1
+9 DO ^DIR
+10 IF Y=-1!($DATA(DIRUT))
SET BWPOP=1
GOTO EXIT
+11 SET BWA=Y
+12 ;---> BELOW, BWGBL IDENTIFIES THE TEMPORARY FILE, BWRTN IDENTIFIES
+13 ;---> THE ROUTINE FOR CONVERTING THE DATA (FROM FIXED LENGTH, ETC.)
+14 ;---> AND FOR TRANSFERING THE DATA FROM THE TEMPORARY FILE TO THE
+15 ;---> PERMANENT FILE.
+16 Begin DoDot:1
+17 IF BWA="CT"
SET BWRTN="^BWUPTNI"
SET BWGBL="^BWTNI("
QUIT
+18 IF BWA="CR"
SET BWRTN="^BWUPRNI"
SET BWGBL="^BWRNI("
QUIT
End DoDot:1
+19 IF '$DATA(@(BWGBL_"0)"))
WRITE !,"Receiving global does not exist."
QUIT
+20 SET BWGBLN=$PIECE(@(BWGBL_"0)"),U)
+21 ;
+22 ;---> ASK FOR HOST FILE NAME.
+23 KILL DIR
+24 WRITE !!?5,"Enter the name of the file you wish to import."
+25 WRITE !?5,"Do not include any slashes in the filename.",!
+26 SET DIR(0)="FOA"
SET DIR("A")=" Enter filename: "
+27 SET DIR("?")=" Enter the filename without any path "
+28 SET DIR("?")=DIR("?")_"--just the filename itself."
+29 DO ^DIR
+30 IF $DATA(DIRUT)
SET BWPOP=1
QUIT
+31 SET BWFLNM=Y
+32 ;
+33 ;---> KILL OFF EXISTING TEMPORARY FILE GLOBAL.
+34 DO ZGBL^BWUTL8(BWGBL)
+35 ;
READ ;EP
+1 ;---> READ LINES OF HOST FILE TEXT AND STUFF AS NODES IN ^BWTNI
+2 SET Y=$$OPEN^%ZISH(BWHNDL,BWHFS,BWFLNM,"R")
+3 IF Y
Begin DoDot:1
+4 WRITE !?10,"* FAILURE TO OPEN HOST FILE: ",BWHFS,BWFLNM," (",Y,")"
+5 WRITE !?10," CHECK FILENAME AND PATH IN SITE PARAMETERS.",!
+6 DO DIRZ^BWUTL3
End DoDot:1
QUIT
+7 ;
+8 WRITE !!?5,"Uploading Host File to ",BWGBLN," file..."
+9 USE IO
+10 FOR BWI=1:1
READ BWLINE:DTIME
IF '$LENGTH(BWLINE)
QUIT
Begin DoDot:1
+11 IF $PIECE(BWLINE,U)?1C.C
QUIT
+12 ;---> CONVERT FIXED LENGTH FIELDS TO VARIABLE, DELIMITED BY "^", ETC.
+13 NEW Y
+14 DO @("CVT"_BWRTN_"(.BWLINE,.Y)")
+15 IF BWLINE=""
QUIT
+16 IF 'Y
SET @(BWGBL_BWI_",0)")=BWLINE
QUIT
+17 SET @(BWGBL_BWI_",0)")=$PIECE(BWLINE,U,1,12)
+18 SET @(BWGBL_BWI_",1)")=$PIECE(BWLINE,U,13,18)
+19 SET @(BWGBL_BWI_",2)")=$PIECE(BWLINE,U,19,25)
End DoDot:1
+20 DO ^%ZISC
+21 ;
INDEX ;EP
+1 ;---> NOW INDEX THE FILE.
+2 WRITE !?5,"Indexing ",BWGBLN," file..."
+3 SET DIK=BWGBL
DO IXALL^DIK
+4 ;
TRANSFER ;EP
+1 ;---> TRANSFER TEMPORARY TABLE ENTRIES TO PERMANENT FILE.
+2 DO @("TRANS"_BWRTN)
+3 ;
+4 WRITE !?5,"Deleting ",BWGBLN," data..."
+5 ;---> CLEANUP: KILL OFF EXISTING TEMPORARY FILE GLOBAL.
+6 DO ZGBL^BWUTL8(BWGBL)
+7 WRITE !?5,"Complete.",!
DO DIRZ^BWUTL3
+8 ;
EXIT ;EP
+1 DO KILLALL^BWUTL8
+2 QUIT
+3 ;
HELPTX ;EP
+1 NEW I,T,X
SET T=""
FOR I=1:1:BWTAB
SET T=T_" "
+2 FOR I=1:1
SET X=$TEXT(@BWLINL+I)
IF X'[";;"
QUIT
SET DIR("?",I)=T_$PIECE(X,";;",2)
+3 SET DIR("?")=DIR("?",I-1)
KILL DIR("?",I-1)
+4 QUIT
+5 ;
HELP1 ;EP
+1 ;;Table files contain the Abbreviations Table for the selected lab.
+2 ;;Results files contain the coded results of patients' tests for
+3 ;;the selected lab.
+4 SET BWTAB=5
SET BWLINL="HELP1"
DO HELPTX
+5 QUIT