Note

Сторінка знаходиться в процесі розробки. Інформація на ній може бути застарілою.

...

PROVIDING_CONDITIONS_ALLOWED

INNM_DOSAGE

eHealth/activity_remaining_quantity_types

Input parameters

Input parameter

Mandatory

Type

Description

Example

1

patient_id

 

String

MPI identifier of the person.

Required

7c3da506-804d-4550-8993-bf17f9ee0402

2

care_plan_id

 

String

Unique Care Plan identifier.

Required

7c3da506-804d-4550-8993-bf17f9ee0403

Request structure

See on API-specification

...

Headers

Request data validation

Authorize

  1. Verify the validity of access token

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

  2. Verify that token is not expired

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

  3. 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)

  4. If BLOCK_UNVERIFIED_PARTY_USERS is true, then check party's data match following condition: verification_status != NOT_VERIFIED or (verification_status = NOT_VERIFIED and updated_at <= current_date - UNVERIFIED_PARTY_PERIOD_DAYS_ALLOWED):

    • in case not match - return 403 ("Access denied. Party is not verified")

Validate legal entity

  1. Extract client_id from token

  2. Check legal entity status is ACTIVE

    1. In case of error - return 409 ('client_id refers to legal entity that is not active')

  3. Check legal entity type in ME_ALLOWED_TRANSACTIONS_LE_TYPES config parameter

    1. in case of error - return 409 ('client_id refers to legal entity with type that is not allowed to create medical events transactions')

...

  1. Extract user_id from token.

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

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

      1. Return 403 ('Access denied') in case employee has no Approval on write

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

    1. 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

  1. Validate request is signed

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

  2. Check DS is valid and not expired

  3. Validate that DS belongs to the author of the activity

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

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

...

  1. Check employee belongs to the user and legal entity (from token)

  2. Employee is:

    1. an employee who has active Approval on write the Care plan

    2. belongs to user

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

  3. Check employee_type is value from list of employee_types in configuration: ACTIVITY_AUTHOR_EMPLOYEE_TYPES_ALLOWED

    • in case of error - return 422 ('Invalid employee type')

Validate activity detail

1. Kind

...

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

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

    1. Return 422 schema validation error

...

  1. If $.detail.kind=medication_request:

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

      1. Return 422 ('value is not allowed in enum')

    2. 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

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

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

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

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

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

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

  3. If $.detail.kind=service_request:

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

      1. Return 422 ('value is not allowed in enum')

    2. If care plan category is class_23, class_24 or class_25:

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

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

  4. 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.

...

  1. Check the value is valid reference o employee resource

  2. Check employee is active and approved

    1. Return 422 ('Invalid employee status')

10. Daily amount

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

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

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

  3. Check activity kind is medication_request

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

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

  5. If $.detail.kind=medication_request:

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

      1. Return 422 ('value is not allowed in enum')

    2. 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

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

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

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

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

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

      1. 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

...

  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:

    1. Set care plan status = active

    2. 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:

      1. 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.

...

Expand
titleResponse Example. Code 202.
Code Block
languagejson
{
  "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"
  }
}

HTTP status codes

Response code

HTTP Status code

Message

Internal name

Description

1

Базові

2

201

Response

 Sync. Use payload from response

3

202

Response

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

4

401

Invalid access token

  • validation fails

  • token is expired

5

403

Access denied

  • invalid scope(s)

6

403

Access denied. Party is not verified

7

403

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

8

404

Program not found

9

409

client_id refers to legal entity that is not active

 

10

409

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

11

409

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

12

409

Person is not active

13

409

Patient is not verified

14

409

Signer DRFO doesn't match with requester tax_id

15

422

Another activity with status ‘scheduled' or ‘in_progress' already exists i

16

422

Activity with such id already exists

17

422

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

18

422

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

19

422

Bounds duration must be within care plan period range

20

422

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

21

422

Care plan with such id is not found

22

422

Care Plan end date is expired

23

422

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

24

422

Cannot refer to service for kind = medication_request

25

422

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

26

422

Cannot refer to medication for kind = service_request

27

422

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

28

422

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

29

422

Clinical impression with patient category exceeds validity period

30

422

Care plan diagnosis is not allowed for the medical program

31

422

document must be signed by 1 signer but contains 0 signatures

32

422

Division is not active

33

422

Event is not within care plan period range

34

422

Forbidden to create care plan activity for this medication!

35

422

High must be within care plan period range

36

422

Invalid care plan status

37

422

Invalid employee status

38

422

Invalid employee type

39

422

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

40

422

<medical event type> with such ID is not found

41

422

Medication should be active

42

422

Medication does not exist

43

422

Medical program must be submitted for kind = medication_request

44

422

Medication is not included in the program

45

422

not allowed in enum

46

422

Only one of the parameters must be present

47

422

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

48

422

Period start time must be within care plan period range

49

422

Program not found

50

422

Service group is not included in the program

51

422

<Service/Service group> should be active

52

422

String does not match pattern

53

422

Service is not included in the program

54

422

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

55

422

Value is not allowed in enum

56

422

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

57

422

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

58

Специфічні

59

Post-processing processes

...