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("018a80c4-292a-7486-a1234-76yuhe23yu14", docRef);// Upload the document using this url in a PUT request, something along these lines for a PDF:// const fileContent = <medical-document-document-contents>;// await axios.put(resp.uploadUrl, fileContent, {// headers: {// "Content-Length": <size-in-bytes>,// "Content-Type": "application/pdf",// },// });
This endpoint returns the DocumentReference ID and a URL to enable you to upload your patients’ medical documents, making them available to other HIEs.
A Coding property, which is a reference to a code defined by a terminology system (such as LOINC) - for example [{ code: "100556-0", system: "http://loinc.org", display: "Burn management Hospital Progress note"}]
Plain text with the facility name and type - for example John Snow Clinic - Acute Care Centre.
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.