Using a custom DomainResource on happy fhir fhir-server


this article discusses a DomainResource.

There are situations however when you might want to create an entirely
custom resource type. This feature should be used only if there is no
other option, since it means you are creating a resource type that
will not be interoperable with other FHIR implementations.

I’ve implemented the code verbatum. (I show the classes below (with no “guts” just for brevity) (full code at the url))

 * This is an example of a custom resource that also uses a custom
 * datatype.
 * Note that we are extensing DomainResource for an STU3
 * resource. For DSTU2 it would be BaseResource. 
@ResourceDef(name = "CustomResource", profile = "")
public class CustomResource extends DomainResource {


 * This is an example of a custom datatype. 
 * This is an STU3 example so it extends Type and implements ICompositeType. For
 * DSTU2 it would extend BaseIdentifiableElement and implement ICompositeDatatype.
public class CustomDatatype extends Type implements ICompositeType {

And I’ve “registered it” in my code base:

		if (null != this.fhirContext)

(~trying to follow the instructions from the URL above)

// Create a context. Note that we declare the custom types we'll be using
// on the context before actually using them
FhirContext ctx = FhirContext.forDstu3();
// Now let's create an instance of our custom resource type
// and populate it with some data
CustomResource res = new CustomResource();
// Add some values, including our custom datatype
DateType value0 = new DateType("2015-01-01");
CustomDatatype value1 = new CustomDatatype();
value1.setDate(new DateTimeType(new Date()));
value1.setKittens(new StringType("FOO"));
res.setDogs(new StringType("Some Dogs"));
// Now let's serialize our instance
String output = ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(res);

But that looks like a console-app usage of two objects…not how to wire it into the fhir-server.

I’ve been trying for 3 hours now to figure out what URL to use.

some things I’ve tried:

to no avail…

What is the URL?

And how do I populate the values for it?