BDSC-CDS / glowing-bear-medco-bioref

A modification of the MedCo front-end project which brings reference intervals to the rescue. Check the following link for a documentation about the BioRef-specific implementation: https://github.com/CHUV-DS/glowing-bear-medco-bioref/blob/bioref/bioref_doc.md
Mozilla Public License 2.0
0 stars 0 forks source link

Creating predetermined cohort filters by enabling the tagging of default cohorts in the "saved cohorts" pane. #9

Closed WiseIndian closed 2 years ago

WiseIndian commented 2 years ago
  • As previously discussed, there needs to be preloaded (and “empty”) cohort criteria of AdministrativeSex, Age and other predetermined conditions for an easier UX. These concepts should be set to “any” or “all” by default. The user then only has to drag and drop the analyte (e.g. sodium) from the ontology for an analysis.

=> add predefined cohort filters in DB that are accessible to all users and cannot be deleted => enable the possibility of tagging one of the cohort filters as "default" => implement the logic to pre-fill the cohort definition panel with the default filter at login time

WiseIndian commented 2 years ago

Add an icon next to the "Important" star to define the default

WiseIndian commented 2 years ago

Properties of a default cohort: Only a single default can exist per medco network. This sort of cohort cannot be deleted. The information of which cohort is set as default is returned by the principal medco node.

We create a new table (default_cohort) which will store a single row that references the default cohort contained in database. Either this table is empty if no default cohort exist or it contains a single element. Only a single information needs to be stored within this table: the cohort_id that links to the saved_cohorts table.

We add a new binary flag column to the saved_cohorts table. It will indicate whether this row is predefined. If it is predefined a saved cohort cannot be deleted. We need to modify all methods which work on the saved cohort (delete, get, post) to ensure they still function with that new column. We need to create a patch pgsql script to create this column.

We have to modify the backend to ensure that the predefined cohorts cannot be deleted. To avoid deletion by the user we need to modify the code which allows deletion of saved cohorts by the user. To respect this pre-requisite the delete method needs to check if the binary flag is set to true.

For each use case where predefined cohorts will be used a script loading those will have to be created.

The front-ends needs to be modified, as well as the API which return information about saved cohorts.

Two new additional piece of information are sent together with saved cohorts from the backend to front-end: whether or not the cohort is a default cohort, whether or not a cohort is a predefined cohort.

The front end needs to forbid a user to delete predefined cohorts. The front end needs to restore the default cohort automatically when a user logs in glowing bear. The front end needs to allow the users to save cohorts as default.

A new API entrypoint needs to be implemented which will allow users to save cohorts as default. This handler will change the content of the default_cohort table. The handler verifies the cohort set as default indeed exists within the saved_cohort table.

JLRaisaro commented 2 years ago

Small correction to the comment above: The predefined cohort should be selectable by the user in the GUI and the user should also be able to decide to not have any predefined cohort but just have the cohort panel empty if no cohort is selected as default.

Question: why do you need to create a new table "default_cohort" can't you just add a column in the "saved_cohort" table?

WiseIndian commented 2 years ago

Question: why do you need to create a new table "default_cohort" can't you just add a column in the "saved_cohort" table?

You are right. I think I forgot that there could be different default cohorts for different users.

WiseIndian commented 2 years ago

Update of the previous comment

Properties of a default cohort: Only a single default cohort can exist per user. The information of which cohort is set as default is returned by the principal medco node.

Predetermined cohorts: This sort of cohort cannot be deleted.

We create a new column default_cohort which will store whether a cohort is a default cohort. This column is added to the saved_cohort table.

We add a new binary flag column to the saved_cohorts table. It will indicate whether this row is predefined. If it is predefined a saved cohort cannot be deleted.

We need to modify all methods which work on the saved cohort (delete, get, post) to ensure they still function with the two new columns.

We need to create a patch pgsql script to create the two new columns.

We have to modify the backend to ensure that the predefined cohorts cannot be deleted. To avoid deletion by the user we need to modify the code which allows deletion of saved cohorts by the user. To respect this pre-requisite the delete method needs to check if the binary flag is set to true.

For each use case where predefined cohorts will be used, a script loading those will have to be created.

The front-ends needs to be modified, as well as the API which return information about saved cohorts.

Two new additional piece of information are sent together with saved cohorts from the backend to front-end: whether or not the cohort is a default cohort, whether or not a cohort is a predefined cohort.

The front end needs to forbid a user to delete predefined cohorts. The front end needs to restore the default cohort automatically when a user logs in glowing bear. The front end needs to allow the users to save cohorts as default.

A new API entrypoint needs to be implemented which will allow users to save cohorts as default. This handler will change the content of the saved_cohort table. The handler verifies the cohort set as default indeed exists within the saved_cohort table. It removes the default flag from other saved_cohorts rows linked to the current user.

JLRaisaro commented 2 years ago

@nfreundl there is a bug when saving a cohort

JLRaisaro commented 2 years ago

the bug could not be reproduced