1 | <?php |
||
2 | |||
3 | |||
4 | namespace elevate\util; |
||
5 | |||
6 | use elevate\HVObjects\MethodObjects\SearchVocabulary\Info; |
||
7 | use elevate\HVObjects\MethodObjects\SearchVocabulary\SearchString; |
||
8 | use elevate\HVObjects\MethodObjects\SearchVocabulary\TextSearchParameters; |
||
9 | use elevate\HVObjects\MethodObjects\SearchVocabulary\VocabularyKey; |
||
10 | |||
11 | class SearchVocabularyInfoHelper |
||
12 | { |
||
13 | |||
14 | /** |
||
15 | * Convenience fn to build the Search object for HV. |
||
16 | * |
||
17 | * @param $searchTerm |
||
18 | * @return Info |
||
19 | */ |
||
20 | static function getHVInfoForMedicationSearchTerm($searchTerm) |
||
0 ignored issues
–
show
|
|||
21 | { |
||
22 | return self::getHVInfoForSearchTerm($searchTerm,'RxNorm Active Medicines','RxNorm' ); |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * Convenience fn to build the Search object for HV. |
||
27 | * |
||
28 | * @param $searchTerm |
||
29 | * @return Info |
||
30 | */ |
||
31 | static function getHVInfoForConditionSearchTerm($searchTerm) |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
It is recommend to declare an explicit visibility for
getHVInfoForConditionSearchTerm .
Generally, we recommend to declare visibility for all methods in your source code. This has the advantage of clearly communication to other developers, and also yourself, how this method should be consumed. If you are not sure which visibility to choose, it is a good idea to start with
the most restrictive visibility, and then raise visibility as needed, i.e.
start with ![]() |
|||
32 | { |
||
33 | return self::getHVInfoForSearchTerm($searchTerm,'icd9cm-reactions','icd' ); |
||
34 | } |
||
35 | |||
36 | |||
37 | /** |
||
38 | * Convenience fn to build the Search object for HV. |
||
39 | * |
||
40 | * @param $searchTerm |
||
41 | * @param string $vocabKey |
||
42 | * @param string $family |
||
43 | * @param string $searchType |
||
44 | * @param string $locale |
||
45 | * @return Info |
||
46 | */ |
||
47 | static function getHVInfoForSearchTerm($searchTerm, |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
It is recommend to declare an explicit visibility for
getHVInfoForSearchTerm .
Generally, we recommend to declare visibility for all methods in your source code. This has the advantage of clearly communication to other developers, and also yourself, how this method should be consumed. If you are not sure which visibility to choose, it is a good idea to start with
the most restrictive visibility, and then raise visibility as needed, i.e.
start with ![]() |
|||
48 | $vocabKey, |
||
49 | $family, |
||
50 | $searchType = 'Prefix', |
||
51 | $locale = 'en-US') |
||
52 | { |
||
53 | $vocabKey = new VocabularyKey($vocabKey, $family, $locale); |
||
54 | $searchStr = new SearchString($searchType, $searchTerm); |
||
55 | $textSearchParam = new TextSearchParameters(10, $searchStr); |
||
56 | |||
57 | return new Info($textSearchParam, $vocabKey); |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * Pulls out an associative array from the SearchVocabularyData |
||
62 | * |
||
63 | * @param $rawResponse |
||
64 | * @return array |
||
65 | */ |
||
66 | static function VocabDataFromXML($rawResponse) |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
It is recommend to declare an explicit visibility for
VocabDataFromXML .
Generally, we recommend to declare visibility for all methods in your source code. This has the advantage of clearly communication to other developers, and also yourself, how this method should be consumed. If you are not sure which visibility to choose, it is a good idea to start with
the most restrictive visibility, and then raise visibility as needed, i.e.
start with ![]() |
|||
67 | { |
||
68 | $xml = simplexml_load_string($rawResponse); |
||
69 | $xml->registerXPathNamespace('wc', 'urn:com.microsoft.wc.methods.response.SearchVocabulary'); |
||
70 | $codeItemsXMLObjects = $xml->xpath('//code-item'); |
||
71 | |||
72 | $vocabData = []; |
||
73 | |||
74 | foreach ($codeItemsXMLObjects as $item) { |
||
75 | $newEntry['name'] = (string)$item->{'display-text'}; |
||
76 | $newEntry['code-value'] = (string)$item->{'code-value'}; |
||
77 | $vocabData[] = $newEntry; |
||
78 | } |
||
79 | |||
80 | return $vocabData; |
||
81 | } |
||
82 | |||
83 | |||
84 | } |
Generally, we recommend to declare visibility for all methods in your source code. This has the advantage of clearly communication to other developers, and also yourself, how this method should be consumed.
If you are not sure which visibility to choose, it is a good idea to start with the most restrictive visibility, and then raise visibility as needed, i.e. start with
private
, and only raise it toprotected
if a sub-class needs to have access, orpublic
if an external class needs access.