Versions Compared

Key

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

Purpose

This WS allows to prequalify care plan activity in order to define whether the medical program could be applied in this particular case or not.

...

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

  2. Activity shouldn’t be signed with DS

Specification

Apiary

Authorization

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

...

  • Check value in enum: medication_request, service_request, device_request

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

2. Product

Check there is one of the required $.detail.product_[x] field is set: product_reference or product_codeable_concept.

  • Return 422 ('Only one of the parameters must be present') in case more then one submitted

If $detail.kind=medication_request:

  • Check $.detail.product_reference field is submittedand has Reference type

    • in case it isn’t submitted - return 422 ('can't be blank')

    • in case of wrong type - return 422 ('type mismatch')

  • Check the value is valid reference on medication resource.

    • Return 422 ('Cannot refer to <resource> for kind = medication_request')

  • Check medication:

    • is active

      • in case of error - return 422 ('Medication should be active')

    • type is INNM_DOSAGE

      • in case of error - return 422 ('Medication does not exist')

If $.detail.kind=service_request:

  • Check $.detail.product_reference field is submitted and has Reference type

    • in case it isn’t submitted - return 422 ('can't be blank')

    • in case of wrong type - return 422 ('type mismatch')

  • Check that value is a reference on service or service_group

    • Return 422 ('Cannot refer to <resource> for kind = service_request')

  • Check service or service_group is active

    • Return 422 ('<Service/Service group> should be active')

If $.detail.kind=device_request:

  • Validate product_reference:

    • Check there value is valid Reference on device_definition resource

      • Return 422 ('Cannot refer to <resource> for kind = device_request')

    • Check the device_definition is active

      • Return 422 ('Device definition is not active')

  • Validate product_codeable_concept:

    • Check that value matches with active values in device_definition_classification_type dictionary.

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

Check there is no another activities (status=scheduled, in_progress) in the Care plan with the same product_reference or product_codeable_concept, and program = $.detail.program

  • Return 422 (“Another activity with status ‘scheduled' or ‘in_progress' already exists in the current Care plan within current program value“value)

3. Reason code

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

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

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

...

  • 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')

...

Validate value in the field $.detail.quantity

  • Check it is submitted if $.detail.kind=device_request

    • Return 422 ('required property quantity was not present')

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

    • Return 422 schema validation error

...

  • 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=service_request:

    • Check that $.detail.quantity.system field’s value is SERVICE_UNIT, if submitted.

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

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

      • Check $.detail.quantity.system and $.detail.quantity.code are set, $.detail.quantity.code = MINUTE

        • Return 422 ('Code field of quantity object should be in MINUTE for care plan’s category <category code>')

  • if $.detail.kind=device_request:

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

      • Return 422 schema validation error

    • Check the $.detail.quantity.system is device_unit dictionary.

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

    • Check that $.detail.quantity.code matches to active values from $.detail.quantity.system.

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

    • Validate Device Definitions in case $.detail.product_codeable_concept and $.detail.program was set:

      • Find all active Device Definitions with packaging_unit that matches to $.detail.quantity.code

      • Check that there is at least one device definition where the remainder of division $.detail.quantity.value/packaging_count is equal to zero

        • Return 422 ('Not found any appropriate Device Definition')

    • Validate Device Definition in case $.detail.product_reference was set:

      • Get Device Definition in the $.detail.product_reference (depends on what was set)

      • Check it has packaging_unit that matches to $.quantity.code of the Activity

        • Return 422 ('Device Definition must have the same units of measure as pointed in the quantity of the Activity')

      • Check the remainder of division $.detail.quantity.value / device_definition.packaging_count is equal to zero

        • Return 422 ('The amount of devices in device request must be divisible to device package quantity')

7. Scheduled

If submitted, validate there is one of the $.detail.scheduled_[x] field: scheduled_timing, scheduled_period or scheduled_string.

  • Return 422 ('Only one of the parameters must be present') in case more then one submitted

Validate value in scheduled_timing, if submitted:

  • 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')

  • if submitted, check day_of_week field values are in DAYS_OF_WEEK dictionary

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

  • if submitted, check time_of_day match regex ^([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\.[0-9]+)?$

    • in case of error - return 422 ('string does not match pattern')

As this method always requires medical programs on its input, so scheduled_period required also:

  • Validate value with schema of the Period type

    • in case of error - return 422 schema validation error

  • Validate $.scheduled_period.end is present:

    • in case it isn’t submitted - return 422 ('can't be blank')

  • 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')

...

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 $.do_not_perform

  • Check it is false

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

...

  • Сheck program exists and active

    • in case not found or is_active==false return 422 '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 200 with status = INVALID and rejection_reason "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 200 with status = INVALID and rejection_reason "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 200 with status = INVALID and rejection_reason "Service group is not included in the program"

    • If product is code from device_definition_classification_type dictionary (product_codeable_concept was set) or product is device_definition (product_reference was set):

      • Find all program devices with:

        • is_active=true

        • care_plan_activity_allowed = true

        • period (start_date and end_date) that includes current date

        • max_daily_count >= $.quantity.value/($.detail.scheduled_period.end - $.detail.scheduled_period.start + 1). Count scheduled_period length in days, without taking into account time

        • related to the Device Definitions that has successfully passed Quantity and Product validations before

          • in case not found return 422 ('No appropriate participants found for this medical 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 return 200 with status = INVALID and rejection_reason “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 200 with status = INVALID and rejection_reason “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 200 with status = INVALID and rejection_reason “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.[].codethat correspond to codes pointed in patient_categories_allowed

        • in case of error return 200 with status = INVALID with rejection_reason ("Clinical impression with patient category should be present in request for this medical program")

    • if there is parameter device_request_allowed_code_types and activity kind=device_request, then check values in the array of values:

      • if it includes CLASSIFICATION_TYPE - it is allowed to set $.detail.product_codeable_concept in the activity

      • if it includes DEVICE_DEFINITION - it is allowed to set $.detail.product_reference in the activity

        • in case of a mismatch between the filled field and the config values - return 422 ("<Device definition/Device classification type> is not allowed to set for this medical program").

If program meets the requirements write status "VALID" according to apiary.

...