Procedure episode template API endpoint

A reusable template that prefills a new procedure episode.

Table of contents

  1. Endpoints
  2. Fields
  3. List
  4. Add
  5. Detail
  6. Change
  7. Delete

Endpoints

  • Private portal: https://www.brainstem.org/api/private/modules/procedureepisodetemplate/ (needs a token; one record: append <id>/)
  • Public portal: https://www.brainstem.org/api/public/modules/procedureepisodetemplate/ (read-only, public projects, no token)
  • Response keys: procedureepisodetemplate (detail, create, update), procedureepisodetemplates (list)
  • Permissions: inherited through projects (from project)

Fields

[required] fields must be sent on create; [read-only] fields are returned but cannot be set. A nestable relation can be traversed in filters (filter{field.other}) and sideloaded with include[]=field.*; other relations can only be compared with ids (filter{field}=<id>). See the query syntax.

FieldDescription
idUUID string [read-only]
namestring [required]; max 200 characters. Descriptive name for this template.
projectslist of project ids. Share with these projects. Leave empty to keep personal.
intervention_classone of anesthesia_only, surgical, non_surgical, euthanasia_tissue_collection, clinical_treatment, other [required]
intervention_class_displaycomputed [read-only]
protocolprotocol id; nullable
licenseslist of license ids
severitychoice (see the list below); nullable
recovery_outcomeone of unknown, recovered, ongoing_recovery, non_recovery, planned_terminal, humane_endpoint, unexpected_death, aborted, cancelled [required]
descriptionstring; nullable
summarycomputed [read-only]
useruser id [read-only]
created_atdatetime [read-only]; nullable
updated_atdatetime [read-only]
  • severity choices: eu_2010_63_non_recovery, eu_2010_63_mild, eu_2010_63_moderate, eu_2010_63_severe, uk_aspa_sub_threshold, uk_aspa_non_recovery, uk_aspa_mild, uk_aspa_moderate, uk_aspa_severe, us_iacuc_usda_no_pain_distress, us_iacuc_usda_pain_distress_relieved, us_iacuc_usda_pain_distress_unrelieved, ca_ccac_category_a, ca_ccac_category_b, ca_ccac_category_c, ca_ccac_category_d, ca_ccac_category_e, local_institutional_sub_threshold, local_institutional_non_recovery, local_institutional_mild, local_institutional_moderate, local_institutional_severe, not_applicable

List

  • Allowed portals: private, public
  • Request method: GET
  • URL: https://www.brainstem.org/api/private/modules/procedureepisodetemplate/
  • Responses: 200 OK; 401 Not authenticated; 403 Not allowed

Use example (Python API tool)

resp = client.load('procedureepisodetemplate', load_all=True)
records = resp['procedureepisodetemplates']

Use example (MATLAB API tool)

resp = client.load('procedureepisodetemplate', 'load_all', true);
records = resp.procedureepisodetemplates;

Response example

{
    "procedureepisodetemplates": [
        {
            "id": "<id>",
            "name": "Procedure episode template 1",
            "projects": [
                "<project-id>"
            ],
            "intervention_class": "anesthesia_only",
            "intervention_class_display": null,
            "protocol": "<protocol-id>",
            "licenses": [
                "<license-id>"
            ],
            "severity": "eu_2010_63_non_recovery",
            "recovery_outcome": "unknown",
            "description": "",
            "summary": null,
            "user": "<user-id>",
            "created_at": "2024-03-22T10:30:00Z",
            "updated_at": "2024-03-22T10:30:00Z"
        }
    ],
    "meta": {
        "page": 1,
        "per_page": 100,
        "total_results": 1,
        "total_pages": 1
    }
}

Add

  • Allowed portals: private
  • Request method: POST
  • URL: https://www.brainstem.org/api/private/modules/procedureepisodetemplate/
  • Data: JSON object with at least the required fields
  • Responses: 201 Created; 400 Bad request (validation errors per field); 403 Not allowed

Use example (Python API tool)

resp = client.save('procedureepisodetemplate', data={"name": "Procedure episode template 1", "intervention_class": "anesthesia_only", "recovery_outcome": "unknown"})
record = resp.json()['procedureepisodetemplate']

Use example (MATLAB API tool)

created = client.save(struct('name', 'Procedure episode template 1', 'intervention_class', 'anesthesia_only', 'recovery_outcome', 'unknown'), 'procedureepisodetemplate');
record = created.procedureepisodetemplate;

Detail

  • Allowed portals: private, public
  • Request method: GET
  • URL: https://www.brainstem.org/api/private/modules/procedureepisodetemplate/<id>/
  • Responses: 200 OK; 403 Not allowed; 404 Not found

Use example (Python API tool)

resp = client.load('procedureepisodetemplate', id='<id>')
record = resp.json()['procedureepisodetemplate']

Use example (MATLAB API tool)

out = client.load('procedureepisodetemplate', 'id', '<id>');
record = out.procedureepisodetemplate;

Response example

{
    "procedureepisodetemplate": {
        "id": "<id>",
        "name": "Procedure episode template 1",
        "projects": [
            "<project-id>"
        ],
        "intervention_class": "anesthesia_only",
        "intervention_class_display": null,
        "protocol": "<protocol-id>",
        "licenses": [
            "<license-id>"
        ],
        "severity": "eu_2010_63_non_recovery",
        "recovery_outcome": "unknown",
        "description": "",
        "summary": null,
        "user": "<user-id>",
        "created_at": "2024-03-22T10:30:00Z",
        "updated_at": "2024-03-22T10:30:00Z"
    }
}

Change

  • Allowed portals: private
  • Request method: PATCH
  • URL: https://www.brainstem.org/api/private/modules/procedureepisodetemplate/<id>/
  • Data: JSON object with the fields to change. Lists (projects, tags, …) and JSON payloads (details, coordinates) are replaced as a whole: read the record first and send the full list or object.
  • Responses: 200 OK; 400 Bad request; 403 Not allowed; 404 Not found

Use example (Python API tool)

resp = client.save('procedureepisodetemplate', id='<id>', data={"name": "Procedure episode template 1 (renamed)"})

Use example (MATLAB API tool)

client.save(struct('id', '<id>', 'name', 'Procedure episode template 1 (renamed)'), 'procedureepisodetemplate', 'method', 'patch');

Delete

  • Allowed portals: private
  • Request method: DELETE
  • URL: https://www.brainstem.org/api/private/modules/procedureepisodetemplate/<id>/
  • Responses: 204 Deleted; 400 Still referenced by other records; 403 Not allowed; 404 Not found

Use example (Python API tool)

resp = client.delete('procedureepisodetemplate', id='<id>')

Use example (MATLAB API tool)

client.delete('<id>', 'procedureepisodetemplate');