Support for tabbed encounters. (#1263)
[openemr.git] / portal / patient / index.php
blob6db203b8f7b75fe56e0661f7b132ce77e899b063
1 <?php
2 /** @package Patient Portal
4 * From phreeze package
5 * @license http://www.gnu.org/copyleft/lesser.html LGPL
7 */
9 //require_once ("./../verify_session.php");
10 /* GlobalConfig object contains all configuration information for the app */
11 include_once("_global_config.php");
12 include_once("_app_config.php");
13 @include_once("_machine_config.php"); // This include auth any framework calls
15 if (!GlobalConfig::$CONNECTION_SETTING) {
16 throw new Exception('GlobalConfig::$CONNECTION_SETTING is not configured. Are you missing _machine_config.php?');
19 /* require framework libs */
20 require_once("verysimple/Phreeze/Dispatcher.php");
22 // the global config is used for all dependency injection
23 $gc = GlobalConfig::GetInstance();
25 try {
26 Dispatcher::Dispatch(
27 $gc->GetPhreezer(),
28 $gc->GetRenderEngine(),
29 '',
30 $gc->GetContext(),
31 $gc->GetRouter()
33 } catch (exception $ex) {
34 // This is the global error handler which will be called in the event of
35 // uncaught errors. If the endpoint appears to be an API request then
36 // render it as JSON, otherwise attempt to render a friendly HTML page
38 $url = RequestUtil::GetCurrentURL();
39 $isApiRequest = (strpos($url, 'api/') !== false);
41 if ($isApiRequest) {
42 $result = new stdClass();
43 $result->success= false;
44 $result->message = $ex->getMessage();
45 $result->data = $ex->getTraceAsString();
47 @header('HTTP/1.1 401 Unauthorized');
48 echo json_encode($result);
49 } else {
50 $gc->GetRenderEngine()->assign("message", $ex->getMessage());
51 $gc->GetRenderEngine()->assign("stacktrace", $ex->getTraceAsString());
52 $gc->GetRenderEngine()->assign("code", $ex->getCode());
54 try {
55 $gc->GetRenderEngine()->display("DefaultErrorFatal.tpl");
56 } catch (Exception $ex2) {
57 // this means there is an error with the template, in which case we can't display it nicely
58 echo "<style>* { font-family: verdana, arial, helvetica, sans-serif; }</style>\n";
59 echo "<h1>Fatal Error:</h1>\n";
60 echo '<h3>' . htmlentities($ex->getMessage()) . "</h3>\n";
61 echo "<h4>Original Stack Trace:</h4>\n";
62 echo '<textarea wrap="off" style="height: 200px; width: 100%;">' . htmlentities($ex->getTraceAsString()) . '</textarea>';
63 echo "<h4>In addition to the above error, the default error template could not be displayed:</h4>\n";
64 echo '<textarea wrap="off" style="height: 200px; width: 100%;">' . htmlentities($ex2->getMessage()) . "\n\n" . htmlentities($ex2->getTraceAsString()) . '</textarea>';