In my current FHIR implementation for 834 x12 , I have a requirement while creating my data model that list of a resource should reside inside another resource , but we want that list of resources to not be contained resources as there is a need for that resources to exist independently so that they can be later enquired by direct GET calls .
To give an example , here I am trying to have list of Domain Resource - Coverage inside another resource MHEnrollmentRequest which extends domain resource EnrollmentRequest :
@ResourceDef(profile="http://fhirserver/fhir/StructureDefinition/MHEnrollmentRequest")
public class MHEnrollmentRequest extends EnrollmentRequest {
@Child(name = "coverages")
@Description(shortDefinition = "X12 uses more than 1 coverage, so we need some extras")
private List<Coverage> coverages;
When using IParser’s method encodeResourceToString , it lets me have one coverage in above list of coverages and I can see json printed fine for EnrollmentRequest, but moment second coverage is added to list of coverages , parser starts failing with this error -
Exception in thread “main” java.lang.Error: Encountered IOException during write to string - This should not happen!
at ca.uhn.fhir.parser.BaseParser.encodeResourceToString(BaseParser.java:275)
Is there a way to have list of independent resources inside another resource in FHIR ? Any other suggestion that doesn’t include contained resources will be very useful !
Thank you