ЕСОЗ - публічна документація

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 32 Next »

Specification

 Click here to expand...

"""
Fields to filter medication in the system.
"""
input MedicationFilter {
  "Primary key identifier from the database."
  databaseId: UUID
  "Medicalation name."
  name: String
  "Activeness status."
  isActive: Boolean
  "Medication form."
  form: String
  "INNMDosage filter."
  innmDosages: INNMDosageFilter
  "Manufacturer filter."
  manufacturer: ManufacturerFilter
  "Anatomical Therapeutic Chemical Classification System"
  atcCode: String
}

"""
Manufacturer filter.
"""
input ManufacturerFilter {
  "Manufactorer name"
  name: String
}

"""
Methods to use when ordering `Medication`.
"""
enum MedicationOrderBy {
  "Sort Medication by form in ascending order."
  FORM_ASC
  "Sort Medication by form in descending order."
  FORM_DESC
  "Sort Medication by inserted_at in ascending order."
  INSERTED_AT_ASC
  "Sort Medication by inserted_at in descending order."
  INSERTED_AT_DESC
  "Sort Medication by manufacturer in ascending order."
  MANUFACTURER_ASC
  "Sort Medication by manufacturer in descending order."
  MANUFACTURER_DESC
  "Sort Medication by name in ascending order."
  NAME_ASC
  "Sort Medication by name in descending order."
  NAME_DESC
}

"""
A connection to a list of `Medication` items.
"""
type MedicationConnection {
  "Information to aid in pagination."
  pageInfo: PageInfo!
  "A list of nodes."
  nodes: [Medication]
  "A list of edges."
  edges: [MedicationEdge]
}

"""
An edge in a connection of `Medication`.
"""
type MedicationEdge {
  "The item at the end of the edge."
  node: Medication!
  "A cursor for use in pagination."
  cursor: String!
}

"""
Input for `createMedication` mutation.
User must have scopes **medication:write**
"""
input CreateMedicationInput {
  "Certificate number"
  certificate: String!
  "A day when certificate expired"
  certificateExpiredAt: Date!
  "Anatomical Therapeutic Chemical Classification System"
  atcCodes: [String]!
  "A container in medication (vacuum packed box, jar, etc.)"
  container: CreateContainerInput!
  "Daily dose of medication, recommended by WHO"
  dailyDosage: Float
  "Form of medication. The value should be present in the `MEDICATION_FORM` dictionary."
  form: String!
  "Ingredients in medication"
  ingredients: [CreateMedicationIngredientInput]!
  "Company that creates medication"
  manufacturer: CreateManufacturerInput!
  "Medication name"
  name: String!
  "A minimum quantity that could be sold"
  packageMinQty: Int!
  "Quantity of pills in medication"
  packageQty: Int!
}
"""
Input for `Container` of `createMedication` mutation.
"""
input CreateContainerInput {
  "Numerator unit. The value should be present in the `MEDICATION_UNIT` dictionary."
  numeratorUnit: String!
  "Numerator value"
  numeratorValue: Int!
  "Denumerator unit. The value should be present in the `MEDICATION_UNIT` dictionary."
  denumeratorUnit: String!
  "Denumerator value"
  denumeratorValue: Int!
}
"""
Input for `MedicationIngredient` of `createMedication` mutation.
"""
input CreateMedicationIngredientInput {
  "The size or frequency of a dose of a medicine or drug."
  dosage: CreateDosageInput!
  "Is the component primary or not"
  isPrimary: Boolean!
  "innmDosage ID"
  innmDosage: ID!
}
"""
Input for `Dosage` of `createMedication` mutation.
"""
input CreateDosageInput {
  "Numerator unit. The value should be present in the `MEDICATION_UNIT` dictionary."
  numeratorUnit: String!
  "Numerator value"
  numeratorValue: Int!
  "Denumerator unit. The value should be present in the `MEDICATION_UNIT` dictionary."
  denumeratorUnit: String!
  "Denumerator value"
  denumeratorValue: Int!
}
"""
Input for `Manufacturer` of `createMedication` mutation.
"""
input CreateManufacturerInput {
  "Manufacturer country"
  country: String!
  "Manufacturer name"
  name: String!
}
"""
Return type for `createMedication` mutation.
"""
type CreateMedicationPayload {
  "Created `Medication`."
  medication: Medication
}
"""
Input for `deactivateMedication` mutation.

User must have scopes **medication:deactivate**
"""
input DeactivateMedicationInput {
  "The ID of an object"
  id: ID!
}

"""
Return type for `deactivateMedication` mutation.
"""
type DeactivateMedicationPayload {
  "Deactivated `Medication`."
  medication: Medication
}

"""
Trade mark medication. User must have a scope **medication:read**
"""
type Medication implements Node {
  "The ID of an object"
  id: ID!
  "Primary key identifier from the database"
  databaseId: UUID!
  "Medication name"
  name: String!
  "Company that creates medication"
  manufacturer: Manufacturer!
  "Anatomical Therapeutic Chemical Classification System"
  atcCodes: [String]!
  "Form of medication. The value should be present in the `MEDICATION_FORM` dictionary."
  form: String
  "A container in medication (vacuum packed box, jar, etc.)"
  container: Container!
  "Quantity of pills in medication"
  packageQty: Int!
  "A minimum quantity that could be sold"
  packageMinQty: Int!
  "Daily dose of medication, recommended by WHO"
  dailyDosage: Float
  "Certificate number"
  certificate: String!
  "A day when certificate expired"
  certificateExpiredAt: Date!
  "Ingredients in medication"
  ingredients: [MedicationIngredient]!
  "is_active status"
  isActive: Boolean!
  "type od medication"
  type: MedicationType
  "Date and time when record was inserted"
  insertedAt: DateTime!
  "Date and time when record was updated"
  updatedAt: DateTime!
}
"""
A company that makes medication.
"""
type Manufacturer {
  "Manufacturer name"
  name: String!
  "Manufacturer country"
  country: String!
}
"""
The kind of container that this package comes as.
"""
type Container {
  "Numerator unit. The value should be present in the `MEDICATION_UNIT` dictionary."
  numeratorUnit: String!
  "Numerator value"
  numeratorValue: String!
  "Denumerator unit. The value should be present in the `MEDICATION_UNIT` dictionary."
  denumeratorUnit: String!
  "Denumerator value"
  denumeratorValue: String!
}
"""
A component part of medication.
"""
type MedicationIngredient implements Ingredient {
  "The size or frequency of a dose of a medicine or drug."
  dosage: Dosage!
  "Is the component primary or not"
  isPrimary: Boolean!
  "International Nonproprietary Name"
  innmDosage: INNMDosage!
}
"""
Medication type.
"""
enum MedicationType {
  "Trade name"
  BRAND
  "Medicinal forms"
  INNM_DOSAGE
}

Purpose

This WS is designed to create new medication.

Input parameters 

  • name

  • manufacturer

     (object)

  • code_atc

  • form

  • container

     info

  • package_qty

  • package_min_qty

  • certificate

  • expired_certificate_at

  • ingredients (array)

Authorize

  1. Verify the validity of access token

  2. Check user scope (scope = 'medication:write') in order to perform this action

    1. In case error - generate 401 response

Validate request

Validate request using features.


 Click here to expand...
Feature: Create medication

  Scenario Outline: Successful creation
    Given my scope is "medication:write"
    And my client type is "NHS"
    And my consumer ID is "1ad3c0e6-e2fc-2d3c-a15c-5101874165a7"
    And the following INNM dosages exist:
      | databaseId        |
      | <innmDosageId>  |
    When I create medication with attributes:
      | name   | atcCodes   | certificate   | certificateExpiredAt   | container   | dailyDosage   | form   | ingredients   | manufacturer   | packageMinQty   | packageQty   |
      | <name> | <atcCodes> | <certificate> | <certificateExpiredAt> | <container> | <dailyDosage> | <form> | <ingredients> | <manufacturer> | <packageMinQty> | <packageQty> |
    Then no errors should be returned
    And request id should be returned
    And I should receive requested item
    And the name of the requested item should be <name>

    Examples:
      | name      | innmDosageId                           | atcCodes               | certificate | certificateExpiredAt | container                                                                                           | dailyDosage | form                           | ingredients                                                                                                                                                                                      | manufacturer                        | packageMinQty | packageQty |
      | "Ниферон" | "01c9b8ae-fe41-4390-8f3c-4744f5b13717" | ["C08CA01", "C08CA02"] | "100-fA-11" | "2019-12-12"         | {"numerator_unit": "ML", "numerator_value": 1, "denumerator_unit": "ML", "denumerator_value": 50}   | 0.02        | "AEROSOL_FOR_INHALATION_DOSED" | [{"innmDosageId": "01c9b8ae-fe41-4390-8f3c-4744f5b13717", "dosage": {"numerator_unit": "DOSE", "numerator_value": 1, "denumerator_unit": "ML", "denumerator_value": 100}, "is_primary": true}]   | {"name": "Bayer", "country": "GER"} | 1             | 5          |
      | "Ниферон" | "01c9b8ae-fe41-4390-8f3c-4744f5b13717" | ["C08CA01", "C08CA02"] | "100-fA-11" | "2019-12-12"         | {"numerator_unit": "ML", "numerator_value": 0.5, "denumerator_unit": "ML", "denumerator_value": 50} | 0.01        | "AEROSOL_FOR_INHALATION_DOSED" | [{"innmDosageId": "01c9b8ae-fe41-4390-8f3c-4744f5b13717", "dosage": {"numerator_unit": "DOSE", "numerator_value": 0.5, "denumerator_unit": "ML", "denumerator_value": 50}, "is_primary": true}] | {"name": "Bayer", "country": "GER"}  | 1             | 5          |

  Scenario: Create with incorrect scope
    Given my scope is "medication:read"
    And my consumer ID is "04796283-74b8-4632-9f7f-9e227ae9426e"
    When I create medication with attributes:
      | name      | atcCodes               | certificate | certificateExpiredAt | container                                                                                         | dailyDosage | form                           | ingredients                                                                                                                                                                                    | manufacturer                        | packageMinQty | packageQty |
      | "Ниферон" | ["C08CA01", "C08CA02"] | "100-fA-11" | "2019-12-12"         | {"numerator_unit": "ML", "numerator_value": 1, "denumerator_unit": "ML", "denumerator_value": 50} | 0.02        | "AEROSOL_FOR_INHALATION_DOSED" | [{"innmDosageId": "01c9b8ae-fe41-4390-8f3c-4744f5b13717", "dosage": {"numerator_unit": "DOSE", "numerator_value": 1, "denumerator_unit": "ML", "denumerator_value": 100}, "is_primary": true}] | {"name": "Bayer", "country": "GER"} | 1             | 5          |
    Then the "FORBIDDEN" error should be returned
    And request id should be returned
    And I should not receive requested item

  Scenario: Create with incorrect client
    Given my scope is "medication:write"
    And my client type is "MSP"
    And my consumer ID is "089c0204-a191-4537-ab92-56dca268443c"
    When I create medication with attributes:
      | name      | atcCodes               | certificate | certificateExpiredAt | container                                                                                         | dailyDosage | form                           | ingredients                                                                                                                                                                                    | manufacturer                        | packageMinQty | packageQty |
      | "Ниферон" | ["C08CA01", "C08CA02"] | "100-fA-11" | "2019-12-12"         | {"numerator_unit": "ML", "numerator_value": 1, "denumerator_unit": "ML", "denumerator_value": 50} | 0.02        | "AEROSOL_FOR_INHALATION_DOSED" | [{"innmDosageId": "01c9b8ae-fe41-4390-8f3c-4744f5b13717", "dosage": {"numerator_unit": "DOSE", "numerator_value": 1, "denumerator_unit": "ML", "denumerator_value": 100}, "is_primary": true}] | {"name": "Bayer", "country": "GER"} | 1             | 5          |
    Then the "FORBIDDEN" error should be returned
    And request id should be returned
    And I should not receive requested item

  Scenario Outline: Create with invalid params
    Given my scope is "medication:write"
    And my client type is "NHS"
    And my consumer ID is "94e4301f-2d28-4403-b59f-b5865e9ca26f"
    When I create medication with attributes:
      | name   | atcCodes   | certificate   | certificateExpiredAt   | container   | dailyDosage   | form   | ingredients   | manufacturer   | packageMinQty   | packageQty   |
      | <name> | <atcCodes> | <certificate> | <certificateExpiredAt> | <container> | <dailyDosage> | <form> | <ingredients> | <manufacturer> | <packageMinQty> | <packageQty> |
    Then the "UNPROCESSABLE_ENTITY" error should be returned
    And request id should be returned
    And I should not receive requested item

    Examples:
      | name      | innmDosageId                           | atcCodes               | certificate | certificateExpiredAt | container                                                                                          | dailyDosage | form                           | ingredients                                                                                                                                                                                    | manufacturer                        | packageMinQty | packageQty |
      | "Ниферон" | "01c9b8ae-fe41-4390-8f3c-4744f5b13717" | ["INVALID"]            | "100-fA-11" | "2019-12-12"         | {"numerator_unit": "ML", "numerator_value": 1, "denumerator_unit": "ML", "denumerator_value": 50}  | 0.02        | "AEROSOL_FOR_INHALATION_DOSED" | [{"innmDosageId": "01c9b8ae-fe41-4390-8f3c-4744f5b13717", "dosage": {"numerator_unit": "DOSE", "numerator_value": 1, "denumerator_unit": "ML", "denumerator_value": 100}, "is_primary": true}] | {"name": "Bayer", "country": "GER"} | 1             | 5          |
      | "Ниферон" | "01c9b8ae-fe41-4390-8f3c-4744f5b13717" | ["C08CA01", "C08CA02"] | "100-fA-11" | "2019-12-12"         | {"numerator_unit": "ML", "numerator_value": 1, "denumerator_unit": "ML", "denumerator_value": 50}  | 0.02        | "AEROSOL_FOR_INHALATION_DOSED" | [{"innmDosageId": "01c9b8ae-fe41-4390-8f3c-4744f5b13717", "dosage": {"numerator_unit": "DOSE", "numerator_value": 1, "denumerator_unit": "ML", "denumerator_value": 100}, "is_primary": true}] | {"name": "Bayer", "country": "GER"} | 1             | 5          |
      | "Ниферон" | "01c9b8ae-fe41-4390-8f3c-4744f5b13717" | ["C08CA01", "C08CA02"] | "100-fA-11" | "2019-12-12"         | {"numerator_unit": "ML", "numerator_value": 1, "denumerator_unit": "MKG", "denumerator_value": 50} | 0.02        | "AEROSOL_FOR_INHALATION_DOSED" | [{"innmDosageId": "01c9b8ae-fe41-4390-8f3c-4744f5b13717", "dosage": {"numerator_unit": "DOSE", "numerator_value": 1, "denumerator_unit": "ML", "denumerator_value": 100}, "is_primary": true}] | {"name": "Bayer", "country": "GER"} | 1             | 5          |

Validate FK 

Purpose validation: Check on existing Substance/Innm in ingredients 

  1. Check exist `Medications` by $.ingredients[].id.

    1. if invalid - return 422 error (message: "INNM in ingredients is not found!")

Validate status  & type ingredients

Purpose validation: Id's in ingredients must be active  

  1. Invoke GetInnmByID($.ingredients[].id). Check exist any innm.is_active=FALSE.

    1. if exists - return 422 error (message: "INNM in ingredients must be active!")

Purpose validation: Ingredients for TYPE=BRAND must be TYPE=INNM_DOSAGE

  1. Check exists Ingredients with type=BRAND.

    1. if exists - return 422 error (message: "Only INNM_DOSAGE can be ingredients!")

Validate status ingredients.is_primary

Purpose validation:  in ingredients only one item must be is primary (TRUE)  

  1. Calculate count() where is_primary=TRUE in ingredients. Check count()>=1.

    1. if invalid - return 422 error (message: "One of ingredients must be is primary!")

Validate Equal Dosage & Container

Purpose validation: Denumerator unit from Ingredients.dosage  must be equal Numerator unit from Container.

  1. Check exist any  ($.ingredients[].dosage.denumerator_unit != $.container.numerator_unit).

    1. if invalid - return 422 error (message: "Denumerator unit from Dosage ingredients must be equal Numerator unit from Container medication!")

Validate multiplicity

Purpose validation:  Package_qty for container_dosage must have multiplicity package_min_qty.  Result (Mod or % operator) must = 0 .

  1. MEDICATION - Validate multiplicity (Mod == 0) $.package_qty Mod $.package_min_qty == 0

  2. if result NOT 0 - return 409 error (message: "Only a multiplicity package quantity for the minimum package quantity medication!")

Validate atc code

  1. Validate value according to regex ^[abcdghjlmnprsvABCDGHJLMNPRSV]{1}[0-9]{2}[a-zA-Z]{2}[0-9]{2}$

    1. in case of error return ('Invalid code')

  2. Check that all elements in array of atc_code are different 

    1. in case of error return 422 error (message `atc codes are duplicated`)

Create new Medication

Saving innm dosage and medication occurs in one table - prm.medications. They are separated by the parameter type - innm_dosage and brand. Therefore, some fields may not be filled in when creating an innm dosage or medication. For example, max_daily_dosage is filled for innm dosage, but not filled for medication, etc.

  1. Create new record in Medications 

  2. Fill data 

Destination

Source

id


name

$.name

TYPE

MEDICATION

is_active 

TRUE

form

$.form

ingredients

$.ingredients

container

$.container

package_qty

$.package_qty

package_min_qty

$.package_min_qty

code_atc

$.code_atc

manufacturer

$.manufacturer

certificate 

$.certificate 

expired_certificate_at

$.expired_certificate_at

inserted_at

:timestamp

inserted_by

user_id

updated_at

:timestamp

updated_by

user_id

daily_dosage

number

Create new Ingredients

  1. Create new record in Ingredients from $.ingredients

  2. Fill data

Destination

Source

id


dosage

$.ingredients.dosage

parent_id

medication_id

innm_child_id

NULL

medication_child_id

$.ingredients.innm_dosage_id

is_primary

$.ingredients.is_primary

inserted_at

:timestamp

inserted_by

user_id

updated_at

:timestamp

updated_by

user_id


  • No labels