Trying to pull up info from linked data tables

What I’m trying to do:

So basically my group and I are trying to create an app for doctor appointments. The idea is that on the homepage, you should be able to click on the name link in the upcoming appointments card when you sign in as admin. Once you click the name, it should bring you to the PatientInfoComponent which should have all their personal info such as name, bday, etc…

What I’ve tried and what’s not working:
I have tried creating a link column that links the appointment table to the users table. So far, I can’t seem to find anything wrong with my code or data bindings but when I try to run it I get this error message: Screen Shot 2021-03-08 at 1.26.22 AM

Other screenshots of the code:

Screen Shot 2021-03-08 at 1.27.19 AM

Screen Shot 2021-03-08 at 1.28.01 AM

Hi @rebecca.bae and welcome to the forum!

In your get_patient_info function, do you mean to return patient_info? Right now you are just returning the same thing you are passing into the function.

Hello Brooke!

I see what you mean. I fixed it and replaced “uploaded_by” with “patient_info” and unfortunately it still doesn’t work. When I try to run it and click one of the name links on the home page it returns a blank screen.

If you haven’t already, it’s good practice to add print statements to your code. Make sure self.item, patient_info, etc are what you think they are. The error you’re receiving is telling you that self.item is not a dictionary like it should be but a list.

Thank you for you fast feedback, I really appreciate all of it! I see what you mean but I still don’t understand why patient info is not coming up when I click the link.

https://anvil.works/build#clone:TEPTUEJAMMHKRQGV=B5RMFR7DEQ6GFVVW562DNH4T

I posted the clone link above. If you are available to, could you take a look at my codes and try to help me with my issue? I’ve been trying to figure it out for hours all day yesterday and still could not find a solution.

The username is admin@admin.com and password is 12345!

Okay, so the first issue is in your get_patient_info function where you are searching the users table for rows where the uploaded_by column has a value of “uploaded_by”. This returns a value of None because there are no such rows. Since the argument you are passing into the function is a row in the appointments DataTable, you can pull the name column from this by doing uploaded_by['name']. So the function becomes something like:

def get_patient_info(uploaded_by):
   name = uploaded_by['name']
   return app_tables.users.get(uploaded_by=name)

The second issue lies in setting the self.repeating_panel_patient_info.items in PatientInfoComponent.ItemTemplate3. Repeating Panels expect to be able to iterate over dictionaries. Right now, you are setting the items property to a single dictionary. You can make it iterable by putting it in a list:
self.repeating_panel_patient_info.items = [anvil.server.call('get_patient_info', uploaded_by)]

However, if you are only going to be displaying one person’s info at a time, you don’t need to use a repeating panel. You can still add Data Bindings to components without one.

I hope that helps! It all seems to be working for me with those changes. :slight_smile:

2 Likes