-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from openeyes/develop
Develop
- Loading branch information
Showing
18 changed files
with
759 additions
and
592 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
/** | ||
* OpenEyes. | ||
* | ||
* (C) Moorfields Eye Hospital NHS Foundation Trust, 2008-2011 | ||
* (C) OpenEyes Foundation, 2011-2013 | ||
* This file is part of OpenEyes. | ||
* OpenEyes is free software: you can redistribute it and/or modify it under the terms of the GNU Affero 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 Affero General Public License for more details. | ||
* You should have received a copy of the GNU Affero General Public License along with OpenEyes in a file titled COPYING. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* @link http://www.openeyes.org.uk | ||
* | ||
* @author OpenEyes <info@openeyes.org.uk> | ||
* @copyright Copyright (c) 2011-2013, OpenEyes Foundation | ||
* @license http://www.gnu.org/licenses/agpl-3.0.html The GNU Affero General Public License V3.0 | ||
*/ | ||
|
||
namespace OEModule\mehstaffdb; | ||
|
||
class CSDClientModule extends \BaseModule | ||
{ | ||
public function init() | ||
{ | ||
// this method is called when the module is being created | ||
// you may place code here to customize the module or the application | ||
|
||
// import the module-level models and components | ||
$this->setImport(array( | ||
'mehstaffdb.components.*', | ||
'mehstaffdb.controllers.*', | ||
)); | ||
parent::init(); | ||
} | ||
|
||
public function beforeControllerAction($controller, $action) | ||
{ | ||
if (parent::beforeControllerAction($controller, $action)) { | ||
// this method is called before any module controller action is performed | ||
// you may place customized code here | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
} |
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
/** | ||
* OpenEyes | ||
* | ||
* (C) OpenEyes Foundation, 2021 | ||
* This file is part of OpenEyes. | ||
* OpenEyes is free software: you can redistribute it and/or modify it under the terms of the GNU Affero 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 Affero General Public License for more details. | ||
* You should have received a copy of the GNU Affero General Public License along with OpenEyes in a file titled COPYING. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* @package OpenEyes | ||
* @link http://www.openeyes.org.uk | ||
* @author OpenEyes <info@openeyes.org.uk> | ||
* @copyright Copyright (c) 2021, OpenEyes Foundation | ||
* @license http://www.gnu.org/licenses/agpl-3.0.html The GNU Affero General Public License V3.0 | ||
*/ | ||
|
||
namespace OEModule\mehstaffdb\components\CSDClient; | ||
|
||
use OEModule\mehstaffdb\components\CSDClient\GetUserDataRequest; | ||
use OEModule\mehstaffdb\components\Singleton; | ||
|
||
/** | ||
* Class CSDClient | ||
* | ||
* This is a facade for all CSD API calls. Other classes should only | ||
* call methods of this class. | ||
* | ||
* @method static CSDClient get() | ||
*/ | ||
|
||
class CSDClient extends Singleton | ||
{ | ||
|
||
/** | ||
* Sends request | ||
* | ||
* @param Request $request | ||
* @return string|null JSON-encoded data on success or null on failure | ||
*/ | ||
private function sendRequest(Request $request): ?string | ||
{ | ||
$response = $request->submit(); | ||
if(!$response["success"]) { | ||
return null; | ||
} | ||
|
||
return $response["success"] > 0 && isset($response["result"]) ? json_encode($response["result"]) : null; | ||
} | ||
|
||
/** | ||
* Retrieves patient data from CSD | ||
* | ||
* @param string $username | ||
* @return string|null JSON-encoded data on success or null on failure | ||
*/ | ||
public function getUserData(string $username): ?string | ||
{ | ||
return $this->sendRequest((new GetUserDataRequest($this))->setUsername($username)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
/** | ||
* OpenEyes | ||
* | ||
* (C) OpenEyes Foundation, 2021 | ||
* This file is part of OpenEyes. | ||
* OpenEyes is free software: you can redistribute it and/or modify it under the terms of the GNU Affero 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 Affero General Public License for more details. | ||
* You should have received a copy of the GNU Affero General Public License along with OpenEyes in a file titled COPYING. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* @package OpenEyes | ||
* @link http://www.openeyes.org.uk | ||
* @author OpenEyes <info@openeyes.org.uk> | ||
* @copyright Copyright (c) 2021, OpenEyes Foundation | ||
* @license http://www.gnu.org/licenses/agpl-3.0.html The GNU Affero General Public License V3.0 | ||
*/ | ||
|
||
namespace OEModule\mehstaffdb\components\CSDClient; | ||
|
||
use OEModule\mehstaffdb\components\CSDClient\Request; | ||
|
||
class GetUserDataRequest extends Request | ||
{ | ||
/** @var string */ | ||
protected $username; | ||
|
||
/** | ||
* @param string $username | ||
* @return GetUserDataRequest | ||
*/ | ||
public function setUsername(string $username): GetUserDataRequest | ||
{ | ||
$this->username = $username; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getActionName(): string | ||
{ | ||
return "CSDAPI/api/staff?DomainUsername=".$this->username; | ||
} | ||
} |
Oops, something went wrong.