healthlocker / oxleas-adhd

https://focus.headscapegreenwich.co.uk/
8 stars 0 forks source link

Medications Page Bug #232

Closed ghost closed 6 years ago

ghost commented 7 years ago

The medication page appears to have a bug as we are not able to update the page for new users. It kept throwing us out.

Info from Client:

Steps taken: Click on Log In -> Enter login/password details [Bones] -> Click “Log In”

Click on “Caseload” -> Click on a Service Users name -> Click on “Details and Meds” -> Click on “Medication” -> Complete all fields -> Click “Save”

This results in Error 404 (i.e. communication with server was successful however the server could not find what was requested)

screenshot 2017-11-06 11 18 32

NOT occurring on all users:

Does an SU work and then stop working? No...

Is occurring on both Desktop and Mobile (ipad not tested yet)

Client is using: Desktop: Tested on IE Ver. 11.0.9600 running Windows 7. Mobile: Samsung Internet browser Ver. 6.2.01.12 (latest version).

I have tried testing this using chrome and have been unable to replicate the bug.

Note: These users are on the test site only... the live site was kept clear of test users but the client have advised today that they have experienced the same on the live site when trying to onboard users.

RobStallion commented 6 years ago

Hey @katyedwards. When you tried to replicate this issue did you use the same log in details the client used?

If not would you be able to get us the log in details used so that we can try to check if this may be something specific to that user?

ghost commented 6 years ago

Yes I tried with the same users they mentioned and it didn't duplicate - and apparently it has occurred with others since. I'll get login details for you.

ghost commented 6 years ago

@RobStallion it looks like one or more of these users isn't showing the correct user ID on this page, but is showing number 6 instead - which we assume is the clinician ID (bones@headscape.com).

ghost commented 6 years ago

@RobStallion @reddog has found the issue!

reddog commented 6 years ago

Sample AppSignal error log at https://appsignal.com/mindwave-ventures-limited/sites/5a31d28dfc940e291200369d/incidents/6/samples/5a3267f8cbf15e47c96827bb

HTTP request error: expected at least one result but got none in query:

from r in Healthlocker.Room,
  join: u0 in Healthlocker.User,
  on: u0.id in ^[6],
  join: u1 in "user_rooms",
  on: u1.user_id == u0.id,
  where: u1.room_id == r.id

In this instance, user ID 6 is the user ID of the logged in clinician, not the service user being viewed.

reddog commented 6 years ago

AppSignal Environment section shows:

req_headers.referer   https://test-focus.headscapegreenwich.co.uk/users/6/medication/new
request_uri   http://test-focus.headscapegreenwich.co.uk:80/caseload/users/6

Hence the incorrect (clinician's) user ID is already in use before getting to the caseload/users/6 page where the error is generated.

reddog commented 6 years ago

There are two links from the clinician's view of the service user on the Details and Meds tab:

  1. the pill bottle
  2. the Medication button.

image 1

In the case where the service user does not have any medications stored, then the link for the Medication button is incorrect, see incorrect use of @current_user at https://github.com/healthlocker/oxleas-adhd/blob/7272412a94c90f657d859a4b8c3a071c67e4b05f/apps/healthlocker/web/templates/oxleas_adhd/caseload/user/details.html.eex#L38 and compare with correct use of @user at https://github.com/healthlocker/oxleas-adhd/blob/7272412a94c90f657d859a4b8c3a071c67e4b05f/apps/healthlocker/web/templates/oxleas_adhd/caseload/user/details.html.eex#L19