-
Notifications
You must be signed in to change notification settings - Fork 2
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 #18 from RUGSoftEng/development
Sprint end pull request.
- Loading branch information
Showing
445 changed files
with
309,386 additions
and
333 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
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
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,29 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
/** | ||
* Reply written to a VerificationComment | ||
* | ||
* @property timestamp created_at | ||
* @property string text | ||
*/ | ||
class CommentReply extends Model | ||
{ | ||
protected $table = 'comment_replies'; | ||
public $timestamps = false; | ||
|
||
protected $fillable = ['text']; | ||
|
||
public function author() | ||
{ | ||
return $this->belongsTo('App\User','author_id'); | ||
} | ||
|
||
public function verificationComment() | ||
{ | ||
return $this->belongsTo('App\VerificationComment','verification_comment_id'); | ||
} | ||
} |
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,96 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Exceptions\JsonDecodeException; | ||
|
||
class EvidencioAPI | ||
{ | ||
/** | ||
* Helper method to perform an API call | ||
* @param string $path URL to the call without leading "https://www.evidencio.com/api/" | ||
* @param array $params list of parameters as a key-value array | ||
* @return array API response converted into a PHP variable | ||
* @throws JsonDecodeException if JSON response could not be decoded | ||
* Other possible exceptions are listed in Guzzle's documentation | ||
*/ | ||
private static function fetch($path, $params = []) | ||
{ | ||
$client = new \GuzzleHttp\Client(['base_uri' => 'https://www.evidencio.com/api/']); | ||
$res = $client->post($path, | ||
[ | ||
'headers' => [ | ||
'Accept' => 'application/json', | ||
'Authorization' => config('app.evidencio_key') | ||
], | ||
'form_params' => $params | ||
]); | ||
|
||
$json = json_decode($res->getBody(),true); | ||
|
||
if(is_null($json)) | ||
{ | ||
throw new JsonDecodeException($res->getBody()); | ||
} | ||
return $json; | ||
} | ||
|
||
/** | ||
* Get basic Evidencio model statistics | ||
* @return array decoded JSON containing number of models that you are | ||
* authorised to use and number of your own models (created using that API key) | ||
*/ | ||
public static function overview() | ||
{ | ||
return self::fetch("overview"); | ||
} | ||
|
||
/** | ||
* Search fro Evidencio models | ||
* @param string $query phrase to search for | ||
* @return array decoded JSON containing all the Evidencio models (with all | ||
* their data) matching the phrase | ||
*/ | ||
public static function search($query) | ||
{ | ||
return self::fetch("search",["query" => $query]); | ||
} | ||
|
||
/** | ||
* Get all Evidencio models | ||
* @return array decoded JSON containing all Evidencio models with all their data | ||
*/ | ||
public static function models() | ||
{ | ||
return self::fetch("models"); | ||
} | ||
|
||
/** | ||
* Get Evidencio model | ||
* @param int $id requested Evidencio model id | ||
* @return array decoded JSON containing requested Evidencio model data | ||
*/ | ||
public static function getModel($id) | ||
{ | ||
return self::fetch("model",["id" => $id]); | ||
} | ||
|
||
/** | ||
* Run Evidencio model | ||
* @param int $id Evidencio model id | ||
* @param array $values a key-value array containing Evidencio model variable | ||
* ids and their corresponding values | ||
* @return array decoded JSON containing the result and additional information | ||
*/ | ||
public static function run($id,$values) | ||
{ | ||
foreach ($values as $value) { | ||
if (is_numeric($value)) { | ||
$value = floatval($value); | ||
} | ||
} | ||
$values["id"] = $id; | ||
return self::fetch("run",$values); | ||
} | ||
|
||
} |
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,20 @@ | ||
<?php | ||
|
||
namespace App\Exceptions; | ||
|
||
use Exception; | ||
|
||
class JsonDecodeException extends Exception { | ||
|
||
/* | ||
* @param $response the code that could not be decoded | ||
* @see Exception | ||
*/ | ||
public function __construct($response, $code = 0, Exception $previous = null) { | ||
|
||
$message = "Could not decode API response to JSON: '".$response."'."; | ||
|
||
parent::__construct($message, $code, $previous); | ||
} | ||
|
||
} |
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,53 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
/** | ||
* Fields that are provided in an input step. They can be either categorical | ||
* (then they contain a number of options and have empty continuous attributes) | ||
* or continuous (they provide additional attributes) | ||
* | ||
* @property string friendly_title Title that is friendly to a patient | ||
* @property string friendly_description Description that is friendly to a patient | ||
* @property int continuous_field_max Maximum input value (Applies only to | ||
* continuous fields) | ||
* @property int continuous_field_min Minimum input value (Applies only to | ||
* continuous fields) | ||
* @property int continuous_field_step_by Interval between possible input values | ||
* (Applies only to continuous fields) | ||
* @property int continuous_field_unit Unit of the value (kilograms, years, etc.) | ||
* (Applies only to continuous fields) | ||
* @property int evidencio_variable_id Evidencio API variable id associated with | ||
* this field in the designer page | ||
*/ | ||
class Field extends Model | ||
{ | ||
public $timestamps = false; | ||
|
||
protected $fillable = [ | ||
'evidencio_variable_id','friendly_title','friendly_description','continuous_field_max','continuous_field_min','continuous_field_step_by','continuous_field_unit' | ||
]; | ||
|
||
/** | ||
* Possible options of a field (Applies only to categorical fields) | ||
*/ | ||
public function options() | ||
{ | ||
return $this->hasMany('App\Option','categorical_field_id'); | ||
} | ||
|
||
/** | ||
* Input steps that have this field | ||
*/ | ||
public function inputSteps() | ||
{ | ||
return $this->belongsToMany('App\Step','field_in_input_steps','field_id','input_step_id'); | ||
} | ||
|
||
public function usedInRunsInSteps() | ||
{ | ||
return $this->belongsToMany('App\Step','model_run_field_mappings','field_id','step_id'); | ||
} | ||
} |
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
Oops, something went wrong.