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

BGP2AU1R.m

Go to the documentation of this file.
BGP2AU1R ; IHS/CMI/LAB - READ, PROCESS GPRA FILE ;
 ;;12.1;IHS CLINICAL REPORTING;;MAY 17, 2012;Build 66
 ;
DESC ;
 ;;This routine reads the contents of the GPRA BGPGPCRSGPRA* files
 ;;and puts the data into FileMan file BGP GPRA FLAT FILE DATA.
 ;;
 ;;$$END
 ;
 N I,X F I=1:1 S X=$P($T(DESC+I),";;",2) Q:X["$$END"  D EN^DDIOL(X)
 Q
EN(BGPF) ;EP -- MAIN ENTRY POINT
 ;
 ;      INPUT:
 ;      BGPF  =  ARRAY OF FILES TO BE UPLOADED
 ;
 ;
 S BGP=0
 F  S BGP=$O(BGPF(BGP)) Q:'BGP  D
 . S BGPFILE=BGPF(BGP)
 . Q:BGPFILE']""
 . D ONE(BGPFILE)
 Q
ONE(BGPFILE) ;
 ;----- PROCESS ONE FILE
 ;
 N BGPOUT,BGPPATH
 ;
 S BGPOUT=0
 ;
 K ^TMP("BGPGP1RD",$J)
 ;
 S BGPPATH=$P($G(^BGPGP1PM(1,1)),U)
 ;
 D READ(BGPPATH,BGPFILE,.BGPOUT)
 Q:BGPOUT
 ;
 D PROC
 K ^TMP("BGPGP1RD",$J)
 ;
 Q
PROC ;
 ;----- PROCESS DATA
 ;
 N BGP,BGP0,BGPBDT,BGPD0,BGPDATA,BGPEDT,BGPFAC,BGPID,BGPIND,BGPN,CNT,I,X,Y
 ;
 S BGPDATA=$G(^TMP("BGPGP1RD",$J,"FILE",1,0))
 F I=11:9:$L(BGPDATA,U) S X=$P(BGPDATA,U,I) S BGPIND(X)=I_U_(I+8)
 ;
 S BGP=3
 F  S BGP=$O(^TMP("BGPGP1RD",$J,"FILE",BGP)) Q:'BGP  D
 . S BGP0=$G(^TMP("BGPGP1RD",$J,"FILE",BGP,0))
 . S BGPFAC=$P(BGP0,U)
 . S X=$P(BGP0,U,5)
 . D ^%DT
 . S BGPBDT=Y
 . S X=$P(BGP0,U,6)
 . D ^%DT
 . S BGPEDT=Y
 . S BGPN=""
 . F  S BGPN=$O(BGPIND(BGPN)) Q:BGPN']""  D
 . . K BGPID,CNT
 . . F  S CNT=$G(CNT)+1 Q:$E(BGPN,CNT)'?1N  S BGPID=$G(BGPID)_$E(BGPN,CNT)
 . . S BGPIND=$P(BGPN,BGPID,2)
 . . S BGPD0=$O(^BGPGP1RD("C",BGPIND,BGPFAC,BGPBDT,BGPEDT,0))
 . . I 'BGPD0 D ADD(BGPIND,.BGPD0)
 . . Q:BGPD0'>0
 . . D EDIT(BGPD0,BGP0,BGPN,BGPID,.BGPIND)
 Q
EDIT(BGPD0,BGP0,BGPN,BGPID,BGPIND) ;
 ;------ SET DATA INTO FILE
 ;
 N BGPDATA,DA,DIE,DR,FR,TO
 ;
 S DIE="^BGPGP1RD("
 S DA=BGPD0
 S FR=$P(BGPIND(BGPN),U)
 S TO=$P(BGPIND(BGPN),U,2)
 S BGPDATA=$P(BGP0,U,FR,TO)
 S DR=".02///"_BGPID                ;INDICATOR NUMBER
 S DR=DR_";.03///"_$P(BGP0,U)       ;SITE NAME
 S DR=DR_";.04///"_$P(BGP0,U,2)     ;ASUFAC
 S DR=DR_";.05///"_$P(BGP0,U,3)     ;DB ID
 S DR=DR_";.06///"_$P(BGP0,U,4)     ;DATE REPORT RUN
 S DR=DR_";.07///"_$P(BGP0,U,5)     ;CURRENT REPORT BEGIN DATE
 S DR=DR_";.08///"_$P(BGP0,U,6)     ;CURRENT REPORT END DATE
 S DR=DR_";.09///"_$P(BGP0,U,7)     ;PREVIOUS YEAR BEGIN DATE
 S DR=DR_";.1///"_$P(BGP0,U,8)      ;PREVIOUS YEAR END DATE
 S DR=DR_";.11///"_$P(BGP0,U,9)     ;BASELINE YEAR BEGIN DATE
 S DR=DR_";.12///"_$P(BGP0,U,10)    ;BASELINE YEAR END DATE
 S DR=DR_";.13///"_$P(BGPDATA,U)    ;CURRENT NUMERATOR
 S DR=DR_";.14///"_$P(BGPDATA,U,2)  ;CURRENT DENOMINATOR
 S DR=DR_";.15///"_$P(BGPDATA,U,3)  ;CURRENT PERCENT
 S DR=DR_";.16///"_$P(BGPDATA,U,4)  ;PREVIOUS NUMERATOR
 S DR=DR_";.17///"_$P(BGPDATA,U,5)  ;PREVIOUS DENOMINATOR
 S DR=DR_";.18///"_$P(BGPDATA,U,6)  ;PREVIOUS PERCENT
 S DR=DR_";.19///"_$P(BGPDATA,U,7)  ;BASELINE NUMERATOR
 S DR=DR_";.2///"_$P(BGPDATA,U,8)   ;BASELINE DENOMINATOR
 S DR=DR_";.21///"_$P(BGPDATA,U,9)  ;BASELINE PERCENT
 D ^DIE
 Q
ADD(BZIND,BGPD0) ;EP
 ;----- ADD NEW ENTRY
 ;
 N DA,DD,DIC,DIE,DLAYGO,DO,DR,X,Y
 ;
 S X=BGPIND
 S DIC="^BGPGP1RD("
 S DIC(0)=""
 S DLAYGO=90245.1
 D FILE^DICN
 S BGPD0=+Y
 ;
 Q
READ(BGPPATH,BGPFILE,BGPOUT) ;
 ;----- READ CONTENTS OF DATA FILE AND PUT INTO ^BGPTMP GLOBAL
 ;
 N BGPCNT,BGPEND,I,POP,X
 ;
 K ^TMP("BGPGP1RD",$J,BGPFILE)
 S BGPOUT=0
 S BGPEND=0
 S BGPCNT=0
 ;W !,"READING FILE "_BGPPATH_BGPFILE_" ..."
 D OPEN^%ZISH("FILE",BGPPATH,BGPFILE,"R")
 I POP D
 . W !?5,"UNABLE TO OPEN FILE '"_BGPPATH_BGPFILE_"'"
 . S BGPOUT=1
 Q:BGPOUT
 F I=1:1 D  Q:BGPEND
 . U IO R X:DTIME
 . I $$STATUS^%ZISH S BGPEND=1
 . Q:BGPEND
 . S BGPCNT=BGPCNT+1
 . S ^TMP("BGPGP1RD",$J,"FILE",I,0)=X
 . S ^TMP("BGPGP1RD",$J,"FILE",0)=BGPCNT
 . I '(BGPCNT#100) U 0 W "."
 ;
 D CLOSE^%ZISH("FILE")
 Q
PATH(BGPPATH,BGPOUT) ;
 ;----- PROMPT FOR DIRECTORY PATH WHERE DATA FILE RESIDES
 ;
 N DIR,DIRUT,DTOUT,DUOUT,X,Y
 ;
 S BGPPATH=""
 S BGPOUT=0
 S DIR(0)="FA"
 S DIR("A")="Select DIRECTORY: "
 S DIR("?")="Enter the PATH or DIRECTORY where the data file resides, e.g., D:\EXPORT\"
 D ^DIR
 I $D(DTOUT)!($D(DIRUT))!($D(DUOUT)) S BGPOUT=1
 Q:BGPOUT
 S X=Y
 D DF^%ZISH(.X)
 S BGPPATH=X
 Q
FILE(BGPFILE,BGPOUT) ;
 ;----- PROMPT FOR DATA FILE
 ;
 N DIR,DIRUT,DIROUT,DTOUT,DUOUT,X,Y
 ;
 S BGPFILE=""
 S DIR(0)="FA"
 S DIR("A")="Select FILE: "
 S DIR("?")="Enter the name of the data file"
 D ^DIR
 I $D(DTOUT)!($D(DIRUT))!($D(DUOUT))!($D(DIROUT))!(Y[U) S BGPOUT=1
 Q:$G(BGPOUT)
 S BGPFILE=Y
 Q