Skip to Content

ECM Activities API

Administrative endpoints for viewing and managing ECM patient activities. Activities track all interactions with ECM patients including tasks, notes, SMS, calls, emails, and in-person appointments.

Activity Types

The ECM system supports the following activity types:

TypeDescriptionRequired Fields
taskA task assigned to a care coordinatormessage, assigned_to_id
noteA general note about the patientbody, assigned_to_id
smsAn SMS message sent to or received from the patientbody, text_message_id, assigned_to_id
callA phone call with the patientvoice_call_id, assigned_to_id
emailAn email sent to the patientemail_to, body, assigned_to_id
in_person_appointmentAn in-person meeting with the patientbooked_at, assigned_to_id

List Patient Activities

Get a paginated list of activities for a specific ECM patient.

Endpoint: GET /v1/clinic/ecm/patients/{patient_id}/activities
Authentication: Required

Path Parameters

ParameterTypeRequiredDescription
patient_idintegerYesPatient ID

Query Parameters

ParameterTypeRequiredDescription
pageintegerNoPage number for pagination (default: 1)
page_sizeintegerNoNumber of items per page (default: 25)
activity_typestringNoFilter by activity type
assigned_to_idintegerNoFilter by assigned user ID
statusstringNoFilter by status (created, complete, cancelled)

Example Request

GET /v1/clinic/ecm/patients/123/activities?activity_type=task&status=created HTTP/1.1 Content-Type: application/json X-User-Token: your_token_here

Example Response

{ "activities": [ { "id": 1, "activity_type": "task", "status": "created", "message": "Follow up with patient about medication", "subject": "Medication Follow-up", "body": null, "occurred_at": "2024-11-20T10:00:00.000Z", "patient_id": 123, "patient_name": "John Doe", "performed_by_id": 456, "performed_by_name": "Jane Coordinator", "assigned_to_id": 789, "assigned_to_name": "Bob Manager", "parent_id": null, "comments_count": 2, "created_at": "2024-11-20T10:00:00.000Z", "updated_at": "2024-11-20T10:00:00.000Z" } ], "pagination": { "current_page": 1, "total_pages": 3, "total_count": 65, "per_page": 25 } }

Get Activity Details

Retrieve detailed information about a specific activity.

Endpoint: GET /v1/clinic/ecm/patients/{patient_id}/activities/{id}
Authentication: Required

Path Parameters

ParameterTypeRequiredDescription
patient_idintegerYesPatient ID
idintegerYesActivity ID

Example Request

GET /v1/clinic/ecm/patients/123/activities/1 HTTP/1.1 Content-Type: application/json X-User-Token: your_token_here

Example Response

{ "activity": { "id": 1, "activity_type": "task", "status": "created", "message": "Follow up with patient about medication", "subject": "Medication Follow-up", "body": "Need to check if patient has started new medication regimen", "occurred_at": "2024-11-20T10:00:00.000Z", "booked_at": null, "email_to": null, "transcript": null, "patient_id": 123, "patient_name": "John Doe", "performed_by_id": 456, "performed_by_name": "Jane Coordinator", "assigned_to_id": 789, "assigned_to_name": "Bob Manager", "parent_id": null, "blocked_by_id": null, "blocking_id": null, "voice_call_id": null, "text_message_id": null, "comments": [ { "id": 1, "body": "Called patient, no answer", "user_id": 789, "user_name": "Bob Manager", "created_at": "2024-11-20T14:00:00.000Z" } ], "subtasks": [], "event": { "id": 1, "event_type": "task", "occurred_at": "2024-11-20T10:00:00.000Z", "status": "created" }, "created_at": "2024-11-20T10:00:00.000Z", "updated_at": "2024-11-20T14:00:00.000Z" } }

Create Activity

Create a new activity for an ECM patient.

Endpoint: POST /v1/clinic/ecm/patients/{patient_id}/activities
Authentication: Required

Path Parameters

ParameterTypeRequiredDescription
patient_idintegerYesPatient ID

Request Body Parameters

ParameterTypeRequiredDescription
activityobjectYesActivity data object
activity.activity_typestringYesType of activity (task, note, sms, call, email, in_person_appointment)
activity.assigned_to_idintegerYesUser ID of the assignee
activity.messagestringConditionalTask message (required for task type)
activity.bodystringConditionalActivity body content (required for note, sms, email types)
activity.subjectstringNoActivity subject line
activity.email_tostringConditionalEmail recipient (required for email type)
activity.booked_atstringConditionalAppointment date/time (required for in_person_appointment type)
activity.voice_call_idintegerConditionalVoice call ID (required for call type)
activity.text_message_idintegerConditionalText message ID (required for sms type)
activity.parent_idintegerNoParent task ID for subtasks
activity.blocked_by_idintegerNoID of blocking activity
activity.blocking_idintegerNoID of activity this blocks
activity.occurred_atstringNoWhen the activity occurred (ISO 8601)
activity.statusstringNoActivity status (created, complete, cancelled)
activity.email_attachmentsarrayNoArray of attachment URLs for email activities

Example Request - Create Task

POST /v1/clinic/ecm/patients/123/activities HTTP/1.1 Content-Type: application/json X-User-Token: your_token_here { "activity": { "activity_type": "task", "assigned_to_id": 789, "message": "Schedule follow-up appointment with patient", "subject": "Follow-up Scheduling" } }

Example Request - Create Note

POST /v1/clinic/ecm/patients/123/activities HTTP/1.1 Content-Type: application/json X-User-Token: your_token_here { "activity": { "activity_type": "note", "assigned_to_id": 789, "body": "Patient reported feeling better after starting new medication. Will continue monitoring progress.", "subject": "Progress Note" } }

Example Request - Create In-Person Appointment

POST /v1/clinic/ecm/patients/123/activities HTTP/1.1 Content-Type: application/json X-User-Token: your_token_here { "activity": { "activity_type": "in_person_appointment", "assigned_to_id": 789, "booked_at": "2024-12-01T14:00:00.000Z", "subject": "Monthly Check-in", "body": "Monthly in-person check-in with patient and family" } }

Example Request - Create Email Activity

POST /v1/clinic/ecm/patients/123/activities HTTP/1.1 Content-Type: application/json X-User-Token: your_token_here { "activity": { "activity_type": "email", "assigned_to_id": 789, "email_to": "[email protected]", "subject": "Care Plan Update", "body": "Dear Parent,\n\nWe wanted to update you on your child's care plan...", "email_attachments": ["https://storage.example.com/documents/care-plan.pdf"] } }

Success Response

{ "activity": { "id": 2, "activity_type": "task", "status": "created", "message": "Schedule follow-up appointment with patient", "subject": "Follow-up Scheduling", "patient_id": 123, "performed_by_id": 456, "assigned_to_id": 789, "created_at": "2024-11-21T10:00:00.000Z", "updated_at": "2024-11-21T10:00:00.000Z" } }

Update Activity

Update an existing activity.

Endpoint: PUT /v1/clinic/ecm/patients/{patient_id}/activities/{id}
Authentication: Required

Path Parameters

ParameterTypeRequiredDescription
patient_idintegerYesPatient ID
idintegerYesActivity ID

Request Body Parameters

Same as Create Activity, all fields optional.

Example Request - Mark Task Complete

PUT /v1/clinic/ecm/patients/123/activities/1 HTTP/1.1 Content-Type: application/json X-User-Token: your_token_here { "activity": { "status": "complete" } }

Delete Activity

Delete an activity.

Endpoint: DELETE /v1/clinic/ecm/patients/{patient_id}/activities/{id}
Authentication: Required

Path Parameters

ParameterTypeRequiredDescription
patient_idintegerYesPatient ID
idintegerYesActivity ID

Example Request

DELETE /v1/clinic/ecm/patients/123/activities/1 HTTP/1.1 Content-Type: application/json X-User-Token: your_token_here

Success Response

HTTP/1.1 204 No Content

Subtasks

Activities of type task can have subtasks. Subtasks are created by setting the parent_id field to the ID of the parent task.

Example Request - Create Subtask

POST /v1/clinic/ecm/patients/123/activities HTTP/1.1 Content-Type: application/json X-User-Token: your_token_here { "activity": { "activity_type": "task", "assigned_to_id": 789, "message": "Call patient to confirm appointment time", "parent_id": 1 } }

Activity Comments

Activities can have comments added by care coordinators.

Activity Comment Fields

FieldTypeDescription
idintegerComment ID
bodystringComment content
user_idintegerID of user who created the comment
user_namestringName of user who created the comment
created_atstringWhen the comment was created

Events

When an activity is created, a corresponding event is automatically generated. Events are used for PRTF report generation and tracking patient encounters.

Event Fields

FieldTypeDescription
idintegerEvent ID
event_typestringType of event (matches activity type)
occurred_atstringWhen the event occurred
statusstringEvent status
subjectstringEvent subject
bodystringEvent body
durationintegerDuration in minutes

Error Responses

404 Not Found - Patient

{ "errors": ["Patient not found"] }

404 Not Found - Activity

{ "errors": ["Activity not found"] }

422 Unprocessable Entity

{ "errors": ["Message can't be blank", "Assigned to can't be blank"] }

Notes

  • All activities are automatically associated with the authenticated user as the performed_by user
  • Creating an activity automatically creates a corresponding event for PRTF reporting
  • Email activities will send an actual email to the specified recipient when created
  • SMS and call activities should be created through the Communications API which handles Twilio integration
  • Subtasks can only be created under task-type activities