Add method to test data builder

This commit is contained in:
jamesagnew 2020-09-11 11:34:50 -04:00
parent f3a5433c06
commit 2bd304ffae
1 changed files with 12 additions and 0 deletions

View File

@ -155,6 +155,18 @@ public interface ITestDataBuilder {
};
}
default Consumer<IBaseResource> withObservationHasMember(@Nullable IIdType theHasMember) {
return t -> {
if (theHasMember != null) {
IBaseReference reference = (IBaseReference) getFhirContext().getElementDefinition("Reference").newInstance();
reference.setReference(theHasMember.getValue());
RuntimeResourceDefinition resourceDef = getFhirContext().getResourceDefinition(t.getClass());
resourceDef.getChildByName("hasMember").getMutator().addValue(t, reference);
}
};
}
/**
* Users of this API must implement this method
*/