faulkj/fhirclient 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

faulkj/fhirclient

最新稳定版本:v3.0.1

Composer 安装命令:

composer require faulkj/fhirclient

包简介

A simple PHP client for SMART on FHIR.

README 文档

README

A simple PHP client for SMART on FHIR, the standard API for integrating applications with any modern healthcare system.

Installation

$ composer require faulkj/fhirclient

Basic Usage

EMR Ebedded Mode

On initial load:

//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();

This will first get an Conformance Statement/SMART Configuration from my.fhirserver.com/FHIRProxy/api/FHIR/R4 to retrieve the authorization and token endpoints. It will then request an authorization code from the authorization endpoint, triggering a redirect to my.website.com.

On my.website.com when redirected:

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;

On subsequent page loads or AJAX calls, the FHIRClient will need to be reinstanciated before yoy can send a query:

use FaulkJ\FHIRClient;
session_start();

$fc = new FHIRClient(...$_SESSION["fhirParams"]);
$pat = $fc->query("Patient/12345678");
if($pat->code == 200) echo $pat->body;

Standalone Mode

On initial load:

use FaulkJ\FHIRClient;
session_start();

$iss = parse_url($_GET["iss"]);
$_SESSION["fhirParams"] = [
   "https:/my.fhirserver.com",
   "1234-5678-9012-3456-7890",
   [
      "state"       => base64_encode(rand()),
      "redirectURI" => "https://my.website.com",
      "authURI"     => "FHIRProxy/oauth2/authorize",
      "tokenURI"    => "FHIRProxy/oauth2/token"
   ]
];
$fc = new FHIRClient(...$_SESSION["fhirParams"]);
$fc->getConformance($_GET["iss"]);
$fc->getAuthCode();

This example includes a randomly generated state parameter and will request an authorization code from my.fhirserver.com/FHIRProxy/oauth2/authorize, triggering a redirect to my.website.com.

On my.website.com when redirected:

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;

On subsequent page loads or AJAX calls, the FHIRClient will need to be reinstanciated before yoy can send a query:

use FaulkJ\FHIRClient;
session_start();

$fc = new FHIRClient(...$_SESSION["fhirParams"]);
$pat = $fc->query("Patient/12345678");
if($pat->code == 200) echo $pat->body;

Backend Mode

use FaulkJ\FHIRClient;

$fc = (new FHIRClient(
   "https:/fhir.server.com",
   "1234-5678-9012-3456-7890",
   [
      "signingKey" => "D:\\privatekey.pem",
      "tokenURI"   => "FHIRProxy/oauth2/token"
   ]
))->debug(true);

$fc->getAccessToken();

$response = $fc->query("FHIRProxy/path/to/api/");
if($response->code == 200) echo $response->body;

统计信息

  • 总下载量: 1.09k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unlicense
  • 更新时间: 2021-09-03