PHP Class ProcessHscicDataCommand

(C) Moorfields Eye Hospital NHS Foundation Trust, 2008-2011 (C) OpenEyes Foundation, 2011-2012 This file is part of OpenEyes. OpenEyes is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenEyes is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenEyes in a file titled COPYING. If not, see .
Author: OpenEyes ([email protected])
Inheritance: extends CConsoleCommand
Datei anzeigen Open project: openeyes/openeyes

Public Properties

Property Type Description
$DOWNLOAD_EMPTY
$DOWNLOAD_FAILED
$UNEXPECTED_FILE_PROBLEM
$UNKNOWN_ERROR
$UNRECOGNISED_CODE
$audit type Audit can be disabled (eg for the first import we probably don't want to generate 78000 'GP imported' audit rows).
$force type Force already imported files to process it again.
$path
$tempPath
$timeout integer
$url type Override the default URL, e.g. to process a specific monthly file.

Public Methods

Method Description
__construct ( )
actionCheckRemovedFromFile ( type $type = 'gp' ) Checking if a database row no longer exists in the file, and if it's the case, we set the status inactive.
actionDownload ( string $type, string $interval = 'full' ) Allows to download a specified file based on the type and interval.
actionDownloadall ( ) Downloads all the full files listed in $this->files['full'] , Gp, Practice, CCG, CCG Assignment can be useful on the first run.
actionImport ( string $type, string $interval = 'full' ) imports a specific file based on the given type and interval eg.: ProcessHscicData import --type=Gp --interval=monthly.
actionImportall ( ) Imports all the full files listed in $this->files['full'], Gp, Practice, CCG, CCG Assignment.
actionIndex ( ) Displaying the help if no action or param passed.
getHelp ( ) Help.
getName ( ) : string Returns the command name/short description.

Protected Methods

Method Description
handleException ( Exception $e ) : mixed Simple routine for consistently handling generated Exceptions.

Private Methods

Method Description
createTempTable ( type $dbTable ) Creating temporary table for CheckRemovedFromFile() method.
download ( type $url, type $file ) Downloads the file(url) and puts to the provided path/filename.
fillTempTable ( string $type, type $file ) Fill temp table for CheckRemovedFromFile() method.
getFileFromUrl ( string $url ) : string Assamble the file path and name from the url.
getFilePointer ( string $file ) : resource Opens the zip file and gets the CSV file pointer and returns it.
getLineCountFromZip ( string $file ) : integer Gets the line count of the CSV file in the zip.
getTableNameByType ( string $type ) : string Returns the database table name based on the give type.
importAddress ( Address $address, array $lines ) Imports the Address.
importCcg ( array $data ) Imports the 'Ccg' CSV file.
importCcgAssignment ( array $data ) Imports the 'CcgAssignment' file.
importGp ( array $data ) Imports the 'Gp' CSV file.
importPractice ( array $data ) Imports the 'Practice' CSV file.
isNewResourceFile ( type $tempFile, type $permanentFile ) : boolean Checks if the newly downloaded file is already processed or not by comparing to the previously downloaded one.
mapFileConfig ( $config ) : array
markInactiveMissingModels ( type $type ) Set status to inactive on models missing from the CSV file.
processCSV ( string $type, string $interval, array $fields, string $file ) Gets the zip file, extracts the CSV file (from the zip) and processes it.
processFile ( string $type, string $interval, array $file ) Processing the given file.
tempToPermanent ( type $tempFile, type $permanentFile ) Checks if the destination folder exists (makes it if not) than copies the file.
tidy ( string $string ) : string Transform the address line to uppercase all the words.

Method Details

__construct() public method

public __construct ( )

actionCheckRemovedFromFile() public method

Checking if a database row no longer exists in the file, and if it's the case, we set the status inactive.
public actionCheckRemovedFromFile ( type $type = 'gp' )
$type type

actionDownload() public method

Allows to download a specified file based on the type and interval.
public actionDownload ( string $type, string $interval = 'full' )
$type string like 'Gp'
$interval string like 'monthly'

actionDownloadall() public method

Downloads all the full files listed in $this->files['full'] , Gp, Practice, CCG, CCG Assignment can be useful on the first run.
public actionDownloadall ( )

actionImport() public method

imports a specific file based on the given type and interval eg.: ProcessHscicData import --type=Gp --interval=monthly.
public actionImport ( string $type, string $interval = 'full' )
$type string gp|Practice|Ccg|CcgAssignment
$interval string full|monthly|quarterly

actionImportall() public method

Imports all the full files listed in $this->files['full'], Gp, Practice, CCG, CCG Assignment.
public actionImportall ( )

actionIndex() public method

Displaying the help if no action or param passed.
public actionIndex ( )

getHelp() public method

Help.
public getHelp ( )

getName() public method

Returns the command name/short description.
public getName ( ) : string
return string

handleException() protected method

Simple routine for consistently handling generated Exceptions.
protected handleException ( Exception $e ) : mixed
$e Exception
return mixed

Property Details

$DOWNLOAD_EMPTY public_oe static_oe property

public static $DOWNLOAD_EMPTY

$DOWNLOAD_FAILED public_oe static_oe property

public static $DOWNLOAD_FAILED

$UNEXPECTED_FILE_PROBLEM public_oe static_oe property

public static $UNEXPECTED_FILE_PROBLEM

$UNKNOWN_ERROR public_oe static_oe property

public static $UNKNOWN_ERROR

$UNRECOGNISED_CODE public_oe static_oe property

public static $UNRECOGNISED_CODE

$audit public_oe property

Audit can be disabled (eg for the first import we probably don't want to generate 78000 'GP imported' audit rows).
public type $audit
return type

$force public_oe property

Force already imported files to process it again.
public type $force
return type

$path public_oe property

public $path

$tempPath public_oe property

public $tempPath

$timeout public_oe property

public int $timeout
return integer

$url public_oe property

Override the default URL, e.g. to process a specific monthly file.
public type $url
return type