phenopolis / phenopolis_genomics_browser

Python API and React frontend for the Phenopolis Genomics Browser
https://dev-live.phenopolis.org
MIT License
31 stars 2 forks source link

Non-Admin User create patient bug #315

Closed YuanTian1991 closed 3 years ago

YuanTian1991 commented 3 years ago

I created two patients via dev-API, one is under my account 'Tian' (PH00008630), and one under Admin account (PH00008631).

They can both be seen in Manage_Patient page, which is Admin only. And the total number of patient shows 8631, which is OK.

image

However, when click the patient ID created by "Tian" account: PH00008630, there is no information could be fetched for this patient. However, PH00008631 works well.

Even, if we now change to My_Patient page. All these new created patients can't be seen. It seems above two API call referred two different DB.

image

Finally, I tried to search the new created patients in dev-live website, only the patient created by Admin (PH00008631) can be found and properly clicked. But it can't be previewed properly. image


YuanTian1991 commented 3 years ago

Update, Thank God I have not merge my current branch, so the naughty Patient PH00008630 could still be deleted by old dev-live system (new branch version can't achieve it actually...maybe I should adopt the old design). However, I leave this sample here for now, to let the backend team check possible bugs.

image

YuanTian1991 commented 3 years ago

Patient Create API

The two patients are created by: https://github.com/phenopolis/phenopolis_browser/blob/3939ea660e70d4ab92e45b371378a16eb3fccafc/views/individual.py#L126-L177

The main error for above API is:

  1. Patient created by a normal user (like Tian) is not accessible. (By the way, Demo user can not create patient at all).
  2. Create Patient does not have proper HPO/All tag in feature, which is vital to be searched out.

Update Patient Information API

Patient information (like features, genes, sex .etc) can be updated by below API: https://github.com/phenopolis/phenopolis_browser/blob/3939ea660e70d4ab92e45b371378a16eb3fccafc/views/individual.py#L95-L123

The potential error for above API is:

When I assign patient with for example 'All', the feature will show HP:0000001, but not All tag will be added. Correct me if I need to pass correct data from front-end.

In summary

I think we should:

  1. Fix the patient creation, fetching, showing on all pages for Admin at least smoothly.
  2. Then make sure all other normal users (non-admin) can achieve the same for patients they have access to.
alanwilter commented 3 years ago

The problem is that, essentially, we are creating the new patient into phenopolis.individual and related tables: phenopolis.individual_feature, phenopolis.individual_gene while autocomplete module still looks into old schema public.individuals.

As I mentioned in the meeting, I need to refactor autocomplete.py and other files, but doing so I need to refactor users (and this gets quite complicated and I'd need to sort several other tables associated to it), but let me see if I can fix only for patient for the moment.

alanwilter commented 3 years ago

I need to refactor hpo.py, to stop using old schema.

alanwilter commented 3 years ago

AFAIK I've fixed all the issues reported here. Just disable cache when using Chrome Inspect to see your changes about patients and so on. Be careful as well when using autocomplete, it's still looking at old tables so, when creating a new patient, "Blindness" may show up but won't work, try e.g. "Skin tags", that will work. My next step to finish refactoring autocomplete.py. Test it yourself and, if happy, close this ticket.

alanwilter commented 3 years ago

Fixed with #324