Problem while creating ObsGroup with FHIR API

Hi everyone, Our team at ICRC is facing an issue when trying to create an ObsGroup using the FHIR API.

Currently, the validation for Observation requires it to have a value, but in OpenMRS, ObsGroups are inherently valueless — they only group related child observations.

For context, in our offline Android app, we first create the parent observation (the group) and then the child observations that reference it using partOf.

Here’s a simplified example of what we’re sending:

Parent Observation (ObsGroup without value):

{

  "resourceType": "Observation",

  "id": "parent-observation",

  "status": "final",

  "code": { "text": "Vital Signs" }

}


Child Observation (references parent using partOf):

{

  "resourceType": "Observation",

  "status": "final",

  "code": { "text": "Heart Rate" },

  "valueQuantity": { "value": 80, "unit": "beats/minute" },

  "partOf": [{ "reference": "Observation/parent-observation" }]

}

Has anyone worked around this validation issue for valueless parent Observations (ObsGroups)? Would it make sense to relax the FHIR validation or handle this mapping differently on the server side?

Thanks! — @parthfloyd & @jofrancisco (ICRC / OpenMRS Android team)

Is there a way to reverse this order of operations? Things will definitely not work creating the grouping obs first, but it is possible to add an obs that was not part of a group to a group and that way when you create the parent obs with children, it should pass validation (the validation here is the standard OpenMRS validation for Obs; there isn’t really a FHIR-specific rule).

Strike that; I get why it won’t work. Currently this isn’t something that’s easy to support through the FHIR API because FHIR and OpenMRS have inverted ideas of how to store the relationship between parent and child obs, but OpenMRS also doesn’t allow empty observations.