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

BGP2AU1D.m

Go to the documentation of this file.
BGP2AU1D ; IHS/CMI/LAB - GPRA FLAT FILE DATA DUMP ;
 ;;12.1;IHS CLINICAL REPORTING;;MAY 17, 2012;Build 66
DESC ;----- ROUTINE DESCRIPTION
 ;;
 ;;This routine creates a text file containing the contents of
 ;;the GPRA FLAT FILE DATA file.
 ;;$$END 
 N I,X F I=1:1 S X=$P($T(DESC+I),";;",2) Q:X["$$END"  D EN^DDIOL(X)
 Q
 ;
EN(BGPBEGDT,BGPEND,BGPDFILE) ;EP -- MAIN ENTRY POINT
 ;
 N %FILE,BGPD0,BGPOUT
 ;
 S BGPOUT=0
 ;
 D FILE(BGPEND,.%FILE,.BGPDFILE,.BGPOUT)
 Q:BGPOUT
 ;
 U %FILE
 S BGPD0=0
 F  S BGPD0=$O(^BGPGP1RD("CBD",BGPBEGDT,BGPD0)) Q:'BGPD0  D
 . S BGPDATA=$G(^BGPGP1RD(BGPD0,0))
 . Q:BGPDATA']""
 . F I=6:1:12 D
 . . S BGPDT=$P(BGPDATA,U,I)
 . . S BGPDT=$$SLDT(BGPDT)
 . . S $P(BGPDATA,U,I)=BGPDT
 . W !,BGPDATA
 D CLOSE^%ZISH("FILE")
 ;
 Q
SLDT(X) ;
 ;----- CONVERTS FM DATE TO MM/DD/YYYY
 ;
 N Y
 S Y=""
 I X D
 . S X=X+17000000
 . S Y=$E(X,5,6)_"/"_$E(X,7,8)_"/"_$E(X,1,4)
 Q Y
FILE(BGPEND,%FILE,BGPDFILE,BGPOUT) ;
 ;----- CREATE FILE CONTAINING THE DATA
 ;
 N BGPERR,BGPOUT
 ;
 ;I '$G(DUZ) S DUZ=1
 D ^XBKVAR
 S BGPOUT=0
 S BGPERR=""
 S BGPDFILE="BGPGP1DD"_BGPEND_"_"_DT
 D HFS(.BGPOUT,.%FILE,BGPDFILE)
 I BGPOUT D  Q
 . S BGPERR="CANNOT OPEN FILE" ;FOR ERROR TRAP
 . ;S $ZE="BGP2AU1D FAILURE" D ^%ZTER
 Q
HFS(BGPOUT,%FILE,BGPDFILE)  ;EP
 ;----- CREATE AND OPEN DATA FILE
 ;
 ;      INPUT:
 ;      FILE    = DATA FILE NAME TO CREATE AND OPEN
 ;
 ;      OUTPUT:
 ;      %FILE   = THE DEVICE NUMBER OF THE FILE
 ;      BGPOUT  = QUIT INDICATOR
 ;
 N I,POP,X,Y,ZISH1,ZISH2,ZISH3,ZISH4
 ;
 S %FILE=""
 S BGPOUT=0
 S ZISH1="FILE"  ;HANDLE
 S ZISH2=$P($G(^BGPGP1PM(1,1)),U)  ;DIRECTORY
 S ZISH3=BGPDFILE  ;FILENAME
 S ZISH4="W"  ;APPEND MODE
 D OPEN^%ZISH(ZISH1,ZISH2,ZISH3,ZISH4)
 I POP S BGPOUT=1
 Q:BGPOUT
 S %FILE=IO
 Q