google / android-fhir

The Android FHIR SDK is a set of Kotlin libraries for building offline-capable, mobile-first healthcare applications using the HL7® FHIR® standard on Android.
https://google.github.io/android-fhir/
Apache License 2.0
479 stars 258 forks source link

minValue and maxValue support for quantity datatype #2381

Closed BuchiNy closed 9 months ago

BuchiNy commented 9 months ago

Is your feature request related to a problem? Please describe. trying to limit the range entered in a field which has the quantity datatype using minValue and maxValue but the two extensions do not work with the quantity datatype

Describe the solution you'd like the user should not be allowed to enter a number outside the minValue and maxValue set.

BuchiNy commented 9 months ago
{
      "extension": [
           {
              "url": "http://hl7.org/fhir/StructureDefinition/minValue",
              "valueQuantity": 1,
              "unit": "months"
           },
           {
              "url": "http://hl7.org/fhir/StructureDefinition/maxValue",
              "valueQuantity": 27,
              "unit": "months"
           },
           {
              "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-unitOption",
              "valueCoding": {
                "system": "http://unitsofmeasure.org",
                "code": "months",
                "display": "months"
             }
           }
         ],
          "linkId": "age-for-an-exposed-infant",
          "text": "<b>Enter:</b> Age (months)",
          "type": "quantity",
          "initial": [
           {
              "valueQuantity": {
                "unit": "months",
                "system": "http://unitsofmeasure.org",
                "code": "months"
             }
           }
         ]
}
MJ1998 commented 9 months ago

Hey @BuchiNy

Try this instead :-

{
  "url": "http://hl7.org/fhir/StructureDefinition/minValue",
  "valueQuantity": {
    "value": 7,
    "unit": "mo",
    "code": "mo",
    "system": "http://unitsofmeasure.org"
  }
},
{
  "url": "http://hl7.org/fhir/StructureDefinition/maxValue",
  "valueQuantity": {
    "value": 27,
    "unit": "mo",
    "code": "mo",
    "system": "http://unitsofmeasure.org"
  }
},
BuchiNy commented 9 months ago

@MJ1998

Hey @BuchiNy

Try this instead :-

{
  "url": "http://hl7.org/fhir/StructureDefinition/minValue",
  "valueQuantity": {
    "value": 7,
    "unit": "mo",
    "code": "mo",
    "system": "http://unitsofmeasure.org"
  }
},
{
  "url": "http://hl7.org/fhir/StructureDefinition/maxValue",
  "valueQuantity": {
    "value": 27,
    "unit": "mo",
    "code": "mo",
    "system": "http://unitsofmeasure.org"
  }
},

thank you for your suggestion but it is still not working and causes the applications to close after entering a number

MJ1998 commented 9 months ago

So this works with the latest code in the datacapture library. Let me check with the released version.

MJ1998 commented 9 months ago

Hey @BuchiNy

Which library version are you using ? Tested with latest version implementation("com.google.android.fhir:data-capture:1.0.0"). This is what it shows:-

Screenshot 2023-12-21 at 14 51 01

It's able to successfully test min and max extensions according to the extension I provided earlier. And there is no app failure.

Note: There is a slight error in the validation message where the value is shown as null. This has been fixed in the current master repo which we will have in the next release.

BuchiNy commented 9 months ago

@MJ1998

so i am using the same version, so i realized your method works like how you have shown when i just run that code on its own but when i integrate it to the rest of the questionnaire it causes problems. but thank you for directing me in the right direction

MJ1998 commented 9 months ago

Ok so due to some other logic in the questionnaire the app is crashing ? If yes, glad to know we are good here. Can we close this issue ?

BuchiNy commented 9 months ago

@MJ1998 yea it's a logic problem. we can close the issue