Skip to content

ResourceType on a contained resource is lost during the de-serialization process. #7289

@epeartree

Description

@epeartree

During the de-serialization process, a contained resource 'resourceType' is lost. I believe the issue to be present for all fhir version supported by the parser.

@BeforeEach
void beforeEachTest() {
    iParser = FhirContext.forR4().newJsonParser();
    iParser.setPrettyPrint(true);
}

@Test
void serializeDeserialiseContainedResource(){
    String expectedRequestGroupId = "RequestGroup/1";

    RequestGroup requestGroup = new RequestGroup();
    requestGroup.setId(expectedRequestGroupId);

    assertEquals(expectedRequestGroupId, requestGroup.getIdElement().getValueAsString());

    CarePlan carePlan = new CarePlan();
    carePlan.addContained(requestGroup);

    String carePlanAsString = iParser.encodeResourceToString(carePlan);
    ourLog.info(carePlanAsString);

    CarePlan parsedCarePlan = iParser.parseResource(CarePlan.class, carePlanAsString);
    Resource containedResource = parsedCarePlan.getContained().get(0);

    assertEquals(expectedRequestGroupId, containedResource.getIdElement().getValueAsString());
}

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