Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Виправлення некоректних посилань.
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')

...

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/MRINEH/pages/19573637972125038856/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.