SureAdhere to EDC API Specification
- 1 Overview
- 1.1 Quick facts
- 2 SureAdhere → EDC: dose adherence
- 3 SureAdhere → EDC: pill counts
- 3.1 Triggers
- 3.2 Field reference
- 4 EDC → SureAdhere: subject enrollment
- 4.1 Endpoint
- 4.2 Responses
- 4.3 Authentication
- 4.4 Example
- 5 Error handling & reliability
- 6 Configuration
- 7 Glossary
Last updated July 2026. This page describes the SureAdhere ↔ Medidata Rave EDC integration as it runs today. Multiple integrations are currently live with active clinical trials. Trial-identifying details (study names, drugs, arms) are intentionally omitted from this page; the three live form layouts are described generically as Study A, B, and C below.
Overview
SureAdhere integrates with Medidata Rave, the electronic data capture (EDC) system used by clinical trials, so that adherence data recorded in SureAdhere lands in the study database automatically — no double data entry by site staff.
Data flows in both directions:
Direction | What is sent | When |
|---|---|---|
SureAdhere → EDC | Dose adherence records (one log line per patient, per drug, per day: pills taken, time, how the dose was observed, meal information) and pill count records (pills dispensed, returned, lost/damaged at each visit). | In real time, whenever a dose or pill count is submitted or updated in SureAdhere (by a provider in the web app or automatically from the patient's mobile app). |
EDC → SureAdhere | Subject enrollment: the Subject ID, trial arm, and site for each newly randomized subject. | In real time, when the subject is randomized — EDC calls a SureAdhere API, which creates the patient automatically. |
Quick facts
Data transfer type | EDC, "Clinical Data – Exposure" (plus drug accountability / pill counts where configured) |
Frequency | Real time (event-driven, queued and delivered asynchronously) |
Direction | Two-way (adherence & pill counts out; subject enrollment in) |
Transfer method | Rave Web Services (RWS), REST over HTTPS. Payloads are CDISC ODM v1.3 XML, UTF-8, sent as log lines with TransactionType Update/Upsert. The maximum size of a single POST is 1,000,000 bytes. |
Unblinded data | No |
Critical data points | Yes |
How it's enabled | Per client, via the Medidata Rave Integration feature flag. Each drug must also be mapped to its Rave form (see Configuration below). |
SureAdhere → EDC: dose adherence
What triggers a transfer
SureAdhere sends (or updates) an adherence log line in Rave whenever any of the following happens:
A provider submits a dose review in the web app. On the Adherence screen, pressing Submit for Review on a dose sends one log line per drug in that dose. Editing and re-submitting the same dose updates the same log line in Rave (no duplicates).
A patient submits from the mobile app. When a patient records a video, self-reports a dose, or an in-person DOT is recorded on the device, the submission is sent to Rave automatically — no provider action needed for the initial record.
Doses with nothing reported are not sent. A drug whose status is still "Open" (nothing observed or reported yet) does not go to Rave. Everything else — including missed doses and 0-pill records (e.g. a held drug) — is sent, because those are deliberate observations the study needs.
What happens behind the scenes
SureAdhere builds a CDISC ODM v1.3 XML message for the patient, drug, and date.
The message is placed on an internal queue and delivered to Rave Web Services asynchronously, with automatic retries if Rave is temporarily unavailable.
Every call and every Rave response is logged, and errors are captured in our monitoring tools for the technical team to review. Web app users never see integration success/failure messages — delivery is asynchronous, so integration issues are handled by the SureAdhere team, not site staff.
Rules that keep the data clean
One log line per patient, per drug, per day. Each log line is uniquely identified by the subject, the dose date, and the drug's form (for twice-daily drugs, also the morning/evening slot). Later edits update the existing line rather than creating a new one.
Adherence log lines are never deleted. SureAdhere only inserts and updates exposure records.
All dates and times are in the patient's local time zone (based on their site). Dates are formatted
dd MMM yyyy, timesHH:mm(24-hour).Times are only sent when they're meaningful. The recorded time is left blank when the submission was made on a different day than the dose date (a back-dated entry's wall-clock time isn't meaningful), or when 0 pills were taken.
If a dose's video exists, the video's recording time is the source of truth for the dose time, even when the observation method comes from a self-report or in-person record from the same session.
Field reference: form layouts
Every study has its own Rave form design, so the set of fields differs per study. The three layouts currently in production are described below (anonymized as Study A, B, and C). The tables list exactly which item OIDs each layout receives and where each value comes from in SureAdhere.
Shared field values
Value | How SureAdhere fills it |
|---|---|
SubjectKey | The patient's MRN in SureAdhere (= the Subject ID sent by EDC at enrollment). SureAdhere does not impose a format. |
LocationOID (SiteRef) | The SureAdhere site code, sent as a Rave |
StudyOID | The Rave study environment configured for the client. Each environment has its own Study OID — e.g. |
Mode of observation | How the dose was observed. Standard values: Self Report, In Person DOT, VDOT Recorded, or blank when no observation applies. Studies using per-drug adherence (layout C) can also receive per-drug statuses: Reported missed dose, No information, SAT uncertain, SAT certain, Partial dose, VDOT (live), MERM, Device Malfunction, Other. |
Meal within last hour |
|
Layout A — standard exposure form
Item | Item OID | SureAdhere source |
|---|---|---|
Start Date | EXSTDAT | Dose date (this is the log line's key) |
Start Time | EXSTTIM | Time the dose was recorded |
Number of Tablets Prescribed | EXPNUM | Pills expected for the drug that day |
Number of Tablets Taken | EXNUM | Pills taken (0 allowed) |
Mode of Observation | EXMODE | See shared values above |
Meal within last hour | EXFOOD | yes / no / UNK |
Layout B — extended exposure form
The richest layout of the three — it also carries drug name and status, prescribed/taken dose in mg, dose comments, and last-meal details.
Item | Item OID | SureAdhere source |
|---|---|---|
Start Date | EXSTDAT | Dose date (log line key) |
Drug Name | EXTRT | Name of the drug |
Drug Status | EXSTATUS | The drug's dose status (Taken, Missed, Held, …) |
Modified Since Last Dose | EXMODIFY |
|
Start Time | EXSTTIM | Time the dose was recorded |
Dose Prescribed / Unit | EXDSTXT / EXDSTXTU | Prescribed dose in mg (unit is always |
Number of Tablets Prescribed | EXPNUM | Pills expected for the drug that day |
Number of Tablets Taken | EXNUM | Pills taken (0 allowed) |
Dose Taken / Unit | EXADSTXT / EXADSTXU | Dose actually taken in mg (unit is always |
Explanation | EXEXPLA | The dose's comments, aggregated |
Mode of Observation | EXMODE | See shared values above |
Last Meal Date / Time | EXLMDAT / EXLMTIM | When the patient last ate, from the patient's self-report or the provider's per-drug edit |
Layout C — per-drug exposure form (suffixed fields)
This layout uses per-drug adherence and a form design where each drug in the regimen writes its own set of fields, distinguished by a numeric suffix. One drug is dosed twice daily, so its log lines are additionally keyed by a morning/evening slot.
Drug | Fields written |
|---|---|
Drug 1 (twice daily, AM/PM) | ECSTDAT (dose date, key), ECSTTIM (time), PALNDOSE ( |
Drug 2 | ECSTDAT_1, ECSTTIM_1, EXPNUM_1, ECDOSE_1, EXMODE_1, EXFOOD_1 |
Drug 3 | ECSTDAT_2, ECSTTIM_2, EXPNUM_2, ECDOSE_2, EXMODE_2, EXFOOD_2 |
Drug 4 | ECSTDAT_3, ECSTTIM_3, EXPNUM_3, ECDOSE_3, EXMODE_3, EXFOOD_3 |
Example XML
Insert / update (layout A)
<ODM xmlns="http://www.cdisc.org/ns/odm/v1.3" ODMVersion="1.3" FileType="Transactional" FileOID="SureAdhereDose" CreationDateTime="2026-07-04T00:00:00">
<ClinicalData StudyOID="<Study OID>" MetaDataVersionOID="1">
<SubjectData SubjectKey="999-888-7777" TransactionType="Update">
<SiteRef LocationOID="999" mdsol:LocationOIDType="StudyEnvSiteNumber"/>
<StudyEventData StudyEventOID="SM" StudyEventRepeatKey="1" TransactionType="Update">
<FormData FormOID="EX" TransactionType="Update">
<ItemGroupData ItemGroupOID="EX" ItemGroupRepeatKey="@CONTEXT" TransactionType="Upsert">
<ItemData ItemOID="EXSTDAT" TransactionType="Context" Value="04 JUL 2026"/>
<ItemData ItemOID="EXSTTIM" TransactionType="Upsert" Value="14:00"/>
<ItemData ItemOID="EXPNUM" TransactionType="Upsert" Value="1"/>
<ItemData ItemOID="EXNUM" TransactionType="Upsert" Value="1"/>
<ItemData ItemOID="EXMODE" TransactionType="Upsert" Value="VDOT Recorded"/>
<ItemData ItemOID="EXFOOD" TransactionType="Upsert" Value="yes"/>
</ItemGroupData>
</FormData>
</StudyEventData>
</SubjectData>
</ClinicalData>
</ODM>The EXSTDAT item uses TransactionType="Context" (it identifies which log line to touch); the data items use Upsert. Updates reuse the same structure and only need to carry the fields that changed.
SureAdhere → EDC: pill counts
For studies that use SureAdhere's pill count feature, pill count visits are also sent to a drug accountability form in Rave — one log line per drug per visit, keyed by the dispensed date.
Triggers
Creating or editing a pill count visit in the web app sends (or updates) the log line for each drug in the visit.
Removing a drug line from a visit sends a removal for that drug's log line. (This is the only place the integration ever deletes anything in Rave.)
Field reference
Item | Item OID | SureAdhere source |
|---|---|---|
Drug Name | DASCAT | Name of the drug |
Kit Number | DAAREFID | The kit number entered with the pill count. Only sent for drugs configured to use kit numbers; omitted for all other drugs. |
Date Dispensed | DISAMT_DADAT | Visit date pills were dispensed (log line key) |
Pills Dispensed / Unit | DISAMT_DAORRES / DISAMT_DAORRESU | Number of pills dispensed and their unit |
Date Returned | RETAMT_DADAT | Date pills were returned (blank if not yet returned) |
Pills Returned / Unit | RETAMT_DAORRES / RETAMT_DAORRESU | Number of pills returned and their unit |
Pills Lost/Damaged | LOSTAMT_DAORRES | Number of pills lost or damaged |
SureAdhere validates pill counts before they can be saved (e.g. pills returned plus lost/damaged can never exceed pills dispensed, and only one pill count visit is allowed per patient per date), so Rave receives internally consistent data.
EDC → SureAdhere: subject enrollment
When a subject is randomized in the study, EDC calls a SureAdhere API in real time. SureAdhere then creates the patient automatically:
The Subject ID becomes the patient's MRN (and their username and display name in the mobile app).
The trial arm is matched to a SureAdhere regimen template of the same name, so the patient's regimen is pre-selected. Site staff only need to open the patient and set the start date — the full regimen populates from the template.
The site code assigns the patient to the correct site in SureAdhere.
Endpoint
POST /treatment/ingest/mrn_regimen
The request body is JSON (UTF-8):
{
"mrn": "100-100-1000",
"regimen": "<trial arm name>",
"site_code": "100"
}Field | Required | Notes |
|---|---|---|
mrn | Yes | The Subject ID from EDC. Must be unique within the client — a duplicate returns 409. Becomes the patient's MRN, username, and first name. |
regimen | Yes | Must exactly match the name of a regimen template configured in SureAdhere for the study (the trial arms). Unrecognized names return 400 with the list of known regimens. |
site_code | Usually | The subject's site. May be omitted only when the MRN itself starts with the site code followed by "S" (e.g. |
Responses
201 — patient created successfully
400 — missing/invalid token, unrecognized regimen name, unrecognized site code, or bad MRN format
409 — a subject with the same MRN already exists
500 — internal server error
If SureAdhere is unreachable, the EDC side should keep retrying until it receives a 201 (or a 409, which means the subject already made it in).
Authentication
Each request must include the client's token in a header named MRNIntegrationToken.
Each token is tied to one SureAdhere client (workspace) — it encodes both authorization and where the data goes.
Tokens are write-only: the EDC system can submit enrollments but cannot read anything back.
Tokens don't expire; they are revoked manually if needed. Firewall IP allow-listing applies.
Example
curl -X POST \
https://<sureadhere-env>/treatment/ingest/mrn_regimen \
-H 'Content-Type: application/json' \
-H 'MRNIntegrationToken: 123abc' \
-d '{
"mrn": "100-100-1000",
"regimen": "<trial arm name>",
"site_code": "100"
}'Error handling & reliability
Delivery is queued with automatic retries. Outbound messages are queued and retried until Rave accepts them or the configured maximum number of attempts is reached; failures are logged for the technical team. By default, up to 3 delivery attempts are made before a failure is escalated for manual review.
Every Rave response is checked. RWS returns
IsTransactionSuccessful(1 = success, 0 = failure) plus an error code, description, and XPath location on failure. Unsuccessful transactions are logged and captured in our error monitoring, then assessed and resolved by the SureAdhere team.Site staff never see integration errors. Because delivery is asynchronous, nurses and providers are not shown success/failure messages; integration issues are an internal operational concern.
Wrong-drug errors are treated as urgent, since they can indicate a patient on the incorrect arm/regimen.
Example successful response
<Response ReferenceNumber="aacbaffe-8eed-45d7-bfe3-4916f4935af4" InboundODMFileOID="FromSureAdhereApp" IsTransactionSuccessful="1" SuccessStatistics="Rave objects touched: Subjects=0; Folders=0; Forms=0; Fields=4; LogLines=0" NewRecords=""></Response>Example failed response
<Response ReferenceNumber="7127e3d0-92e3-4448-97b2-d6338de897f2" InboundODMFileOID="FromSureAdhereApp" IsTransactionSuccessful="0" ReasonCode="RWS00041" ErrorOriginLocation="/ODM/ClinicalData[1]/SubjectData[1]/StudyEventData[1]/FormData[1]/ItemGroupData[1]/ItemData[1]" SuccessStatistics="Rave objects touched: Subjects=0; Folders=0; Forms=0; Fields=0; LogLines=0" ErrorClientResponseMessage="Field does not exist."></Response>Who to contact for failures
Errors about a subject ID or site → contact the client
Errors about forms/fields → contact the client
System errors from Rave itself → Medidata support & the client
Configuration
These elements are agreed per study and per environment, and drive the integration's behavior:
Setting | What it is | Where it lives |
|---|---|---|
Rave Web Services URL | The RWS endpoint for the study, provided by the client/Medidata | SureAdhere environment configuration |
Study OID (Rave environment) | Identifies the study and environment, e.g. | Per client, in SureAdhere's client settings |
Drug ↔ form mapping | For each drug: the adherence form OID and study event OID, and (if pill counts are used) the pill count form OID and study event OID | Admin panel → RAVE Drugs tab (SureAdhere admins can add, edit, and delete mappings) |
Regimen template names | Must exactly match the trial arm names EDC sends to the enrollment API | SureAdhere regimen templates |
Site codes | Must match between EDC and SureAdhere — used both for enrollment and as the | SureAdhere site configuration |
Integration credentials | The client provides Dimagi at least two Rave accounts with permission to update subject forms: one for testing environments (DEV/UAT) and one for production only. The production account must not have access to test environments. In the other direction, Dimagi issues the client an MRNIntegrationToken per environment. | Exchanged securely during integration setup |
Glossary
EDC — Electronic data capture system; the source of truth for clinical trial data. All current integrations use Medidata Rave.
RWS — Rave Web Services, Medidata's API for exchanging CDISC ODM v1.3 data with third-party systems. This integration was built against the Rave Web Services for Rave 5.6.4 User Guide.
CDISC ODM — the XML standard used for the clinical data payloads.
Subject ID — the trial's patient identifier; stored in SureAdhere as the MRN.
Trial arm — the treatment group; matched to a SureAdhere regimen template by name.
Log line — a repeating row on a Rave form; each patient-drug-day of adherence data is one log line.
Exposure — Rave's term for medication-taken data (the daily adherence records).
DOT / VDOT — (Video) Directly Observed Therapy.