android-fhir icon indicating copy to clipboard operation
android-fhir copied to clipboard

Restricting DatePicker to select date from outside the defined Range (Min/Max). Added support for fhir path expression in Min / Max Validators

Open aurangzaibumer opened this issue 2 years ago • 4 comments

IMPORTANT: All PRs must be linked to an issue (except for extremely trivial and straightforward changes).

Fixes #1040

Description The min/max validators are updated to use fhir path expressions. For date picker specifically, the widget doesn't allow input outside of the date range, this is a widget specific behavior. User can specify minimum and maximum date range using minValue and maxValue expression in questionnaire in order to prevent selecting the dates from outside the specified range. cqf-calculatedvalue expression is used to make the expression dynamic and use for some purpose as Age case (for example we can only registered a child that is born after 2020) (min value case).

Alternative(s) considered Have you considered any alternatives? And if so, why have you chosen the approach in this PR?

Type Choose one: Feature

Screenshots (if applicable)

Checklist

  • [x] I have read and acknowledged the Code of conduct.
  • [x] I have read the Contributing page.
  • [x] I have signed the Google Individual CLA, or I am covered by my company's Corporate CLA.
  • [x] I have discussed my proposed solution with code owners in the linked issue(s) and we have agreed upon the general approach.
  • [x] I have run ./gradlew spotlessApply and ./gradlew spotlessCheck to check my code follows the style guide of this project.
  • [ ] I have run ./gradlew check and ./gradlew connectedCheck to test my changes locally.
  • [x] I have built and run the demo app(s) to verify my change fixes the issue and/or does not break the demo app(s).

aurangzaibumer avatar Jun 07 '22 06:06 aurangzaibumer

Codecov Report

Merging #1442 (9896a87) into master (eb894de) will decrease coverage by 35.30%. The diff coverage is n/a.

:exclamation: Current head 9896a87 differs from pull request most recent head 1e5bc7b. Consider uploading reports for the commit 1e5bc7b to get more accurate results

@@             Coverage Diff              @@
##             master   #1442       +/-   ##
============================================
- Coverage     35.30%       0   -35.31%     
============================================
  Files           144       0      -144     
  Lines          4830       0     -4830     
  Branches        853       0      -853     
============================================
- Hits           1705       0     -1705     
+ Misses         2904       0     -2904     
+ Partials        221       0      -221     
Impacted Files Coverage Δ
...hir/datacapture/MoreQuestionnaireItemComponents.kt
...acapture/validation/MaxValueConstraintValidator.kt
...acapture/validation/MinValueConstraintValidator.kt
...ws/QuestionnaireItemDatePickerViewHolderFactory.kt
...android/fhir/datacapture/mapping/ResourceMapper.kt
.../QuestionnaireItemAutoCompleteViewHolderFactory.kt
...e/android/fhir/db/ResourceNotFoundInDbException.kt
.../com/google/android/fhir/workflow/FhirEngineDal.kt
...tionnaireItemBooleanTypePickerViewHolderFactory.kt
...datacapture/fhirpath/FHIRPathEngineHostServices.kt
... and 134 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov[bot] avatar Jun 14 '22 10:06 codecov[bot]

Thanks for the change. This PR actually does 2 things:

  1. the min/max validators are updated to use fhir path expressions. for this part, please add unit tests
  2. for date picker specifically, the widget doesn't allow input outside of the date range, this is a widget specfic behavior

Please update the description to reflect this.

jingtang10 avatar Jun 16 '22 08:06 jingtang10

@jingtang10 This PR is ready for review CC @Tarun-Bhardwaj

f-odhiambo avatar Jun 20 '22 12:06 f-odhiambo

https://user-images.githubusercontent.com/35099184/180433662-5c6fde87-bbcf-4558-b2f7-ad1d47f7eeb7.mp4

I've resolved non-test case classes feedback, can you please review so that i can move to resolve the unit test cases. thanks in advance. @jingtang10

cc @f-odhiambo

aurangzaibumer avatar Jul 22 '22 11:07 aurangzaibumer

@aurangzaibumer please fix build errors (run spotlessApply)

omarismail94 avatar Aug 22 '22 10:08 omarismail94

@aurangzaibumer please fix build errors (run spotlessApply)

done. thanks

aurangzaibumer avatar Aug 22 '22 11:08 aurangzaibumer

Hello @omarismail94 I've tried updating the branch with master couple of times but PR gateways are still failing. Error Caused by: kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 120000 ms Can you please guide me on this. Thanks

aurangzaibumer avatar Sep 20 '22 06:09 aurangzaibumer

For testing purpose updating example

  "resourceType": "Questionnaire",
  "item": [
    {
      "linkId": "1",
      "text": "When was your last menstrual period? (LMP)",
      "type": "date",
      "extension": [
        {
          "url": "http://hl7.org/fhir/StructureDefinition/maxValue",
          "valueDate": "2022-12-30"
        },
        {
          "url": "http://hl7.org/fhir/StructureDefinition/minValue",
          "valueDate": "2022-12-21"
        }
]
...

santosh-pingle avatar Oct 21 '22 06:10 santosh-pingle