Validating structural issues in FhirValidator: parsed Bundle vs raw JSON

4 views
Skip to first unread message

Vinod A

unread,
Aug 20, 2025, 10:16:56 AMAug 20
to HAPI FHIR
Hello HAPI FHIR team,

Note: I’m starting a new thread because my previous private message in this group was not delivered due to email account issues.  
Reference to previous thread: [
https://groups.google.com/g/hapi-fhir/c/n5f-deE5lRo]


I noticed that certain structural issues in FHIR JSON are **not detected when validating a parsed Bundle**, but **are detected when validating raw JSON**.

Examples not caught by the Bundle option but detected when passing raw JSON:

1. **Extra array nesting in `category.coding`:**

"category": [
  {
    "coding": [
      [
        {
          "code": "food-insecurity",
          "system": "http://hl7.org/fhir/us/sdoh-clinicalcare/CodeSystem/SDOHCC-CodeSystemTemporaryCodes",
          "display": "Food Insecurity"
        }
      ]
    ]
  }
]


2. **Address object vs array mismatch:**

"address": [
  {
    "use": "work",
    "city": "Verona",
    "line": ["2025 Milky Way"],
    "text": "2025 Milky Way Verona, WI 53593-2222",
    "state": "WI",
    "country": "USA",
    "district": "DANE",
    "postalCode": "53593-2222"
  }
]


It seems that once the JSON is parsed, the original structure is lost, preventing both the Parser Error Handler and HAPI FHIR validator from detecting these structural issues.

Would passing the raw JSON directly to the validator be the recommended approach to catch these problems?  
Do you have any best practices or recommendations for ensuring such errors are always detected, even when working with parsed Bundles?

Thanks,  
Vinod A
Reply all
Reply to author
Forward
0 new messages