Identifying resources failing validation during an R4 $hapi.fhir.merge

187 views
Skip to first unread message

Sophia Jaffe

unread,
Aug 28, 2026, 8:02:37 AMAug 28
to HAPI FHIR
Hi -

We're trying to use the $hapi.fhir.merge operation in an environment with a lot of old resources created prior to (possibly breaking) changes in our internal FHIR IG. For certain patients, the merge is failing with HAPI-1700 when it finds a resource which isn't compliant with our current IG.

We're on R4, hapi-fhir version 8.10.0, using the JPA server starter project. Our IG implements USCore/QICore.

Below are a couple errors from the merge operation response. The patients with issues have hundreds of resources, and so far we haven't been able to find any resources that should be failing validation against the base IG nor our own IG.

Are there any ways to find which resources are failing validation during a merge operation? I'd rather not fork hapi-fhir to add logging. My only other idea is somehow using the $validate operation against every resource the $hapi.fhir.merge operation would touch - assuming it's the same validation that occurs during a merge.

"name": "outcome",
"resource": {
"issue": [
{
"code": "exception",
"diagnostics": "HAPI-1700: Unknown child name 'author' in
element Annotation - Valid names are: [authorOrganization, authorPatient,
authorPractitioner, authorReference, authorRelatedPerson, authorResource,
authorString, author[x], extension, extension[x], id, text, time]",
"severity": "error"
}
],
"resourceType": "OperationOutcome"
}
}

{
"name": "outcome",
"resource": {
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "error",
"code": "exception",
"diagnostics": "HAPI-1700: Unknown child name
'value' in element Extension - Valid names are: [extension, extension[x],
id, url, valueAddress, valueAge, valueAnnotation, valueAttachment,
valueBase64Binary, valueBoolean, valueCanonical, valueCode,
valueCodeableConcept, valueCoding, valueContactDetail,
valueContactPoint, valueContributor, valueCount, valueDataRequirement,
valueDate, valueDateTime, valueDecimal, valueDistance, valueDosage,
valueDuration, valueElementDefinition, valueExpression, valueExtension,
valueHumanName, valueId, valueIdentifier, valueInstant, valueInteger,
valueMarkdown, valueMarketingStatus, valueMeta, valueMoney, valueNarrative,
valueOid, valueParameterDefinition, valuePeriod, valuePopulation,
valuePositiveInt, valueProdCharacteristic, valueProductShelfLife,
valueQuantity, valueRange, valueRatio, valueReference, valueRelatedArtifact,
valueSampledData, valueSignature, valueString, valueSubstanceAmount,
valueTime, valueTiming, valueTriggerDefinition, valueUnsignedInt,
valueUri, valueUrl, valueUsageContext, valueUuid, valueXhtml, value[x]]"
}
]
}
}

Sandy Wright

unread,
Aug 28, 2026, 12:36:33 PMAug 28
to HAPI FHIR
Hi, adding some more context to this!

We actually discovered the issue with the first error - we had the old patient identified as a reference in the `authorReference` field of several Annotation elements. The merge process correctly identified that this reference should be updated, however it DROPPED the `Reference` suffix when updating the resource. The error was thus not due to any original or legacy resources that were malformed, but rather the merge process itself failing to maintain the proper structure with the author[x] field. 

Is this on HAPI's radar as an issue? Is there any way for us to fix this via server configuration? This is a pretty big malfunction on the merge process' part.

James Agnew

unread,
Aug 28, 2026, 12:38:54 PMAug 28
to Sandy Wright, HAPI FHIR
Hi Sandy,

I'm not sure I follow your description of the issue. If you're able to turn this into a reproduction via a failing unit test though, a bug ticket would be appreciated.

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/hapi-fhir/5afe1955-e467-4c9d-8415-febac2be2da8n%40googlegroups.com.

Sandy Wright

unread,
Aug 28, 2026, 1:43:55 PMAug 28
to HAPI FHIR
Hi James! 

I'll work on the test + bug ticket with Sophia today, but here are some example resources to help explain the issue.

Say we have the given original Patient record + an Observation record for their account formatted like so:

{
  "resourceType": "Patient",
  "id": "original-patient",
  "active": true,
  "name": [{
    "family": "PATIENT",
    "given": [
      "TEST"
    ]
  }],
  "gender": "female",
  "birthDate": "1990-05-01",
}

{
  "resourceType": "Observation",
  "id": "original-occupation-obs",
  "status": "final",
  "category": [{
    "coding": [{
      "system": "http://terminology.hl7.org/CodeSystem/observation-category",
      "code": "social-history",
      "display": "Social History"
    }],
    "text": "Social History"
  }],
  "code": {
    "coding": [{
      "system": "http://snomed.info/sct",
      "code": "14679004",
      "display": "occupation"
    }],
    "text": "occupation"
  },
  "subject": {
    "reference": "Patient/original-patient"
  },
  "effectiveDateTime": "2022-01-27T00:56:41.614000+00:00",
  "valueString": "present",
  "note": [{
    "authorReference": {
      "reference": "Patient/original-patient"
    },
    "time": "2022-01-27T00:56:41.614Z",
    "text": "Software Engineer"
  }]
}

Now if I were to run $hapi.fhir.merge with this patient as the original, and a new hypothetical Patient `new-patient` as the target, I would receive the error Sophia outlined above:

"HAPI-1700: Unknown child name 'author' in
element Annotation - Valid names are: [authorOrganization, authorPatient,
authorPractitioner, authorReference, authorRelatedPerson, authorResource,
authorString, author[x], extension, extension[x], id, text, time]"

The Annotation element here is the "note" field in the Observation. If I then change the Observation record to have a note field like so:

  "note": [{
    "authorString": "TEST PATIENT",
    "time": "2022-01-27T00:56:41.614Z",
    "text": "Software Engineer"
  }]

The merge operation would then succeed. This suggests that it's the merge itself that is updating the Annotation's `authorReference` field incorrectly, resulting in a FHIR validation failure.

Sandy Wright

unread,
Sep 1, 2026, 5:09:07 PMSep 1
to HAPI FHIR
Hey James, here is an official bug report in GitHub: https://github.com/hapifhir/hapi-fhir/issues/8344

Would appreciate it if you could give it another look as this is blocking us on some internal features. Thanks!

Sophia Jaffe

unread,
Sep 16, 2026, 2:19:23 PMSep 16
to HAPI FHIR
Hi - We've identified a third failure case during merge and added it to the github issue:  https://github.com/hapifhir/hapi-fhir/issues/8344#issuecomment-5546516320 

Is there anything else we can provide to have a fix implemented? Thanks

Asavari Arunrao Deokar

unread,
Sep 20, 2026, 2:25:25 PMSep 20
to HAPI FHIR
Hi HAPI team,

quick follow-up on this — we've found a third failure mode on the same operation and added it to the issue Sandy added earlier : https://github.com/hapifhir/hapi-fhir/issues/8344#issuecomment-5546516320Would really appreciate another look — this is blocking an internal feature in production on our side. Thanks!
Reply all
Reply to author
Forward
0 new messages