Stream: hapi
Topic: profiles customized
Binu DGIT (Nov 27 2016 at 04:45):
Hi James,
As observed from the devdays, I tried to customize the patient resource type for Oman needs. Further, I was able to upload the definition to HAPI server, but data upload fails. How can I specify OmanPatient instead of Patient in the resource type? Is it required to make OmanPatient as an inherited class in HAPI server ?
Binu DGIT (Nov 27 2016 at 08:22):
I have noticed MyOrganization under restful-server-example which is inherited from Organization. Further OrganizationResourceProvider class is available to read data corresponding to MyOrganization. Is it part of the custom profiles? Do we need to implement the similar to manage custom profiles like OmanPatient?
Binu DGIT (Nov 27 2016 at 08:35):
Following documentation is found out in HAPI .. Please confirm the way I can define the custom profiles..
Sometimes you may not know in advance exactly which type you will be receiving. For example, there are Patient resources which conform to several different profiles on a server and you aren't sure which profile you will get back for a specific read, you can declare the "primary" type for a given profile.
This is declared at the FhirContext level, and will apply to any clients created from this context (including clients created before the default was set).
FhirContext ctx = FhirContext.forDstu3();
// Instruct the context that if it receives a resource which
// claims to conform to the given profile (by URL), it should
// use the MyPatient type to parse this resource
ctx.setDefaultTypeForProfile("http://example.com/StructureDefinition/mypatient", MyPatient.class);
// You can declare as many default types as you like
ctx.setDefaultTypeForProfile("http://foo.com/anotherProfile", CustomObservation.class);
// Create a client
IGenericClient client = ctx.newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu3");
// You can also read the resource back like normal
Patient patient = client.read().resource(Patient.class).withId("123").execute();
if (patient instanceof MyPatient) {
// If the server supplied a resource which declared to conform
// to the given profile, MyPatient will have been returned so
// process it differently..
}
Binu DGIT (Nov 28 2016 at 09:32):
I am continuing my effort to upload the DutchPatient profile to HAPI server.. the following error occured..
Resource ValueSet/identifier-use not found, specified in path: StructureDefinition.snapshot.element.binding.valueSet[X].
@James Agnew , Can you please advise..
Binu DGIT (Nov 28 2016 at 09:34):
I was not able to publish the structure definition of the profile from the Forge tool, instead I tried using HAPI interface itself .. using the CRUD operations.
James Agnew (Nov 30 2016 at 02:59):
Hi Binu,
Just to confirm, you have created a DSTU2 profile in Forge and you are seeing this issue when uploading the profile to your JPA server instance, or when validating a resource against it?
FYI, you don't need to generate any HAPI classes in order to do the type of validation you're looking to do. It should be possible to upload the profile definition to HAPI's server and then validate based on that. I will caution you that the validator in DSTU2 is not as powerful as the validator in DSTU3. If you have advanced validation requirements it is sometimes easier to simply code them in Java code and enforce them via an interceptor instead of relying on the native validator.
This situation is a great deal better in STU3 though, the validator works very well on that version.
Binu DGIT (Nov 30 2016 at 07:55):
Thank you James for the detailed reply..
What you said is true.. I am trying to upload the profile to JPA server instance and basically trying to apply some constraints ..
I was able to upload the same into public HAPI server with out any issue, please note the following link.
http://fhirtest.uhn.ca/baseDstu2/StructureDefinition/DutchPatient
Is it the right way to upload the profile? If so, issue is in my HAPI server configuration which I have to trace..
But corresponding to the last element, placeOfBirth is an extension corresponding to which I could not send a value using FHIR message.
Is that means the profile is not verified as expected?
Binu DGIT (Nov 30 2016 at 07:59):
I have tried the following FHIR message against the DutchPatient profile..
{
"resourceType": "Patient",
"id": "67.20068.14731",
"meta": {
"versionId": "1",
"lastUpdated": "2016-11-30T02:18:24.929-05:00",
"profile": [
"http://example.org/fhir/StructureDefinition/DutchPatient"
]
},
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\"> GHASIYA <b>AL WAHEIBI </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Identifier</td><td>14731</td></tr><tr><td>Address</td><td></td></tr><tr><td>Date of birth</td><td><span>01 January 1981</span></td></tr></tbody></table></div>"
},
"identifier": [
{
"value": "14731",
"period": {
"start": "2005-03-15"
}
}
],
"active": false,
"name": [
{
"family": [
"AL WAHEIBI"
],
"given": [
"GHASIYA"
]
}
],
"gender": "female",
"birthDate": "1981-01-01",
"deceasedBoolean": true,
"address": [
{
"use": "home"
}
],
"placeOfBirth" : {
"url" : "http://hl7.org/fhir/StructureDefinition/birthPlace",
"valueString": "Narakal"
}
}
Binu DGIT (Nov 30 2016 at 08:12):
In the above message, following element is not accepted
"placeOfBirth" : {
"url" : "http://hl7.org/fhir/StructureDefinition/birthPlace",
"valueString": "Narakal"
}
Binu DGIT (Dec 01 2016 at 08:11):
@James Agnew
I am able to upload a test patient profile which is attached here by into the public test HAPI server and able to validate against even the extension added. But when I upload into my local HAPI server, I am getting the following error..
Error: HTTP 400 Bad Request: Resource ValueSet/administrative-gender not found, specified in path: StructureDefinition.snapshot.element.binding.valueSet[x]
I do understand that, it is the verification on the valuset uri, but I would like to know how it is bypassed in the public test server?
TestPatient.structuredefinition.xml
James Agnew (Dec 01 2016 at 16:51):
Hi Binu,
Let me have a look if I can replicate your issue with uploading the testpatient profile here locally.
One thing to note, your syntax isn't quite right on that placeofbirth extension. FHIR's extension syntax in JSON should look more like this:
"extension" : [ { "url" : "http://hl7.org/fhir/StructureDefinition/birthPlace", "valueString": "Narakal" } ]
James Agnew (Dec 01 2016 at 16:51):
..which could go in the exact same place in the resource where you have
"placeOfBirth" : { "url" : "http://hl7.org/fhir/StructureDefinition/birthPlace", "valueString": "Narakal" }
James Agnew (Dec 01 2016 at 17:30):
Ok, I'm a bit confused now. I am not able to replicate your issue... I did the following:
1. Create a local server based on the jpaserver-example project
2. Upload your TestPatient.structuredefinition.xml
to this server
3. Validate the example Patient with id 67.20068.14731
that you posted above by POSTing it to http://localhost:8080/hapi-fhir-jpaserver-example/baseDstu2/Patient/$validate
The test patient had a couple of JSON syntax error I had to fix, and the profile URL doesn't actually match (TestPatient vs. DutchPatient) but once I fixed those things it validated correctly. There were some validation issues, but nothing about missing valuesets, just normal problems with the patient resource's conformance to that profile
How does this compare to what you're trying to do?
Binu DGIT (Dec 04 2016 at 04:14):
Sorry for belated response.. I was bit away.. syntax of the extension is corrected and I could upload the same into the public HAPI.
Right now my issue is only on the first part, getting valueset error while uploading the Structure definition TestPatient.Structuredefinition.xml.
Exactly I am getting 400 Bad Request after the value set warning.. please note the following message
Warning!
Error: HTTP 400 Bad Request: Resource ValueSet/administrative-gender not found, specified in path: StructureDefinition.snapshot.element.binding.valueSet[x]
Binu DGIT (Dec 04 2016 at 06:22):
Please note the following in my new local server..
Warning!
Error: HTTP 400 Bad Request: Resource contains external reference to URL "http://hl7.org/fhir/ValueSet/administrative-gender" but this server is not configured to allow external references
Binu DGIT (Dec 04 2016 at 08:27):
Please not the following statements about DaoConfig
@Bean()
public DaoConfig daoConfig() {
DaoConfig retVal = new DaoConfig();
retVal.setAllowMultipleDelete(true);
retVal.setAllowInlineMatchUrlReferences(true);
return retVal;
}
What is the purpose of "setAllowInlineMatchUrlReferences(true)"?
James Agnew (Dec 05 2016 at 11:40):
That setting allows you to include search strings in references within a resource within a transaction, it's probably not the one you want.
You're looking for
retVal.setAllowExternalReferences(true);
Binu DGIT (Dec 05 2016 at 13:19):
That is very much true.. I have fixed the issue .. Thanks
Last updated: Apr 12 2022 at 19:14 UTC