Purpose
This WS is designed to search Episodes of Care grouped by Groups of Diagnoses. If the user has approval on the Group of Diagnoses, he will receive a list of short Episodes of Care which contain diagnoses from this Group. To receive full Episode of Care data user must have the approval and use https://edenlab.atlassian.net/wiki/spaces/EH/pages/610041863 endpoint.
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 = 'episode:read')
Return (403, 'Your scope does not allow to access this resource. Missing allowances: episode:read') in case of invalid scope(s)
Search params
period_from. Filter Episodes of Care where
period.start
is greater thanperiod_from
.period_to. Filter Episodes of Care where
period.end
is less thanperiod_to
.diagnoses_group_id.
Get
diagnoses_codes
array from PRM.diagnoses_group_codes bydiagnoses_group_id
.Select Episodes of Care where
diagnoses_history.code
is indiagnoses_codes
array.
managing_organization_id. Filter Episodes of Care where
managing_organization.identifier.value
is likemanaging_organization_id
.
Service logic
Service returns list of short Episodes of Care, which contain diagnoses from Groups of Diagnoses user has approval on, filtered by submitted parameters:
Select list of employees from PRM.employees related to the current user in the current legal_entity, using data from the token.
Select all active approvals on
diagnoses_groups
from ME.approvals (Mongo DB), where these employees referenced asgranted_to
.Get
diagnoses_codes
array fromdiagnoses_groups
(PRM.diagnoses_group_codes DB).Get Episodes of Care by person_id from ME.episodes (Mongo DB) where:
status
is "active"at least one code from
diagnoses_history
is indiagnoses_codes
array and wherediagnoses_history.status
== "active".
Filter Episodes of Care by submitted search params (period_from, period_to, diagnoses_group_id, managing_organization_id).
Order Episodes of Care by
inserted_at
and render a response according to specification:diagnoses
block should contain diagnoses with codes fromdiagnoses_codes
array only.