StanfordBDHG / ResearchKitOnFHIR

HL7 FHIR Structured Data Capture with ResearchKit on iOS
https://swiftpackageindex.com/StanfordBDHG/ResearchKitOnFHIR/documentation
MIT License
13 stars 2 forks source link

šŸ› Bug report: Custom error messages not displayed for number and text validation #65

Closed iadereggalternova closed 8 months ago

iadereggalternova commented 11 months ago

Description

I've noticed an issue where custom error messages for both Number and Text type questions in our survey forms aren't being displayed as expected. While the validations are functioning correctly, the custom error messages we've set up arenā€™t showing up when a user fails to meet the validation criteria.

Reproduction

To give you a better idea, hereā€™s how you can reproduce the issue:

For Number Question

For Text Question

JSON sample

{
  "title": "Test custom error message",
  "resourceType": "Questionnaire",
  "language": "en-US",
  "status": "draft",
  "publisher": "Stanford Biodesign Digital Health",
  "meta": {
    "profile": [
      "http://spezi.health/fhir/StructureDefinition/sdf-Questionnaire"
    ],
    "tag": [
      { "system": "urn:ietf:bcp:47", "code": "en-US", "display": "English" }
    ]
  },
  "useContext": [
    {
      "code": {
        "system": "http://hl7.org/fhir/ValueSet/usage-context-type",
        "code": "focus",
        "display": "Clinical Focus"
      },
      "valueCodeableConcept": {
        "coding": [
          {
            "system": "urn:oid:2.16.578.1.12.4.1.1.8655",
            "display": "Test custom error message"
          }
        ]
      }
    }
  ],
  "contact": [{ "name": "http://spezi.health" }],
  "subjectType": ["Patient"],
  "url": "http://spezi.health/fhir/questionnaire/dd859ee0-4e7a-4131-f6fa-2239f0ad08b2",
  "item": [
    {
      "linkId": "282ca91c-5123-4c68-9755-8b5aab297dac",
      "type": "integer",
      "extension": [
        {
          "url": "http://hl7.org/fhir/StructureDefinition/minValue",
          "valueInteger": 0
        },
        {
          "url": "http://hl7.org/fhir/StructureDefinition/maxValue",
          "valueInteger": 10
        },
        {
          "url": "http://ehelse.no/fhir/StructureDefinition/validationtext",
          "valueString": "Custom error message..."
        }
      ],
      "required": false,
      "text": "Please, rate your attention"
    },
    {
      "linkId": "1d0a234f-bbd2-4ef4-8b26-1110cce45efe",
      "type": "string",
      "text": "Please describe the characteristics of you pain?",
      "required": false,
      "extension": [
        {
          "url": "http://ehelse.no/fhir/StructureDefinition/validationtext",
          "valueString": "Custom error message..."
        },
        {
          "url": "http://hl7.org/fhir/StructureDefinition/regex",
          "valueString": "^\\s*\\S+(\\s+\\S+){0,2}\\s*$"
        }
      ]
    }
  ]
}

Expected behavior

Ideally, when a user inputs data that doesn't meet the validation criteria, our custom error message should be displayed to guide them.

Additional context

No response

Code of Conduct

vishnuravi commented 8 months ago

Hi @iadereggalternova, the issue is that we use a different validation message extension in ResearchKitOnFHIR than you have in your JSON, which was likely generated with an older version of the Phoenix survey builder. If you update it to "http://biodesign.stanford.edu/fhir/StructureDefinition/validationtext", it should work with ResearchKitOnFHIR. Hope this helps!