3 * FhirEncounterRestController
6 * @link http://www.open-emr.org
7 * @author Jerry Padgett <sjpadgett@gmail.com>
8 * @copyright Copyright (c) 2018 Jerry Padgett <sjpadgett@gmail.com>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 namespace OpenEMR\RestControllers
;
15 use OpenEMR\Services\EncounterService
;
16 use OpenEMR\Services\FhirResourcesService
;
17 use OpenEMR\RestControllers\RestControllerHelper
;
18 use HL7\FHIR\STU3\FHIRResource\FHIRBundle\FHIRBundleEntry
;
20 class FhirEncounterRestController
22 private $encounterService;
25 public function __construct()
27 $this->encounterService
= new EncounterService();
28 $this->fhirService
= new FhirResourcesService();
31 // implement put post in future
33 public function getOne($eid)
35 $oept = $this->encounterService
->getEncounter($eid);
36 $encounterResource = $this->fhirService
->createEncounterResource($eid, $oept, false);
38 return RestControllerHelper
::responseHandler($encounterResource, null, 200);
41 public function getAll($search)
43 $resourceURL = \RestConfig
::$REST_FULL_URL;
44 if (strpos($resourceURL, '?') > 0) {
45 $resourceURL = strstr($resourceURL, '?', true);
49 'pid' => $search['patient'],
50 'provider_id' => $search['practitioner']);
52 $searchResult = $this->encounterService
->getEncountersBySearch($searchParam);
53 if ($searchResult === false) {
54 http_response_code(404);
58 foreach ($searchResult as $oept) {
59 $entryResource = $this->fhirService
->createEncounterResource($oept['encounter'], $oept, false);
61 'fullUrl' => $resourceURL . "/" . $oept['encounter'],
62 'resource' => $entryResource
64 $entries[] = new FHIRBundleEntry($entry);
66 $searchResult = $this->fhirService
->createBundle('Encounter', $entries, false);
67 return RestControllerHelper
::responseHandler($searchResult, null, 200);