|
1
|
|
|
<?php |
|
2
|
|
|
namespace src\riesgos; |
|
3
|
|
|
|
|
4
|
|
|
use src\sustancias\Inhalables; |
|
5
|
|
|
|
|
6
|
|
|
class RiesgoInhalables |
|
7
|
|
|
{ |
|
8
|
|
|
/** |
|
9
|
|
|
* |
|
10
|
|
|
* @var array |
|
11
|
|
|
*/ |
|
12
|
|
|
private array $_intervencion = [ |
|
13
|
|
|
'0-3' => 'No requiere intervención (consejo breve)', |
|
14
|
|
|
'4-26' => 'Requiere intervención breve', |
|
15
|
|
|
'27-99' => 'Requiere tratamiento más intensivo' |
|
16
|
|
|
]; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* |
|
20
|
|
|
* @var array |
|
21
|
|
|
*/ |
|
22
|
|
|
private array $_riesgo = [ |
|
23
|
|
|
'0-3' => 'Riesgo bajo', |
|
24
|
|
|
'4-26' => 'Riesgo moderado', |
|
25
|
|
|
'27-99' => 'Riesgo alto' |
|
26
|
|
|
]; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* |
|
30
|
|
|
* @var \src\sustancias\Inhalables |
|
31
|
|
|
*/ |
|
32
|
|
|
private Inhalables $_inhalables; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* |
|
36
|
|
|
* @param \src\sustancias\Inhalables $Inhalables |
|
37
|
|
|
*/ |
|
38
|
11 |
|
public function __construct(Inhalables $Inhalables) |
|
39
|
|
|
{ |
|
40
|
11 |
|
$this->_inhalables = $Inhalables; |
|
41
|
11 |
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* |
|
45
|
|
|
* @return string |
|
46
|
|
|
*/ |
|
47
|
2 |
|
public function numero(): string |
|
48
|
|
|
{ |
|
49
|
|
|
return |
|
50
|
2 |
|
$this->_inhalables->preguntaDos()->numero() + |
|
51
|
2 |
|
$this->_inhalables->preguntaTres()->numero() + |
|
52
|
2 |
|
$this->_inhalables->preguntaCuatro()->numero() + |
|
53
|
2 |
|
$this->_inhalables->preguntaCinco()->numero() + |
|
54
|
2 |
|
$this->_inhalables->preguntaSeis()->numero() + |
|
55
|
2 |
|
$this->_inhalables->preguntaSiete()->numero(); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* |
|
60
|
|
|
* @return string |
|
61
|
|
|
*/ |
|
62
|
2 |
|
public function texto(): string |
|
63
|
|
|
{ |
|
64
|
2 |
|
return $this->setRiesgo($this->numero(), $this->_riesgo); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* |
|
69
|
|
|
* @return string |
|
70
|
|
|
*/ |
|
71
|
2 |
|
public function intervencion(): string |
|
72
|
|
|
{ |
|
73
|
2 |
|
return $this->setRiesgo($this->numero(), $this->_intervencion); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* |
|
78
|
|
|
* @param string $riesgo |
|
79
|
|
|
* @param array $comparador |
|
80
|
|
|
* |
|
81
|
|
|
* @return string |
|
82
|
|
|
*/ |
|
83
|
2 |
|
private function setRiesgo(string $riesgo, array $comparador): string |
|
84
|
|
|
{ |
|
85
|
2 |
|
foreach ($comparador as $key => $value) { |
|
86
|
2 |
|
$val = explode('-', $key); |
|
87
|
|
|
|
|
88
|
2 |
|
if ($riesgo >= $val[0] && $riesgo <= $val[1]) { |
|
89
|
2 |
|
$riesgo = $value; |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
2 |
|
return $riesgo; |
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
|