1. Go to this page and download the library: Download faulkj/fhirclient library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
faulkj / fhirclient example snippets
//Assumining this is the URL loaded by the EMR: https://my.website.com/launch/?iss=https://my.fhirserver.com/FHIRProxy/api/FHIR/R4&launch=abc123
use FaulkJ\FHIRClient;
session_start();
$iss = parse_url($_GET["iss"]);
$_SESSION["fhirParams"] = [
"{$iss['scheme']}://{$iss['host']}",
"1234-5678-9012-3456-7890",
[
"redirectURI" => "https://my.website.com"
]
];
$fhir = new FHIRClient(...$_SESSION["fhirParams"]);
$fhir->getConformance($_GET["iss"]);
$fhir->getAuthCode();
use FaulkJ\FHIRClient;
session_start();
$fc = new FHIRClient(...$_SESSION["fhirParams"]);
$fc->getAccessToken($_GET["code"]);
//You are now authenticated and may query the FHIR server
$obs = $fc->query("Observation?patient=12345678&code=12345-6");
if($obs->code == 200) echo $obs->body;
use FaulkJ\FHIRClient;
session_start();
$fc = new FHIRClient(...$_SESSION["fhirParams"]);
$pat = $fc->query("Patient/12345678");
if($pat->code == 200) echo $pat->body;
use FaulkJ\FHIRClient;
session_start();
$fc = new FHIRClient(...$_SESSION["fhirParams"]);
$fc->getAccessToken($_GET["code"]);
//You are now authenticated and may query the FHIR server
$obs = $fc->query("Observation?patient=12345678&code=12345-6");
if($obs->code == 200) echo $obs->body;
use FaulkJ\FHIRClient;
session_start();
$fc = new FHIRClient(...$_SESSION["fhirParams"]);
$pat = $fc->query("Patient/12345678");
if($pat->code == 200) echo $pat->body;