Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
minLevel1
maxLevel3

Purpose

This WS allows to add activity to the specified Care plan.

https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/2125038637/care+plan#%D0%A1%D1%82%D0%B2%D0%BE%D1%80%D0%B5%D0%BD%D0%BD%D1%8F-%D0%BF%D0%B5%D1%80%D0%B2%D0%B8%D0%BD%D0%BD%D0%BE%D0%B3%D0%BE-%D0%BF%D1%80%D0%B8%D0%B7%D0%BD%D0%B0%D1%87%D0%B5%D0%BD%D0%BD%D1%8F-%D0%BF%D0%BB%D0%B0%D0%BD%D1%83-%D0%BB%D1%96%D0%BA%D1%83%D0%B2%D0%B0%D0%BD%D0%BD%D1%8F

Specification

...

Link

...

https://medicaleventsmisapi.docs.apiary.io/#reference/care-plan/create-care-plan-activity/create-care-plan-activity

...

Resource

...

/api/patients/{{patient_id}}/care_plans/{{care_plan_id}}/activities

...

Scope

...

care_plan:write

...

Components

...

Care plan

...

Microservices

me/api-medical-events

me/event-consumer

me/kafka-consumer

Table of Contents
minLevel1
maxLevel3

Purpose

This WS allows to add activity to the specified Care plan.

https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/2125038637/care+plan#%D0%A1%D1%82%D0%B2%D0%BE%D1%80%D0%B5%D0%BD%D0%BD%D1%8F-%D0%BF%D0%B5%D1%80%D0%B2%D0%B8%D0%BD%D0%BD%D0%BE%D0%B3%D0%BE-%D0%BF%D1%80%D0%B8%D0%B7%D0%BD%D0%B0%D1%87%D0%B5%D0%BD%D0%BD%D1%8F-%D0%BF%D0%BB%D0%B0%D0%BD%D1%83-%D0%BB%D1%96%D0%BA%D1%83%D0%B2%D0%B0%D0%BD%D0%BD%D1%8F

Specification

Page Properties

Link

https://medicaleventsmisapi.docs.apiary.io/#reference/care-plan/create-care-plan-activity/create-care-plan-activity

Resource

/api/patients/{{patient_id}}/care_plans/{{care_plan_id}}/activities

Scope

care_plan:write

Components

Care plan

Microservices

me/api-medical-events

me/event-consumer

me/kafka-consumer

il/api(rpc)

Protocol type

REST

Request type

POST

Sync/Async

Async

Public/Private/Internal

Public

...

PROVIDING_CONDITIONS_ALLOWED

INNM_DOSAGE

eHealth/activity_remaining_quantity_types

Request structure

See on Apiary

...

  • Verify the validity of access token

    • Return (401, 'Invalid access token') in case of validation fails

  • Verify that token is not expired

    • in case of error - return (401, 'Invalid access token')

  • Check user scopes in order to perform this action (scope = 'care_plan:write')

    • Return (403, 'Your scope does not allow to access this resource. Missing allowances: care_plan:write') in case of invalid scope(s)

Headers

Наприклад:

Content-Type:application/json
Authorization:Bearer {{access_token}}
API-key:{{mis_client_secret}}

...

  • Extract user_id from token.

  • Check user has an active and approved employee from legal entity (token) that:

    • has an active Approval granted by the Patient on write the Care plan resource (care plan id from URL)

      • Return 403 ('Access denied') in case employee has no Approval on writeno Approval on write

  • Check user's employee is from the same legal entity (token) as managing_organisation from the care_plan:

    • Return 422 ('User is not allowed to create care plan activity for this care plan') in case employee’s legal_entity do not match managing_organisation of related care_plan

Validate Digital Sign

  • Validate request is signed

    • in case of error - return 422 (“document must be signed by 1 signer but contains 0 signatures”)

  • Check DS is valid and not expired

  • Validate that DS belongs to the author of the activity

    • Check that DRFO from DS and user's party.tax_id matches

      • in case of error - return 409 (“Signer DRFO doesn't match with requester tax_id“)

...

  • Check that value matches with values in eHealth/ICD10_AM/condition_codes dictionarycodes dictionary

    • in case of error - return 422 ('value is not allowed in enum')

4. Reason reference

Validate value in the field $.detail.reason_reference, if submitted

  • Check that value is an array with references of condition, observation, diagnostic report or clinical impression types.

    • in case of error - return 422 ('value is not allowed in enum')

  • Check that each reference:

    • is valid ME

    • belongs to the patient ($.subject)

      • in case of error - return 422 ('

      value
      • <medical event type> with such ID is not

      allowed in enum
      • found')

4. Reason reference

...

  • If $.detail.reason_reference

...

  • Check that value is an array with references of condition, observation, diagnostic report or clinical impression types.=clinical_impression:

    • Check that clinical impression is valid based on clinical_impression.code.coding.code and CLINICAL_IMPRESSION_PATIENT_CATEGORIES_<CODE.VALUE>_VALIDITY_PERIOD chart parameter: difference between now() and $.clinical_impression.effective_date_time OR $.clinical_impression.effective_period.end date must be less than a value in chart parameter (pointed in config for a corresponding care plan category) for clinical impression code

      • in case of error - return 422 (

      'value is not allowed in enum'
      • "Clinical impression with patient category exceeds validity period")

    • Check that

    each reference:
    • is valid ME

    • belongs to the patient ($.subject)

      • in case of error - return 422 ('<medical event type> with such ID is not found')

    If $.detail.reason_reference=clinical_impression:

    • Check that clinical impression is valid based on clinicalclinical impression is based on active rule engine rule (exists record in rule_engine_rules collection with is_active=true, code.code=clinical_impression.code.coding.code, code.system=clinical_impression.code.coding.code and CLINICAL_IMPRESSION_PATIENT_CATEGORIES_<CODE.VALUE>_VALIDITY_PERIOD chart parameter: difference between now() and $.clinical_impression.effective_date_time OR $.clinical_impression.effective_period.end date must be less than a value in chart parameter (pointed in config for a corresponding care plan category) for clinical impression codesystem)

      • if true - check that clinical impression still corresponds to configured rule

        • in case of error - return 422 (“Clinical impression with patient category does not correspond to rule engine rule“)

      • if false - skip rule validation

5. Goal

Validate value in the field $.detail.goal, if submitted

  • Check that value matches with values in eHealth/care_plan_activity_goals dictionary

    • in case of error - return 422 (

      "Clinical impression with patient category exceeds validity period")
    • Check that clinical impression is based on active rule engine rule (exists record in rule_engine_rules collection with is_active=true, code.code=clinical_impression.code.coding.code, code.system=clinical_impression.code.coding.system)

      • if true - check that clinical impression still corresponds to configured rule

        • in case of error - return 422 (“Clinical impression with patient category does not correspond to rule engine rule“)

      • if false - skip rule validation

5. Goal

Validate value in the field $.detail.goal, if submitted

  • Check that value matches with values in eHealth/care_plan_activity_goals dictionary

    • in case of error - return 422 ('value is not allowed in enum')

6. Quantity

Validate value in the field $.detail.quantity, if submitted

  • Check $.detail.quantity.value is not empty, is integer, greater than zero

    • Return 422 schema validation error

...

    • 'value is not allowed in enum')

6. Quantity

Validate value in the field $.detail.quantity, if submitted

  • Check $.detail.quantity.value is not empty, is fractional, greater than zero

    • Return 422 schema validation error

Validate $.detail.quantity.system, $.detail.quantity.code fields and their values in the object $.detail.quantity

  • If $.detail.kind=medication_request:

    • Check (by schemata) the $.detail.quantity.system field’s value is MEDICATION_UNIT.

      • Return 422 ('value is not allowed in enum')

    • Check the $.detail.quantity.code field’s value equals to dosage.denumerator_unit of one of INNMs of a INNM_DOSAGE where innms with is_primary = true

      • Return 422 ('Code field of quantity object should be equal to denumerator_unit of one of medication’s innms')

  • If $.detail.kind is other than medication_request:

    • Check the $.detail.quantity.system field is not present.

      • Return 422 ('System field of quantity object is not allowed for kind other than medication_request')

    • Check the $.detail.quantity.code field is not present.

      • Return 422 ('Code field of quantity object is not allowed for kind other than medication_request')

  • If $.detail.kind=medicationservice_request:

    • Check (by schemata) the that $.detail.quantity.system field’s value is MEDICATIONSERVICE_UNIT, if submitted.

      • Return 422 ('value is not allowed in enum')

    • Check the $.detail.quantity.code field’s value equals to dosage.denumerator_unit of one of INNMs of a INNM_DOSAGE where innms with is_primary = true

      • Return 422 ('Code field of quantity object should be equal to denumerator_unit of one of medication’s innms')

    If $.detail.kind is other than medication_request:

    • Check the If care plan category is class_23, class_24 or class_25:

      • Check $.detail.quantity.system

      field is not present.
      • Return 422 ('System field of quantity object is not allowed for kind other than medication_request')

      Check the
      • and $.detail.quantity.code are set, $.detail.quantity.code

      field is not present.
      • = MINUTE

        • Return 422 ('Code field of quantity object

        is not allowed for kind other than medication_request
        • should be in MINUTE for care plan’s category <category code>')

  • Set remaining_quantity.value = $.detail.quantity.value, and use for remaining_quantity.system, remaining_quantity.code, remaining_quantity.unit fields, which were specified in $.detail.quantity object.

...

  • Check the value is valid reference o employee resource

  • Check employee is active and approved

    • Return 422 ('Invalid employee status')

10. Daily amount

If submitted, check $.detail.daily_amount has the same code and system as quantity field.

  • Return 422 ('Units of daily_amount field should be equal to units of quantity field')

Validate value in the field $.detail.daily_amount, if submitted.

  • Check activity kind is medication_request

    • Return 422 ('Field is allowed for medication request activities only') in case kind is not medication_request

Validate $.detail.daily_amount.system, $.detail.daily_amount.code fields and their values in the object $.detail.daily_amount

  • If $.detail.kind=medication_request:

    • Check (by schemata) the $.detail.daily_amount.system field’s value is MEDICATION_UNIT.

      • Return 422 ('value is not allowed in enum')

    • Check the $.detail.daily_amount.code field’s value equals to dosage.denumerator_unit of one of INNMs of a INNM_DOSAGE where innms with is_primary = true

      • Return 422 ('Code field of daily_amount object should be equal to denumerator_unit of one of medication’s innms')

  • If $.detail.kind is other than medication_request:

    • Check the $.detail.daily_amount.system field is not present.

      • Return 422 ('System field of daily_amount object is not allowed for kind other than medication_request')

    • Check the $.detail.daily_amount.code field is not present.

      • Return 422 ('Code field of daily_amount object is not allowed for kind other than medication_request')

11. Medical program

Validate field exists for kind = medication_request

...

  • Сheck program exists and active

    • in case not found or is_active==false return 404 "Program not found"

  • Validate product is program participant:

    • If product is medication - validate:

      • that medication has brand that is an active member of the program (program_medications table)

        • in case not found or is_active==false return 422 "Medication is not included in the program"

      • that care_plan_activity_allowed for program medication == true

        • in case ==false return 422 "Forbidden to create care plan activity for this medication!"

    • If product is service - validate that service is an active member of the program

      • in case not found or is_active==false return 422 "Service is not included in the program"

    • if product is service_group - validate that service group is an active member of the program

      • in case not found or is_active==false return 422 "Service group is not included in the program"

    Validate medical program settings (prm.medical_programs table):

    • if there is a parameter SPECIALITY_TYPES_ALLOWED:

      Check author’s speciality is present in SPECIALITY_TYPES_ALLOWED

      program

      • in case not found or is_active==false return 422 "Service is not included in the program"

    • if product is service_group - validate that service group is an active member of the program

      • in case not found or is_active==false return 422 "Service group is not included in the program"

  • Validate medical program settings (prm.medical_programs table):

    • if there is a parameter SPECIALITY_TYPES_ALLOWED:

      • Check author’s speciality is present in SPECIALITY_TYPES_ALLOWED

        • in case of error - return 422 “Author’s specialty doesn't allow to create activity with medical program from request”

    • if there is a parameter CONDITIONS_ICD10_AM_ALLOWED or/and CONDITIONS_ICPC2_ALLOWED:

      • Check related Care plan has condition codes in addresses field that correspond to codes pointed in CONDITIONS_ICD10_AM_ALLOWED or/and CONDITIONS_ICPC2_ALLOWED (depending on dictionary - eHealth/ICD10_AM/condition_codes or eHealth/ICPC2/condition_codes)

        • in case of error - return 422 “Care plan diagnosis is not allowed for the medical program“

    • If there is a parameter PROVIDING_CONDITIONS_ALLOWED:

      • Check related Care plan has a value in terms_of_service field that is included in the list of PROVIDING_CONDITIONS_ALLOWED parameter

        • in case of error - return 422 “Author’s specialty doesn't allow to create activity with medical program from request”“Care plan’s terms of service are not allowed for the medical program“

    • if there is a parameter CONDITIONSpatient_ICD10_AM_ALLOWED or/and CONDITIONS_ICPC2_ALLOWED:

      Check related Care plan has condition codes in addresses field

      categories_allowed:

      • check that patient_categories_allowed has codes in $.detail.reason_reference.[].clinical_impression.code.[].code that correspond to codes pointed in CONDITIONSpatient_ICD10_AM_ALLOWED or/and CONDITIONS_ICPC2_ALLOWED (depending on dictionary - eHealth/ICD10_AM/condition_codes or eHealth/ICPC2/condition_codes)categories_allowed

        • in case of error - return 422 "Clinical impression with patient category should be present in request for this medical program".

12. Do not perform flag

Validate value in the field $.do_not_perform

  • Check it is false

    • in case of error - return 422

      “Care plan diagnosis is not allowed for the medical program“

      If there is a parameter PROVIDING_CONDITIONS_ALLOWED:

      Check related Care plan has a value in terms_of_service field that is included in the list of PROVIDING_CONDITIONS_ALLOWED parameter

      ('not allowed in enum')

13. Status

Validate value in the field $.status

  • Check it has value = scheduled

    • in case of error - return 422

      “Care plan’s terms of service are not allowed for the medical program“
    • if there is a parameter patient_categories_allowed:

      • check that patient_categories_allowed has codes in $.detail.reason_reference.[].clinical_impression.code.[].code that correspond to codes pointed in patient_categories_allowed

        • in case of error - return 422 "Clinical impression with patient category should be present in request for this medical program".

12. Do not perform flag

Validate value in the field $.do_not_perform

  • Check it is false

    • in case of error - return 422 ('not allowed in enum')

13. Status

Validate value in the field $.status

  • Check it has value = scheduled

    • in case of error - return 422 ('value is not allowed in enum')

Processing

...

Save signed content to media storage

...

Save data to care_plan_activities collection in DB according to Care plan data model

  1. for kind = medication_request

    1. add unit (and its value) field into quantity, daily_amount, objects based on system, code out of MEDICATION_UNIT dictionary.

    2. add system, code, unit fields into remaining_quantity based on quantity object

...

Save link from media storage to the $.signed_content_links field in care plan activities collection

If Care plan has status = new:

...

Set care plan status = active

Check if patient has another active or/and new Care plans with such condition code in the addresses field and the same terms of service:

...

    • ('value is not allowed in enum')

Processing

  1. Save signed content to media storage

  2. Save data to care_plan_activities collection in DB according to Care plan data model

    1. for kind = medication_request

      1. add unit (and its value) field into quantity, daily_amount, objects based on system, code out of MEDICATION_UNIT or SERVICE_UNIT dictionary.

      2. add system, code, unit fields into remaining_quantity based on quantity object

  3. Save link from media storage to the $.signed_content_links field in care plan activities collection

  4. If Care plan has status = new:

    • Set care plan status = active

    • Check if patient has another active or/and new Care plans with such condition code in the addresses field and the same terms of service:

      • If such Care plans found - set these Care plans statuses to TERMINATED (related activities doesn`t change their status)

  5. Set $.details.remaining_quantity_type:

    1. If $.details.kind = medication_request check $.details.quantity:

      1. if $.details.quantity = null then set $.details.remaining_quantity_type = null

      2. if $.details.quantity is not null then:

        1. set $.details.remaining_quantity_type = for_request

    2. If $.details.kind = service_request check $.details.quantity:

      1. if $.details.quantity = null then set $.details.remaining_quantity_type = null

      2. if $.details.quantity is not null then check $.details.quantity.code:

        1. if $.details.quantity.code is not null then set $.details.remaining_quantity_type = for_request

        2. if $.details.quantity.code = null then set $.details.remaining_quantity_type = for_use

  6. Create job and return it’s id.

...

Page Properties

HTTP status code

Message

What caused the error

201

Response

 Sync. Use payload from response

202

Response

 Async: default method. use Get job details to get processing result. Response payload will be returned in the job details

401

Invalid access token

  • validation fails

  • token is expired

403

  • Your scope does not allow to access this resource. Missing allowances: care_plan:write

  • Access denied

  • invalid scope(s)

409

  • client_id refers to legal entity that is not active

  • client_id refers to legal entity with type that is not allowed to create medical events transactions

  • Person is not active

  • Patient is not verified

  • Signer DRFO doesn't match with requester tax_id

  • Care Plan from url does not match to Care Plan ID specified in body

422

  • document must be signed by 1 signer but contains 0 signatures

  • Medical program must be submitted for kind = medication_request

  • Activity with such id already exists

  • Care plan with such id is not found

  • Invalid care plan status

  • Care Plan end date is expired

  • User is not allowed to create care plan activity for the employee

  • Value is not allowed in enum

  • Cannot refer to service for kind = medication_request

  • Medication should be active

  • Medication does not exist

  • Another activity with status ‘scheduled' or ‘in_progress' already exists in the current Care plan

  • Cannot refer to medication for kind = service_request

  • <Service/Service group> should be active

  • Another activity with status ‘scheduled' or ‘in_progress' already exists in the current Care plan

  • <medical event type> with such ID is not found

  • Clinical impression with patient category does not correspond to rule engine rule

  • Code field of quantity object should be equal to denumerator_unit of one of medication’s innms

  • System field of quantity object is not allowed for kind other than medication_request

  • Code field of quantity object is not allowed for kind other than medication_request

  • Only one of the parameters must be present

  • Event is not within care plan period range

  • Period end time must be within care plan period range, after period start date

  • Period start time must be within care plan period range

  • Bounds duration must be within care plan period range

  • Low must be within care plan period range, less than high, have the same code as high

  • High must be within care plan period range

  • String does not match pattern

  • Division is not active

  • Invalid employee status

  • Field is allowed for medication request activities only

  • Code field of daily_amount object should be equal to denumerator_unit of one of medication’s innms

  • System field of daily_amount object is not allowed for kind other than medication_request

  • Code field of daily_amount object is not allowed for kind other than medication_request

  • Program not found

  • Forbidden to create care plan activity for this medication!

  • Clinical impression with patient category exceeds validity period

  • Medication is not included in the program

  • Service is not included in the program

  • Service group is not included in the program

  • Author’s specialty doesn't allow to create activity with medical program from request

  • Care plan diagnosis is not allowed for the medical program

  • Care plan’s terms of service are not allowed for the medical program

  • Clinical impression with patient category should be present in request for this medical program

  • User is not allowed to create care plan activity for this care plan

  • Code field of quantity object should be in MINUTE for care plan’s category <category code>

  • Units of daily_amount field should be equal to units of quantity field

Validation error