Purpose
This WS gives the opportunity to update external identifier of unidentified person in eHealth.
Specification
Service logic
Only authenticated and authorized OWNER, SPECIALIST, ASSISTANT, RECEPTIONIST, DOCTOR, ADMIN employees can update external_id of preperson.
Preperson can be updated by any legal entity type except PHARMACY, if person_id is being known (returns after Create preperson).
Only external_id field can be updated.
Update allowed for prepersons with status = ACTIVE.
Authentication
Verify the validity of access token
Return 401 in case validation fails
Check user scopes in order to perform this action (scope = 'preperson:update')
Return 403 in case invalid scope(s)
Validate legal entity
Check that legal entity is active (status = ACTIVE, SUSPENDED) and belongs to the user
Extract client_id from token (token.client_id == legal_entity_id)
Check legal entity status (status = ACTIVE, SUSPENDED)
In case of error - return 409 (Legal entity must be ACTIVE or SUSPENDED)
Validate person_id
Check person_id belongs to preperson
Check there is no entry in MPI.persons with this person_id
In case error - return 422 (Person_id doesn’t belong to unidentified person)
Convert person_id into patient_id. Check patient_id exists in medical_data.patients collection
In case error - 404
Check preperson has status=active
In case error - return 422 (Unidentified person is not active)
Validate external_id
Check external_id is not empty.
In case of error - return 422 (external_id should not be empty)
Check external_id is unique ? (unique within le?)
In case of error - return 422 (external_id already exists) ?
Update object in DB (mongo)
patients collection
Parameter | Source | Description |
---|---|---|
external_id | Request: external_id | Identifier from external system, required. Get from request body |
updated_at | timestamp: now() | Get current date-time |
updated_by | uuid | Extract user from token |