Test data creator

This commit is contained in:
jamesagnew 2020-09-11 11:46:19 -04:00
parent e637a841a1
commit 064e4f5e15
1 changed files with 11 additions and 0 deletions

View File

@ -106,6 +106,13 @@ public interface ITestDataBuilder {
};
}
/**
* Set Organization.name
*/
default Consumer<IBaseResource> withName(String theStatus) {
return t -> __setPrimitiveChild(getFhirContext(), t, "name", "string", theStatus);
}
default Consumer<IBaseResource> withId(String theId) {
return t -> {
assertThat(theId, matchesPattern("[a-zA-Z0-9]+"));
@ -129,6 +136,10 @@ public interface ITestDataBuilder {
return createResource("Patient", theModifiers);
}
default IIdType createOrganization(Consumer<IBaseResource>... theModifiers) {
return createResource("Organization", theModifiers);
}
default IIdType createResource(String theResourceType, Consumer<IBaseResource>[] theModifiers) {
IBaseResource resource = getFhirContext().getResourceDefinition(theResourceType).newInstance();
for (Consumer<IBaseResource> next : theModifiers) {