http://hapifhir.io/doc_custom_structures.html
本文讨论了 DomainResource。
但是,在某些情况下,您可能想要创建完全自定义的资源类型。仅当没有其他选项时才应使用此功能,因为这意味着您正在创建一个不能与其他 FHIR 实现互操作的资源类型。
我已经实现了代码逐字。(我展示了下面的类(为了简洁,没有“胆量”)(完整的代码在 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 = "http://hl7.org/fhir/profiles/custom-resource")
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.
*/
@DatatypeDef(name="CustomDatatype")
public class CustomDatatype extends Type implements ICompositeType {
}
我已经在我的代码库中“注册”了它:
if (null != this.fhirContext)
{
this.fhirContext.registerCustomType(CustomResource.class);
this.fhirContext.registerCustomType(CustomDatatype.class);
}
(〜尝试按照上面网址中的说明进行操作)
// 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();
ctx.registerCustomType(CustomResource.class);
ctx.registerCustomType(CustomDatatype.class);
// 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");
res.getTelevision().add(value0);
CustomDatatype value1 = new CustomDatatype();
value1.setDate(new DateTimeType(new Date()));
value1.setKittens(new StringType("FOO"));
res.getTelevision().add(value1);
res.setDogs(new StringType("Some Dogs"));
// Now let's serialize our instance
String output = ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(res);
System.out.println(output);
但这看起来像是控制台应用程序对两个对象的使用……而不是如何将其连接到 fhir-server。
我已经尝试了 3 个小时来弄清楚要使用的 URL。
我尝试过的一些事情:
http://127.0.0.1:8080/fhir/CustomResource
http://127.0.0.1:8080/fhir/profiles/custom-resource
http://127.0.0.1:8080/fhir/custom-resource
无济于事...
网址是什么?
以及如何填充它的值?