Service logic
Create job and return it’s id.
Update Composition record with following:
status = $.status
status_reason = $.status_reason
explanatory_letter =$.explanatory_letter
updated_at = current datetime
updated_by = user_id from token
Send SMS to patient with composition number via template
MARK_IN_ERROR_{{COMPOSITION_TYPE}}_COMPOSITION_SMS_TEMPLATE
If $.inform_with
authorize_withis submitted - use it as patient’s authentication exists in Composition and is not empty, check:Authentication method exists in person_authentication_methods table in MPI DB (with is_active=true), is active (ended_at > now() or null)
Get value of THIRD_PERSON_CONFIDANT_PERSON_RELATIONSHIP_CHECK config parameter
if it is set to true - for authentication method with type = THIRD_PERSON check that person from value is an approved confidant for a person from Composition:
exists active and approved confidant person relationship between patient from the Composition and confidant_person_id from authentication method value (using following logic: Check confidant person relationship with person_id = person from request and confidant_person_id = value from auth method - expected :ok, :approved response)
in case any validation failed - do not send SMS to person
else - send SMS to authorization method