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

AGSSPLIT.m

Go to the documentation of this file.
  1. AGSSPLIT ; IHS/ADC/CRG - Split Unix Area File into site files. ; [ 11/05/97 10:07 AM ]
  1. ;;6.0;IHS PATIENT REGISTRATION;**2**;MAR 20, 1995
  1. ;;Y2K/OK - IHS/ADC/ESJ 11-05-97
  1. S ;
  1. S1 ;Load Master tape
  1. D DT^DICRW S IOP="HOME" D ^%ZIS G:POP EXIT
  1. K ^AGSSFTMP ;kill of temp glo
  1. W !,"This will process multiple tapes into seperate",!,"facility files.",!
  1. K DIR S DIR(0)="N^0:10",DIR("A")="How many tapes/files do you have to load ?" D ^DIR K DIR
  1. I X'>0 G EXIT
  1. S AGSS("TAPES")=X
  1. W !,"This will take some space .. ",!,"The number of BYTES necessary is estimated at : >>> ",$FN(AGSS("TAPES")*12000000,","),!!
  1. S AGSS("CMD")="df -t" D CALL
  1. PATH ;
  1. W !,"Please indicate the complete directory path you want to use.",!,?10," example: /usr2 ",!,?10,"or ^ to exit",!
  1. K DIR S DIR(0)="F^0:30" S DIR("A")="Path ? ",DIR("B")="/usr/mumps" D ^DIR K DIR
  1. I Y["",Y'["^"
  1. E Q ;--->
  1. S:Y="/" Y=""
  1. S AGSS("PATH")=Y_"/"
  1. W !,"Files will be created as: ",!,?10,AGSS("PATH"),"xxxxx.ssn",!
  1. K DIR S DIR(0)="Y",DIR("A")="Is this acceptable ",DIR("B")="Yes" D ^DIR K DIR
  1. I Y=0 G PATH ;---^
  1. W !,"This will display any files already present.",!
  1. S AGSS("CMD")="ls -l "_AGSS("PATH")_"*.ss*" D CALL
  1. K DIR S DIR(0)="Y",DIR("A")="Is this acceptable ",DIR("B")="Yes" D ^DIR K DIR
  1. I Y=0 G PATH ;---^
  1. D READTAPE,PROCESS
  1. Q
  1. ;-----------------
  1. READTAPE ; read tapes
  1. K DIR S DIR(0)="Y",DIR("A")="Are you loading the files from nine track tape ?" D ^DIR K DIR
  1. I Y=0 W !,"Since you answered no ...",!," be sure the *.ssa files are present in the previous listing.",!,"prior to processing !!.",!! Q ;---^
  1. F AGSSNUM=1:1:AGSS("TAPES") D TAPE
  1. Q
  1. ;----
  1. TAPE ; process each individual tape
  1. W !,"You can skip the loading of a tape with an ""^"" .",!!
  1. W !,"Please Load tape number : ",AGSSNUM,!,"Tape must be loaded and on-line",*7
  1. K DIR S DIR(0)="E" D ^DIR I $G(DUOUT) S AGSS("DUOUT")=1 Q
  1. W ! S AGSS("CMD")="rm "_AGSS("PATH")_"ssa_area"_AGSSNUM_".ssa" D CALL
  1. W !,"Reading into file "_AGSS("PATH")_"ssa_area"_AGSSNUM_".ssa",!,"Starting : " D T^AG
  1. S AGSS("CMD")="dd if=/dev/rmt0 of="_AGSS("PATH")_"ssa_area"_AGSSNUM_".ssa bs=68" D CALL
  1. W !,"Unix file "_AGSS("PATH")_"ssa_area"_AGSSNUM_".ssa loaded ..."
  1. D T^AG
  1. Q
  1. ;
  1. PROCESS ;
  1. W !!,"This application requires two host file devices for file(s) IO",!!
  1. S AGSSHFC=0
  1. F AGSSI=51:1:54 S IOP=AGSSI D ^%ZIS I 'POP S AGSSHFC=AGSSHFC+1 S AGSSHF(AGSSHFC)=AGSSI Q:AGSSHFC=2
  1. I AGSSHFC<2 D G EXIT
  1. .W *7,!!,"<< Sorry ... There are not 2 Host file devices available.",!,"stopping the software.",!!
  1. .I AGSSHFC=1 S IO=AGSSHF(AGSSHFC) D ^%ZISC D HOME^%ZIS
  1. K DIR S DIR(0)="Y",DIR("A")="Do you want to process ?" D ^DIR K DIR I Y=0 S DUOUT=1 Q ;----^
  1. S XBIOP="0;P-DEC;80;55",XBRP="PROCESS1^AGSSPLIT",XBRX="EXIT^AGSSPLIT",XBNS="AGS" D ^XBDBQUE
  1. Q
  1. ;-----
  1. PROCESS1 F AGSSNUM=1:1:AGSS("TAPES") D AREA
  1. D FINISH
  1. Q
  1. ;----
  1. AREA ;open ssa_area file and process individual facilities
  1. S IOP=AGSSHF(2),%ZIS("IOPAR")="("""_AGSS("PATH")_"ssa_area"_AGSSNUM_".ssa"":""R"")"
  1. D ^%ZIS Q:POP
  1. U IO(0) W !!,"Starting Area ",AGSSNUM,!!
  1. D DT^DICRW
  1. S AGSS("LFILE")="",AGSS("RCOUNT")=0,AGSS("TCOUNT")=0
  1. S AGSS("CMD")="echo Start: `date` >> "_AGSS("PATH")_"ssa_stats.ssn" D CALL
  1. F U AGSSHF(2) R AGX:1 Q:AGX="" D
  1. .S AGSS("NFILE")=$E(AGX,1,6) I AGSS("NFILE")'=AGSS("LFILE") D
  1. ..I AGSS("LFILE")'="" D CLOSE ;log counts
  1. ..S AGSS("SFILE")=AGSS("PATH")_AGSS("NFILE")_".ssn",AGSS("FACNM")="" ;set SFILE
  1. ..I $D(^AUTTLOC("C",AGSS("NFILE"))) S AGSS("FACNM")=$O(^AUTTLOC("C",AGSS("NFILE"),0)) I +AGSS("FACNM"),$D(^DIC(4,AGSS("FACNM"))) S AGSS("FACNM")=$P(^DIC(4,AGSS("FACNM"),0),"^") ;set FACNM
  1. ..U IO(0) W !!,"Starting file : ",AGSS("SFILE"),?40,AGSS("FACNM")
  1. ..S AGSSIO=IO S IO=AGSSHF(1) D ^%ZISC S IO=AGSSIO K AGSSIO
  1. ..S %ZIS("IOPAR")="("""_AGSS("SFILE")_""":""A"")",IOP=AGSSHF(1) D ^%ZIS I POP U IO(0) W !,"NO OPEN ON AGSSHF(1)",! G:POP EXIT ;---> ;open new unix file or exit
  1. ..S AGSS("RCOUNT")=0
  1. .S AGSS("RCOUNT")=AGSS("RCOUNT")+1,AGSS("TCOUNT")=AGSS("TCOUNT")+1
  1. .I '(AGSS("RCOUNT")#5000) U IO(0) W !,?10,AGSS("RCOUNT"),?30,AGSS("TCOUNT"),?40 D T^AG
  1. .U AGSSHF(1) W AGX,! ;put AGX to unix file
  1. .S AGSS("LFILE")=AGSS("NFILE")
  1. D CLOSE
  1. U IO(0) W !!,"total records",?15,AGSS("TCOUNT"),?40 D T^AG W !
  1. S AGSS("CMD")="echo Completed : `date` >> "_AGSS("PATH")_"ssa_stats.ssn" D CALL
  1. Q
  1. ;
  1. CLOSE ;
  1. S IO=AGSSHF(1) D ^%ZISC
  1. U IO(0) W !,AGSS("FACNM"),?30,"Finish : ",?40,AGSS("RCOUNT"),?50,AGSS("TCOUNT"),!
  1. S ^AGSSFTMP(AGSS("LFILE"),"RCOUNT")=$G(^AGSSFTMP(AGSS("LFILE"),"RCOUNT"))+AGSS("RCOUNT")
  1. S ^AGSSFTMP(AGSS("LFILE"),"NM")=AGSS("FACNM")
  1. I '$G(AGSS("TAPES")) K DIR S DIR(0)="N^1:9" D ^DIR K DIR Q:X'>1 S AGSS("TAPES")=X
  1. S AGSS("CMD")="echo '"_AGSS("SFILE")_"\t"_AGSS("RCOUNT")_"\t"_AGSS("TCOUNT")_"\t"_AGSS("FACNM")_"' >> "_AGSS("PATH")_"ssa_stats.ssn" D CALL
  1. Q
  1. ;
  1. FINISH ;set up final files and report
  1. D ^AGSSPLI1
  1. Q
  1. EXIT ;
  1. K AGSS,AGSSFAC,AGSSNUM,AGY,^AGSSFTMP,AGSSI,AGSSHFC,AGSSHF ;kill of temporary global
  1. Q
  1. ;
  1. CALL ;
  1. I $G(AGSS("TRACE")) U IO(0) W !,?10,AGSS("CMD")
  1. S AGY="S X=$$TERMINAL^%HOSTCMD("""_AGSS("CMD")_""")" X AGY
  1. Q
  1. RESTART S AGSS("CMD")="rm "_AGSS("PATH")_"*.ssn" D CALL
  1. Q