Skip to content

Added simplified cohort sample UI.#2373

Merged
chrisknoll merged 6 commits into
masterfrom
cohort-sample-lite
Nov 19, 2020
Merged

Added simplified cohort sample UI.#2373
chrisknoll merged 6 commits into
masterfrom
cohort-sample-lite

Conversation

@chrisknoll
Copy link
Copy Markdown
Collaborator

Depends on OHDSI/WebAPI#1657.

Thank you Andries Purnal (Andries.Purnal@ucb.com), Florence Giesen (Florence.Giesen@ucb.com), @MaximMoinat and The Hyve for their implementation, which this PR is based on.

This is the simplified cohort sample functionality which allows a sample to be pulled from a source, and then navigated to the current patient profile UI.

@chrisknoll
Copy link
Copy Markdown
Collaborator Author

Back-end has been merged (so the endpoints are now available in WebAPI. Need a review on the UI side.

@blootsvoets
Copy link
Copy Markdown
Contributor

blootsvoets commented Nov 13, 2020

The create sample form validation creates some errors now. Expected behaviour:

Situation 1: no values have been filled and no button has been pressed.

Expected behaviour: All fields are empty, no warnings are shown.
Actual behaviour: The Name, Number of patients, and Age text inputs show error messages and they are indicated as being erroneous.
Possible resolution: don't do form validation until someone presses the submit button or possibly when they leave a form input field.

Situation 2. Sampling without age criteria

Expected behaviour: if no value is filled for age criteria, a sample is created with no age criteria applied.
Actual behaviour: form validation prohibits an empty age criteria, meaning that all samples now need age criteria.
Possible solution: allow an empty value in age criteria OR add a default dropdown option "No age criteria" that removes the age field from view.

@chrisknoll
Copy link
Copy Markdown
Collaborator Author

Hello,
For the first item, I think showing validation errors as the form is populated is good UX: you don't want to have to wait for the user to click a button in order to point out the things that are wrong. In addition, the submit button is disabled until the form is valid, so I can't validate-on-submit.

Good catch on the second one, I misunderstood the validation logic for a required field. I can fix that.

@chrisknoll
Copy link
Copy Markdown
Collaborator Author

Ok, I fixed the optional age range validation, and also noticed that the validation called for non-equal values, so I added that check too.

Thanks for checking!

this.patientCountError=ko.pureComputed(() => !(this.patientCount() > 0)); // this works because null == 0
this.isAgeRange =ko.pureComputed(() => ['between','notBetween'].includes(this.sampleAgeType()));
this.firstAgeError = ko.pureComputed(() => this.firstAge() != null && this.firstAge() < 0);
this.isAgeRangeError = ko.pureComputed(() => this.isAgeRange() && (this.firstAgeError() || (this.secondAge() != null && this.secondAge() < 0) || this.firstAge() == this.secondAge()));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is encoded, it think that another age range condition is firstAge <= secondAge.

Copy link
Copy Markdown
Collaborator Author

@chrisknoll chrisknoll Nov 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the age order doesn't matter (I was surprised to find this) that's why the validation error message says that it's an error if they are equal. When the form is submitted, the smaller value is put as firstAge, and the larger is secondAge.

blootsvoets
blootsvoets previously approved these changes Nov 17, 2020
Copy link
Copy Markdown
Contributor

@blootsvoets blootsvoets left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

@blootsvoets blootsvoets left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I retested with the new configuration, there's still some issues there

  1. If one age field is provided in between or notBetween, the form accepts the input, but the backend rejects it because it requires two ages. I think this input should be rejected in the form.
  2. If first the "between" dropdown is selected, the second input is filled, and then "Less than" is selected with no text input, the data still includes an age criterion "age":{"value":null,"mode":"lessThan","min":null,"max":null}. If no age is provided in the current dropdown also no age criterion should be sent to the backend ("age": null).
  3. The behaviour of the age selection would be more consistent if it either allowed any dropdown option without any input to indicate no age criterion (this does not work for between/notBetween), or to have a dedicated "Any age" dropdown option.
  4. If no age was selected, the sample table shows "Random age" as age selection. Perhaps "Any age" would be more appropriate. Likewise, instead of "Mix", "Any gender" could be shown.

this.newSampleCreatingLoader(true);
sampleService.createSample(payload, {cohortDefinitionId, sourceKey})
.then(res => {
if(res.ok) {
Copy link
Copy Markdown
Contributor

@blootsvoets blootsvoets Nov 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the server rejects the input, res is undefined and the console throws an error that res.ok does not exist. The following would avoid an error:

Suggested change
if(res.ok) {
if(res && res.ok) {

@chrisknoll
Copy link
Copy Markdown
Collaborator Author

Thanks for the hints, I'll work on these changes.

Use await and try..catch to handle errors.
@chrisknoll
Copy link
Copy Markdown
Collaborator Author

Ok, I've made the changes you've suggested. This includes moving to an 'async..await' form of handling promises so that try..catch works predictably. The issue with prior code was how .catch() handlers were being attached to the promises, leading to then() being invoked even in case of error. Now, the then() will only get fired when the request was successful, and the catch() and finally() will be handled within he context of the await.

@chrisknoll
Copy link
Copy Markdown
Collaborator Author

I'm hoping that the final reviews are completed, and can get sign-off on this PR. Please let me know if you have any additional comments, as I'm anxious/excited to close this out.

@blootsvoets
Copy link
Copy Markdown
Contributor

Yes, looks good to me. Thanks for your hard work in making this suitable for merge!

@chrisknoll chrisknoll merged commit ff1d774 into master Nov 19, 2020
@delete-merged-branch delete-merged-branch Bot deleted the cohort-sample-lite branch November 19, 2020 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants