Skip to content

Create and update patients

This guide covers creating and updating patient records in CollaborateMD, supporting both XML and HL7 payload formats.

Overview

Patient management operates on a “create or update” or “upsert” principle: if the API call matches an existing patient for that customer, the record is updated; if not, a new one is created. You do not need to check for existence first.

CollaborateMD has multiple ways of matching patients; the system works through the following list, stopping when it has narrowed down to one patient:

  • Using the Identifier (XML) or PID-2.0 (HL7) field matched to the CollaborateMD Patient Account Number. Store this in your system to always ensure an exact match.
  • Using the OtherIdentifier (XML) or the first repetition of PID-3.0 (HL7) matched to the patient’s Reference # in CollaborateMD. Use this to match the Patient in CollaborateMD based on your system’s ID (such as a Medical Records Number, MRN).
  • Using the SSN (XML) or PID-4.0 (HL7), if it has been provided and is already set on the patient account in CollaborateMD.
  • Finally, we will match by the LastName (PID-5.0), FirstName (PID-5.1), and BirthDate (PID-7.0) against what is currently on the record in CollaborateMD.
    • If multiple patients match at this point, the first match is used
    • If no patient match at this point, a new patient will be created

A stable identifier (either CMD’s identifier or your own) is the ideal method to ensure that patient matching is always successful.

Submitting a patient requires the PATIENT or ADMIN permission; the read-only lookups require PATIENT.

Endpoints

You can create or update patients using either XML or HL7 format:

New integrations should use v2. See v1 vs v2 for guidance.

Submitting Patient Data

Via XML

To create or update a patient via XML, send a POST request with the patient data in XML format and a Content-Type: application/xml header.

The body is a PatientUpdate document with two required child elements, both of which are wrappers — the patient’s own fields are nested inside <Patient>, not placed at the top level:

Element Required What it holds
Provider Yes The rendering provider. Resolved by Identifier, then NPI, then last and first name.
Patient Yes The patient’s demographic data.
Facility No The service facility.
Referring No The referring provider.
Ordering No The ordering provider.
Supervising No The supervising provider.

Within <Patient>, these four fields are required: LastName, FirstName, BirthDate, and Gender.

Identifying an existing patient is a cascade. We recommend that you supply at least one of Identifier (the CollaborateMD account number), OtherIdentifier (your own MRN), or SSN. If none is given, the patient is matched on LastName + FirstName + BirthDate.

<PatientUpdate>
<Provider>
<Identifier>4455</Identifier>
</Provider>
<Patient>
<OtherIdentifier>00123456</OtherIdentifier>
<LastName>Doe</LastName>
<FirstName>John</FirstName>
<BirthDate>01/15/1975</BirthDate>
<Gender>M</Gender>
<Address>
<Line1>123 Main St</Line1>
<City>Anytown</City>
<State>CA</State>
<Zipcode>12345</Zipcode>
</Address>
<HomePhone>555-0123</HomePhone>
</Patient>
</PatientUpdate>

Note the exact element names: BirthDate (not DateOfBirth), Zipcode (not ZipCode), HomePhone (not Phone), and an Address wrapper rather than flattened address fields. Gender accepts M, F, or U.

For the complete field reference, including every optional element, see the endpoint documentation: POST /v1/customer/{custno}/patient/xml

Via HL7

To create or update a patient via HL7, send a POST request with the patient data in HL7 ADT (Admission, Discharge, Transfer) message format.

Patient create/update requests use ADT messages, and the accepted trigger events are A04 (register a patient) and A08 (update patient information). Messages are HL7 v2.3.1, pipe-delimited.

For the field-by-field specification — including which fields are required, their lengths, and the accepted enumerations — see the HL7 Reference.

Example ADT^A04:

MSH|^~\&|SendingApp|SendingFacility|CMD|CMD|20240101120000||ADT^A04|12345|P|2.3.1
EVN|A04|20240101120000
PID|1|4021|00123456~V-1001||Doe^John||19750115|M|||123 Main St^^Anytown^CA^12345||555-0123
IN1|1||PAYER123|Payer Name|||||||||||Doe^John|18|19750115

The HL7 reference is the authority on segment content; the example above shows shape, not a complete message.

PID-3 repetitions

PID-3 can repeat. Repetitions are separated by ~ and are read by position. This is different from the component numbering used elsewhere in these docs (the .0 in PID-3.0), which counts the parts within one repetition.

Repetition Saved as Used for matching Max
1st Patient GUID if it is 36 characters long, otherwise Reference # Yes 20 (36 for a GUID)
2nd Visit ID No 50
3rd Reference # No 20

The 3rd repetition replaces any Reference # already on the patient. It is ignored if the same message already sets the Reference # through PID-18 or a non-GUID 1st repetition. A value longer than the maximum is logged as an invalid field and not saved, and blank values are ignored. A PID-18 that is rejected this way (blank or over 20 characters) is treated as if it wasn’t in the message, so the 1st repetition is handled as usual: as the GUID or as the Reference #. If the 1st repetition is also rejected, the 3rd repetition is used. Values are saved exactly as sent, including any spaces, so send the same value each time to keep matching on it.

PID|1||8dde407b-1b51-4df0-bac2-480658a6a3a0~AUR-2026-104-DETOX~36483||Doe^John||19900812|M

This message sets the GUID to 8dde407b-1b51-4df0-bac2-480658a6a3a0, the Visit ID to AUR-2026-104-DETOX, and the Reference # to 36483.

Content-Type: The HL7 endpoints declare no required request content type, so any value is accepted. The XML endpoints are the strict ones. See Content-Type Requirements for the per-endpoint table.

Retrieving and Searching for Patients

Read-only lookups; these never create records.

Retrieve one patient by account number:

The {patient} segment is the CollaborateMD account number — an integer. It is not your MRN. An invalid value returns Status: INVALID CRITERIA; a valid one that does not exist returns Status: NOT FOUND.

Search by demographics:

Accepts the optional query parameters firstName, lastName, birthDate, and SSN. Use this when you hold identifying details but not the account number.

Response Format

Responses are XML by default, and JSON when you send Accept: application/json. The JSON keys are the XML element names — Status, not status. The examples below show the JSON form.

A patient create/update returns a GenericResponseXML with exactly three fields:

{
"Status": "SUCCESS",
"StatusMessage": "10001001",
"Identifier": 4021
}

Two things to know about these fields:

  • Identifier is the API request ID. It identifies the API request that CollaborateMD recorded, and it is an integer. The patient account number is in the StatusMessage.
  • StatusMessage is the patient ID. as long as the Status is “SUCCESS.”

On failure, Identifier is absent and StatusMessage explains why:

{
"Status": "ERROR",
"StatusMessage": "Incorrect birth date format. Correct format is MM/DD/YYYY. Value:1975-01-15"
}

The v2 XML endpoint returns a richer ResponseWithReview instead, adding EligibilityReports, AddressVerifications, and Estimates alongside the same three base fields.

Always check the Status field — HTTP 200 does not mean success. See Reading Responses for the full convention.

Example Workflow

Create a patient via XML

Terminal window
# Credentials come from the environment, never from the script.
: "${CMD_API_USER:?set CMD_API_USER}"
: "${CMD_API_SECRET:?set CMD_API_SECRET}"
CUSTNO="12345678"
curl --fail-with-body --silent --show-error \
-X POST "https://webapi.example.com/v1/customer/$CUSTNO/patient/xml" \
--user "${CMD_API_USER}:${CMD_API_SECRET}" \
-H "Content-Type: application/xml" \
-d '<?xml version="1.0" encoding="UTF-8"?>
<PatientUpdate>
<Provider>
<Identifier>4455</Identifier>
</Provider>
<Patient>
<OtherIdentifier>00123456</OtherIdentifier>
<LastName>Doe</LastName>
<FirstName>John</FirstName>
<BirthDate>01/15/1975</BirthDate>
<Gender>M</Gender>
<Address>
<Line1>123 Main St</Line1>
<City>Anytown</City>
<State>CA</State>
<Zipcode>12345</Zipcode>
</Address>
<HomePhone>555-0123</HomePhone>
</Patient>
</PatientUpdate>'

Retrieve a patient by account number

Terminal window
# 4021 is the CollaborateMD account number, not your MRN.
curl --fail-with-body --silent --show-error \
"https://webapi.example.com/v1/customer/$CUSTNO/patient/find/4021/xml" \
--user "${CMD_API_USER}:${CMD_API_SECRET}"

Search when you only know demographics

Terminal window
curl --fail-with-body --silent --show-error \
--get "https://webapi.example.com/v1/customer/$CUSTNO/patient/find" \
--data-urlencode "lastName=Doe" \
--data-urlencode "firstName=John" \
--data-urlencode "birthDate=01/15/1975" \
--user "${CMD_API_USER}:${CMD_API_SECRET}"

Permissions

Patient creation and updating require either:

  • PATIENT role — Standard patient data access (typical for practice integrations)
  • ADMIN role — Administrative access (typically reserved for system integration accounts)

If your credential does not have the required permission, contact your account representative.

Next Steps