ЕСОЗ - публічна документація
RС_[NEW] (GraphQl) Create Program device_EN
Purpose
This WS allows to create a participant of medication program with device type.
Key points
This is a graphQl method used in Administration panel only.
Only authenticated and authorized NHS employee with appropriate scope can create Program device.
Specification
Authorization
Verify the validity of access token
Return (401, 'Invalid access token') in case of validation fails
Verify that token is not expired
in case of error - return (401, 'Invalid access token')
Check user scopes in order to perform this action (scope = 'program_device:write')
Return (403, 'Your scope does not allow to access this resource. Missing allowances: program_device:write') in case of invalid scope(s)
Validate legal entity
Extract client_id from token.
Check legal entity status (status = ACTIVE)
In case of error - return 409 ('client_id refers to legal entity that is not active')
Check client type (type = NHS)
In case of error - return 403 ('You don't have permission to access this resource')
Validate request
Validate device definition submitted in
$.deviceDefinitionId
Check that device definition by id exists in device_definitions table (PRM DB) and is active (is_active = true)
in case of error - return 422 ('Device definition not found')
Validate medical program submitted in
$.medicalProgramId
Check that medical program by id exists in medical_programs table (PRM DB) and is active (is_active = true)
in case of error - return 422 ('Medical program not found')
Check that medical program has type DEVICE
in case of error - return 422 ('Medical program type should be DEVICE')
Validate reimbursement details submitted in
$.reimbursement
If
$.reimbursement.type = FIXED
, than$.reimbursement.reimbursementAmount
field is requiredIf
$.reimbursement.type = PERCENTAGE
, than$.reimbursement.percentageDiscount
field is requiredin case of error - return 422 ('can't be blank')
If
$.reimbursement.percentageDiscount
submitted, check that its value is in range from 0 to 100in case of error - return 422 ('expected the value to be <= 100')
Validate program device start date submitted in
$.startDate
If
$.endDate
is submitted, check that program device start date is lesser than end datein case of error - return 422 ('must be earlier than the end date')
Service logic
Create program device entity in program_devices table in PRM DB with values from input. Also, set values:
id = autogenerate uuid
is_active = true
inserted_at = now()
updated_at = now()
inserted_by = user_id from token
updated_by = user_id from token
Render a response according to specification.
ЕСОЗ - публічна документація