SearchParameter for on nested extensions

154 views
Skip to first unread message

FN LN

unread,
Apr 29, 2022, 6:23:29 PM4/29/22
to HAPI FHIR
Hello,

I am trying to add a custom search parameter on an extension that itself is a list of extensions. Here is the high level view of the class structure.

public Class MyCoverage extends Coverage {
...
@Child(name="specialDates")
@Extension(url="<base-url>/MyCoverage#specialDates", definedLocally=false, isModifier=false)
@Description(shortDefinition="Special Dates")
private List<SpecialDate> dates;
...
}

public Class SpecialDate extends BackboneElement {
@Child(name="field1")
@Extension(url="<base-url>#field1", definedLocally=false, isModifier=false)
@Description(shortDefinition="field1")
private String field1;

@Child(name="date")
@Extension(url="<base-url>#date", definedLocally=false, isModifier=false)
@Description(shortDefinition="date")

private DateTimeType date;
}

I know that for extensions that use built-in types like String, or Int the client can add search parameters by doing something like:

SearchParameter sp = new SearchParameter()
.setName("path.to.element")
.setType(Enumerations.SearchParamType.REFERENCE)
.setExpression("ResourceName.field")
.setStatus(Enumerations.PublicationStatus.ACTIVE)
.setCode("codeName")
.addBase("ResourceName")
.setXpathUsage(SearchParameter.XPathUsageType.NORMAL)

Then submitting to the server.

How would I go about setting this up if I want a search parameter on the MyCoverage.dates?

Thanks in advance.

Andrea Caloni

unread,
Nov 17, 2022, 2:59:37 AM11/17/22
to HAPI FHIR
Hello, did you manage to fix this problem ? 
I am having the same issue with search parameters on nested extensions, and I am not able to find a solution...

Thanks, Andrea

James Agnew

unread,
Nov 17, 2022, 7:22:43 AM11/17/22
to Andrea Caloni, HAPI FHIR
Unfortunately I don't know that it's possible to define compound extensions using custom structures. Probably the easiest way to solve this is to use dynamic binding (e.g. calling addExtension() on a normal Coverage object, and then adding child extensions to the result of that call).

You can then create search parameters with expressions like:

Coverage.extension('http://ext-url').extension('http://child-ext-url').value

Cheers,
James

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/26333378-71b1-4859-944c-2c6abe36f3f8n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages