Skip to content

dcarbone/php-fhir-test

Repository files navigation

PHP FHIR Testing Resources

This repository contains test resources and server to be used by the php-fhir project. All other use cases are unsupported.

Generated Resources

This little webserver embeds any / all resources contained under the ./resources directory. These are static and this webserver is (currently) read-only.

Data Sources

Resources were generated / sourced from the below sources:

Building and Running Binary

$ make build
$ ./bin/php-fhir-test-server

The above command compiles and runs the php-fhir-test-server binary. The webserver binds to 127.0.0.1:8080 by default, but you may change this by providing the -bind flag at runtime.

Building and Running Local Docker

$ make docker-local
$ docker run --rm -p '127.0.0.1:8080:8080' ghcr.io/dcarbone/php-fhir-test-server

The above command compiles and runs a new container image, binding 127.0.0.1:8080 on your host. You can change the port bound on your host by changing the final :8080 segment in the value passed to -p.

Supported APIs

Below is the list of supported API's, along with an example query & response of each.

GET /

Returns list of all available FHIR versions with resources.

Parameters:

Name Type Default Description
_pretty boolean false If set and not equal to false, "pretty prints" the output
_format string - Must be one of: [xml json]. May also be set with Accept header.

Example:

curl -L -H 'Accept: application/json' http://127.0.0.1:8080/\?_pretty
JSON example
[
"DSTU1",
"DSTU2",
"STU3",
"R4",
"R4B",
"R5"
]
curl -L -H 'Accept: application/xml' http://127.0.0.1:8080/\?_pretty
XML example
<?xml version="1.0" encoding="UTF-8"?>
<FHIRVersions>
<FHIRVersion value="DSTU1"></FHIRVersion>
<FHIRVersion value="DSTU2"></FHIRVersion>
<FHIRVersion value="STU3"></FHIRVersion>
<FHIRVersion value="R4"></FHIRVersion>
<FHIRVersion value="R4B"></FHIRVersion>
<FHIRVersion value="R5"></FHIRVersion>
</FHIRVersions>

GET /{fhir_version}

Returns a list of available resource types for a given FHIR version.

Parameters:

Name Type Default Description
_pretty boolean false If set and not equal to false, "pretty prints" the output
_format string - Must be one of: [xml json]. May also be set with Accept header.

Example:

curl -L -H 'Accept: application/json' http://127.0.0.1:8080/R4\?_pretty
JSON example
{
"fhirVersion": 4,
"resources": [
  "CarePlan",
  "CareTeam",
  "Claim",
  "Condition",
  "Device",
  "DiagnosticReport",
  "DocumentReference",
  "Encounter",
  "ExplanationOfBenefit",
  "ImagingStudy",
  "Immunization",
  "Location",
  "Medication",
  "MedicationAdministration",
  "MedicationRequest",
  "Observation",
  "Organization",
  "Parameters",
  "Patient",
  "Practitioner",
  "PractitionerRole",
  "Procedure",
  "Provenance",
  "SupplyDelivery"
]
}
curl -L -H 'Accept: application/xml' http://127.0.0.1:8080/R4\?_pretty
XML example
<?xml version="1.0" encoding="UTF-8"?>
<FHIRVersion value="R4">
<Resources>
  <Resource value="CarePlan"></Resource>
  <Resource value="CareTeam"></Resource>
  <Resource value="Claim"></Resource>
  <Resource value="Condition"></Resource>
  <Resource value="Device"></Resource>
  <Resource value="DiagnosticReport"></Resource>
  <Resource value="DocumentReference"></Resource>
  <Resource value="Encounter"></Resource>
  <Resource value="ExplanationOfBenefit"></Resource>
  <Resource value="ImagingStudy"></Resource>
  <Resource value="Immunization"></Resource>
  <Resource value="Location"></Resource>
  <Resource value="Medication"></Resource>
  <Resource value="MedicationAdministration"></Resource>
  <Resource value="MedicationRequest"></Resource>
  <Resource value="Observation"></Resource>
  <Resource value="Organization"></Resource>
  <Resource value="Parameters"></Resource>
  <Resource value="Patient"></Resource>
  <Resource value="Practitioner"></Resource>
  <Resource value="PractitionerRole"></Resource>
  <Resource value="Procedure"></Resource>
  <Resource value="Provenance"></Resource>
  <Resource value="SupplyDelivery"></Resource>
</Resources>
</FHIRVersion>

GET /{fhir_version}/{resource_type}

Returns a Bundle of resources of a particular type for a particular FHIR version.

Parameters:

Name Type Default Description
_pretty boolean false If set and not equal to false, "pretty prints" the output
_format string - Must be one of: [xml json]. May also be set with Accept header.
_count integer 0 Maximum number of resources to return. Value must be >= 0, and 0 means return all.

Query Example:

curl -L -H 'Accept: application/json' http://127.0.0.1:8080/R4/Patient\?_pretty\&_count\=2
curl -L -H 'Accept: application/xml' http://127.0.0.1:8080/R4/Patient\?_pretty\&_count\=2

GET /{fhir_version}/{resource_type}/{resource_id}

Returns a Bundle of resources of a particular type for a particular FHIR version.

Parameters:

Name Type Default Description
_pretty boolean false If set and not equal to false, "pretty prints" the output
_format string - Must be one of: [xml json]. May also be set with Accept header.

Query Example:

curl -L -H 'Accept: application/json' http://127.0.0.1:8080/R4/Patient/2028cf85-bdf0-4a2e-2f82-5f3a37078971\?_pretty
curl -L -H 'Accept: application/xml' http://127.0.0.1:8080/R4/Patient/2028cf85-bdf0-4a2e-2f82-5f3a37078971\?_pretty

About

Testing utilities for PHP FHIR

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages