Class: MedplumClient
The MedplumClient class provides a client for the Medplum FHIR server.
The client can be used in the browser, in a Node.js application, or in a Medplum Bot.
The client provides helpful methods for common operations such as: 1) Authenticating 2) Creating resources 2) Reading resources 3) Updating resources 5) Deleting resources 6) Searching 7) Making GraphQL queries
Here is a quick example of how to use the client:
import { MedplumClient } from '@medplum/core';
const medplum = new MedplumClient();
Create a Patient:
const patient = await medplum.createResource({
resourceType: 'Patient',
name: [{
given: ['Alice'],
family: 'Smith'
}]
});
Read a Patient by ID:
const patient = await medplum.readResource('Patient', '123');
console.log(patient.name[0].given[0]);
Search for a Patient by name:
const bundle = await medplum.search('Patient', 'name=Alice');
console.log(bundle.total);
Hierarchy
EventTarget↳
MedplumClient
Read
readResource
▸ readResource<K>(resourceType, id, options?): ReadablePromise<ExtractResource<K>>
Reads a resource by resource type and ID.
Example:
const patient = await medplum.readResource('Patient', '123');
console.log(patient);
See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
Type parameters
| Name | Type |
|---|---|
K | extends "Observation" | "Patient" | "Practitioner" | "RelatedPerson" | "AccessPolicy" | "Account" | "ActivityDefinition" | "AdverseEvent" | "AllergyIntolerance" | "Appointment" | "AppointmentResponse" | "AuditEvent" | "Basic" | "Binary" | "BiologicallyDerivedProduct" | "BodyStructure" | "Bot" | "BulkDataExport" | "Bundle" | "CapabilityStatement" | "CarePlan" | "CareTeam" | "CatalogEntry" | "ChargeItem" | "ChargeItemDefinition" | "Claim" | "ClaimResponse" | "ClientApplication" | "ClinicalImpression" | "CodeSystem" | "Communication" | "CommunicationRequest" | "CompartmentDefinition" | "Composition" | "ConceptMap" | "Condition" | "Consent" | "Contract" | "Coverage" | "CoverageEligibilityRequest" | "CoverageEligibilityResponse" | "DetectedIssue" | "Device" | "DeviceDefinition" | "DeviceMetric" | "DeviceRequest" | "DeviceUseStatement" | "DiagnosticReport" | "DocumentManifest" | "DocumentReference" | "DomainConfiguration" | "EffectEvidenceSynthesis" | "Encounter" | "Endpoint" | "EnrollmentRequest" | "EnrollmentResponse" | "EpisodeOfCare" | "EventDefinition" | "Evidence" | "EvidenceVariable" | "ExampleScenario" | "ExplanationOfBenefit" | "FamilyMemberHistory" | "Flag" | "Goal" | "GraphDefinition" | "Group" | "GuidanceResponse" | "HealthcareService" | "ImagingStudy" | "Immunization" | "ImmunizationEvaluation" | "ImmunizationRecommendation" | "ImplementationGuide" | "InsurancePlan" | "Invoice" | "JsonWebKey" | "Library" | "Linkage" | "List" | "Location" | "Login" | "Measure" | "MeasureReport" | "Media" | "Medication" | "MedicationAdministration" | "MedicationDispense" | "MedicationKnowledge" | "MedicationRequest" | "MedicationStatement" | "MedicinalProduct" | "MedicinalProductAuthorization" | "MedicinalProductContraindication" | "MedicinalProductIndication" | "MedicinalProductIngredient" | "MedicinalProductInteraction" | "MedicinalProductManufactured" | "MedicinalProductPackaged" | "MedicinalProductPharmaceutical" | "MedicinalProductUndesirableEffect" | "MessageDefinition" | "MessageHeader" | "MolecularSequence" | "NamingSystem" | "NutritionOrder" | "ObservationDefinition" | "OperationDefinition" | "OperationOutcome" | "Organization" | "OrganizationAffiliation" | "Parameters" | "PasswordChangeRequest" | "PaymentNotice" | "PaymentReconciliation" | "Person" | "PlanDefinition" | "PractitionerRole" | "Procedure" | "Project" | "ProjectMembership" | "Provenance" | "Questionnaire" | "QuestionnaireResponse" | "RequestGroup" | "ResearchDefinition" | "ResearchElementDefinition" | "ResearchStudy" | "ResearchSubject" | "RiskAssessment" | "RiskEvidenceSynthesis" | "Schedule" | "SearchParameter" | "ServiceRequest" | "Slot" | "SmartAppLaunch" | "Specimen" | "SpecimenDefinition" | "StructureDefinition" | "StructureMap" | "Subscription" | "Substance" | "SubstanceNucleicAcid" | "SubstancePolymer" | "SubstanceProtein" | "SubstanceReferenceInformation" | "SubstanceSourceMaterial" | "SubstanceSpecification" | "SupplyDelivery" | "SupplyRequest" | "Task" | "TerminologyCapabilities" | "TestReport" | "TestScript" | "User" | "UserConfiguration" | "ValueSet" | "VerificationResult" | "VisionPrescription" |
Parameters
| Name | Type | Description |
|---|---|---|
resourceType | K | The FHIR resource type. |
id | string | The resource ID. |
options | RequestInit | Optional fetch options. |
Returns
ReadablePromise<ExtractResource<K>>
The resource if available; undefined otherwise.
Defined in
packages/core/src/client.ts:1123
readReference
▸ readReference<T>(reference, options?): ReadablePromise<T>
Reads a resource by Reference.
This is a convenience method for readResource() that accepts a Reference object.
Example:
const serviceRequest = await medplum.readResource('ServiceRequest', '123');
const patient = await medplum.readReference(serviceRequest.subject);
console.log(patient);
See the FHIR "read" operation for full details: https://www.hl7.org/fhir/http.html#read
Type parameters
| Name | Type |
|---|---|
T | extends Resource |
Parameters
| Name | Type | Description |
|---|---|---|
reference | Reference<T> | The FHIR reference object. |
options | RequestInit | Optional fetch options. |
Returns
The resource if available; undefined otherwise.
Defined in
packages/core/src/client.ts:1151
readHistory
▸ readHistory<K>(resourceType, id, options?): ReadablePromise<Bundle<ExtractResource<K>>>
Reads resource history by resource type and ID.
The return value is a bundle of all versions of the resource.
Example:
const history = await medplum.readHistory('Patient', '123');
console.log(history);
See the FHIR "history" operation for full details: https://www.hl7.org/fhir/http.html#history
Type parameters
| Name | Type |
|---|---|
K | extends "Observation" | "Patient" | "Practitioner" | "RelatedPerson" | "AccessPolicy" | "Account" | "ActivityDefinition" | "AdverseEvent" | "AllergyIntolerance" | "Appointment" | "AppointmentResponse" | "AuditEvent" | "Basic" | "Binary" | "BiologicallyDerivedProduct" | "BodyStructure" | "Bot" | "BulkDataExport" | "Bundle" | "CapabilityStatement" | "CarePlan" | "CareTeam" | "CatalogEntry" | "ChargeItem" | "ChargeItemDefinition" | "Claim" | "ClaimResponse" | "ClientApplication" | "ClinicalImpression" | "CodeSystem" | "Communication" | "CommunicationRequest" | "CompartmentDefinition" | "Composition" | "ConceptMap" | "Condition" | "Consent" | "Contract" | "Coverage" | "CoverageEligibilityRequest" | "CoverageEligibilityResponse" | "DetectedIssue" | "Device" | "DeviceDefinition" | "DeviceMetric" | "DeviceRequest" | "DeviceUseStatement" | "DiagnosticReport" | "DocumentManifest" | "DocumentReference" | "DomainConfiguration" | "EffectEvidenceSynthesis" | "Encounter" | "Endpoint" | "EnrollmentRequest" | "EnrollmentResponse" | "EpisodeOfCare" | "EventDefinition" | "Evidence" | "EvidenceVariable" | "ExampleScenario" | "ExplanationOfBenefit" | "FamilyMemberHistory" | "Flag" | "Goal" | "GraphDefinition" | "Group" | "GuidanceResponse" | "HealthcareService" | "ImagingStudy" | "Immunization" | "ImmunizationEvaluation" | "ImmunizationRecommendation" | "ImplementationGuide" | "InsurancePlan" | "Invoice" | "JsonWebKey" | "Library" | "Linkage" | "List" | "Location" | "Login" | "Measure" | "MeasureReport" | "Media" | "Medication" | "MedicationAdministration" | "MedicationDispense" | "MedicationKnowledge" | "MedicationRequest" | "MedicationStatement" | "MedicinalProduct" | "MedicinalProductAuthorization" | "MedicinalProductContraindication" | "MedicinalProductIndication" | "MedicinalProductIngredient" | "MedicinalProductInteraction" | "MedicinalProductManufactured" | "MedicinalProductPackaged" | "MedicinalProductPharmaceutical" | "MedicinalProductUndesirableEffect" | "MessageDefinition" | "MessageHeader" | "MolecularSequence" | "NamingSystem" | "NutritionOrder" | "ObservationDefinition" | "OperationDefinition" | "OperationOutcome" | "Organization" | "OrganizationAffiliation" | "Parameters" | "PasswordChangeRequest" | "PaymentNotice" | "PaymentReconciliation" | "Person" | "PlanDefinition" | "PractitionerRole" | "Procedure" | "Project" | "ProjectMembership" | "Provenance" | "Questionnaire" | "QuestionnaireResponse" | "RequestGroup" | "ResearchDefinition" | "ResearchElementDefinition" | "ResearchStudy" | "ResearchSubject" | "RiskAssessment" | "RiskEvidenceSynthesis" | "Schedule" | "SearchParameter" | "ServiceRequest" | "Slot" | "SmartAppLaunch" | "Specimen" | "SpecimenDefinition" | "StructureDefinition" | "StructureMap" | "Subscription" | "Substance" | "SubstanceNucleicAcid" | "SubstancePolymer" | "SubstanceProtein" | "SubstanceReferenceInformation" | "SubstanceSourceMaterial" | "SubstanceSpecification" | "SupplyDelivery" | "SupplyRequest" | "Task" | "TerminologyCapabilities" | "TestReport" | "TestScript" | "User" | "UserConfiguration" | "ValueSet" | "VerificationResult" | "VisionPrescription" |
Parameters
| Name | Type | Description |
|---|---|---|
resourceType | K | The FHIR resource type. |
id | string | The resource ID. |
options | RequestInit | Optional fetch options. |
Returns
ReadablePromise<Bundle<ExtractResource<K>>>
Promise to the resource history.
Defined in
packages/core/src/client.ts:1265
readVersion
▸ readVersion<K>(resourceType, id, vid, options?): ReadablePromise<ExtractResource<K>>
Reads a specific version of a resource by resource type, ID, and version ID.
Example:
const version = await medplum.readVersion('Patient', '123', '456');
console.log(version);
See the FHIR "vread" operation for full details: https://www.hl7.org/fhir/http.html#vread
Type parameters
| Name | Type |
|---|---|
K | extends "Observation" | "Patient" | "Practitioner" | "RelatedPerson" | "AccessPolicy" | "Account" | "ActivityDefinition" | "AdverseEvent" | "AllergyIntolerance" | "Appointment" | "AppointmentResponse" | "AuditEvent" | "Basic" | "Binary" | "BiologicallyDerivedProduct" | "BodyStructure" | "Bot" | "BulkDataExport" | "Bundle" | "CapabilityStatement" | "CarePlan" | "CareTeam" | "CatalogEntry" | "ChargeItem" | "ChargeItemDefinition" | "Claim" | "ClaimResponse" | "ClientApplication" | "ClinicalImpression" | "CodeSystem" | "Communication" | "CommunicationRequest" | "CompartmentDefinition" | "Composition" | "ConceptMap" | "Condition" | "Consent" | "Contract" | "Coverage" | "CoverageEligibilityRequest" | "CoverageEligibilityResponse" | "DetectedIssue" | "Device" | "DeviceDefinition" | "DeviceMetric" | "DeviceRequest" | "DeviceUseStatement" | "DiagnosticReport" | "DocumentManifest" | "DocumentReference" | "DomainConfiguration" | "EffectEvidenceSynthesis" | "Encounter" | "Endpoint" | "EnrollmentRequest" | "EnrollmentResponse" | "EpisodeOfCare" | "EventDefinition" | "Evidence" | "EvidenceVariable" | "ExampleScenario" | "ExplanationOfBenefit" | "FamilyMemberHistory" | "Flag" | "Goal" | "GraphDefinition" | "Group" | "GuidanceResponse" | "HealthcareService" | "ImagingStudy" | "Immunization" | "ImmunizationEvaluation" | "ImmunizationRecommendation" | "ImplementationGuide" | "InsurancePlan" | "Invoice" | "JsonWebKey" | "Library" | "Linkage" | "List" | "Location" | "Login" | "Measure" | "MeasureReport" | "Media" | "Medication" | "MedicationAdministration" | "MedicationDispense" | "MedicationKnowledge" | "MedicationRequest" | "MedicationStatement" | "MedicinalProduct" | "MedicinalProductAuthorization" | "MedicinalProductContraindication" | "MedicinalProductIndication" | "MedicinalProductIngredient" | "MedicinalProductInteraction" | "MedicinalProductManufactured" | "MedicinalProductPackaged" | "MedicinalProductPharmaceutical" | "MedicinalProductUndesirableEffect" | "MessageDefinition" | "MessageHeader" | "MolecularSequence" | "NamingSystem" | "NutritionOrder" | "ObservationDefinition" | "OperationDefinition" | "OperationOutcome" | "Organization" | "OrganizationAffiliation" | "Parameters" | "PasswordChangeRequest" | "PaymentNotice" | "PaymentReconciliation" | "Person" | "PlanDefinition" | "PractitionerRole" | "Procedure" | "Project" | "ProjectMembership" | "Provenance" | "Questionnaire" | "QuestionnaireResponse" | "RequestGroup" | "ResearchDefinition" | "ResearchElementDefinition" | "ResearchStudy" | "ResearchSubject" | "RiskAssessment" | "RiskEvidenceSynthesis" | "Schedule" | "SearchParameter" | "ServiceRequest" | "Slot" | "SmartAppLaunch" | "Specimen" | "SpecimenDefinition" | "StructureDefinition" | "StructureMap" | "Subscription" | "Substance" | "SubstanceNucleicAcid" | "SubstancePolymer" | "SubstanceProtein" | "SubstanceReferenceInformation" | "SubstanceSourceMaterial" | "SubstanceSpecification" | "SupplyDelivery" | "SupplyRequest" | "Task" | "TerminologyCapabilities" | "TestReport" | "TestScript" | "User" | "UserConfiguration" | "ValueSet" | "VerificationResult" | "VisionPrescription" |
Parameters
| Name | Type | Description |
|---|---|---|
resourceType | K | The FHIR resource type. |
id | string | The resource ID. |
vid | string | The version ID. |
options | RequestInit | Optional fetch options. |
Returns
ReadablePromise<ExtractResource<K>>
The resource if available; undefined otherwise.
Defined in
packages/core/src/client.ts:1292
readPatientEverything
▸ readPatientEverything(id, options?): ReadablePromise<Bundle<Resource>>
Executes the Patient "everything" operation for a patient.
Example:
const bundle = await medplum.readPatientEverything('123');
console.log(bundle);
See the FHIR "patient-everything" operation for full details: https://hl7.org/fhir/operation-patient-everything.html
Parameters
| Name | Type | Description |
|---|---|---|
id | string | The Patient Id |
options | RequestInit | Optional fetch options. |
Returns
ReadablePromise<Bundle<Resource>>
A Bundle of all Resources related to the Patient
Defined in
packages/core/src/client.ts:1318
graphql
▸ graphql(query, operationName?, variables?, options?): Promise<any>
Executes a GraphQL query.
Example:
const result = await medplum.graphql(`{
Patient(id: "123") {
resourceType
id
name {
given
family
}
}
}`);
Advanced queries such as named operations and variable substitution are supported:
const result = await medplum.graphql(
`query GetPatientById($patientId: ID!) {
Patient(id: $patientId) {
resourceType
id
name {
given
family
}
}
}`,
'GetPatientById',
{ patientId: '123' }
);
See the GraphQL documentation for more details: https://graphql.org/learn/
See the FHIR GraphQL documentation for FHIR specific details: https://www.hl7.org/fhir/graphql.html
Parameters
| Name | Type | Description |
|---|---|---|
query | string | The GraphQL query. |
operationName? | null | string | Optional GraphQL operation name. |
variables? | any | Optional GraphQL variables. |
options? | RequestInit | Optional fetch options. |
Returns
Promise<any>
The GraphQL result.
Defined in
packages/core/src/client.ts:1810
readResourceGraph
▸ readResourceGraph<K>(resourceType, id, graphName): ReadablePromise<Bundle<Resource>>
Executes the $graph operation on this resource to fetch a Bundle of resources linked to the target resource according to a graph definition
Type parameters
| Name | Type |
|---|---|
K | extends "Observation" | "Patient" | "Practitioner" | "RelatedPerson" | "AccessPolicy" | "Account" | "ActivityDefinition" | "AdverseEvent" | "AllergyIntolerance" | "Appointment" | "AppointmentResponse" | "AuditEvent" | "Basic" | "Binary" | "BiologicallyDerivedProduct" | "BodyStructure" | "Bot" | "BulkDataExport" | "Bundle" | "CapabilityStatement" | "CarePlan" | "CareTeam" | "CatalogEntry" | "ChargeItem" | "ChargeItemDefinition" | "Claim" | "ClaimResponse" | "ClientApplication" | "ClinicalImpression" | "CodeSystem" | "Communication" | "CommunicationRequest" | "CompartmentDefinition" | "Composition" | "ConceptMap" | "Condition" | "Consent" | "Contract" | "Coverage" | "CoverageEligibilityRequest" | "CoverageEligibilityResponse" | "DetectedIssue" | "Device" | "DeviceDefinition" | "DeviceMetric" | "DeviceRequest" | "DeviceUseStatement" | "DiagnosticReport" | "DocumentManifest" | "DocumentReference" | "DomainConfiguration" | "EffectEvidenceSynthesis" | "Encounter" | "Endpoint" | "EnrollmentRequest" | "EnrollmentResponse" | "EpisodeOfCare" | "EventDefinition" | "Evidence" | "EvidenceVariable" | "ExampleScenario" | "ExplanationOfBenefit" | "FamilyMemberHistory" | "Flag" | "Goal" | "GraphDefinition" | "Group" | "GuidanceResponse" | "HealthcareService" | "ImagingStudy" | "Immunization" | "ImmunizationEvaluation" | "ImmunizationRecommendation" | "ImplementationGuide" | "InsurancePlan" | "Invoice" | "JsonWebKey" | "Library" | "Linkage" | "List" | "Location" | "Login" | "Measure" | "MeasureReport" | "Media" | "Medication" | "MedicationAdministration" | "MedicationDispense" | "MedicationKnowledge" | "MedicationRequest" | "MedicationStatement" | "MedicinalProduct" | "MedicinalProductAuthorization" | "MedicinalProductContraindication" | "MedicinalProductIndication" | "MedicinalProductIngredient" | "MedicinalProductInteraction" | "MedicinalProductManufactured" | "MedicinalProductPackaged" | "MedicinalProductPharmaceutical" | "MedicinalProductUndesirableEffect" | "MessageDefinition" | "MessageHeader" | "MolecularSequence" | "NamingSystem" | "NutritionOrder" | "ObservationDefinition" | "OperationDefinition" | "OperationOutcome" | "Organization" | "OrganizationAffiliation" | "Parameters" | "PasswordChangeRequest" | "PaymentNotice" | "PaymentReconciliation" | "Person" | "PlanDefinition" | "PractitionerRole" | "Procedure" | "Project" | "ProjectMembership" | "Provenance" | "Questionnaire" | "QuestionnaireResponse" | "RequestGroup" | "ResearchDefinition" | "ResearchElementDefinition" | "ResearchStudy" | "ResearchSubject" | "RiskAssessment" | "RiskEvidenceSynthesis" | "Schedule" | "SearchParameter" | "ServiceRequest" | "Slot" | "SmartAppLaunch" | "Specimen" | "SpecimenDefinition" | "StructureDefinition" | "StructureMap" | "Subscription" | "Substance" | "SubstanceNucleicAcid" | "SubstancePolymer" | "SubstanceProtein" | "SubstanceReferenceInformation" | "SubstanceSourceMaterial" | "SubstanceSpecification" | "SupplyDelivery" | "SupplyRequest" | "Task" | "TerminologyCapabilities" | "TestReport" | "TestScript" | "User" | "UserConfiguration" | "ValueSet" | "VerificationResult" | "VisionPrescription" |
Parameters
| Name | Type | Description |
|---|---|---|
resourceType | K | The FHIR resource type. |
id | string | The resource ID. |
graphName | string | name parameter of the GraphDefinition |
Returns
ReadablePromise<Bundle<Resource>>
A Bundle
Defined in
packages/core/src/client.ts:1825
download
▸ download(url, options?): Promise<Blob>
Downloads the URL as a blob.
Parameters
| Name | Type | Description |
|---|---|---|
url | string | URL | The URL to request. |
options | RequestInit | - |
Returns
Promise<Blob>
Promise to the response body as a blob.
Defined in
packages/core/src/client.ts:1940
Write
updateResource
▸ updateResource<T>(resource): Promise<T>
Updates a FHIR resource.
The return value is the updated resource, including the ID and meta.
Example:
const result = await medplum.updateResource({
resourceType: 'Patient',
id: '123',
name: [{
family: 'Smith',
given: ['John']
}]
});
console.log(result.meta.versionId);
See the FHIR "update" operation for full details: https://www.hl7.org/fhir/http.html#update
Type parameters
| Name | Type |
|---|---|
T | extends Resource |
Parameters
| Name | Type | Description |
|---|---|---|
resource | T | The FHIR resource to update. |
Returns
Promise<T>
The result of the update operation.
Defined in
packages/core/src/client.ts:1575
patchResource
▸ patchResource<K>(resourceType, id, operations): Promise<ExtractResource<K>>
Updates a FHIR resource using JSONPatch operations.
The return value is the updated resource, including the ID and meta.
Example:
const result = await medplum.patchResource('Patient', '123', [
{op: 'replace', path: '/name/0/family', value: 'Smith'},
]);
console.log(result.meta.versionId);
See the FHIR "update" operation for full details: https://www.hl7.org/fhir/http.html#patch
See the JSONPatch specification for full details: https://tools.ietf.org/html/rfc6902
Type parameters
| Name | Type |
|---|---|
K | extends "Observation" | "Patient" | "Practitioner" | "RelatedPerson" | "AccessPolicy" | "Account" | "ActivityDefinition" | "AdverseEvent" | "AllergyIntolerance" | "Appointment" | "AppointmentResponse" | "AuditEvent" | "Basic" | "Binary" | "BiologicallyDerivedProduct" | "BodyStructure" | "Bot" | "BulkDataExport" | "Bundle" | "CapabilityStatement" | "CarePlan" | "CareTeam" | "CatalogEntry" | "ChargeItem" | "ChargeItemDefinition" | "Claim" | "ClaimResponse" | "ClientApplication" | "ClinicalImpression" | "CodeSystem" | "Communication" | "CommunicationRequest" | "CompartmentDefinition" | "Composition" | "ConceptMap" | "Condition" | "Consent" | "Contract" | "Coverage" | "CoverageEligibilityRequest" | "CoverageEligibilityResponse" | "DetectedIssue" | "Device" | "DeviceDefinition" | "DeviceMetric" | "DeviceRequest" | "DeviceUseStatement" | "DiagnosticReport" | "DocumentManifest" | "DocumentReference" | "DomainConfiguration" | "EffectEvidenceSynthesis" | "Encounter" | "Endpoint" | "EnrollmentRequest" | "EnrollmentResponse" | "EpisodeOfCare" | "EventDefinition" | "Evidence" | "EvidenceVariable" | "ExampleScenario" | "ExplanationOfBenefit" | "FamilyMemberHistory" | "Flag" | "Goal" | "GraphDefinition" | "Group" | "GuidanceResponse" | "HealthcareService" | "ImagingStudy" | "Immunization" | "ImmunizationEvaluation" | "ImmunizationRecommendation" | "ImplementationGuide" | "InsurancePlan" | "Invoice" | "JsonWebKey" | "Library" | "Linkage" | "List" | "Location" | "Login" | "Measure" | "MeasureReport" | "Media" | "Medication" | "MedicationAdministration" | "MedicationDispense" | "MedicationKnowledge" | "MedicationRequest" | "MedicationStatement" | "MedicinalProduct" | "MedicinalProductAuthorization" | "MedicinalProductContraindication" | "MedicinalProductIndication" | "MedicinalProductIngredient" | "MedicinalProductInteraction" | "MedicinalProductManufactured" | "MedicinalProductPackaged" | "MedicinalProductPharmaceutical" | "MedicinalProductUndesirableEffect" | "MessageDefinition" | "MessageHeader" | "MolecularSequence" | "NamingSystem" | "NutritionOrder" | "ObservationDefinition" | "OperationDefinition" | "OperationOutcome" | "Organization" | "OrganizationAffiliation" | "Parameters" | "PasswordChangeRequest" | "PaymentNotice" | "PaymentReconciliation" | "Person" | "PlanDefinition" | "PractitionerRole" | "Procedure" | "Project" | "ProjectMembership" | "Provenance" | "Questionnaire" | "QuestionnaireResponse" | "RequestGroup" | "ResearchDefinition" | "ResearchElementDefinition" | "ResearchStudy" | "ResearchSubject" | "RiskAssessment" | "RiskEvidenceSynthesis" | "Schedule" | "SearchParameter" | "ServiceRequest" | "Slot" | "SmartAppLaunch" | "Specimen" | "SpecimenDefinition" | "StructureDefinition" | "StructureMap" | "Subscription" | "Substance" | "SubstanceNucleicAcid" | "SubstancePolymer" | "SubstanceProtein" | "SubstanceReferenceInformation" | "SubstanceSourceMaterial" | "SubstanceSpecification" | "SupplyDelivery" | "SupplyRequest" | "Task" | "TerminologyCapabilities" | "TestReport" | "TestScript" | "User" | "UserConfiguration" | "ValueSet" | "VerificationResult" | "VisionPrescription" |
Parameters
| Name | Type | Description |
|---|---|---|
resourceType | K | The FHIR resource type. |
id | string | The resource ID. |
operations | PatchOperation[] | The JSONPatch operations. |
Returns
Promise<ExtractResource<K>>
The result of the patch operations.
Defined in
packages/core/src/client.ts:1618
Create
createResource
▸ createResource<T>(resource): Promise<T>
Creates a new FHIR resource.
The return value is the newly created resource, including the ID and meta.
Example:
const result = await medplum.createResource({
resourceType: 'Patient',
name: [{
family: 'Smith',
given: ['John']
}]
});
console.log(result.id);
See the FHIR "create" operation for full details: https://www.hl7.org/fhir/http.html#create
Type parameters
| Name | Type |
|---|---|
T | extends Resource |
Parameters
| Name | Type | Description |
|---|---|---|
resource | T | The FHIR resource to create. |
Returns
Promise<T>
The result of the create operation.
Defined in
packages/core/src/client.ts:1346
createResourceIfNoneExist
▸ createResourceIfNoneExist<T>(resource, query): Promise<T>
Conditionally create a new FHIR resource only if some equivalent resource does not already exist on the server.
The return value is the existing resource or the newly created resource, including the ID and meta.
Example:
const result = await medplum.createResourceIfNoneExist(
{
resourceType: 'Patient',
identifier: [{
system: 'http://example.com/mrn',
value: '123'
}]
name: [{
family: 'Smith',
given: ['John']
}]
},
'identifier=123'
);
console.log(result.id);
This method is syntactic sugar for:
return searchOne(resourceType, query) ?? createResource(resource);
The query parameter only contains the search parameters (what would be in the URL following the "?").
See the FHIR "conditional create" operation for full details: https://www.hl7.org/fhir/http.html#ccreate
Type parameters
| Name | Type |
|---|---|
T | extends Resource |
Parameters
| Name | Type | Description |
|---|---|---|
resource | T | The FHIR resource to create. |
query | string | The search query for an equivalent resource (should not include resource type or "?"). |
Returns
Promise<T>
The result of the create operation.
Defined in
packages/core/src/client.ts:1394
createBinary
▸ createBinary(data, filename, contentType, onProgress?): Promise<Binary>
Creates a FHIR Binary resource with the provided data content.
The return value is the newly created resource, including the ID and meta.
The data parameter can be a string or a File object.
A File object often comes from a <input type="file"> element.
Example:
const result = await medplum.createBinary(myFile, 'test.jpg', 'image/jpeg');
console.log(result.id);
See the FHIR "create" operation for full details: https://www.hl7.org/fhir/http.html#create
Parameters
| Name | Type | Description |
|---|---|---|
data | string | Uint8Array | File | Blob | The binary data to upload. |
filename | undefined | string | Optional filename for the binary. |
contentType | string | Content type for the binary. |
onProgress? | (e: ProgressEvent<EventTarget>) => void | - |
Returns
Promise<Binary>
The result of the create operation.
Defined in
packages/core/src/client.ts:1422
createComment
▸ createComment(resource, text): Promise<Communication>
Creates a FHIR Communication resource with the provided data content.
This is a convenience method to handle commmon cases where a Communication resource is created with a payload.
Parameters
| Name | Type | Description |
|---|---|---|
resource | Resource | The FHIR resource to comment on. |
text | string | The text of the comment. |
Returns
Promise<Communication>
The result of the create operation.
Defined in
packages/core/src/client.ts:1520
Delete
deleteResource
▸ deleteResource(resourceType, id): Promise<any>
Deletes a FHIR resource by resource type and ID.
Example:
await medplum.deleteResource('Patient', '123');
See the FHIR "delete" operation for full details: https://www.hl7.org/fhir/http.html#delete
Parameters
| Name | Type | Description |
|---|---|---|
resourceType | "Observation" | "Patient" | "Practitioner" | "RelatedPerson" | "AccessPolicy" | "Account" | "ActivityDefinition" | "AdverseEvent" | "AllergyIntolerance" | "Appointment" | "AppointmentResponse" | "AuditEvent" | "Basic" | "Binary" | "BiologicallyDerivedProduct" | "BodyStructure" | "Bot" | "BulkDataExport" | "Bundle" | "CapabilityStatement" | "CarePlan" | "CareTeam" | "CatalogEntry" | "ChargeItem" | "ChargeItemDefinition" | "Claim" | "ClaimResponse" | "ClientApplication" | "ClinicalImpression" | "CodeSystem" | "Communication" | "CommunicationRequest" | "CompartmentDefinition" | "Composition" | "ConceptMap" | "Condition" | "Consent" | "Contract" | "Coverage" | "CoverageEligibilityRequest" | "CoverageEligibilityResponse" | "DetectedIssue" | "Device" | "DeviceDefinition" | "DeviceMetric" | "DeviceRequest" | "DeviceUseStatement" | "DiagnosticReport" | "DocumentManifest" | "DocumentReference" | "DomainConfiguration" | "EffectEvidenceSynthesis" | "Encounter" | "Endpoint" | "EnrollmentRequest" | "EnrollmentResponse" | "EpisodeOfCare" | "EventDefinition" | "Evidence" | "EvidenceVariable" | "ExampleScenario" | "ExplanationOfBenefit" | "FamilyMemberHistory" | "Flag" | "Goal" | "GraphDefinition" | "Group" | "GuidanceResponse" | "HealthcareService" | "ImagingStudy" | "Immunization" | "ImmunizationEvaluation" | "ImmunizationRecommendation" | "ImplementationGuide" | "InsurancePlan" | "Invoice" | "JsonWebKey" | "Library" | "Linkage" | "List" | "Location" | "Login" | "Measure" | "MeasureReport" | "Media" | "Medication" | "MedicationAdministration" | "MedicationDispense" | "MedicationKnowledge" | "MedicationRequest" | "MedicationStatement" | "MedicinalProduct" | "MedicinalProductAuthorization" | "MedicinalProductContraindication" | "MedicinalProductIndication" | "MedicinalProductIngredient" | "MedicinalProductInteraction" | "MedicinalProductManufactured" | "MedicinalProductPackaged" | "MedicinalProductPharmaceutical" | "MedicinalProductUndesirableEffect" | "MessageDefinition" | "MessageHeader" | "MolecularSequence" | "NamingSystem" | "NutritionOrder" | "ObservationDefinition" | "OperationDefinition" | "OperationOutcome" | "Organization" | "OrganizationAffiliation" | "Parameters" | "PasswordChangeRequest" | "PaymentNotice" | "PaymentReconciliation" | "Person" | "PlanDefinition" | "PractitionerRole" | "Procedure" | "Project" | "ProjectMembership" | "Provenance" | "Questionnaire" | "QuestionnaireResponse" | "RequestGroup" | "ResearchDefinition" | "ResearchElementDefinition" | "ResearchStudy" | "ResearchSubject" | "RiskAssessment" | "RiskEvidenceSynthesis" | "Schedule" | "SearchParameter" | "ServiceRequest" | "Slot" | "SmartAppLaunch" | "Specimen" | "SpecimenDefinition" | "StructureDefinition" | "StructureMap" | "Subscription" | "Substance" | "SubstanceNucleicAcid" | "SubstancePolymer" | "SubstanceProtein" | "SubstanceReferenceInformation" | "SubstanceSourceMaterial" | "SubstanceSpecification" | "SupplyDelivery" | "SupplyRequest" | "Task" | "TerminologyCapabilities" | "TestReport" | "TestScript" | "User" | "UserConfiguration" | "ValueSet" | "VerificationResult" | "VisionPrescription" | The FHIR resource type. |
id | string | The resource ID. |
Returns
Promise<any>
The result of the delete operation.
Defined in
packages/core/src/client.ts:1643
Media
createPdf
▸ createPdf(docDefinition, filename?, tableLayouts?, fonts?): Promise<Binary>
Creates a PDF as a FHIR Binary resource based on pdfmake document definition.
The return value is the newly created resource, including the ID and meta.
The docDefinition parameter is a pdfmake document definition.
Example:
const result = await medplum.createPdf({
content: ['Hello world']
});
console.log(result.id);
See the pdfmake document definition for full details: https://pdfmake.github.io/docs/0.1/document-definition-object/
Parameters
| Name | Type | Description |
|---|---|---|
docDefinition | TDocumentDefinitions | The PDF document definition. |
filename? | string | - |
tableLayouts? | Object | - |
fonts? | TFontDictionary | - |
Returns
Promise<Binary>
The result of the create operation.
Defined in
packages/core/src/client.ts:1497
sendEmail
▸ sendEmail(email): Promise<OperationOutcome>
Sends an email using the Medplum Email API.
Builds the email using nodemailer MailComposer.
Examples:
Send a simple text email:
await medplum.sendEmail({
to: 'alice@example.com',
cc: 'bob@example.com',
subject: 'Hello',
text: 'Hello Alice',
});
Send an email with a Binary attachment:
await medplum.sendEmail({
to: 'alice@example.com',
subject: 'Email with attachment',
text: 'See the attached report',
attachments: [{
filename: 'report.pdf',
path: "Binary/" + binary.id
}]
});
See options here: https://nodemailer.com/extras/mailcomposer/
Parameters
| Name | Type |
|---|---|
email | MailOptions |
Returns
Promise<OperationOutcome>
Promise to the operation outcome.
Defined in
packages/core/src/client.ts:1758
Authentication
clear
▸ clear(): void
Clears all auth state including local storage and session storage.
Returns
void
Defined in
packages/core/src/client.ts:522
clearActiveLogin
▸ clearActiveLogin(): void
Clears the active login from local storage. Does not clear all local storage (such as other logins).
Returns
void
Defined in
packages/core/src/client.ts:532
startNewUser
▸ startNewUser(newUserRequest): Promise<LoginAuthenticationResponse>
Initiates a new user flow.
This method is part of the two different user registration flows: 1) New Practitioner and new Project 2) New Patient registration
Parameters
| Name | Type | Description |
|---|---|---|
newUserRequest | NewUserRequest | Register request including email and password. |
Returns
Promise<LoginAuthenticationResponse>
Promise to the authentication response.
Defined in
packages/core/src/client.ts:712
startLogin
▸ startLogin(loginRequest): Promise<LoginAuthenticationResponse>
Initiates a user login flow.
Parameters
| Name | Type | Description |
|---|---|---|
loginRequest | EmailPasswordLoginRequest | Login request including email and password. |
Returns
Promise<LoginAuthenticationResponse>
Promise to the authentication response.
Defined in
packages/core/src/client.ts:751
startGoogleLogin
▸ startGoogleLogin(loginRequest): Promise<LoginAuthenticationResponse>
Tries to sign in with Google authentication. The response parameter is the result of a Google authentication. See: https://developers.google.com/identity/gsi/web/guides/handle-credential-responses-js-functions
Parameters
| Name | Type | Description |
|---|---|---|
loginRequest | GoogleLoginRequest | Login request including Google credential response. |
Returns
Promise<LoginAuthenticationResponse>
Promise to the authentication response.
Defined in
packages/core/src/client.ts:767
ensureCodeChallenge
▸ ensureCodeChallenge<T>(loginRequest): Promise<T>
Returns the PKCE code challenge and method. If the login request already includes a code challenge, it is returned. Otherwise, a new PKCE code challenge is generated.
Type parameters
| Name | Type |
|---|---|
T | extends BaseLoginRequest |
Parameters
| Name | Type | Description |
|---|---|---|
loginRequest | T | The original login request. |
Returns
Promise<T>
The PKCE code challenge and method.
Defined in
packages/core/src/client.ts:783
signOut
▸ signOut(): Promise<void>
Signs out locally. Does not invalidate tokens with the server.
Returns
Promise<void>
Defined in
packages/core/src/client.ts:795
signInWithRedirect
▸ signInWithRedirect(loginParams?): Promise<void | ProfileResource>
Tries to sign in the user. Returns true if the user is signed in. This may result in navigating away to the sign in page.
Parameters
| Name | Type | Description |
|---|---|---|
loginParams? | Partial<BaseLoginRequest> | Optional login parameters. |
Returns
Promise<void | ProfileResource>
Defined in
packages/core/src/client.ts:807
signOutWithRedirect
▸ signOutWithRedirect(): void
Tries to sign out the user. See: https://docs.aws.amazon.com/cognito/latest/developerguide/logout-endpoint.html
Returns
void
Defined in
packages/core/src/client.ts:823
signInWithExternalAuth
▸ signInWithExternalAuth(authorizeUrl, clientId, redirectUri, baseLogin): Promise<void>
Initiates sign in with an external identity provider.
Parameters
| Name | Type | Description |
|---|---|---|
authorizeUrl | string | The external authorization URL. |
clientId | string | The external client ID. |
redirectUri | string | The external identity provider redirect URI. |
baseLogin | BaseLoginRequest | The Medplum login request. |
Returns
Promise<void>
Defined in
packages/core/src/client.ts:835
getExternalAuthRedirectUri
▸ getExternalAuthRedirectUri(authorizeUrl, clientId, redirectUri, loginRequest): string
Builds the external identity provider redirect URI.
Parameters
| Name | Type | Description |
|---|---|---|
authorizeUrl | string | The external authorization URL. |
clientId | string | The external client ID. |
redirectUri | string | The external identity provider redirect URI. |
loginRequest | BaseLoginRequest | The Medplum login request. |
Returns
string
The external identity provider redirect URI.
Defined in
packages/core/src/client.ts:854
getActiveLogin
▸ getActiveLogin(): undefined | LoginState
Returns
undefined | LoginState
The Login State
Defined in
packages/core/src/client.ts:1837
setActiveLogin
▸ setActiveLogin(login): Promise<void>
Parameters
| Name | Type |
|---|---|
login | LoginState |
Returns
Promise<void>
Defined in
packages/core/src/client.ts:1844
getAccessToken
▸ getAccessToken(): undefined | string
Returns the current access token.
Returns
undefined | string
Defined in
packages/core/src/client.ts:1858
setAccessToken
▸ setAccessToken(accessToken): void
Sets the current access token.
Parameters
| Name | Type |
|---|---|
accessToken | string |
Returns
void
Defined in
packages/core/src/client.ts:1866
getLogins
▸ getLogins(): LoginState[]
Returns
Defined in
packages/core/src/client.ts:1876
isLoading
▸ isLoading(): boolean
Returns
boolean
Defined in
packages/core/src/client.ts:1905
startPkce
▸ startPkce(): Promise<{ codeChallengeMethod: string ; codeChallenge: string }>
Starts a new PKCE flow. These PKCE values are stateful, and must survive redirects and page refreshes.
Returns
Promise<{ codeChallengeMethod: string ; codeChallenge: string }>
Defined in
packages/core/src/client.ts:2200
processCode
▸ processCode(code, loginParams?): Promise<ProfileResource>
Processes an OAuth authorization code. See: https://openid.net/specs/openid-connect-core-1_0.html#TokenRequest
Parameters
| Name | Type | Description |
|---|---|---|
code | string | The authorization code received by URL parameter. |
loginParams? | Partial<BaseLoginRequest> | Optional login parameters. |
Returns
Promise<ProfileResource>
Defined in
packages/core/src/client.ts:2239
startClientLogin
▸ startClientLogin(clientId, clientSecret): Promise<ProfileResource>
Starts a new OAuth2 client credentials flow. See: https://datatracker.ietf.org/doc/html/rfc6749#section-4.4
Parameters
| Name | Type | Description |
|---|---|---|
clientId | string | The client ID. |
clientSecret | string | The client secret. |
Returns
Promise<ProfileResource>
Promise that resolves to the client profile.
Defined in
packages/core/src/client.ts:2290
Search
fhirSearchUrl
▸ fhirSearchUrl(resourceType, query): URL
Builds a FHIR search URL from a search query or structured query object.
Parameters
| Name | Type | Description |
|---|---|---|
resourceType | "Observation" | "Patient" | "Practitioner" | "RelatedPerson" | "AccessPolicy" | "Account" | "ActivityDefinition" | "AdverseEvent" | "AllergyIntolerance" | "Appointment" | "AppointmentResponse" | "AuditEvent" | "Basic" | "Binary" | "BiologicallyDerivedProduct" | "BodyStructure" | "Bot" | "BulkDataExport" | "Bundle" | "CapabilityStatement" | "CarePlan" | "CareTeam" | "CatalogEntry" | "ChargeItem" | "ChargeItemDefinition" | "Claim" | "ClaimResponse" | "ClientApplication" | "ClinicalImpression" | "CodeSystem" | "Communication" | "CommunicationRequest" | "CompartmentDefinition" | "Composition" | "ConceptMap" | "Condition" | "Consent" | "Contract" | "Coverage" | "CoverageEligibilityRequest" | "CoverageEligibilityResponse" | "DetectedIssue" | "Device" | "DeviceDefinition" | "DeviceMetric" | "DeviceRequest" | "DeviceUseStatement" | "DiagnosticReport" | "DocumentManifest" | "DocumentReference" | "DomainConfiguration" | "EffectEvidenceSynthesis" | "Encounter" | "Endpoint" | "EnrollmentRequest" | "EnrollmentResponse" | "EpisodeOfCare" | "EventDefinition" | "Evidence" | "EvidenceVariable" | "ExampleScenario" | "ExplanationOfBenefit" | "FamilyMemberHistory" | "Flag" | "Goal" | "GraphDefinition" | "Group" | "GuidanceResponse" | "HealthcareService" | "ImagingStudy" | "Immunization" | "ImmunizationEvaluation" | "ImmunizationRecommendation" | "ImplementationGuide" | "InsurancePlan" | "Invoice" | "JsonWebKey" | "Library" | "Linkage" | "List" | "Location" | "Login" | "Measure" | "MeasureReport" | "Media" | "Medication" | "MedicationAdministration" | "MedicationDispense" | "MedicationKnowledge" | "MedicationRequest" | "MedicationStatement" | "MedicinalProduct" | "MedicinalProductAuthorization" | "MedicinalProductContraindication" | "MedicinalProductIndication" | "MedicinalProductIngredient" | "MedicinalProductInteraction" | "MedicinalProductManufactured" | "MedicinalProductPackaged" | "MedicinalProductPharmaceutical" | "MedicinalProductUndesirableEffect" | "MessageDefinition" | "MessageHeader" | "MolecularSequence" | "NamingSystem" | "NutritionOrder" | "ObservationDefinition" | "OperationDefinition" | "OperationOutcome" | "Organization" | "OrganizationAffiliation" | "Parameters" | "PasswordChangeRequest" | "PaymentNotice" | "PaymentReconciliation" | "Person" | "PlanDefinition" | "PractitionerRole" | "Procedure" | "Project" | "ProjectMembership" | "Provenance" | "Questionnaire" | "QuestionnaireResponse" | "RequestGroup" | "ResearchDefinition" | "ResearchElementDefinition" | "ResearchStudy" | "ResearchSubject" | "RiskAssessment" | "RiskEvidenceSynthesis" | "Schedule" | "SearchParameter" | "ServiceRequest" | "Slot" | "SmartAppLaunch" | "Specimen" | "SpecimenDefinition" | "StructureDefinition" | "StructureMap" | "Subscription" | "Substance" | "SubstanceNucleicAcid" | "SubstancePolymer" | "SubstanceProtein" | "SubstanceReferenceInformation" | "SubstanceSourceMaterial" | "SubstanceSpecification" | "SupplyDelivery" | "SupplyRequest" | "Task" | "TerminologyCapabilities" | "TestReport" | "TestScript" | "User" | "UserConfiguration" | "ValueSet" | "VerificationResult" | "VisionPrescription" | The FHIR resource type. |
query | QueryTypes | The FHIR search query or structured query object. Can be any valid input to the URLSearchParams() constructor. |
Returns
URL
The well-formed FHIR URL.
Defined in
packages/core/src/client.ts:888
search
▸ search<K>(resourceType, query?, options?): ReadablePromise<Bundle<ExtractResource<K>>>
Sends a FHIR search request.
Example using a FHIR search string:
const bundle = await client.search('Patient', 'name=Alice');
console.log(bundle);
The return value is a FHIR bundle:
{
"resourceType": "Bundle",
"type": "searchset",
"entry": [
{
"resource": {
"resourceType": "Patient",
"name": [
{
"given": [
"George"
],
"family": "Washington"
}
],
}
}
]
}
To query the count of a search, use the summary feature like so:
const patients = medplum.search('Patient', '_summary=count');
See FHIR search for full details: https://www.hl7.org/fhir/search.html
Type parameters
| Name | Type |
|---|---|
K | extends "Observation" | "Patient" | "Practitioner" | "RelatedPerson" | "AccessPolicy" | "Account" | "ActivityDefinition" | "AdverseEvent" | "AllergyIntolerance" | "Appointment" | "AppointmentResponse" | "AuditEvent" | "Basic" | "Binary" | "BiologicallyDerivedProduct" | "BodyStructure" | "Bot" | "BulkDataExport" | "Bundle" | "CapabilityStatement" | "CarePlan" | "CareTeam" | "CatalogEntry" | "ChargeItem" | "ChargeItemDefinition" | "Claim" | "ClaimResponse" | "ClientApplication" | "ClinicalImpression" | "CodeSystem" | "Communication" | "CommunicationRequest" | "CompartmentDefinition" | "Composition" | "ConceptMap" | "Condition" | "Consent" | "Contract" | "Coverage" | "CoverageEligibilityRequest" | "CoverageEligibilityResponse" | "DetectedIssue" | "Device" | "DeviceDefinition" | "DeviceMetric" | "DeviceRequest" | "DeviceUseStatement" | "DiagnosticReport" | "DocumentManifest" | "DocumentReference" | "DomainConfiguration" | "EffectEvidenceSynthesis" | "Encounter" | "Endpoint" | "EnrollmentRequest" | "EnrollmentResponse" | "EpisodeOfCare" | "EventDefinition" | "Evidence" | "EvidenceVariable" | "ExampleScenario" | "ExplanationOfBenefit" | "FamilyMemberHistory" | "Flag" | "Goal" | "GraphDefinition" | "Group" | "GuidanceResponse" | "HealthcareService" | "ImagingStudy" | "Immunization" | "ImmunizationEvaluation" | "ImmunizationRecommendation" | "ImplementationGuide" | "InsurancePlan" | "Invoice" | "JsonWebKey" | "Library" | "Linkage" | "List" | "Location" | "Login" | "Measure" | "MeasureReport" | "Media" | "Medication" | "MedicationAdministration" | "MedicationDispense" | "MedicationKnowledge" | "MedicationRequest" | "MedicationStatement" | "MedicinalProduct" | "MedicinalProductAuthorization" | "MedicinalProductContraindication" | "MedicinalProductIndication" | "MedicinalProductIngredient" | "MedicinalProductInteraction" | "MedicinalProductManufactured" | "MedicinalProductPackaged" | "MedicinalProductPharmaceutical" | "MedicinalProductUndesirableEffect" | "MessageDefinition" | "MessageHeader" | "MolecularSequence" | "NamingSystem" | "NutritionOrder" | "ObservationDefinition" | "OperationDefinition" | "OperationOutcome" | "Organization" | "OrganizationAffiliation" | "Parameters" | "PasswordChangeRequest" | "PaymentNotice" | "PaymentReconciliation" | "Person" | "PlanDefinition" | "PractitionerRole" | "Procedure" | "Project" | "ProjectMembership" | "Provenance" | "Questionnaire" | "QuestionnaireResponse" | "RequestGroup" | "ResearchDefinition" | "ResearchElementDefinition" | "ResearchStudy" | "ResearchSubject" | "RiskAssessment" | "RiskEvidenceSynthesis" | "Schedule" | "SearchParameter" | "ServiceRequest" | "Slot" | "SmartAppLaunch" | "Specimen" | "SpecimenDefinition" | "StructureDefinition" | "StructureMap" | "Subscription" | "Substance" | "SubstanceNucleicAcid" | "SubstancePolymer" | "SubstanceProtein" | "SubstanceReferenceInformation" | "SubstanceSourceMaterial" | "SubstanceSpecification" | "SupplyDelivery" | "SupplyRequest" | "Task" | "TerminologyCapabilities" | "TestReport" | "TestScript" | "User" | "UserConfiguration" | "ValueSet" | "VerificationResult" | "VisionPrescription" |
Parameters
| Name | Type | Description |
|---|---|---|
resourceType | K | The FHIR resource type. |
query? | QueryTypes | Optional FHIR search query or structured query object. Can be any valid input to the URLSearchParams() constructor. |
options | RequestInit | Optional fetch options. |
Returns
ReadablePromise<Bundle<ExtractResource<K>>>
Promise to the search result bundle.
Defined in
packages/core/src/client.ts:944
searchOne
▸ searchOne<K>(resourceType, query?, options?): ReadablePromise<undefined | ExtractResource<K>>
Sends a FHIR search request for a single resource.
This is a convenience method for search() that returns the first resource rather than a Bundle.
Example using a FHIR search string:
const patient = await client.searchOne('Patient', 'identifier=123');
console.log(patient);
The return value is the resource, if available; otherwise, undefined.
See FHIR search for full details: https://www.hl7.org/fhir/search.html
Type parameters
| Name | Type |
|---|---|
K | extends "Observation" | "Patient" | "Practitioner" | "RelatedPerson" | "AccessPolicy" | "Account" | "ActivityDefinition" | "AdverseEvent" | "AllergyIntolerance" | "Appointment" | "AppointmentResponse" | "AuditEvent" | "Basic" | "Binary" | "BiologicallyDerivedProduct" | "BodyStructure" | "Bot" | "BulkDataExport" | "Bundle" | "CapabilityStatement" | "CarePlan" | "CareTeam" | "CatalogEntry" | "ChargeItem" | "ChargeItemDefinition" | "Claim" | "ClaimResponse" | "ClientApplication" | "ClinicalImpression" | "CodeSystem" | "Communication" | "CommunicationRequest" | "CompartmentDefinition" | "Composition" | "ConceptMap" | "Condition" | "Consent" | "Contract" | "Coverage" | "CoverageEligibilityRequest" | "CoverageEligibilityResponse" | "DetectedIssue" | "Device" | "DeviceDefinition" | "DeviceMetric" | "DeviceRequest" | "DeviceUseStatement" | "DiagnosticReport" | "DocumentManifest" | "DocumentReference" | "DomainConfiguration" | "EffectEvidenceSynthesis" | "Encounter" | "Endpoint" | "EnrollmentRequest" | "EnrollmentResponse" | "EpisodeOfCare" | "EventDefinition" | "Evidence" | "EvidenceVariable" | "ExampleScenario" | "ExplanationOfBenefit" | "FamilyMemberHistory" | "Flag" | "Goal" | "GraphDefinition" | "Group" | "GuidanceResponse" | "HealthcareService" | "ImagingStudy" | "Immunization" | "ImmunizationEvaluation" | "ImmunizationRecommendation" | "ImplementationGuide" | "InsurancePlan" | "Invoice" | "JsonWebKey" | "Library" | "Linkage" | "List" | "Location" | "Login" | "Measure" | "MeasureReport" | "Media" | "Medication" | "MedicationAdministration" | "MedicationDispense" | "MedicationKnowledge" | "MedicationRequest" | "MedicationStatement" | "MedicinalProduct" | "MedicinalProductAuthorization" | "MedicinalProductContraindication" | "MedicinalProductIndication" | "MedicinalProductIngredient" | "MedicinalProductInteraction" | "MedicinalProductManufactured" | "MedicinalProductPackaged" | "MedicinalProductPharmaceutical" | "MedicinalProductUndesirableEffect" | "MessageDefinition" | "MessageHeader" | "MolecularSequence" | "NamingSystem" | "NutritionOrder" | "ObservationDefinition" | "OperationDefinition" | "OperationOutcome" | "Organization" | "OrganizationAffiliation" | "Parameters" | "PasswordChangeRequest" | "PaymentNotice" | "PaymentReconciliation" | "Person" | "PlanDefinition" | "PractitionerRole" | "Procedure" | "Project" | "ProjectMembership" | "Provenance" | "Questionnaire" | "QuestionnaireResponse" | "RequestGroup" | "ResearchDefinition" | "ResearchElementDefinition" | "ResearchStudy" | "ResearchSubject" | "RiskAssessment" | "RiskEvidenceSynthesis" | "Schedule" | "SearchParameter" | "ServiceRequest" | "Slot" | "SmartAppLaunch" | "Specimen" | "SpecimenDefinition" | "StructureDefinition" | "StructureMap" | "Subscription" | "Substance" | "SubstanceNucleicAcid" | "SubstancePolymer" | "SubstanceProtein" | "SubstanceReferenceInformation" | "SubstanceSourceMaterial" | "SubstanceSpecification" | "SupplyDelivery" | "SupplyRequest" | "Task" | "TerminologyCapabilities" | "TestReport" | "TestScript" | "User" | "UserConfiguration" | "ValueSet" | "VerificationResult" | "VisionPrescription" |
Parameters
| Name | Type | Description |
|---|---|---|
resourceType | K | The FHIR resource type. |
query? | QueryTypes | Optional FHIR search query or structured query object. Can be any valid input to the URLSearchParams() constructor. |
options | RequestInit | Optional fetch options. |
Returns
ReadablePromise<undefined | ExtractResource<K>>
Promise to the first search result.
Defined in
packages/core/src/client.ts:992
searchResources
▸ searchResources<K>(resourceType, query?, options?): ReadablePromise<ExtractResource<K>[]>
Sends a FHIR search request for an array of resources.
This is a convenience method for search() that returns the resources as an array rather than a Bundle.
Example using a FHIR search string:
const patients = await client.searchResources('Patient', 'name=Alice');
console.log(patients);
The return value is an array of resources.
See FHIR search for full details: https://www.hl7.org/fhir/search.html
Type parameters
| Name | Type |
|---|---|
K | extends "Observation" | "Patient" | "Practitioner" | "RelatedPerson" | "AccessPolicy" | "Account" | "ActivityDefinition" | "AdverseEvent" | "AllergyIntolerance" | "Appointment" | "AppointmentResponse" | "AuditEvent" | "Basic" | "Binary" | "BiologicallyDerivedProduct" | "BodyStructure" | "Bot" | "BulkDataExport" | "Bundle" | "CapabilityStatement" | "CarePlan" | "CareTeam" | "CatalogEntry" | "ChargeItem" | "ChargeItemDefinition" | "Claim" | "ClaimResponse" | "ClientApplication" | "ClinicalImpression" | "CodeSystem" | "Communication" | "CommunicationRequest" | "CompartmentDefinition" | "Composition" | "ConceptMap" | "Condition" | "Consent" | "Contract" | "Coverage" | "CoverageEligibilityRequest" | "CoverageEligibilityResponse" | "DetectedIssue" | "Device" | "DeviceDefinition" | "DeviceMetric" | "DeviceRequest" | "DeviceUseStatement" | "DiagnosticReport" | "DocumentManifest" | "DocumentReference" | "DomainConfiguration" | "EffectEvidenceSynthesis" | "Encounter" | "Endpoint" | "EnrollmentRequest" | "EnrollmentResponse" | "EpisodeOfCare" | "EventDefinition" | "Evidence" | "EvidenceVariable" | "ExampleScenario" | "ExplanationOfBenefit" | "FamilyMemberHistory" | "Flag" | "Goal" | "GraphDefinition" | "Group" | "GuidanceResponse" | "HealthcareService" | "ImagingStudy" | "Immunization" | "ImmunizationEvaluation" | "ImmunizationRecommendation" | "ImplementationGuide" | "InsurancePlan" | "Invoice" | "JsonWebKey" | "Library" | "Linkage" | "List" | "Location" | "Login" | "Measure" | "MeasureReport" | "Media" | "Medication" | "MedicationAdministration" | "MedicationDispense" | "MedicationKnowledge" | "MedicationRequest" | "MedicationStatement" | "MedicinalProduct" | "MedicinalProductAuthorization" | "MedicinalProductContraindication" | "MedicinalProductIndication" | "MedicinalProductIngredient" | "MedicinalProductInteraction" | "MedicinalProductManufactured" | "MedicinalProductPackaged" | "MedicinalProductPharmaceutical" | "MedicinalProductUndesirableEffect" | "MessageDefinition" | "MessageHeader" | "MolecularSequence" | "NamingSystem" | "NutritionOrder" | "ObservationDefinition" | "OperationDefinition" | "OperationOutcome" | "Organization" | "OrganizationAffiliation" | "Parameters" | "PasswordChangeRequest" | "PaymentNotice" | "PaymentReconciliation" | "Person" | "PlanDefinition" | "PractitionerRole" | "Procedure" | "Project" | "ProjectMembership" | "Provenance" | "Questionnaire" | "QuestionnaireResponse" | "RequestGroup" | "ResearchDefinition" | "ResearchElementDefinition" | "ResearchStudy" | "ResearchSubject" | "RiskAssessment" | "RiskEvidenceSynthesis" | "Schedule" | "SearchParameter" | "ServiceRequest" | "Slot" | "SmartAppLaunch" | "Specimen" | "SpecimenDefinition" | "StructureDefinition" | "StructureMap" | "Subscription" | "Substance" | "SubstanceNucleicAcid" | "SubstancePolymer" | "SubstanceProtein" | "SubstanceReferenceInformation" | "SubstanceSourceMaterial" | "SubstanceSpecification" | "SupplyDelivery" | "SupplyRequest" | "Task" | "TerminologyCapabilities" | "TestReport" | "TestScript" | "User" | "UserConfiguration" | "ValueSet" | "VerificationResult" | "VisionPrescription" |
Parameters
| Name | Type | Description |
|---|---|---|
resourceType | K | The FHIR resource type. |
query? | QueryTypes | Optional FHIR search query or structured query object. Can be any valid input to the URLSearchParams() constructor. |
options | RequestInit | Optional fetch options. |
Returns
ReadablePromise<ExtractResource<K>[]>
Promise to the array of search results.
Defined in
packages/core/src/client.ts:1034
searchValueSet
▸ searchValueSet(system, filter, options?): ReadablePromise<ValueSet>
Searches a ValueSet resource using the "expand" operation. See: https://www.hl7.org/fhir/operation-valueset-expand.html
Parameters
| Name | Type | Description |
|---|---|---|
system | string | The ValueSet system url. |
filter | string | The search string. |
options | RequestInit | Optional fetch options. |
Returns
ReadablePromise<ValueSet>
Promise to expanded ValueSet.
Defined in
packages/core/src/client.ts:1064
Caching
invalidateUrl
▸ invalidateUrl(url): void
Invalidates any cached values or cached requests for the given URL.
Parameters
| Name | Type | Description |
|---|---|---|
url | string | URL | The URL to invalidate. |
Returns
void
Defined in
packages/core/src/client.ts:547
invalidateSearches
▸ invalidateSearches<K>(resourceType): void
Invalidates all cached search results or cached requests for the given resourceType.
Type parameters
| Name | Type |
|---|---|
K | extends "Observation" | "Patient" | "Practitioner" | "RelatedPerson" | "AccessPolicy" | "Account" | "ActivityDefinition" | "AdverseEvent" | "AllergyIntolerance" | "Appointment" | "AppointmentResponse" | "AuditEvent" | "Basic" | "Binary" | "BiologicallyDerivedProduct" | "BodyStructure" | "Bot" | "BulkDataExport" | "Bundle" | "CapabilityStatement" | "CarePlan" | "CareTeam" | "CatalogEntry" | "ChargeItem" | "ChargeItemDefinition" | "Claim" | "ClaimResponse" | "ClientApplication" | "ClinicalImpression" | "CodeSystem" | "Communication" | "CommunicationRequest" | "CompartmentDefinition" | "Composition" | "ConceptMap" | "Condition" | "Consent" | "Contract" | "Coverage" | "CoverageEligibilityRequest" | "CoverageEligibilityResponse" | "DetectedIssue" | "Device" | "DeviceDefinition" | "DeviceMetric" | "DeviceRequest" | "DeviceUseStatement" | "DiagnosticReport" | "DocumentManifest" | "DocumentReference" | "DomainConfiguration" | "EffectEvidenceSynthesis" | "Encounter" | "Endpoint" | "EnrollmentRequest" | "EnrollmentResponse" | "EpisodeOfCare" | "EventDefinition" | "Evidence" | "EvidenceVariable" | "ExampleScenario" | "ExplanationOfBenefit" | "FamilyMemberHistory" | "Flag" | "Goal" | "GraphDefinition" | "Group" | "GuidanceResponse" | "HealthcareService" | "ImagingStudy" | "Immunization" | "ImmunizationEvaluation" | "ImmunizationRecommendation" | "ImplementationGuide" | "InsurancePlan" | "Invoice" | "JsonWebKey" | "Library" | "Linkage" | "List" | "Location" | "Login" | "Measure" | "MeasureReport" | "Media" | "Medication" | "MedicationAdministration" | "MedicationDispense" | "MedicationKnowledge" | "MedicationRequest" | "MedicationStatement" | "MedicinalProduct" | "MedicinalProductAuthorization" | "MedicinalProductContraindication" | "MedicinalProductIndication" | "MedicinalProductIngredient" | "MedicinalProductInteraction" | "MedicinalProductManufactured" | "MedicinalProductPackaged" | "MedicinalProductPharmaceutical" | "MedicinalProductUndesirableEffect" | "MessageDefinition" | "MessageHeader" | "MolecularSequence" | "NamingSystem" | "NutritionOrder" | "ObservationDefinition" | "OperationDefinition" | "OperationOutcome" | "Organization" | "OrganizationAffiliation" | "Parameters" | "PasswordChangeRequest" | "PaymentNotice" | "PaymentReconciliation" | "Person" | "PlanDefinition" | "PractitionerRole" | "Procedure" | "Project" | "ProjectMembership" | "Provenance" | "Questionnaire" | "QuestionnaireResponse" | "RequestGroup" | "ResearchDefinition" | "ResearchElementDefinition" | "ResearchStudy" | "ResearchSubject" | "RiskAssessment" | "RiskEvidenceSynthesis" | "Schedule" | "SearchParameter" | "ServiceRequest" | "Slot" | "SmartAppLaunch" | "Specimen" | "SpecimenDefinition" | "StructureDefinition" | "StructureMap" | "Subscription" | "Substance" | "SubstanceNucleicAcid" | "SubstancePolymer" | "SubstanceProtein" | "SubstanceReferenceInformation" | "SubstanceSourceMaterial" | "SubstanceSpecification" | "SupplyDelivery" | "SupplyRequest" | "Task" | "TerminologyCapabilities" | "TestReport" | "TestScript" | "User" | "UserConfiguration" | "ValueSet" | "VerificationResult" | "VisionPrescription" |
Parameters
| Name | Type | Description |
|---|---|---|
resourceType | K | The resource type to invalidate. |
Returns
void
Defined in
packages/core/src/client.ts:557
getCached
▸ getCached<K>(resourceType, id): undefined | ExtractResource<K>
Returns a cached resource if it is available.
Type parameters
| Name | Type |
|---|---|
K | extends "Observation" | "Patient" | "Practitioner" | "RelatedPerson" | "AccessPolicy" | "Account" | "ActivityDefinition" | "AdverseEvent" | "AllergyIntolerance" | "Appointment" | "AppointmentResponse" | "AuditEvent" | "Basic" | "Binary" | "BiologicallyDerivedProduct" | "BodyStructure" | "Bot" | "BulkDataExport" | "Bundle" | "CapabilityStatement" | "CarePlan" | "CareTeam" | "CatalogEntry" | "ChargeItem" | "ChargeItemDefinition" | "Claim" | "ClaimResponse" | "ClientApplication" | "ClinicalImpression" | "CodeSystem" | "Communication" | "CommunicationRequest" | "CompartmentDefinition" | "Composition" | "ConceptMap" | "Condition" | "Consent" | "Contract" | "Coverage" | "CoverageEligibilityRequest" | "CoverageEligibilityResponse" | "DetectedIssue" | "Device" | "DeviceDefinition" | "DeviceMetric" | "DeviceRequest" | "DeviceUseStatement" | "DiagnosticReport" | "DocumentManifest" | "DocumentReference" | "DomainConfiguration" | "EffectEvidenceSynthesis" | "Encounter" | "Endpoint" | "EnrollmentRequest" | "EnrollmentResponse" | "EpisodeOfCare" | "EventDefinition" | "Evidence" | "EvidenceVariable" | "ExampleScenario" | "ExplanationOfBenefit" | "FamilyMemberHistory" | "Flag" | "Goal" | "GraphDefinition" | "Group" | "GuidanceResponse" | "HealthcareService" | "ImagingStudy" | "Immunization" | "ImmunizationEvaluation" | "ImmunizationRecommendation" | "ImplementationGuide" | "InsurancePlan" | "Invoice" | "JsonWebKey" | "Library" | "Linkage" | "List" | "Location" | "Login" | "Measure" | "MeasureReport" | "Media" | "Medication" | "MedicationAdministration" | "MedicationDispense" | "MedicationKnowledge" | "MedicationRequest" | "MedicationStatement" | "MedicinalProduct" | "MedicinalProductAuthorization" | "MedicinalProductContraindication" | "MedicinalProductIndication" | "MedicinalProductIngredient" | "MedicinalProductInteraction" | "MedicinalProductManufactured" | "MedicinalProductPackaged" | "MedicinalProductPharmaceutical" | "MedicinalProductUndesirableEffect" | "MessageDefinition" | "MessageHeader" | "MolecularSequence" | "NamingSystem" | "NutritionOrder" | "ObservationDefinition" | "OperationDefinition" | "OperationOutcome" | "Organization" | "OrganizationAffiliation" | "Parameters" | "PasswordChangeRequest" | "PaymentNotice" | "PaymentReconciliation" | "Person" | "PlanDefinition" | "PractitionerRole" | "Procedure" | "Project" | "ProjectMembership" | "Provenance" | "Questionnaire" | "QuestionnaireResponse" | "RequestGroup" | "ResearchDefinition" | "ResearchElementDefinition" | "ResearchStudy" | "ResearchSubject" | "RiskAssessment" | "RiskEvidenceSynthesis" | "Schedule" | "SearchParameter" | "ServiceRequest" | "Slot" | "SmartAppLaunch" | "Specimen" | "SpecimenDefinition" | "StructureDefinition" | "StructureMap" | "Subscription" | "Substance" | "SubstanceNucleicAcid" | "SubstancePolymer" | "SubstanceProtein" | "SubstanceReferenceInformation" | "SubstanceSourceMaterial" | "SubstanceSpecification" | "SupplyDelivery" | "SupplyRequest" | "Task" | "TerminologyCapabilities" | "TestReport" | "TestScript" | "User" | "UserConfiguration" | "ValueSet" | "VerificationResult" | "VisionPrescription" |
Parameters
| Name | Type | Description |
|---|---|---|
resourceType | K | The FHIR resource type. |
id | string | The FHIR resource ID. |
Returns
undefined | ExtractResource<K>
The resource if it is available in the cache; undefined otherwise.
Defined in
packages/core/src/client.ts:1078
getCachedReference
▸ getCachedReference<T>(reference): undefined | T
Returns a cached resource if it is available.
Type parameters
| Name | Type |
|---|---|
T | extends Resource |
Parameters
| Name | Type |
|---|---|
reference | Reference<T> |
Returns
undefined | T
The resource if it is available in the cache; undefined otherwise.
Defined in
packages/core/src/client.ts:1090
Batch
executeBatch
▸ executeBatch(bundle): Promise<Bundle<Resource>>
Executes a batch or transaction of FHIR operations.
Example:
await medplum.executeBatch({
"resourceType": "Bundle",
"type": "transaction",
"entry": [
{
"fullUrl": "urn:uuid:61ebe359-bfdc-4613-8bf2-c5e300945f0a",
"resource": {
"resourceType": "Patient",
"name": [{ "use": "official", "given": ["Alice"], "family": "Smith" }],
"gender": "female",
"birthDate": "1974-12-25"
},
"request": {
"method": "POST",
"url": "Patient"
}
},
{
"fullUrl": "urn:uuid:88f151c0-a954-468a-88bd-5ae15c08e059",
"resource": {
"resourceType": "Patient",
"identifier": [{ "system": "http:/example.org/fhir/ids", "value": "234234" }],
"name": [{ "use": "official", "given": ["Bob"], "family": "Jones" }],
"gender": "male",
"birthDate": "1974-12-25"
},
"request": {
"method": "POST",
"url": "Patient",
"ifNoneExist": "identifier=http:/example.org/fhir/ids|234234"
}
}
]
});
See The FHIR "batch/transaction" section for full details: https://hl7.org/fhir/http.html#transaction
Parameters
| Name | Type | Description |
|---|---|---|
bundle | Bundle<Resource> | The FHIR batch/transaction bundle. |
Returns
Promise<Bundle<Resource>>
The FHIR batch/transaction response bundle.
Defined in
packages/core/src/client.ts:1717
HTTP
getBaseUrl
▸ getBaseUrl(): string
Returns the current base URL for all API requests.
By default, this is set to https://api.medplum.com/.
This can be overridden by setting the baseUrl option when creating the client.
Returns
string
The current base URL for all API requests.
Defined in
packages/core/src/client.ts:514
get
▸ get<T>(url, options?): ReadablePromise<T>
Makes an HTTP GET request to the specified URL.
This is a lower level method for custom requests.
For common operations, we recommend using higher level methods
such as readResource(), search(), etc.
Type parameters
| Name | Type |
|---|---|
T | any |
Parameters
| Name | Type | Description |
|---|---|---|
url | string | URL | The target URL. |
options | RequestInit | Optional fetch options. |
Returns
Promise to the response content.
Defined in
packages/core/src/client.ts:578
post
▸ post(url, body, contentType?, options?): Promise<any>
Makes an HTTP POST request to the specified URL.
This is a lower level method for custom requests.
For common operations, we recommend using higher level methods
such as createResource().
Parameters
| Name | Type | Description |
|---|---|---|
url | string | URL | The target URL. |
body | any | The content body. Strings and File objects are passed directly. Other objects are converted to JSON. |
contentType? | string | The content type to be included in the "Content-Type" header. |
options | RequestInit | Optional fetch options. |
Returns
Promise<any>
Promise to the response content.
Defined in
packages/core/src/client.ts:623
put
▸ put(url, body, contentType?, options?): Promise<any>
Makes an HTTP PUT request to the specified URL.
This is a lower level method for custom requests.
For common operations, we recommend using higher level methods
such as updateResource().
Parameters
| Name | Type | Description |
|---|---|---|
url | string | URL | The target URL. |
body | any | The content body. Strings and File objects are passed directly. Other objects are converted to JSON. |
contentType? | string | The content type to be included in the "Content-Type" header. |
options | RequestInit | Optional fetch options. |
Returns
Promise<any>
Promise to the response content.
Defined in
packages/core/src/client.ts:649
patch
▸ patch(url, operations, options?): Promise<any>
Makes an HTTP PATCH request to the specified URL.
This is a lower level method for custom requests.
For common operations, we recommend using higher level methods
such as patchResource().
Parameters
| Name | Type | Description |
|---|---|---|
url | string | URL | The target URL. |
operations | PatchOperation[] | Array of JSONPatch operations. |
options | RequestInit | Optional fetch options. |
Returns
Promise<any>
Promise to the response content.
Defined in
packages/core/src/client.ts:674
delete
▸ delete(url, options?): Promise<any>
Makes an HTTP DELETE request to the specified URL.
This is a lower level method for custom requests.
For common operations, we recommend using higher level methods
such as deleteResource().
Parameters
| Name | Type | Description |
|---|---|---|
url | string | URL | The target URL. |
options | RequestInit | Optional fetch options. |
Returns
Promise<any>
Promise to the response content.
Defined in
packages/core/src/client.ts:695
fhirUrl
▸ fhirUrl(...path): URL
Builds a FHIR URL from a collection of URL path components.
For example, buildUrl('/Patient', '123') returns fhir/R4/Patient/123.
Parameters
| Name | Type | Description |
|---|---|---|
...path | string[] | The path component of the URL. |
Returns
URL
The well-formed FHIR URL.
Defined in
packages/core/src/client.ts:876
fhirSearchUrl
▸ fhirSearchUrl(resourceType, query): URL
Builds a FHIR search URL from a search query or structured query object.
Parameters
| Name | Type | Description |
|---|---|---|
resourceType | "Observation" | "Patient" | "Practitioner" | "RelatedPerson" | "AccessPolicy" | "Account" | "ActivityDefinition" | "AdverseEvent" | "AllergyIntolerance" | "Appointment" | "AppointmentResponse" | "AuditEvent" | "Basic" | "Binary" | "BiologicallyDerivedProduct" | "BodyStructure" | "Bot" | "BulkDataExport" | "Bundle" | "CapabilityStatement" | "CarePlan" | "CareTeam" | "CatalogEntry" | "ChargeItem" | "ChargeItemDefinition" | "Claim" | "ClaimResponse" | "ClientApplication" | "ClinicalImpression" | "CodeSystem" | "Communication" | "CommunicationRequest" | "CompartmentDefinition" | "Composition" | "ConceptMap" | "Condition" | "Consent" | "Contract" | "Coverage" | "CoverageEligibilityRequest" | "CoverageEligibilityResponse" | "DetectedIssue" | "Device" | "DeviceDefinition" | "DeviceMetric" | "DeviceRequest" | "DeviceUseStatement" | "DiagnosticReport" | "DocumentManifest" | "DocumentReference" | "DomainConfiguration" | "EffectEvidenceSynthesis" | "Encounter" | "Endpoint" | "EnrollmentRequest" | "EnrollmentResponse" | "EpisodeOfCare" | "EventDefinition" | "Evidence" | "EvidenceVariable" | "ExampleScenario" | "ExplanationOfBenefit" | "FamilyMemberHistory" | "Flag" | "Goal" | "GraphDefinition" | "Group" | "GuidanceResponse" | "HealthcareService" | "ImagingStudy" | "Immunization" | "ImmunizationEvaluation" | "ImmunizationRecommendation" | "ImplementationGuide" | "InsurancePlan" | "Invoice" | "JsonWebKey" | "Library" | "Linkage" | "List" | "Location" | "Login" | "Measure" | "MeasureReport" | "Media" | "Medication" | "MedicationAdministration" | "MedicationDispense" | "MedicationKnowledge" | "MedicationRequest" | "MedicationStatement" | "MedicinalProduct" | "MedicinalProductAuthorization" | "MedicinalProductContraindication" | "MedicinalProductIndication" | "MedicinalProductIngredient" | "MedicinalProductInteraction" | "MedicinalProductManufactured" | "MedicinalProductPackaged" | "MedicinalProductPharmaceutical" | "MedicinalProductUndesirableEffect" | "MessageDefinition" | "MessageHeader" | "MolecularSequence" | "NamingSystem" | "NutritionOrder" | "ObservationDefinition" | "OperationDefinition" | "OperationOutcome" | "Organization" | "OrganizationAffiliation" | "Parameters" | "PasswordChangeRequest" | "PaymentNotice" | "PaymentReconciliation" | "Person" | "PlanDefinition" | "PractitionerRole" | "Procedure" | "Project" | "ProjectMembership" | "Provenance" | "Questionnaire" | "QuestionnaireResponse" | "RequestGroup" | "ResearchDefinition" | "ResearchElementDefinition" | "ResearchStudy" | "ResearchSubject" | "RiskAssessment" | "RiskEvidenceSynthesis" | "Schedule" | "SearchParameter" | "ServiceRequest" | "Slot" | "SmartAppLaunch" | "Specimen" | "SpecimenDefinition" | "StructureDefinition" | "StructureMap" | "Subscription" | "Substance" | "SubstanceNucleicAcid" | "SubstancePolymer" | "SubstanceProtein" | "SubstanceReferenceInformation" | "SubstanceSourceMaterial" | "SubstanceSpecification" | "SupplyDelivery" | "SupplyRequest" | "Task" | "TerminologyCapabilities" | "TestReport" | "TestScript" | "User" | "UserConfiguration" | "ValueSet" | "VerificationResult" | "VisionPrescription" | The FHIR resource type. |
query | QueryTypes | The FHIR search query or structured query object. Can be any valid input to the URLSearchParams() constructor. |
Returns
URL
The well-formed FHIR URL.
Defined in
packages/core/src/client.ts:888
Schema
getSchema
▸ getSchema(): IndexedStructureDefinition
Returns a cached schema for a resource type. If the schema is not cached, returns undefined. It is assumed that a client will call requestSchema before using this method.
Deprecated
Use globalSchema instead.
Returns
The schema if immediately available, undefined otherwise.
Defined in
packages/core/src/client.ts:1174
requestSchema
▸ requestSchema(resourceType): Promise<IndexedStructureDefinition>
Requests the schema for a resource type. If the schema is already cached, the promise is resolved immediately.
Parameters
| Name | Type | Description |
|---|---|---|
resourceType | string | The FHIR resource type. |
Returns
Promise<IndexedStructureDefinition>
Promise to a schema with the requested resource type.
Defined in
packages/core/src/client.ts:1185
User Profile
getProfile
▸ getProfile(): undefined | ProfileResource
Returns
undefined | ProfileResource
Defined in
packages/core/src/client.ts:1912
getProfileAsync
▸ getProfileAsync(): Promise<undefined | ProfileResource>
Returns
Promise<undefined | ProfileResource>
Defined in
packages/core/src/client.ts:1919
getUserConfiguration
▸ getUserConfiguration(): undefined | UserConfiguration
Returns
undefined | UserConfiguration
Defined in
packages/core/src/client.ts:1929
Other
constructor
• new MedplumClient(options?)
Parameters
| Name | Type |
|---|---|
options? | MedplumClientOptions |
Overrides
EventTarget.constructor
Defined in
packages/core/src/client.ts:473
startNewProject
▸ startNewProject(newProjectRequest): Promise<LoginAuthenticationResponse>
Initiates a new project flow.
This requires a partial login from startNewUser or startNewGoogleUser.
Parameters
| Name | Type | Description |
|---|---|---|
newProjectRequest | NewProjectRequest | Register request including email and password. |
Returns
Promise<LoginAuthenticationResponse>
Promise to the authentication response.
Defined in
packages/core/src/client.ts:729
startNewPatient
▸ startNewPatient(newPatientRequest): Promise<LoginAuthenticationResponse>
Initiates a new patient flow.
This requires a partial login from startNewUser or startNewGoogleUser.
Parameters
| Name | Type | Description |
|---|---|---|
newPatientRequest | NewPatientRequest | Register request including email and password. |
Returns
Promise<LoginAuthenticationResponse>
Promise to the authentication response.
Defined in
packages/core/src/client.ts:741
uploadwithProgress
▸ uploadwithProgress(url, data, contentType, onProgress): Promise<any>
Parameters
| Name | Type |
|---|---|
url | URL |
data | string | Uint8Array | File | Blob |
contentType | string |
onProgress | (e: ProgressEvent<EventTarget>) => void |
Returns
Promise<any>
Defined in
packages/core/src/client.ts:1440
validateResource
▸ validateResource<T>(resource): Promise<OperationOutcome>
Executes the validate operation with the provided resource.
Example:
const result = await medplum.validateResource({
resourceType: 'Patient',
name: [{ given: ['Alice'], family: 'Smith' }],
});
See the FHIR "$validate" operation for full details: https://www.hl7.org/fhir/resource-operation-validate.html
Type parameters
| Name | Type |
|---|---|
T | extends Resource |
Parameters
| Name | Type | Description |
|---|---|---|
resource | T | The FHIR resource. |
Returns
Promise<OperationOutcome>
The validate operation outcome.
Defined in
packages/core/src/client.ts:1666
addEventListener
▸ addEventListener(type, callback): void
Parameters
| Name | Type |
|---|---|
type | string |
callback | EventListener |
Returns
void
Inherited from
EventTarget.addEventListener
Defined in
packages/core/src/eventtarget.ts:19
removeEventListeneer
▸ removeEventListeneer(type, callback): void
Parameters
| Name | Type |
|---|---|
type | string |
callback | EventListener |
Returns
void
Inherited from
EventTarget.removeEventListeneer
Defined in
packages/core/src/eventtarget.ts:26
dispatchEvent
▸ dispatchEvent(event): boolean
Parameters
| Name | Type |
|---|---|
event | Event |
Returns
boolean
Inherited from
EventTarget.dispatchEvent
Defined in
packages/core/src/eventtarget.ts:39