Versions Compared

Key

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

...

Page Properties

Link

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

Resource

/api/patients/{{patient_id}}/care_plans

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

Logic

...

Preconditions

Sign message (pkcs7) that consists of signed content, digital signature, and signer public key

Logic

This method allows to create Care Plan for a person in eHealth. Method receives signed message (pkcs7) that consists of signed content, digital signature and signer public key. All signature fields will be validated (including signer certificate authority). Service will store signed copy of Care Plan in Media Content Storage if all checks is passed.

Key points

  1. Only authenticated and authorized user with employee_type from the list of CARE_PLAN_AUTHOR_EMPLOYEE_TYPES_ALLOWED
    config with appropriate speciality pointed in CARE_PLAN_<category>_SPECIALITIES_ALLOWED config can create a Care plan.

  2. Care plan can be created from MSP, PRIMARY_CARE or OUTPATIENT legal entity.

  3. Care plan can be created for persons and prepersons.

  4. Care plan should be signed with DS.

  5. Care plan creates in async way as all MEs.

  6. Activities are added to a Care plan using Create Care Plan activity method. Thus, Care plan is being initially created without activities.

Input parameters

...

Input parameter

...

Values

...

Type

...

Description

...

Example

...

patient_id

...

String

...

MPI identifier of the person

...

7075e0e2-6b57-47fd-aff7-324806efa7e5

Request structure

See on Apiary

Example:

Expand
titleRequest example
Code Block
{
  "signed_data": "ew0KICAicGVyaW9kIjogew0KIC..."
}

Dummy Care plan

Example:

Global and configurable parameters

https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/2125039308/Care+Plan+dictionaries+and+configurable+parameters+UA#%D0%9A%D0%BE%D0%BD%D1%84%D1%96%D0%B3%D1%83%D1%80%D0%B0%D1%86%D1%96%D0%B9%D0%BD%D1%96-%D0%BF%D0%B0%D1%80%D0%B0%D0%BC%D0%B5%D1%82%D1%80%D0%B8

https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/583402009/Medical+Events+Dictionaries+and+configurations#ME_ALLOWED_TRANSACTIONS_LE_TYPES

Input parameters

Input parameter

Values

Type

Description

Example

patient_id

String

MPI identifier of the person

7075e0e2-6b57-47fd-aff7-324806efa7e5

Filters

No

Dictionaries

eHealth/care_plan_categories

eHealth/care_plan_cancel_reasons

eHealth/care_plan_complete_reasons

eHealth/ICD10_AM/condition_codes

PROVIDING_CONDITION

Request structure

See on Apiary

Example:

Expand
titleRequest example
Code Block
{
  "idsigned_data": "90a9e15b-b71b-4caf-"ew0KICAicGVyaW9kIjogew0KIC..."
}

Dummy Care plan

Example:

Expand
titleRequest example
Code Block
{
  "id": "90a9e15b-b71b-4caf-8f2e-ff247e8a5600",
  "based_on": {
    "identifier": {
      "type": {
        "coding": [
          {
            "system": "eHealth/resources",
            "code": "care_plan"
          }
        ]
      },
      "value": "9183a36b-4d45-4244-9339-63d81cd08d9c"
    }
  },
  "part_of": {
    "identifier": {
      "type": {
        "coding": [
          {
            "system": "eHealth/resources",
            "code": "care_plan"
          }
        ]
      },
      "value": "9183a36b-4d45-4244-9339-63d81cd08d9c"
    }
  },
  "category": {
    "coding": [
      {
        "system": "eHealth/care_plan_categories",
        "code": "diabetics"
      }
    ]
  },
  "title": "Diabetics health plan",
  "description": "Some description of the care plan",
  "period": {
    "start": "2018-08-02T10:45:16.000Z",
    "end": "2018-08-02T11:00:00.000Z"
  },
  "supporting_info": [
    {
      "identifier": {
        "type": {
          "coding": [
            {
              "system": "eHealth/resources",
              "code": "episode_of_care"
            }
          ]
        },
        "value": "9183a36b-4d45-4244-9339-63d81cd08d9c"
      }
    }
  ],
  "note": "Some notes",
  "intent": "order",
  "encounter": {
    "identifier": {
      "type": {
        "coding": [
          {
            "system": "eHealth/resources",
            "code": "encounter"
          }
        ]
      },
      "value": "9183a36b-4d45-4244-9339-63d81cd08d9c"
    }
  },
  "addresses": [
    {
      "coding": [
        {
          "system": "eHealth/ICD10_AM/condition_codes",
          "code": "E11.9"
        }
      ]
    }
  ],
  "author": {
    "identifier": {
      "type": {
        "coding": [
          {
            "system": "eHealth/resources",
            "code": "employee"
          }
        ]
      },
      "value": "9183a36b-4d45-4244-9339-63d81cd08d9c"
    }
  },
  "contributor": [
    {
      "identifier": {
        "type": {
          "coding": [
            {
              "system": "eHealth/resources",
              "code": "employee"
            }
          ]
        },
        "value": "9183a36b-4d45-4244-9339-63d81cd08d9c"
      }
    }
  ],
  "terms_of_service": {
    "coding": [
      {
        "system": "PROVIDING_CONDITION",
        "code": "INPATIENT"
      }
    ]
  },
  "inform_with": {
    "auth_method_id": "cc949559-5dfe-420f-ac05-065e443b2cc6"
  },
  "status": "new"
}

...

Request to process the request using a token in the headers

Headers

Наприклад:

  • Content-Type:application/json

  • Authorization:Bearer mF_9.B5f-4.1JqM

  • api-key:aFBLVTZ6Z2dON1V

...

Validate encoded and decoded request using schema.

Return 422 with the list of validation errors in case validation fails.

...

  • Extract user_id from token. Check that author belongs to one of the user’s employee.

    • in case of error - return 422 ('User is not allowed to create care plan for the employee')

  • Check that author is an active and approved employee and related to the legal entity (client_id from token).

    • in case of error - return 403 ('Access denied')

  • for employees with employee_type from CARE_PLAN_AUTHOR_ROLE_CHECK_EMPLOYEE_TYPES config:

    • Сheck it has at least one employee role that:

      • is active and has active status

      • refers to healthcare service with providing_conditions=$.terms_of_service value

        • in case of error - return 422 ('Employee does not have active role that correspond to the submitted terms of service')

  • If DOCTOR, then no additional validations needed

  • Check author’s speciality (speciality_officio == true) pointed in config for a corresponding care plan category.

    • in case of error - return 409 (“Invalid employee speciality”)

...

  • Check the value is valid reference on encounter resource

    • Check encounter is active (status is not entered_in_error)

      • in case of error - return 422 ('Encounter in "entered_in_error" status can not be referenced')

    • Check encounter belongs to patient ($.subject)

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

    • Check that encounter diagnosis is not empty in $.encounter.diagnosis

      • in case of error - return 422 ('Encounter without diagnosis can not be referenced')

  • Validate primary diagnosis Condition in the Encounter:

    • Check condition codes is in allowed condition code list for the care plan’s category (chart variables in config: for employee types: SPECIALIST, DOCTOR and MED_COORDINATOR)

      • in case of error - return 422 ('Primary diagnosis condition code and care plan category mismatch')

    • Check the condition system/codes has strict match with the value in the Addresses field

      • in case of error - return 422 ('Primary diagnosis condition codes do not match with codes in addresses') in case condition code in addresses is not the same as in the encounter diagnosis.

  • Validate Episode related to the Encounter:

    • exists

      • in case of error - return 422 ('Encounter refers to episode that does not exist')

    • is active

      • in case of error - return 422 ('Encounter refers to episode that is not active')

    • it’s managing organization matches with author’s legal entity (client_id)

      • in case of error - return 422 ('Encounter is from another legal entity')

...

  • Check that there is values from a dictionary PROVIDING_CONDITION.

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

  • Check submitted value:

7. Period

Validate value in the field $.period, required.

...

Expand
titleResponse example
Code Block
{
  "data": {
    "status": "pending",
    "eta": "2018-08-02T10:45:16.000Z",
    "links": [
      {
        "entity": "job",
        "href": "/Jobs/NBXk9EyErUZv1RhXgyvgg"
      }
    ]
  },
  "meta": {
    "code": 202,
    "url": "http://example.com/resource",
    "type": "object",
    "request_id": "req-adasdoijasdojsda"
  }
}

Post-processing processes

API paragraph not found

HTTP status codes

...

HTTP status code

...

Message

...

What caused the error

...

 201

...

Response

...

 

...

 202

...

Response

...

 

...

401

...

Invalid access token

...

403

...

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

  • Access denied

...

409

...

Validation failed

...

": "req-adasdoijasdojsda"
  }
}

Post-processing processes

API paragraph not found

HTTP status codes

Page Properties

HTTP status code

Message

What caused the error

 201

Response

 

 202

Response

 

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

  • Signer DRFO doesn't match with requester tax_id

  • 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

  • Invalid employee speciality

  • Care plan with such id already exists

Validation failed

422

type mismatch or schema validation error

list of validation errors in case validation fails

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

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

  • Employee does not have active role that correspond to the submitted terms of service

  • Value is not allowed in enum

  • Encounter in "entered_in_error" status can not be referenced

  • Encounter with such id is not found

  • Encounter without diagnosis can not be referenced

  • Primary diagnosis condition code and care plan category mismatch

  • Primary diagnosis condition codes do not match with codes in addresses

  • Encounter refers to episode that does not exist

  • Encounter refers to episode that is not active

  • Encounter is from another legal entity

  • Start date must be in the future

  • End date must be greater than or equal the start date

  • Care plan with such id is not found

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

  • Invalid employee status

  • Authentication method doesn't exist, is inactive or does not belong to this person

Validation failed