Database search using a list as keyword

Hi,

in my app, users have medical issues, and each medical issue has a list of rehabilitation exercises. I want to create a workflow that attaches the list of rehabilitation exercises to a user based on his medical issues.

My data structure looks as follows:

  1. The table User contains a list of Medical Issues and a User’s Exercise List (which I would like to populate):

  1. The table Medical Issues contains a Rehab Exercise List for each Medical Issue:

In order to attach the list of rehabilitation exercises to a user based on his medical issues, I need a workflow that does the following:

  • Search the table Medical Issues using the list of medical issues of the user, and return all the relevant rehabilitation exercises
  • Add the relevant rehabilitation exercises in the field “Rehab Exercise List” on the User table

It would be awesome if you could help me! Please let me know if I need to clarify.

Thank you!

Nicola

Hello again @nicola.kegel, :slight_smile:

In this scenario, it may make things easier if you also stored a list of “Exercises” on the Medical Issue data type, and stored a list of “Medical Issues” on the Exercise data type. This way, after your User adds their “Medical Issues”, you could display a list of the recommended “Exercises” using:


This data source would display all of the Exercises associated with each of the Current User’s Medical Issues. :uniqueelements ensures that no duplicate Exercises will be shown.

Then you can show the User which Medical Issue each Exercise helps with using this expression:


(This expression uses the “intersect with” operator which takes the Medical Issues associated with the Current cell’s Exercise, compares that list of Medical Issues, to the Current User’s list of Medical Issues, and returns only Medical Issues that are the same in both lists. In summary, the expression takes the Medical Issues that the Exercise is useful for, and only displays Medical Issues that the Current User has.

For example, if the Exercise is “Walking”, and Walking’s list of Medical Issues is Herniated Discs and Sprained Ankles - and the Current User’s only medical issue is “Sprained Ankles”- then the text in the repeating group would read “This exercise will help you with: Sprained Ankles”, not “This exercise will help you with: Herniated Discs and Sprained Ankles”, since Herniated Discs is not relevant to the Current User.)

That should work, but feel free to let me know if you have any questions! :slight_smile:

3 Likes

Thank you sooo much Faye! :hugs::slightly_smiling_face:

1 Like

This is a fascinating setup. Thanks for this answer. And @nicola.kegel, Thanks for asking this question.

2 Likes

No problem at all, @mike_verbruggen! :smiley: