Comments

A comment/update posted against a care enquiry or service user.

The comment object

Attributes

  • _id
    string

    A unique Id for the comment.

  • anonymized
    string

    The date/time the comment was anonymized (if anonymized).

  • care_enquiry
    string

    The care enquiry the comment was posted against.

  • comment
    string

    The body of the comment.

  • created
    string

    The date/time the comment was created.

  • location
    string

    The Id of the location this comment relates to.

  • modified
    string

    The date/time the comment was created.

  • pinned
    boolean

    Flag indicating if the comment should appear (pinned) on the details page for the associated care enquiry / service user.

  • service_user
    string

    The service user the comment was posted against.

  • user
    string

    The user that posted the comment.

  • user_sticky_label
    string

    A snapshot of the name of the user that posted the comment, used for scenarios where no user posted the comment or the user that posted the comment has been removed from CareHQ.

The comment object
{
    "_id": "6724fbcb4f73a2cebf638852",
    "anonymized": null,
    "care_enquiry": "6724fbca4f73a2cebf63858e",
    "comment": "Gordon has asked us to give him a call in 3 weeks as his sister is about to go into hospital for a minor operation and he would like to be able to visit the home with her when she is well enough.\n",
    "created": "2024-11-01 16:03:23",
    "location": "6724fbc74f73a2cebf6377fa",
    "modified": "2024-11-01 16:03:23",
    "pinned": true,
    "service_user": null,
    "user": "6724fbc74f73a2cebf637806",
    "user_sticky_label": "Mark Walford"
}

Create a comment

Parameters

  • care_enquiry
    optional

    The Id of the care enquiry the comment relates to.

  • comment
    required

    The body of the comment.

  • pinned
    optional

    A flag indicating if the comment should appear (pinned) on the details page for the associated care enquiry / service user.

  • service_user
    optional

    The Id of the service user the comment relates to.

  • user
    optional

    The Id of user posting the comment. If you do not specify a user then comment will be marked as posted by the API.

Response

Returns the comment object created.

PUT
/v1/comments
var comment = apiClient.Request(
    HttpMethod.Put,
    "comments",
    null,
    new MultiValueDict()
        .Add("care_enquiry", careEnquiryId)
        .Add(
            "comment",
            "Bob was a keen gardener before his and would " +
            "like a ground floor room that has views of the gardens."
        )
        .Add("pinned", true)
);
<?php

$comment = $api_client->request(
    'PUT',
    'comments',
    NULL
    [
        'care_enquiry'=>care_enquiry_id,
        'comment'=>'Bob was a keen gardener before his fall and would '
            . 'like a ground floor room that has views of the gardens.',
        'pinned'=>True
    ]
);
comment = api_client(
    'PUT',
    'comments',
    data={
        'care_enquiry': care_enquiry_id,
        'comment': (
            'Bob was a keen gardener before his fall and would like a '
            'ground floor room that has views of the gardens.'
        ),
        'pinned': True
    }
)
comment = api_client.request(
    'PUT',
    'comments',
    data: {
        'care_enquiry' => care_enquiry_id,
        'comment' => 'Bob was a keen gardener before his fall and would ' +
            'like a ground floor room that has views of the gardens.'
        ),
        'pinned' => true
    }
)
Response
{
    "_id": "6724fbd53cd2cde34170f2bc",
    "care_enquiry": "6724fbd54f73a2cebf638f1d",
    "comment": "Bob was a keen gardener before his fall and would like a ground floor room that has views of the gardens.",
    "created": "2024-11-01 16:03:33",
    "location": "6724fbc74f73a2cebf6377fa",
    "modified": "2024-11-01 16:03:33",
    "pinned": true,
    "service_user": null,
    "user_sticky_label": "CareHQ API: Demo (6724fbc74f73a2cebf6376fc)"
}

List all comments

Return a list of comments.

Parameters

  • attributes
    optional
    default ['_id']

    A list of attributes to include for fetched objects.

  • filters-anonymized
    optional
    default unset

    A filter that allows comments to be filtered by whether the comment is anonymized.

    • unset
    • yes
    • no
  • filters-care_enquiry
    optional

    A filter that accepts a list of care enquiry Ids and filters comments by the enquiry the comments are posted against.

  • filters-end_date
    optional

    A filter that accepts a date and filters comments to those posted before or on the end date.

  • filters-ids
    optional

    A filter that accepts a list of Ids and filters the items returned to those with an Id in the list.

  • filters-modified_after
    optional

    A filter that accepts a date/time and filters the items returned to those modified after the date/time.

  • filters-modified_before
    optional

    A filter that accepts a date/time and filters the items returned to those modified before the date/time.

  • filters-pinned
    optional
    default unset

    A filter that allows comments to be filtered by whether the comment is pinned.

    • unset
    • yes
    • no
  • filters-q
    optional

    A case insensitive keyword filter applied to the following fields; comment.

  • filters-service_user
    optional

    A filter that accepts a list of service user Ids and filters comments by the service user the comments are posted against.

  • filters-start_date
    optional

    A filter that accepts a date and filters comments to those posted after or on the start date.

  • filters-user
    optional

    A filter that accepts a list of user Ids and filters comments by the user that posted them.

  • page
    optional
    default 1

    The page number to fetch.

  • per_page
    optional
    default 10

    The number of items to return per page.

  • sort_by
    optional
    default _id

    A list of fields the returned items can be sorted by. Fields prefixed with minus (-) sign are sorted in descending order.

    • _id
    • created
    • modified

Response

Returns a page of comments.

GET
/v1/comments
var comments = apiClient.Request(
    HttpMethod.Get,
    "comments",
    new MultiValueDict()
        .Add("attributes", "comment")
        .Add("filters-q", "coffee")
);
<?php

$comments = $api_client->request(
    'GET',
    'comments',
    [
        'attributes'=>['comment'],
        'filters-q'=>'coffee'
    ]
);
comments = api_client(
    'GET',
    'comments',
    params={
        'attributes': ['comment'],
        'filters-q': 'coffee'
    }
)
comments = api_client.request(
    'GET',
    'comments',
    params: {
        'attributes' => ['comment'],
        'filters-q' => 'coffee'
    }
)
Response
{
    "item_count": 1,
    "items": [
        {
            "_id": "6724fbcb4f73a2cebf638854",
            "comment": "Anna's Gransdson Justin visits most weekends (coffee black + 1 sugar).\n\nSometimes Anna get's confused with the days and will ask what time he's comming, if she gets really agitated calling Justin so she can talk to him helps to calm her.\n"
        }
    ],
    "page": 1,
    "page_count": 1,
    "per_page": 10
}

Retrieve a comment

Retreive a comment object.

Response

Returns a comment object.

GET
/v1/comments/<comment_id>
var comment = apiClient.Request(HttpMethod.Get, $"comments/{commentId}");
<?php

$comment = $api_client->request('GET', 'comments/' . $comment_id);
comment = api_client('GET', f'comments/{comment_id}')
comment = api_client.request('GET', "comments/#{comment_id}")
Response
{
    "_id": "6724fbcb4f73a2cebf638852",
    "anonymized": null,
    "care_enquiry": "6724fbca4f73a2cebf63858e",
    "comment": "Gordon has asked us to give him a call in 3 weeks as his sister is about to go into hospital for a minor operation and he would like to be able to visit the home with her when she is well enough.\n",
    "created": "2024-11-01 16:03:23",
    "location": "6724fbc74f73a2cebf6377fa",
    "modified": "2024-11-01 16:03:23",
    "pinned": true,
    "service_user": null,
    "user": "6724fbc74f73a2cebf637806",
    "user_sticky_label": "Mark Walford"
}