-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig1.php
155 lines (135 loc) · 6.09 KB
/
config1.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?php
require 'token_generator.php';
require 'priaid_client.php';
class schecker{
public $config;
public $diagnosisClient;
function __construct(){
$this->config = parse_ini_file('config.ini');
}
public function checkRequiredParameters()
{
$pass = true;
if (!isset($this->config['username']))
{
$pass = false;
print "You didn't set username in config.ini" ;
}
if (!isset($this->config['password']))
{
$pass = false;
print "You didn't set password in config.ini" ;
}
if (!isset($this->config['authServiceUrl']))
{
$pass = false;
print "You didn't set authServiceUrl in config.ini" ;
}
if (!isset($this->config['healthServiceUrl']))
{
$pass = false;
print "You didn't set healthserviceUrl in config.ini" ;
}
return $pass;
}
public function simulate()
{
if (!$this->checkRequiredParameters())
return;
$tokenGenerator = new TokenGenerator($this->config['username'], $this->config['password'], $this->config['authServiceUrl']);
$token = $tokenGenerator->loadToken();
if (!isset($token))
exit();
$this->diagnosisClient = new DiagnosisClient($token, $this->config['healthServiceUrl'], 'en-gb');
$bodyLocations = $this->diagnosisClient->loadBodyLocations();
if (!isset($bodyLocations))
exit();
// $this->printSimpleObject($bodyLocations);
$bodylocarray = array_values($bodyLocations);
// print_r($bodylocarray);
/*
// get random body location
$locRandomIndex = rand(0, count($bodyLocations)-1);
$locRandomId = $bodyLocations[$locRandomIndex]['ID'];
$locRandomName = $bodyLocations[$locRandomIndex]['Name'];
$bodySublocations = $this->diagnosisClient->loadBodySublocations($locRandomId);
if (!isset($bodySublocations))
exit();
print("<h3>Body Subocations for $locRandomName($locRandomId)</h3>");
$this->printSimpleObject($bodySublocations);
// get random body sublocation
$sublocRandomIndex = rand(0, count($bodySublocations)-1);
$sublocRandomId = $bodySublocations[$sublocRandomIndex]['ID'];
$sublocRandomName = $bodySublocations[$sublocRandomIndex]['Name'];
$symptoms = $this->diagnosisClient->loadSublocationSymptoms($sublocRandomId,'man');
print("<h3>Symptoms in body sublocation $sublocRandomName($sublocRandomId)</h3>");
if (!isset($symptoms))
exit();
if (count($symptoms) == 0)
die("No symptoms for selected body sublocation");
$this->printSimpleObject($symptoms);
// get diagnosis
$randomSymptomIndex = rand(0, count($symptoms)-1);
$randomSymptomId = $symptoms[$randomSymptomIndex]['ID'];
$randomSymptomName = $symptoms[$randomSymptomIndex]['Name'];
$selectedSymptoms = array($randomSymptomId);
$diagnosis = $this->diagnosisClient->loadDiagnosis($selectedSymptoms, 'male', 1988);
if (!isset($diagnosis))
exit();
print("<h3>Calculated diagnosis for $randomSymptomName($randomSymptomId)</h3>");
$this->printDiagnosis($diagnosis);
// get specialisations
$specialisations = $this->diagnosisClient->loadSpecialisations($selectedSymptoms, 'male', 1988);
if (!isset($specialisations))
exit();
print("<h3>Calculated specialisations for $randomSymptomName($randomSymptomId)</h3>");
$this->printSpecialisations($specialisations);
// get proposed symptoms
$proposedSymptoms = $this->diagnosisClient->loadProposedSymptoms($selectedSymptoms, 'male', 1988);
if (!isset($proposedSymptoms))
exit();
print("<h3>Proposed symptoms for selected $randomSymptomName($randomSymptomId)</h3>");
$this->printSimpleObject($proposedSymptoms);
// get red flag text
$redFlagText = $this->diagnosisClient->loadRedFlag($randomSymptomId);
if (!isset($redFlagText))
exit();
print("<h3>Red flag text for selected $randomSymptomName($randomSymptomId)</h3>");
print($redFlagText);
// get issue info
reset($diagnosis);
while (list($key, $val) = each($diagnosis)) {
$this->loadIssueInfo($val['Issue']['ID']);
}
print('</body></html>');
*/
}
public function getbodyloc(){
if (!$this->checkRequiredParameters())
return;
$tokenGenerator = new TokenGenerator($this->config['username'], $this->config['password'], $this->config['authServiceUrl']);
$token = $tokenGenerator->loadToken();
if (!isset($token))
exit();
$this->diagnosisClient = new DiagnosisClient($token, $this->config['healthServiceUrl'], 'en-gb');
$bodyLocations = $this->diagnosisClient->loadBodyLocations();
if (!isset($bodyLocations))
exit();
$bodylocarray = array_values($bodyLocations);
//print_r($bodylocarray);
return $bodylocarray;
}
public function getbodysubloc(){
$tokenGenerator = new TokenGenerator($this->config['username'], $this->config['password'], $this->config['authServiceUrl']);
$token = $tokenGenerator->loadToken();
if (!isset($token))
exit();
$selbloc = $_POST['sloc'];
$bodySublocations = $this->diagnosisClient->loadBodySublocations($selbloc);
if (!isset($bodySublocations))
exit();
$bodysublocarray = array_values($bodySublocations);
return $bodysublocarray;
}
}
?>