4 * FhirAllergyIntoleranceRestController
7 * @link http://www.open-emr.org
8 * @author Yash Bothra <yashrajbothra786@gmail.com>
9 * @copyright Copyright (c) 2020 Yash Bothra <yashrajbothra786@gmail.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 namespace OpenEMR\RestControllers\FHIR
;
15 use OpenEMR\Services\FHIR\FhirAllergyIntoleranceService
;
16 use OpenEMR\Services\FHIR\FhirResourcesService
;
17 use OpenEMR\RestControllers\RestControllerHelper
;
18 use OpenEMR\FHIR\R4\FHIRResource\FHIRBundle\FHIRBundleEntry
;
20 class FhirAllergyIntoleranceRestController
22 private $fhirAllergyIntoleranceService;
25 public function __construct()
27 $this->fhirAllergyIntoleranceService
= new FhirAllergyIntoleranceService();
28 $this->fhirService
= new FhirResourcesService();
32 * Queries for a single FHIR allergyIntolerance resource by FHIR id
33 * @param $fhirId The FHIR allergyIntolerance resource id (uuid)
34 * @param $puuidBind - Optional variable to only allow visibility of the patient with this puuid.
35 * @returns 200 if the operation completes successfully
37 public function getOne($fhirId, $puuidBind = null)
39 $processingResult = $this->fhirAllergyIntoleranceService
->getOne($fhirId, $puuidBind);
40 return RestControllerHelper
::handleFhirProcessingResult($processingResult, 200);
44 * Queries for FHIR allergyIntolerance resources using various search parameters.
45 * Search parameters include:
47 * @param $puuidBind - Optional variable to only allow visibility of the patient with this puuid.
48 * @return FHIR bundle with query results, if found
50 public function getAll($searchParams, $puuidBind = null)
52 $processingResult = $this->fhirAllergyIntoleranceService
->getAll($searchParams, $puuidBind);
53 $bundleEntries = array();
54 foreach ($processingResult->getData() as $index => $searchResult) {
56 'fullUrl' => $GLOBALS['site_addr_oath'] . ($_SERVER['REDIRECT_URL'] ??
'') . '/' . $searchResult->getId(),
57 'resource' => $searchResult
59 $fhirBundleEntry = new FHIRBundleEntry($bundleEntry);
60 array_push($bundleEntries, $fhirBundleEntry);
62 $bundleSearchResult = $this->fhirService
->createBundle('AllergyIntolerance', $bundleEntries, false);
63 $searchResponseBody = RestControllerHelper
::responseHandler($bundleSearchResult, null, 200);
64 return $searchResponseBody;