Versions Compared

Key

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

Purpose

...

  1. With one request can be added only one activity to the Care plan

  2. Activity can be added by the employee who has an Approval granted by the patient on write Care plan resource

  3. Activity adds in async way. Result of the activity addition job should be link on the created activity (look at Get Care plan activity by ID).

  4. Activity should be signed with DS. Signed content stores in the media storage.

...

  • Get Care plan identifier from the URL

  • Check Care plan:

    • belongs to patient (from url)

      • in case of error - return 422 ('Care plan with such id is not found')

    • is not in final status

      • in case of error - return 422 ('Invalid care plan status')

    • Care plan’s period.end >= current date.

      • in case of error - return 422 ('Care Plan end date is expired')

...

  • Get person_id from URL

  • Validate patient status is active

    • in case of error - return 409 ('Person is not active')

  • Validate patient'sverification_status is not equal to NOT_VERIFIED.

    • in case of error return 409, "Patient is not verified"

Validate User

  • 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 write

...

  • Validate value with schema of Timing type

    • in case of error - return 422 schema validation error

  • If submitted, check values of the event within $.CarePlan.Period value

    • in case of error - return 422 ('event is not within care plan period range')

  • If submitted, check bounds_period within $.CarePlan.Period value

    • in case of bounds_period.end validation error - return 422 ('Period end time must be within care plan period range, after period start date')

    • in case of bounds_period.start validation error - return 422 ('Period start time must be within care plan period range')

  • If submitted, check bounds_duration within $.CarePlan.Period value. Calculate bounds start date as care plan period start date if activity creates before care plan has started, else if activity creates during care plan performing - bound start date calculates as activity creation date. Bounds end date as bounds start date plus count of days specified in bounds_duration.

    • If comparator field in bounds_duration - use it to compare bounds_duration value and care plan duration (possible values >, >=, =, <=, <)

    • in case of error - return 422 ('Bounds duration must be within care plan period range')

  • If submitted, check when field values are in EVENT_TIMING dictionary

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

  • If submitted, check bounds_range within $.CarePlan.Period value: calculate bounds start - end date for bounds_range.low and bounds_range.high as described for bounds_duration (but w/o comparator field). Also, validate low.code = high.code, high.value > low.value

    • in case bounds_range.low validation error - return 422 ('low must be within care plan period range, less than high, have the same code as high')

    • in case bounds_range.high validation error - return 422 ('high must be within care plan period range')

...

  • Validate value with schema of the Period type

    • in case of error - return 422 schema validation error

  • Check values within $.CarePlan.Period

    • in case period.end validation error - return 422 ('Period end time must be within care plan period range, after period start date')

    • in case period.start validation error - return 422 ('Period start time must be within care plan period range')

...

  • С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 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"

    • If product is 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 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 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 parameter CONDITIONS_ICD10_AM_ALLOWED or or/and and CONDITIONS_ICPC2_ALLOWED:

      • Check related Care plan has condition codes in in addresses field 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  or eHealth/ICPC2/condition_codes)

        • in case of error - return 422 “Care plan diagnosis with code #{condition_code} is not allowed for the medical program“

    • If there is a parameter parameter PROVIDING_CONDITIONS_ALLOWED:

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

        • in case of error - return 422 “Care plan’s terms of service are not allowed for the medical program“

Expand
titleHow to check medication is in program. Script example

SELECT *

FROM medications MI -- 2nd level: Medication - type = INNM_DOSAGE

INNER JOIN ingredients I

ON I.medication_child_id = MI.id

AND I.is_primary =TRUE

INNER JOIN medications MED -- 3rd level: Medication - type = BRAND

ON MED.type == BRAND

AND I.parent_id = MED.id

AND MED.is_active == TRUE

INNER JOIN program_medications MP

ON MP.medical_program_id == `$.product.identifier.value`

MED.id = MP.medication_id

AND MP.is_active == TRUE

AND MP.medication_request_allowed == TRUE

WHERE MI.id == $.medication_id

AND MI.type == INNM_DOSAGE

AND MI.is_active == TRUE

...

  1. Save signed content to media storage

  2. Save data to care_plan_activities collection in DB according to https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/2125038856/Care+plan+data+model_+EN

  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

  5. Create job and return it’s id.