4 * FhirDiagnosticReportRestController.php
6 * @link http://www.open-emr.org
7 * @author Stephen Nielson <stephen@nielson.org>
8 * @copyright Copyright (c) 2021 Stephen Nielson <stephen@nielson.org>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
12 namespace OpenEMR\RestControllers\FHIR
;
14 use OpenEMR\Services\FHIR\FhirResourcesService
;
15 use OpenEMR\RestControllers\RestControllerHelper
;
16 use OpenEMR\FHIR\R4\FHIRResource\FHIRBundle\FHIRBundleEntry
;
17 use OpenEMR\Validators\ProcessingResult
;
19 class FhirDiagnosticReportRestController
23 public function __construct()
25 $this->fhirService
= new FhirResourcesService();
29 * Queries for a single FHIR location resource by FHIR id
30 * @param $fhirId The FHIR location resource id (uuid)
31 * @param $puuidBind - Optional variable to only allow visibility of the patient with this puuid.
32 * @returns 200 if the operation completes successfully
34 public function getOne($fhirId, $puuidBind = null)
36 $processingResult = new ProcessingResult(); // return nothing for now
37 return RestControllerHelper
::handleFhirProcessingResult($processingResult, 200);
41 * Queries for FHIR location resources using various search parameters.
42 * @param $puuidBind - Optional variable to only allow visibility of the patient with this puuid.
43 * @return FHIR bundle with query results, if found
45 public function getAll($searchParams, $puuidBind = null)
47 $processingResult = new ProcessingResult(); // return nothing for now
48 $bundleEntries = array();
49 foreach ($processingResult->getData() as $index => $searchResult) {
51 'fullUrl' => $GLOBALS['site_addr_oath'] . ($_SERVER['REDIRECT_URL'] ??
'') . '/' . $searchResult->getId(),
52 'resource' => $searchResult
54 $fhirBundleEntry = new FHIRBundleEntry($bundleEntry);
55 array_push($bundleEntries, $fhirBundleEntry);
57 $bundleSearchResult = $this->fhirService
->createBundle('CarePlan', $bundleEntries, false);
58 $searchResponseBody = RestControllerHelper
::responseHandler($bundleSearchResult, null, 200);
59 return $searchResponseBody;