Table of Contents |
---|
...
Check that value is in allowed active values from
device_definition_classification_type
dictionary.in case of error - return 422 ('value is not allowed in enum')
...
Get value from configuration parameter (equipmentEQUIPMENT_TYPES_typesWITH_serialREQUIRED_numberSERIAL_neededNUMBER)
If $.type is in list then $.serial_number is required
in case of error return 422 "Serial number is required for this type of equipment"
...
Check that $.properties.type is in allowed values from
device_properties
dictionary.in case of error - return 422 ('value is not allowed in enum')
Check $.properties.value[x] is one of the following:
value_integer
,value_decimal
,value_boolean
,value_string
in case of value[x] is missing - return 422 ('One and only one key is allowed from the list: [value_integer, value_decimal, value_boolean, value_string], but the following are present: [].')
in case of more than one value[x] provided - return 422 ('One and only one key is allowed from the list: [value_integer, value_decimal, value_boolean, value_string], but the following are present: [value[x], value[x], …].')
in case of value[x] is provided with incorrect type - return 422 ('type mismatch. Expected <expected_type> but got <actual_type>')
Check config
DEVICE_PROPERTY_DICTIONARIES
- if device property is associated with dictionary in this configuration parameteronly
value_string
is allowed for this propertyin case of error - return 422 ('Only value_string is allowed for dictionary values')
check that
value_string
is one of the corresponding dictionary for this propertyin case of error - return 422 ('value is not allowed in enum')
11. Validate inventory number
...
Save equipment record to the prm.equipments table (see [NEW] Equipment status model https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/17890836669) with the following:
id = generate uuid
inventory_number = $.inventory_number
serial_number = $.serial_number
device_definition_id = $.device_definition_id
status = $.status
error_reason = null
availability_status = $.availability_status
manufacturer = $.manufacturer
manufacture_date = $.manufacture_date
model_number = $.model_number
type = $.type
properties = $.properties
legal_entity_id = $.token.client_id
division_id = $.division_id
note = $.note
parent_id = $.parent_id
lot_number = $.lot_number
expiration_date = $.expiration_date
udi = $.udi
is_active = true
recorder = $.recorder
inserted_at = current datetime
inserted_by = user_id from token
updated_at = current datetime
updated_by = user_id from token
Insert each name from $.names into prm.equipment_names with the following:
id = generate uuid
equipment_id = reference to equipment
type = $.names.type
name = $.names.name
inserted_at = current datetime
inserted_by = user_id from token
updated_at = current datetime
updated_by = user_id from token