-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
18 changed files
with
3,055 additions
and
0 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,52 @@ | ||
<?php | ||
/** | ||
* | ||
* Copyright (c) 2016 Sam Likins WSI-Services | ||
* Copyright (c) 2016 SunCoast Connection | ||
* | ||
* LICENSE: This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0 | ||
* See the Mozilla Public License for more details. | ||
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* @package Librehealth EHR | ||
* @author Sam Likins <[email protected]> | ||
* @link http://suncoastconnection.com | ||
* @link http://librehealth.io | ||
* | ||
* Please help the overall project by sending changes you make to the author and to the LibreEHR community. | ||
* | ||
*/ | ||
|
||
$sanitize_all_escapes = true; | ||
$fake_register_globals = false; | ||
|
||
require_once('../../interface/globals.php'); | ||
require_once($srcdir.'/acl.inc'); | ||
|
||
if(!acl_check('admin', 'super')) { | ||
die(xlt('Not authorized')); | ||
} else { | ||
define('MERGE_ENCOUNTERS', true); | ||
} | ||
|
||
require_once(__DIR__.'/lib/functions.php'); | ||
|
||
$service = getElementIfExist($_GET, 'service', null); | ||
|
||
switch($service) { | ||
case 'json-duplicates': | ||
includeService('JSON-Duplicates'); | ||
break; | ||
|
||
case 'json-encounters': | ||
includeService('JSON-Encounters'); | ||
break; | ||
|
||
case 'json-merge': | ||
includeService('JSON-Merge'); | ||
break; | ||
|
||
case null: | ||
includeService('Screen'); | ||
break; | ||
} |
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,118 @@ | ||
<?php | ||
/** | ||
* | ||
* Copyright (c) 2016 Sam Likins WSI-Services | ||
* Copyright (c) 2016 SunCoast Connection | ||
* | ||
* LICENSE: This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0 | ||
* See the Mozilla Public License for more details. | ||
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* @package Librehealth EHR | ||
* @author Sam Likins <[email protected]> | ||
* @link http://suncoastconnection.com | ||
* @link http://librehealth.io | ||
* | ||
* Please help the overall project by sending changes you make to the author and to the LibreEHR community. | ||
* | ||
*/ | ||
|
||
const JSON_STATUS_OK = 1; | ||
const JSON_STATUS_SUCCESS = 2; | ||
const JSON_STATUS_FAIL = 3; | ||
|
||
// JSON Handler | ||
|
||
class JsonHandler { | ||
|
||
protected static $jsonStatusMessages = [ | ||
JSON_STATUS_OK => 'OK', | ||
JSON_STATUS_SUCCESS => 'SUCCESS', | ||
JSON_STATUS_FAIL => 'FAIL', | ||
]; | ||
|
||
public static function encode($value, $options = 0) { | ||
$result = json_encode($value, $options); | ||
|
||
if($result) { | ||
return $result; | ||
} | ||
|
||
throw new RuntimeException(json_last_error_msg(), json_last_error()); | ||
} | ||
|
||
public static function decode($json, $assoc = false) { | ||
$result = json_decode($json, $assoc); | ||
|
||
if($result) { | ||
return $result; | ||
} | ||
|
||
throw new RuntimeException(json_last_error_msg(), json_last_error()); | ||
} | ||
|
||
protected $status; | ||
|
||
protected $errors = []; | ||
|
||
protected $data; | ||
|
||
public function __construct($status = JSON_STATUS_OK) { | ||
$this->setStatus($status); | ||
} | ||
|
||
public function setStatus($status) { | ||
if(array_key_exists($status, static::$jsonStatusMessages)) { | ||
$this->status = $status; | ||
} | ||
} | ||
|
||
public function getStatus() { | ||
return $this->status; | ||
} | ||
|
||
public function addError($error) { | ||
$this->errors[] = $error; | ||
} | ||
|
||
public function getErrors() { | ||
return $this->errors; | ||
} | ||
|
||
public function setData($data) { | ||
$this->data = $data; | ||
} | ||
|
||
public function &getData() { | ||
return $this->data; | ||
} | ||
|
||
public function response($options = 0) { | ||
try { | ||
if(array_key_exists($this->getStatus(), static::$jsonStatusMessages)) { | ||
$status = static::$jsonStatusMessages[$this->getStatus()]; | ||
} else { | ||
$status = static::$jsonStatusMessages[JSON_STATUS_FAIL]; | ||
} | ||
|
||
$return = [ | ||
'status' => $status, | ||
'errors' => $this->getErrors(), | ||
'data' => $this->getData() | ||
]; | ||
|
||
array_walk_recursive($return, function(&$item) { | ||
$item = utf8_encode($item); | ||
}); | ||
|
||
$return = static::encode($return, $options); | ||
|
||
header('Content-type: application/json;charset=utf-8'); | ||
} catch (RuntimeException $exception) { | ||
$return = $exception->getMessage(); | ||
} | ||
|
||
echo $return; | ||
} | ||
|
||
} |
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,63 @@ | ||
<?php | ||
/** | ||
* | ||
* Copyright (c) 2016 Sam Likins WSI-Services | ||
* Copyright (c) 2016 SunCoast Connection | ||
* | ||
* LICENSE: This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0 | ||
* See the Mozilla Public License for more details. | ||
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* @package Librehealth EHR | ||
* @author Sam Likins <[email protected]> | ||
* @link http://suncoastconnection.com | ||
* @link http://librehealth.io | ||
* | ||
* Please help the overall project by sending changes you make to the author and to the LibreEHR community. | ||
* | ||
*/ | ||
|
||
function getElementIfExist(&$array, $key, $default = null) { | ||
if(array_key_exists($key, $array)) { | ||
return $array[$key]; | ||
} else { | ||
return $default; | ||
} | ||
} | ||
|
||
function includeService($service) { | ||
$service = realpath(__DIR__.'/../service').'/'.$service.'.php'; | ||
|
||
if(file_exists($service)) { | ||
include($service); | ||
} | ||
} | ||
|
||
function pathToResource($resourceName, $version = false) { | ||
$path = './resource/'; | ||
|
||
if(file_exists(__DIR__.'/.'.$path.$resourceName)) { | ||
return $path.$resourceName.( | ||
$version | ||
? '?v='.( | ||
$version === true | ||
? time() | ||
: $version | ||
) | ||
: '' | ||
); | ||
} | ||
} | ||
|
||
function getDatabaseConnection() { | ||
global $sqlconf; | ||
|
||
try { | ||
$databaseConnection = new PDO('mysql:host='.$sqlconf['host'].';dbname='.$sqlconf['dbase'], $sqlconf['login'], $sqlconf['pass']); | ||
$databaseConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | ||
} catch(PDOException $exception) { | ||
echo 'ERROR: ' . $exception->getMessage(); | ||
} | ||
|
||
return $databaseConnection; | ||
} |
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,9 @@ | ||
# LibreHealthEHR Merge Encounters | ||
|
||
## Technologies Used | ||
|
||
- [JQuery|https://jquery.com] | ||
- [KnockOutJS|http://knockoutjs.com] | ||
- [KoGrid|https://knockout-contrib.github.io/KoGrid] | ||
- [Split-Pane|https://github.com/shagstrom/split-pane] | ||
- [KoSortingTable|http://develothink.com/sorting-tables-using-knockoutjs] |
3 changes: 3 additions & 0 deletions
3
modules/merge_encounters/merge_encounter_docs/merge_enc_user_doc.md
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,3 @@ | ||
Merge Encounters User Documentation. | ||
|
||
This is a stub. |
Oops, something went wrong.