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

AIBMRG.m

Go to the documentation of this file.
AIBMRG ;RPMS/CMB/TJF ;GENERIC IBM DATA GLOBAL MERGE ROUTINE [ 02/01/89  8:29 AM ]
 ;1.3; 1/13/89 DISALLOW MULTIPLE MERGES FOR A SINGLE FACILITY 
 ;1.3 ;ALLOW READ DSM ON MSM, CHS LOGIC & DISALLOW MULTIPLE MERGE 
 ;1.3; 9/23/88 RESTRUCTURE, ALLOW FOR REGISTRATION ELIGIBILITY AND PCC FILES
 ;1.00 ;2/12/88
INTRO ;INITIALIZATION LOGIC
 S:'$D(DTIME) DTIME=300 S:'$D(AIBFFN) AIBFFN=""
 W !,"GENERIC MERGE FILE TO GLOBAL PROGRAM FOR IBM RECORDS"
BEGIN ;ENTRY POINT FOR FRONT END TELECOMMUNICATIONS PROGRAM AIBTCFLM
 D INIT^AIBMRG1 G:AIBA="A" ABEND G:AIBA="C" OPCANCL S AIBPSV=AIBPARMS
 U AIBDEV R AIBTIME:DTIME X AIBTONL G:'$T FILERROR
 I $E(AIBTIME)="~"!($E(AIBTIME)="|") G PCCMSG
 G READCMT
PCCMSG ;SET SWITCH FOR PCC LOGIC AND DISPLAY MESSAGE
 S AIBPCC=1
 U AIBCDV W !,"Begin merging Patient Care Component records"
 S AIBGV=AIBTIME G PCCGBLNM
READCMT ;READ COMMENT FROM SAVED GLOBAL FILE
 U AIBDEV R AIBCMT:DTIME X AIBTONL G:'$T FILERROR I AIBTIME="" G FILERROR
 U AIBCDV S AIBSEQ=1
 W !!,"Global saved at ",AIBTIME,".",!,"Header comment is : ",AIBCMT,!
START ;BEGIN MERGING FILE
 U AIBCDV W !!,"Begin Merging of Global: "
NEXTGBL ;PROCESS NEXT FILE
 K AIBGSEL
NEXTVOL ;PROCESS NEXT VOLUME OF FILE
 U AIBDEV I AIBPCC G SKIPSUBZ
 R AIBGN:DTIME X AIBTONL G:'$T FILERROR
SKIPSUBZ ;SKIP READ OF ZEROTH NODE SUBSCRIPT DATA - PCC FLAT FILE
 R AIBGV:DTIME X AIBTONL G:'$T FILERROR G:AIBPCC PCCGBLNM
 I AIBGN="*E" D NEXTFILE^AIBMRG1 G NEXTVOL:'QUIT
 G ENDFILE:AIBGN="**",FILERROR:AIBGN="",NEXTGBL:AIBGN="*"
 I $E(AIBGN)="*" S AIBGSEL=$E(AIBGN,2,999) G NEXTVOL
 S AIBGNN=$P(AIBGN,"("),AIBGNL=$L(AIBGNN)+1 S:'$D(AIBGSEL) AIBGSEL=AIBGNN
 I $L(AIBGV)>0 G INITINDR
 I AIBOS="D" G NEXTGBL
 R "INPUT FILE APPEARS TO IN DSM FORMAT, IS THIS CORRECT? (Y,N) Y// ",X:DTIME I X["N" G FILERROR
 G NEXTGBL
PCCGBLNM ;INITIALIZE GLOBAL PREFIX NAME FOR PCC
 S (AIBGSEL,AIBGNN)="^APCC",AIBGNL=6
INITINDR ;INITIALIZE INDIRECTION VARIABLES
 D FACTSET^AIBMRG1
 I $D(@AIBGBLN) G RTVGTZN
 S @AIBGBLN="9999999^0^0^0^0"
RTVGTZN ;RETREVE VARIABLES FROM GRAND TOTAL ZEROTH NODE IN MERGE GLOBAL
 D ZERSET^AIBMRG1 G:AIBA="A" ABEND
 S AIBZN=AIBZN+1
RTVFCZN ;RETREIVE FACILITY DATA FROM ZEROTH FACILITY NODE IN MERGE GLOBAL
 D FACSET^AIBMRG1 G:AIBA="A" ABEND
 I AIBS>0 G:AIBGSEL["AGTX" NOMRG G:AIBGSEL["APCC" NOMRG
 S AIBCT=AIBS+1
 S (AIBRC,AIBNC)=0
 I AIBPCC S (AIBRC,AIBNC)=1 G BLDNODE
READ ;READ NEXT RECORD NODE DATA FROM INPUT FILE
 U AIBDEV I AIBPCC G SKIPSUBD
 R AIBGN:DTIME X AIBTONL G:'$T FILERROR
SKIPSUBD ;SKIP SUBSCRIPTS FOR DATA RECORDS - PCC FLAT FILE
 R AIBGV:DTIME X AIBTONL G:'$T FILERROR G:AIBPCC CKPCCEOF
 G:AIBGN="" FILERROR I AIBGN="*E" D NEXTFILE^AIBMRG1 G READ:'QUIT
 G:$E(AIBGN,1,7)="**END**" ENDFILE ; OKC FORMAT
 I AIBGN="*" U AIBCDV W !," ... Global Merged" G NEXTGBL
 G NEXTGBL:AIBGN="*",ENDFILE:AIBGN="**"
 G BLDNODE
CKPCCEOF ;END OF FILE LOGIC FOR PCC FLAT FILE
 G:$E(AIBGV)="~"!($E(AIBGV)="|") SETPCCID G ENDFILE
SETPCCID ;SET NODE ID PIECE FOR PCC
 S AIBGV="PCC"_U_AIBGV
BLDNODE ;PLACE DATA IN MERGE GLOBAL RECORD NODE
 S:"^ACHS"=$E(AIBGSEL,1,5) AIBGV="CHS"_U_AIBGV
 S @AIBGBLD=AIBGV
 S AIBCT=AIBCT+1,AIBNC=AIBNC+1 I $E(AIBGV,1,3)'="RG1" S AIBRC=AIBRC+1
 E  G READ
 U AIBCDV S AIBRM=AIBRC#10 G:AIBRM>0 READ
 S AIBLK="",AIBLK=AIBLK_$J("",8-$L(AIBRC)) W AIBLK,AIBRC G READ
ENDFILE ;END OF FILE PROCESSING
 D UPDATE^AIBMRG1
 I AIBFFN=2 G QUIT
 R !,"Merge Another? Y// ",AIBA:DTIME
 S:AIBA="" AIBA="Y" G:"YESyes"[AIBA BEGIN G QUIT
NOMRG ;DISALLOW MULTIPLE MERGE FOR A FACILITY
 S AIBMSG="Records for this facility already on file - additional merge not allowed" G ABEND
FILERROR ;ERROR IN FILE FORMAT - ABEND AFTER MESSAGE
 S AIBMSG="Invalid backup format...unable to merge."
ABEND ;ABNORMAL END OF JOB
 D ABEND^AIBCVT6 D KILLVAR^AIBMRG1 G QUIT
OPCANCL ;ABEND BECAUSE OPERATOR CANCLED JOB
 D OPCANCL^AIBCVT6 D KILLVAR^AIBMRG1 G QUIT
QUIT ;
 K AIBOS G RETURN
RETURN ;RETURN TO CALLING PROGRAM
 Q