4 * FhirCarePlanRestController.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\FhirCareTeamService
;
15 use OpenEMR\Services\FHIR\FhirResourcesService
;
16 use OpenEMR\RestControllers\RestControllerHelper
;
17 use OpenEMR\FHIR\R4\FHIRResource\FHIRBundle\FHIRBundleEntry
;
18 use OpenEMR\Validators\ProcessingResult
;
20 class FhirCarePlanRestController
24 public function __construct()
26 $this->fhirService
= new FhirResourcesService();
30 * Queries for a single FHIR location resource by FHIR id
31 * @param $fhirId The FHIR location resource id (uuid)
32 * @param $puuidBind - Optional variable to only allow visibility of the patient with this puuid.
33 * @returns 200 if the operation completes successfully
35 public function getOne($fhirId, $puuidBind = null)
37 $processingResult = new ProcessingResult(); // return nothing for now
38 return RestControllerHelper
::handleFhirProcessingResult($processingResult, 200);
42 * Queries for FHIR location resources using various search parameters.
43 * @param $puuidBind - Optional variable to only allow visibility of the patient with this puuid.
44 * @return FHIR bundle with query results, if found
46 public function getAll($searchParams, $puuidBind = null)
48 $processingResult = new ProcessingResult(); // return nothing for now
49 $bundleEntries = array();
50 foreach ($processingResult->getData() as $index => $searchResult) {
52 'fullUrl' => $GLOBALS['site_addr_oath'] . ($_SERVER['REDIRECT_URL'] ??
'') . '/' . $searchResult->getId(),
53 'resource' => $searchResult
55 $fhirBundleEntry = new FHIRBundleEntry($bundleEntry);
56 array_push($bundleEntries, $fhirBundleEntry);
58 $bundleSearchResult = $this->fhirService
->createBundle('CarePlan', $bundleEntries, false);
59 $searchResponseBody = RestControllerHelper
::responseHandler($bundleSearchResult, null, 200);
60 return $searchResponseBody;