A person can have an array of authentication methods.
To determine necessery the method of patient authentication, if person hasn’t active authentication_method - return null.
If person has active auth_method.type = OTP - select it, if it is not - select active auth_method.type =OFFLINE. And if there is no OTP or OFFLINE, select the one that is of the active auth method with type = third_person where type = OTP and the first one is added. Then the auth method isn’t found, select the first added active auth method.type =third person where third_person.auth_method.type = OFFLINE. If nothing is found, return null.
This method return person’s auth method. which person can use and one of this method has primary=True.
Example when adult person has selt auth_method = OTP and three auth_method with type = third_person (third_person_1 has auth_method.type = NA, third_person_2 has auth_method.type = OTP and third_person_3 has auth_method.type = OFFLINE ).
[ { type : OTP, phone_number : +380951111119, is_primary : TRUE}, {type : THIRD_PERSON, value : 6eaeea53-47ac-459a-bcd8-c90a36947de6, reference: { type = OTP, phone_number : +380952222222} is_primary : FALSE}, type : THIRD_PERSON, value : b8c6679d-0df2-4407-8c3e-3fe58fa32655, reference: { type = OFFLINE}, is_primary : FALSE} ]