Upload Document
curl --request POST \
--url https://api.sandbox.metriport.com/medical/v1/document/upload \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '{
"type": {
"text": "<string>",
"coding": []
},
"description": "<string>",
"context": [
{
"period": {},
"facilityType": {}
}
]
}'
import { MetriportMedicalApi } from "@metriport/api-sdk";
import axios from "axios";
const metriport = new MetriportMedicalApi("YOUR_API_KEY");
const docRef: Partial<DocumentReference> = {
description: "Third degree wrist burn treatment",
type: {
text: "Burn management Hospital Progress note",
coding: [
{
code: "100556-0",
system: "http://loinc.org",
display: "Burn management Hospital Progress note",
},
],
},
context: {
period: {
start: "2023-10-10T14:14:17Z",
},
facilityType: {
text: "My Clinic Name - Acute Care",
},
},
};
const resp = await metriport.createDocumentReference("my-patient-id", docRef);
// Upload the document using this url in a PUT request, something along these lines:
// const fileContent = <medical-document-document-contents>;
// await axios.put(resp.uploadUrl, document, {
// headers: {
// "Content-Length": <size-in-bytes>,
// },
// });
This endpoint returns the DocumentReference ID and a URL to enable you to upload your patients’ medical documents, making them available to other HIEs.
Overview
To use this endpoint, you will need to follow these steps:
-
Create a
DocumentReference
to describe the document that’s being uploaded (see sections below for details on the expected fields and format). -
Execute the endpoint and receive a URL to use for the document upload.
-
Upload the document by executing a
PUT
request using theURL
with aContent-Length
header specifying the size of the document.
Query Params
The ID of the Patient.
Body
A FHIR DocumentReference.
A CodeableConcept of the document type.
A brief description of the document - for example Discharge Summary
.
Context of the document content.
Note that you do not need to include a Patient or Organization resource in the contained property, as those will be inferred on our end - if you do, they will be overwritten.
Example Payload:
{
description: "Third degree wrist burn treatment",
type: {
text: "Burn management Hospital Progress note",
coding: [
{
code: "100556-0",
system: "http://loinc.org",
display: "Burn management Hospital Progress note"
},
],
},
context: {
period: {
start: "2023-10-10T14:14:17Z",
end: "2023-10-10T15:30:30Z",
},
facilityType: {
text: "John Snow Clinic - Acute Care Centre",
},
},
};
Response
The DocumentReference ID and a URL to be used for file upload.
{
"documentReferenceId": "<DocumentReference-ID-string>",
"uploadUrl": "<url-string>"
}
curl --request POST \
--url https://api.sandbox.metriport.com/medical/v1/document/upload \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '{
"type": {
"text": "<string>",
"coding": []
},
"description": "<string>",
"context": [
{
"period": {},
"facilityType": {}
}
]
}'
import { MetriportMedicalApi } from "@metriport/api-sdk";
import axios from "axios";
const metriport = new MetriportMedicalApi("YOUR_API_KEY");
const docRef: Partial<DocumentReference> = {
description: "Third degree wrist burn treatment",
type: {
text: "Burn management Hospital Progress note",
coding: [
{
code: "100556-0",
system: "http://loinc.org",
display: "Burn management Hospital Progress note",
},
],
},
context: {
period: {
start: "2023-10-10T14:14:17Z",
},
facilityType: {
text: "My Clinic Name - Acute Care",
},
},
};
const resp = await metriport.createDocumentReference("my-patient-id", docRef);
// Upload the document using this url in a PUT request, something along these lines:
// const fileContent = <medical-document-document-contents>;
// await axios.put(resp.uploadUrl, document, {
// headers: {
// "Content-Length": <size-in-bytes>,
// },
// });