@@ -8,7 +8,7 @@ defmodule NdbRestApiWeb.Api.PractitionerController do
88 action_fallback NdbRestApiWeb.FallbackController
99
1010 def index ( conn , _params ) do
11- practitioners = Practitioners . list_practitioners ( ) |> Repo . preload ( : hospitals)
11+ practitioners = Practitioners . list_practitioners ( ) |> Repo . preload ( [ :gender , :role , : hospitals] )
1212 render ( conn , :index , practitioners: practitioners )
1313 end
1414
@@ -23,12 +23,12 @@ defmodule NdbRestApiWeb.Api.PractitionerController do
2323 end
2424
2525 def show ( conn , % { "id" => id } ) do
26- practitioner = Practitioners . get_practitioner! ( id ) |> Repo . preload ( : hospitals)
26+ practitioner = Practitioners . get_practitioner! ( id ) |> Repo . preload ( [ :gender , :role , : hospitals] )
2727 render ( conn , :show , practitioner: practitioner )
2828 end
2929
3030 def update ( conn , % { "id" => id , "practitioner" => practitioner_params } ) do
31- practitioner = Practitioners . get_practitioner! ( id ) |> Repo . preload ( : hospitals)
31+ practitioner = Practitioners . get_practitioner! ( id ) |> Repo . preload ( [ :gender , :role , : hospitals] )
3232
3333 with { :ok , % Practitioner { } = practitioner } <-
3434 Practitioners . update_practitioner ( practitioner , practitioner_params ) do
@@ -37,7 +37,7 @@ defmodule NdbRestApiWeb.Api.PractitionerController do
3737 end
3838
3939 def delete ( conn , % { "id" => id } ) do
40- practitioner = Practitioners . get_practitioner! ( id ) |> Repo . preload ( : hospitals)
40+ practitioner = Practitioners . get_practitioner! ( id ) |> Repo . preload ( [ :gender , :role , : hospitals] )
4141
4242 with { :ok , % Practitioner { } } <- Practitioners . delete_practitioner ( practitioner ) do
4343 send_resp ( conn , :no_content , "" )
@@ -48,7 +48,7 @@ defmodule NdbRestApiWeb.Api.PractitionerController do
4848 Searches a specific practitioner by email.
4949 """
5050 def search ( conn , % { "email" => email } ) do
51- practitioner = Practitioners . get_practitioner_by_email ( email )
51+ practitioner = Practitioners . get_practitioner_by_email ( email ) |> Repo . preload ( [ :gender , :role , :hospitals ] )
5252 render ( conn , :show , practitioner: practitioner )
5353 end
5454end
0 commit comments