Create Patient's Consolidated Data
curl --request PUT \
--url https://api.sandbox.metriport.com/medical/v1/patient/{id}/consolidated \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"resourceType": "<string>",
"type": "<string>",
"entry": [
{
"resource": {}
}
]
}
'import requests
url = "https://api.sandbox.metriport.com/medical/v1/patient/{id}/consolidated"
payload = {
"resourceType": "<string>",
"type": "<string>",
"entry": [{ "resource": {} }]
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({resourceType: '<string>', type: '<string>', entry: [{resource: {}}]})
};
fetch('https://api.sandbox.metriport.com/medical/v1/patient/{id}/consolidated', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sandbox.metriport.com/medical/v1/patient/{id}/consolidated",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'resourceType' => '<string>',
'type' => '<string>',
'entry' => [
[
'resource' => [
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sandbox.metriport.com/medical/v1/patient/{id}/consolidated"
payload := strings.NewReader("{\n \"resourceType\": \"<string>\",\n \"type\": \"<string>\",\n \"entry\": [\n {\n \"resource\": {}\n }\n ]\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.sandbox.metriport.com/medical/v1/patient/{id}/consolidated")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"resourceType\": \"<string>\",\n \"type\": \"<string>\",\n \"entry\": [\n {\n \"resource\": {}\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.metriport.com/medical/v1/patient/{id}/consolidated")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"resourceType\": \"<string>\",\n \"type\": \"<string>\",\n \"entry\": [\n {\n \"resource\": {}\n }\n ]\n}"
response = http.request(request)
puts response.read_bodyimport { MetriportMedicalApi } from "@metriport/api-sdk";
const metriport = new MetriportMedicalApi("YOUR_API_KEY");
await metriport.createPatientConsolidated(patientId, {
resourceType: "Bundle",
type: "collection",
entry: [
{
resource: {
resourceType: "Appointment",
status: "booked",
participant: [
{
actor: {
reference: `Patient/${patientId}`,
display: "John Doe",
},
status: "accepted",
period: {
start: "2021-05-24T13:21:28.527Z",
end: "2021-05-24T13:21:28.527Z",
},
},
],
meta: {
versionId: "12345",
lastUpdated: "2023-05-24T13:21:28.527Z",
},
},
},
],
});
FHIR
Create Patient's Consolidated Data
Create Patient’s Consolidated Data with a FHIR Bundle.
PUT
/
medical
/
v1
/
patient
/
{id}
/
consolidated
Create Patient's Consolidated Data
curl --request PUT \
--url https://api.sandbox.metriport.com/medical/v1/patient/{id}/consolidated \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"resourceType": "<string>",
"type": "<string>",
"entry": [
{
"resource": {}
}
]
}
'import requests
url = "https://api.sandbox.metriport.com/medical/v1/patient/{id}/consolidated"
payload = {
"resourceType": "<string>",
"type": "<string>",
"entry": [{ "resource": {} }]
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({resourceType: '<string>', type: '<string>', entry: [{resource: {}}]})
};
fetch('https://api.sandbox.metriport.com/medical/v1/patient/{id}/consolidated', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sandbox.metriport.com/medical/v1/patient/{id}/consolidated",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'resourceType' => '<string>',
'type' => '<string>',
'entry' => [
[
'resource' => [
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sandbox.metriport.com/medical/v1/patient/{id}/consolidated"
payload := strings.NewReader("{\n \"resourceType\": \"<string>\",\n \"type\": \"<string>\",\n \"entry\": [\n {\n \"resource\": {}\n }\n ]\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.sandbox.metriport.com/medical/v1/patient/{id}/consolidated")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"resourceType\": \"<string>\",\n \"type\": \"<string>\",\n \"entry\": [\n {\n \"resource\": {}\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.metriport.com/medical/v1/patient/{id}/consolidated")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"resourceType\": \"<string>\",\n \"type\": \"<string>\",\n \"entry\": [\n {\n \"resource\": {}\n }\n ]\n}"
response = http.request(request)
puts response.read_bodyimport { MetriportMedicalApi } from "@metriport/api-sdk";
const metriport = new MetriportMedicalApi("YOUR_API_KEY");
await metriport.createPatientConsolidated(patientId, {
resourceType: "Bundle",
type: "collection",
entry: [
{
resource: {
resourceType: "Appointment",
status: "booked",
participant: [
{
actor: {
reference: `Patient/${patientId}`,
display: "John Doe",
},
status: "accepted",
period: {
start: "2021-05-24T13:21:28.527Z",
end: "2021-05-24T13:21:28.527Z",
},
},
],
meta: {
versionId: "12345",
lastUpdated: "2023-05-24T13:21:28.527Z",
},
},
},
],
});
Path Params
The ID of the Patient.
Body
The resource needs to be “Bundle”
The type needs to be “collection”
The entry needs to be an array of BackboneElement, containing:
Hide entry properties
Hide entry properties
The FHIR resource being contributed.
At the moment there is a limit to how much data you can
send in a single request. The content-length must not
exceed 1MB (and 50 resources when in
sandbox).Response
Returns a Bundle of type “transaction-response” with the entry being the outcome of the query.import { MetriportMedicalApi } from "@metriport/api-sdk";
const metriport = new MetriportMedicalApi("YOUR_API_KEY");
await metriport.createPatientConsolidated(patientId, {
resourceType: "Bundle",
type: "collection",
entry: [
{
resource: {
resourceType: "Appointment",
status: "booked",
participant: [
{
actor: {
reference: `Patient/${patientId}`,
display: "John Doe",
},
status: "accepted",
period: {
start: "2021-05-24T13:21:28.527Z",
end: "2021-05-24T13:21:28.527Z",
},
},
],
meta: {
versionId: "12345",
lastUpdated: "2023-05-24T13:21:28.527Z",
},
},
},
],
});
{
"resourceType": "Bundle",
"id": "bc0fcad0-6457-4b9e-93b3-44212e386138",
"type": "transaction-response",
"entry": [
{
"response": {
"status": "201 Created",
"location": "Appointment/3/_history/1",
"etag": "1",
"lastModified": "2023-07-27T21:29:31.491+00:00",
"outcome": {
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "information",
"code": "informational",
"details": {
"coding": [
{
"system": "https://public.metriport.com/fhir/StructureDefinition/operation-outcome",
"code": "SUCCESSFUL_CREATE",
"display": "Create succeeded."
}
]
},
"diagnostics": "Successfully created resource \"Appointment/3/_history/1\". Took 7ms."
}
]
}
}
}
]
}
⌘I

