curl --request POST \
--url https://api.maxcare.ai/v4/ehr/patients/{patientId}/merge \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Organization-Id: <x-organization-id>' \
--header 'idempotency-key: <idempotency-key>' \
--data '
{
"intoPatientId": "pat_c56103bcd39c46d39f3138dd2b5e05f6",
"acknowledgeWarnings": false
}
'import requests
url = "https://api.maxcare.ai/v4/ehr/patients/{patientId}/merge"
payload = {
"intoPatientId": "pat_c56103bcd39c46d39f3138dd2b5e05f6",
"acknowledgeWarnings": False
}
headers = {
"idempotency-key": "<idempotency-key>",
"X-Organization-Id": "<x-organization-id>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'idempotency-key': '<idempotency-key>',
'X-Organization-Id': '<x-organization-id>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
intoPatientId: 'pat_c56103bcd39c46d39f3138dd2b5e05f6',
acknowledgeWarnings: false
})
};
fetch('https://api.maxcare.ai/v4/ehr/patients/{patientId}/merge', 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.maxcare.ai/v4/ehr/patients/{patientId}/merge",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'intoPatientId' => 'pat_c56103bcd39c46d39f3138dd2b5e05f6',
'acknowledgeWarnings' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Organization-Id: <x-organization-id>",
"idempotency-key: <idempotency-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.maxcare.ai/v4/ehr/patients/{patientId}/merge"
payload := strings.NewReader("{\n \"intoPatientId\": \"pat_c56103bcd39c46d39f3138dd2b5e05f6\",\n \"acknowledgeWarnings\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("idempotency-key", "<idempotency-key>")
req.Header.Add("X-Organization-Id", "<x-organization-id>")
req.Header.Add("Authorization", "Bearer <token>")
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.post("https://api.maxcare.ai/v4/ehr/patients/{patientId}/merge")
.header("idempotency-key", "<idempotency-key>")
.header("X-Organization-Id", "<x-organization-id>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"intoPatientId\": \"pat_c56103bcd39c46d39f3138dd2b5e05f6\",\n \"acknowledgeWarnings\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.maxcare.ai/v4/ehr/patients/{patientId}/merge")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["idempotency-key"] = '<idempotency-key>'
request["X-Organization-Id"] = '<x-organization-id>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"intoPatientId\": \"pat_c56103bcd39c46d39f3138dd2b5e05f6\",\n \"acknowledgeWarnings\": false\n}"
response = http.request(request)
puts response.read_body{
"code": "success",
"data": {
"id": "pmg_0b6f1c1e8d2a4f7e9a3b5c7d9e1f2a3b",
"status": "queued",
"patientId": "<string>",
"intoPatientId": "<string>",
"errorCode": "<string>",
"errorMessage": "<string>",
"requiresReconciliation": true,
"requestedAt": "<string>",
"completedAt": "<string>",
"updatedAt": "<string>"
}
}{
"code": "bad_request",
"message": "'id' must be a valid UUID",
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"code": "unauthorized",
"message": "Invalid or missing API key",
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"code": "forbidden",
"message": "Insufficient scope",
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"code": "not_found",
"message": "Resource not found",
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"code": "conflict",
"message": "Cannot edit a signed note",
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"code": "controlled_substance_unsupported",
"message": "Controlled substances cannot be prescribed through the API",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"data": {}
}{
"code": "rate_limit_exceeded",
"message": "Rate limit exceeded. Maximum 1000 requests per 60 seconds.",
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"code": "capability_unsupported",
"message": "This organization's EHR has no appointment finder.",
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"code": "unexpected_integration_error",
"message": "EHR sync failed",
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}Merge this chart into another
IRREVERSIBLE. Merges the path patient (source) into intoPatientId in the EHR: EMA copies the source’s clinical data into the target and archives the source. Returns 202 with a merge to poll at GET /v4/ehr/patient-merges/{id} until completed or failed; patient.merged fires on completion. Refusals answer at once and merge nothing: 409 merge_blocked (with the EHR’s blockers), merge_instance_mismatch, patient_already_merged, merge_in_progress, patient_not_in_ehr; 400 merge_same_patient; 403 ehr_permission_missing; 501 capability_unsupported. 409 ehr_write_uncertain with mergeId when the merge was sent and the EHR never answered: poll it, never resend.
curl --request POST \
--url https://api.maxcare.ai/v4/ehr/patients/{patientId}/merge \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Organization-Id: <x-organization-id>' \
--header 'idempotency-key: <idempotency-key>' \
--data '
{
"intoPatientId": "pat_c56103bcd39c46d39f3138dd2b5e05f6",
"acknowledgeWarnings": false
}
'import requests
url = "https://api.maxcare.ai/v4/ehr/patients/{patientId}/merge"
payload = {
"intoPatientId": "pat_c56103bcd39c46d39f3138dd2b5e05f6",
"acknowledgeWarnings": False
}
headers = {
"idempotency-key": "<idempotency-key>",
"X-Organization-Id": "<x-organization-id>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'idempotency-key': '<idempotency-key>',
'X-Organization-Id': '<x-organization-id>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
intoPatientId: 'pat_c56103bcd39c46d39f3138dd2b5e05f6',
acknowledgeWarnings: false
})
};
fetch('https://api.maxcare.ai/v4/ehr/patients/{patientId}/merge', 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.maxcare.ai/v4/ehr/patients/{patientId}/merge",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'intoPatientId' => 'pat_c56103bcd39c46d39f3138dd2b5e05f6',
'acknowledgeWarnings' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Organization-Id: <x-organization-id>",
"idempotency-key: <idempotency-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.maxcare.ai/v4/ehr/patients/{patientId}/merge"
payload := strings.NewReader("{\n \"intoPatientId\": \"pat_c56103bcd39c46d39f3138dd2b5e05f6\",\n \"acknowledgeWarnings\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("idempotency-key", "<idempotency-key>")
req.Header.Add("X-Organization-Id", "<x-organization-id>")
req.Header.Add("Authorization", "Bearer <token>")
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.post("https://api.maxcare.ai/v4/ehr/patients/{patientId}/merge")
.header("idempotency-key", "<idempotency-key>")
.header("X-Organization-Id", "<x-organization-id>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"intoPatientId\": \"pat_c56103bcd39c46d39f3138dd2b5e05f6\",\n \"acknowledgeWarnings\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.maxcare.ai/v4/ehr/patients/{patientId}/merge")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["idempotency-key"] = '<idempotency-key>'
request["X-Organization-Id"] = '<x-organization-id>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"intoPatientId\": \"pat_c56103bcd39c46d39f3138dd2b5e05f6\",\n \"acknowledgeWarnings\": false\n}"
response = http.request(request)
puts response.read_body{
"code": "success",
"data": {
"id": "pmg_0b6f1c1e8d2a4f7e9a3b5c7d9e1f2a3b",
"status": "queued",
"patientId": "<string>",
"intoPatientId": "<string>",
"errorCode": "<string>",
"errorMessage": "<string>",
"requiresReconciliation": true,
"requestedAt": "<string>",
"completedAt": "<string>",
"updatedAt": "<string>"
}
}{
"code": "bad_request",
"message": "'id' must be a valid UUID",
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"code": "unauthorized",
"message": "Invalid or missing API key",
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"code": "forbidden",
"message": "Insufficient scope",
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"code": "not_found",
"message": "Resource not found",
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"code": "conflict",
"message": "Cannot edit a signed note",
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"code": "controlled_substance_unsupported",
"message": "Controlled substances cannot be prescribed through the API",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"data": {}
}{
"code": "rate_limit_exceeded",
"message": "Rate limit exceeded. Maximum 1000 requests per 60 seconds.",
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"code": "capability_unsupported",
"message": "This organization's EHR has no appointment finder.",
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"code": "unexpected_integration_error",
"message": "EHR sync failed",
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}Authorizations
Marketplace API key
Headers
Required. A retry with the same key and body returns the same merge; never merges twice.
Target clinic organization ID
Path Parameters
Body
The surviving chart. Same organization and same EHR instance as the path patient.
"pat_c56103bcd39c46d39f3138dd2b5e05f6"
Merge even though the EHR warned about the pair (e.g. differing first names), after staff confirmed both charts are the same person. Without it such a merge answers 409 merge_needs_confirmation. Blocks on either chart (balances, open bills) still refuse.
