Guide
Request records from a facility
Create a request, follow it to completion, and download what came back.
A record request asks one facility for one patient’s records, bounded by a range of service dates. A search discovers data; a request retrieves documents. A patient usually needs several requests, one for each place they were treated.
Create the request
Create it with
POST /v0/companies/{companyId}/projects/{projectId}/patients/{patientId}/record-requests:
curl https://api.hermeshealth.ai/v0/companies/COMPANY_ID/projects/PROJECT_ID/patients/PATIENT_ID/record-requests \
-X POST \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"siteId": "<site_id>",
"medicalRecord": true,
"billing": false,
"imaging": false,
"ccda": false,
"startDateOfService": "2024-01-15",
"endDateOfService": "2024-02-20"
}'
import requests
response = requests.post(
"https://api.hermeshealth.ai/v0/companies/COMPANY_ID/projects/PROJECT_ID/patients/PATIENT_ID/record-requests",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"siteId": "<site_id>",
"medicalRecord": True,
"billing": False,
"imaging": False,
"ccda": False,
"startDateOfService": "2024-01-15",
"endDateOfService": "2024-02-20",
},
)
response.raise_for_status()
print(response.json()["requests"])
const response = await fetch("https://api.hermeshealth.ai/v0/companies/COMPANY_ID/projects/PROJECT_ID/patients/PATIENT_ID/record-requests", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
"siteId": "<site_id>",
"medicalRecord": true,
"billing": false,
"imaging": false,
"ccda": false,
"startDateOfService": "2024-01-15",
"endDateOfService": "2024-02-20"
}),
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data.requests);
medicalRecord, billing, imaging and both service dates are required.
ccda is optional and defaults to false. A C-CDA request needs a siteId
whose facility has a live electronic health record connection that accepts
requests for the project; a visit row’s ccda.actionable says whether its
facility qualifies, and any other site is refused with a 400. On a sandbox
project every facility qualifies, and the request completes on its own with a
sample C-CDA package.
The response is RecordRequestMany { requests: [...] }, with one entry per
flag you turned on: each record type goes to the facility as its own request.
Keep every request.id.
Identify the facility
Two ways.
By siteId (preferred), taken from a visit row after a search. See
Find where a patient was treated. Hermes
already knows that site’s address, NPI and submission preferences. The site
must be a facility: a visit with an individual practitioner has a site whose
providerType is Practitioner, and its site.id is refused with a 400.
Identify that visit’s facility by name and address instead.
On a live project Hermes re-checks the site before the request can be sent,
so the request comes back with siteId null and the site’s name and address
in its submittedSite* fields. Within about a minute Hermes links the site its
matching finds, which can be a different one, such as an in-network site at
the same address; a note on the request then names both. When matching finds
no confident match, the site you passed is linked. The link leaves the
request’s status unchanged and sends no recordRequest webhook event, so poll
the request until siteId is set before acting on it. C-CDA requests and
sandbox projects skip the re-check and keep the site you passed from the start.
By name and address, when you already know where to ask and have no site
ID. Pass siteName, siteAddressLine1, siteCity, siteState and siteZip
(plus optional siteAddressLine2), and Hermes resolves the facility.
Send it
To send a request to its facility yourself, generate its provider packet (the cover letter, request and authorization the facility receives), then send it:
curl https://api.hermeshealth.ai/v0/companies/COMPANY_ID/projects/PROJECT_ID/patients/PATIENT_ID/record-requests/RECORD_REQUEST_ID/provider-packet \
-X POST \
-H "Authorization: Bearer YOUR_API_KEY"
import requests
response = requests.post(
"https://api.hermeshealth.ai/v0/companies/COMPANY_ID/projects/PROJECT_ID/patients/PATIENT_ID/record-requests/RECORD_REQUEST_ID/provider-packet",
headers={"Authorization": "Bearer YOUR_API_KEY"},
)
response.raise_for_status()
const response = await fetch("https://api.hermeshealth.ai/v0/companies/COMPANY_ID/projects/PROJECT_ID/patients/PATIENT_ID/record-requests/RECORD_REQUEST_ID/provider-packet", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
},
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
curl https://api.hermeshealth.ai/v0/companies/COMPANY_ID/projects/PROJECT_ID/patients/PATIENT_ID/record-requests/RECORD_REQUEST_ID/send \
-X POST \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"requestMethod": "Fax"
}'
import requests
response = requests.post(
"https://api.hermeshealth.ai/v0/companies/COMPANY_ID/projects/PROJECT_ID/patients/PATIENT_ID/record-requests/RECORD_REQUEST_ID/send",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"requestMethod": "Fax",
},
)
response.raise_for_status()
print(response.json()["method"])
const response = await fetch("https://api.hermeshealth.ai/v0/companies/COMPANY_ID/projects/PROJECT_ID/patients/PATIENT_ID/record-requests/RECORD_REQUEST_ID/send", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
"requestMethod": "Fax"
}),
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data.method);
The packet needs the request’s dates of service and, unless the project’s
purpose is covered by the patient’s general authorization, an authorization
that names the site. Sending without a packet answers 409.
Leave out the body to send by the method the site’s records department
takes. requestMethod may be Fax, Email or Mail; the fax number, inbox
and postal address always come from the department. Any other method answers
403. A letter carries a check for the department’s records fee, charged to
you as a site fee when sent from a live project; send quote=true first to see
it. Fax and email charge nothing.
Each call sends again. A request in a closed project cannot be sent (409).
Your company may send 60 requests in any hour, 20 of them by mail, and generate
120 provider packets; past that the call answers 429 with a Retry-After
header giving the seconds to wait. A send that fails at the delivery service
still counts.
Sending and generating the packet need the SendRecordRequests permission,
which company administrators hold; another user’s key answers 403.
Track it
Poll each request with
GET /v0/companies/{companyId}/projects/{projectId}/patients/{patientId}/record-requests/{recordRequestId}:
curl https://api.hermeshealth.ai/v0/companies/COMPANY_ID/projects/PROJECT_ID/patients/PATIENT_ID/record-requests/RECORD_REQUEST_ID \
-H "Authorization: Bearer YOUR_API_KEY"
import requests
response = requests.get(
"https://api.hermeshealth.ai/v0/companies/COMPANY_ID/projects/PROJECT_ID/patients/PATIENT_ID/record-requests/RECORD_REQUEST_ID",
headers={"Authorization": "Bearer YOUR_API_KEY"},
)
response.raise_for_status()
print(response.json()["request"]["status"])
const response = await fetch("https://api.hermeshealth.ai/v0/companies/COMPANY_ID/projects/PROJECT_ID/patients/PATIENT_ID/record-requests/RECORD_REQUEST_ID", {
method: "GET",
headers: {
Authorization: "Bearer YOUR_API_KEY",
},
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data.request.status);
request.status is one of twenty-two values rolling up into six categories, which
is the useful way to read them.
| Category | Statuses | Meaning |
|---|---|---|
| Pending | Pending, InfoConfirmed, SiteConfirmed, MailOnly, Resubmitted | Not yet with the facility. |
| Processing | RequestSent, RequestConfirmed, NeedToReviewResults | With the facility, waiting on them, or records arrived and are being reviewed. |
| Needs resolution | AuthDenied, PaymentPending, NeedSiteSpecificAuth | Blocked on an action. |
| Completed | Completed, Partial | Records came back. |
| Records not found | PatientNotFound, ServiceDatesNotFound, SiteClosed, FacilityRefusal, NoRecordFound | Finished with nothing. |
| Cancelled | Canceled, Void, ChaseStopped, DuplicateRequest, WrongSiteName | Stopped. |
Twelve are terminal: Completed, Partial, Canceled, Void, ChaseStopped,
DuplicateRequest, WrongSiteName, PatientNotFound, ServiceDatesNotFound,
SiteClosed, FacilityRefusal, NoRecordFound.
Test the category, not one value.
Partialis terminal and carries real deliverables, so code waiting for exactlyCompletedwaits forever on a request whose documents already arrived. AndAuthDeniedis not terminal: the request moves again once the authorization is fixed.
Be told instead of polling
Subscribe a webhook to recordRequest / columnChanged on status. Hermes
posts on every transition and data.status carries the new value.
The payload holds only your subscribed columns, not the full request. When the
status reaches the Completed category, GET the path in the payload’s
resource field to read the deliverables. See
Receive webhook events.
Download the deliverables
Once the status is Completed or Partial, the deliverables array on that
same GET is populated. There is no separate fetch: the polling response is the
download manifest.
Each entry carries a download url. It is valid for about an hour, so
download from it rather than storing it.
Send no
Authorizationheader to a deliverableurl. The URL is already signed, and an extra header makes the download fail.
Two fields hold documents, and they are different things:
deliverables(plural) lists every raw document that came back.deliverable(singular) is the one combined chart Hermes generates, once it has published one, downloaded asEHR_Charts_Combined.pdf. It is not the first entry of the array.
The listing presents the request the way the web app does, not the way S3 stores it. Three rules follow from that:
| Field | What it is | Address a file with it? |
|---|---|---|
fileName | Unique across the request; a repeat name reads as CCDA_80154372 (2).xml | Yes: GET/HEAD/DELETE .../deliverables/{fileName} |
folder | The display folder, /-joined, omitted at the top level | No. It is for display and grouping only. |
key | The real S3 key | No, though it is unchanged: nothing here moves a stored file. |
Renaming is the one exception. PATCH .../deliverables/{path} takes the
stored path, which is the part of key after /deliverables/ and may have
several segments, because it moves the file rather than reading it.
When a send fails
When a send fails depends on the channel and the project:
- In production, a fax that is not delivered and a letter that is canceled fail after the call returns. An email the facility’s mail server refuses and a release-of-information request the service rejects fail during the call, which answers an error.
- In a sandbox project, every channel’s reserved failing value is accepted by the call and fails afterwards, as listed under “In a sandbox project” below.
Either way the request’s lastDeliveryFailure names the channel, a stable
code (faxFailed, faxCanceled, emailRejected, mailCanceled or
roiRejected), a readable message and failedAt, and
recordRequest.deliveryFailed is sent to your webhooks. A later send that is
accepted sets lastDeliveryFailure back to null.
A call that fails without a refusal from the channel records no failure: a login the mail server refused, or a release-of-information service that did not answer. The call answers an error, and the service may still have received the request, so check before sending it again.
A failed send is not a status. The request keeps its status, and Hermes does
not send it again: send it again, through the same channel or another, or
change the request, as you decide.
When a request fails
Three are blocked rather than finished, and can move again:
AuthDenied: the facility rejected the authorization on file. Usually a missing signature, an expired date, or a form that does not name the facility. Fix it and the request proceeds.NeedSiteSpecificAuth: this facility wants its own authorization form.PaymentPending: the facility charges for records and has not been paid.
Five are terminal and produce nothing:
PatientNotFound: no record of this patient there, or the identity you sent does not match theirs.ServiceDatesNotFound: they have the patient but nothing in your date range. Widen it and raise a new request.SiteClosed: the facility has shut down. Records may sit with a successor organisation, which is a different site and a new request.FacilityRefusal: they declined to release.NoRecordFound: the request reached the right place and came back empty.
Five are stopped:
WrongSiteName: the facility named is not the one holding the records. Raise a new request against the right site, using asiteIdif you have one.DuplicateRequest: an identical request already exists. Find the original.Canceled: cancelled.Void: voided, and will not be worked.ChaseStopped: the chase for the records was stopped, and the request will not be worked further.
Partial is not a failure. It is terminal, in the Completed category, and the
facility sent some of what was asked for. Those deliverables are all you will
get from that request; chase the gap with a new one.
Watch many at once
POST /v0/record-requests/browse takes the same query syntax as the clinical
tables (see Query large tables), so one call finds
everything sitting in Needs resolution across a project. That is the set worth
a human’s attention, since the terminal ones will not change whatever you do.
In a sandbox project
Requests auto-complete shortly after creation with a stub deliverable, so the whole path (create, poll, read the array, download a file) can be proven before a real facility is contacted.
Sending a sandbox request answers as a live send does and records the
submission, but nothing reaches a facility, vendor or electronic health record:
every channel is simulated. A few seconds apart, the submission’s
deliveryStatus moves through the statuses the real channel reports (a fax
sending then delivered; a letter ready, printing,
processed_for_delivery then completed; an ROI task submitted,
in-progress then completed), the request moves as a live send moves it
(a delivered fax to RequestSent), and the request then completes, sending the
same recordRequest webhook events a live request does. A sent request
completes when its send’s simulation ends rather than shortly after creation.
To exercise your failure handling, send to one of these reserved values. Each
fails only on a sandbox project; on a live project it is an ordinary value. A
send to one is accepted like any other: it answers 200 with the same body and
records its submission. Once the channel’s simulated delay has passed, the
submission’s deliveryStatus reads the channel’s failure status, as the real
channel reports a failure. The request’s lastDeliveryFailure is set and
recordRequest.deliveryFailed is sent, exactly as for a real failure. The
request is never completed, and no other webhook beyond the ones the send
itself caused is sent.
| Channel | Reserved value | What happens |
|---|---|---|
| Fax | the department fax number +12025550199 | The send is accepted, then its deliveryStatus reads failed, and the request stays where it was |
the department email undeliverable@sandbox.invalid | The send is accepted and its submission’s requestMethodId is the recipient address, as for any email, then its deliveryStatus reads failure, and the request stays where the send left it | |
the department address line 0 Undeliverable Way | The letter is accepted and stays ready, then its deliveryStatus reads cancelled, and the request stays where the send left it | |
| ROI | a patient last name of Sandbox-Refused | The task is accepted and moves through submitted and in-progress, then its deliveryStatus reads rejected with no records returned, and the request stays where the send left it |
Next steps
- Receive webhook events: be told about every status change instead of polling.
- Query large tables: the query syntax behind
POST /v0/record-requests/browse.