Versions Compared

Key

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

Event Manager is used to collect different events (like ATTRIBUTE_CHANGED, OBJECT_ADDED etc) from different sources and store them in one place.Image Removed

...

Overview

  • The monitoring of changed statuses will be implemented to the code

  • Event manager reflects statuses of different objects

  • In case status was changed the information is sent to EventDB to be stored

  • This method does not guarantee the fact of storing data in EventDB

  • At the moment only statuses are monitored. Other events can be added in future, but they are not in a scope today.

  • This manager is used by MIS.

  • Context is not used to obtain data from DB.

  • Only changed statuses should be stored to EventDB, not new.\

  • events Events are transferred to event manager via Kafka

...

StatusChangeEvent

Statuses to collect

...

serverSystem JIRA
serverIdd9171809-9c5e-36f7-ab17-a56a875b6d19
keyBAT-1818

Save data to Event DB

...

N

Step

Description

Owner

1

Status was changed

Status was changed on the one of events that are monitores

system

System

2

Collect Data

After changing status System collect all necessary data in the required format 

system

System

3

Save Data to EDB

Collected data are saved to EventDB.

Save Data directly to EventDB

system

System

Employee status changed

Save also employee_id value to EventDB

Code Block
    {
      "id": "df9f70ee-4b12-4740-b0f5-bb5aea116863",
      "event_type": "StatusChangeEvent",
      "entity_type": "EmployeeRequest",
      "entity_id": "df9f70ee-4b12-4740-b0f5-bb5aea116863",
      "properties": {
        "status": {
          "new_value": "APPROVED"
        },
        "employee_id": {
          "new_value": "e1453f4c-1077-4e85-8c98-c13ffca0063e"
        }
      },
      "event_time": "2017-04-20T19:14:13Z",
      "changed_by": "df9f70ee-4b12-4740-b0f5-bb5aea116863"
    }

Data format

id

PK

event_type

string

String, the name of event (ex. StatusChangeEvent)

entity_type

string

String, the name on entity that was changed (ex. Medication_request)

entity_id

uuid

Uuid, id of changed object

properties

json

Json, consists of datas that describe changed element (status: new_value)

event_time

datetime

Datetime, date and time of event

changed_by

uuid

Uuid, id of a person

Obtain data from EventDB

Get list

GET https://dev.ehealth.world/api/eventsApiary

Input parameters (optional)
  • date

  • date_to

  • event_type

  • entity_type

  • attribute_name

  • attribute_name & new_value

  • page

  • page_size

Period of events provided in the response of method cannot exceed value of EVENTS_LIST_MAX_PERIOD_HOURS variable (if variable is not specified, the default value is 1 hour) specified in configuration of Event Manager

  1. if date and date_to parameters are set, the following condition must be met: date - date_to <= EVENTS_LIST_MAX_PERIOD_HOURS

    1. in case of error return 422 ("Period must be less than or equal to {period} hours. Please set allowed period to the query")

  2. if date and date_to parameters are not set, use date_to as now() and the following condition must be met: date - date_to = EVENTS_LIST_MAX_PERIOD_HOURS

  3. if date_to parameter is set and date is not set, the following condition must be met: date - date_to = EVENTS_LIST_MAX_PERIOD_HOURS

  4. if date parameter is set and date_to is not set, the following condition must be met: date - date_to = EVENTS_LIST_MAX_PERIOD_HOURS

Logic WS

  1. Verify the validity of access token

  2. Check user scopes in order to perform this action (scope = 'event:read')

    • return 403 in case invalid scope(s)

Validate EventType

Each event type can be filtered by scopes. At the moment we have only one event - StatusChangeEvent

  1. Check user scopes in order to perform this action (scope = 'event:read')

    • return 403 in case invalid scope(s)

Get by ID

GET https://uaehealthapi.docs.apiary.io/reference/public.-event-manager/get-events-by-id/get-events-by-id Apiary

Input parameters

  • id

Logic WS

  1. Verify the validity of access token

  2. Check user scopes in order to perform this action (scope = 'event:read')

    1. return 403 in case invalid scope(s)

Event termination

...

N

Step

Description

Owner

1

Once in 24H timer starts

system

System

2

Check amount of data in DB

The number of data in DB should be checked.

amount

Amount of data in DB > event_max_number

system

System

3

Delete data in DB

all

All data > event_max_number should be deleted

system

System

N

Step

Description

Owner

1

Once in 24H timer starts

system

System

2

Check amount of data in DB

the

The Insert_at date in DB sould be checked

insert_at > event_max_time

system

System

3

Delete data in DB

All data with (inserted_at>event_max_time) should be deleted

system

System

Event termination starts with cron sqedule schedule filtered by

  • time (event_max_time)

  • amount of data (event_max_number)

All filteres are parametrized. By default event_max_time=month, event_max_number=50.000.

Cron starts once in 24H and delete data if events.id > "amount of data" OR events.event_time > "time".