Need help creating a changeset function with multiple fields check both from database and changeset


I’m trying to create a function for the last couple of hours with no luck so I could really use your help.

So, it’s a Phoenix app and I have a user profile form. There are several fields in that form like name, city, country, etc and when the user fills all the fields, I want to do some action. The problem I have is that some of those fields may be already filled by a user in the past, for example; user can enter a name one time and then add city and country at some other time. That means that I have to check both the existing user profile and the changeset to see if all the fields are filled. When all the fields are filled, wether in profile or in the changeset, I want it to do some action.
I have really hard time checking for all those things, there are quite a lot of conditionals here so I could really use some guidance on how to create a function that would do all those checks. I’m still a beginner and this is probably simple thing but I’m really struggling at the moment.

def changeset(%Profile{} = profile, attrs \\ %{}) do
    |> cast(attrs, [:name, :bio, :city, :state, :country])
    |> maybe_complete_profile(profile)

defp maybe_complete_profile(changeset, profile) do
   # if all the fields, in profile or in the changeset are filled do something
   # else return changeset

validate_required would tell if you all the required fields are present or not

There’s a specific function to do this - Ecto.Changeset.get_field/3