Skip to content

Polymorphism of Task.input.value[x] incorrect? #3

@reinkrul

Description

@reinkrul

When marshalling a Task with input (type TaskInput) set, it marshals all empty fields as well. I see that this works for Observation, as the value options are defined as pointers (with omitempty).

I'm somewhat new to FHIR, but if you point me to the right direction I can give it a go fixing it (thanks in advance).

For example, the following test:

func TestMarshalTask(t *testing.T) {
	task := Task{}
	task.Input = []TaskInput{
		{
			ValueInteger: 5,
		},
	}
	data, _ := json.MarshalIndent(task, "", "  ")
	println(string(data))
}

gives:

{
  "status": "draft",
  "intent": "",
  "input": [
    {
      "type": {},
      "valueBase64Binary": "",
      "valueBoolean": false,
      "valueCanonical": "",
      "valueCode": "",
      "valueDate": "",
      "valueDateTime": "",
      "valueDecimal": 0,
      "valueID": "",
      "valueInstant": "",
      "valueInteger": 5,
      "valueMarkdown": "",
      "valueOid": "",
      "valuePositiveInt": 0,
      "valueString": "",
      "valueTime": "",
      "valueUnsignedInt": 0,
      "valueUri": "",
      "valueUrl": "",
      "valueUuid": "",
      "valueAddress": {},
      "valueAge": {},
      "valueAnnotation": {
        "text": ""
      },
      "valueAttachment": {},
      "valueCodeableConcept": {},
      "valueCoding": {},
      "valueContactPoint": {},
      "valueCount": {},
      "valueDistance": {},
      "valueDuration": {},
      "valueHumanName": {},
      "valueIdentifier": {},
      "valueMoney": {},
      "valuePeriod": {},
      "valueQuantity": {},
      "valueRange": {},
      "valueRatio": {},
      "valueReference": {},
      "valueSampledData": {
        "origin": {},
        "period": 0,
        "dimensions": 0
      },
      "valueSignature": {
        "type": null,
        "when": "",
        "who": {}
      },
      "valueTiming": {},
      "valueContactDetail": {},
      "valueContributor": {
        "type": "author",
        "name": ""
      },
      "valueDataRequirement": {
        "type": ""
      },
      "valueExpression": {
        "language": ""
      },
      "valueParameterDefinition": {
        "use": "in",
        "type": ""
      },
      "valueRelatedArtifact": {
        "type": "documentation"
      },
      "valueTriggerDefinition": {
        "type": "named-event"
      },
      "valueUsageContext": {
        "code": {},
        "valueCodeableConcept": {},
        "valueQuantity": {},
        "valueRange": {},
        "valueReference": {}
      },
      "valueDosage": {},
      "valueMeta": {}
    }
  ],
  "resourceType": "Task"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions