4 * FhirURLResolver is a simple class that takes in a FHIR base server url and can be used to extract pieces of the URL
5 * that are needed within the FHIR system such as a resource's relative URI
7 * @link http://www.open-emr.org
8 * @author Stephen Nielson <stephen@nielson.org>
9 * @copyright Copyright (c) 2021 Stephen Nielson <stephen@nielson.org>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 namespace OpenEMR\Services\FHIR
;
19 private $baseUrlLength;
21 public function __construct($baseURL)
23 $this->fhirBaseURL
= $baseURL;
24 $this->baseUrlLength
= strlen($baseURL);
27 public function getRelativeUrl($url): ?
string
29 // extracts everything but the resource/:id portion of a URL from the base url.
30 // if the URI passed in does not match the base fhir URI we do nothing with it
31 if (strstr($url, $this->fhirBaseURL
) === false) {
34 // grab everything from our string onwards...
35 $relativeUrl = substr($url, $this->baseUrlLength
- 1);
36 return $relativeUrl !== false ?
$relativeUrl : null;