FHIR Chat · Custom Operation Not being Recognized · hapi

Stream: hapi

Topic: Custom Operation Not being Recognized


view this post on Zulip Neil Lott (Dec 29 2020 at 23:57):

So starting from hapi-fhir-jpaserver-starter-5.2.0 I've added my custom operations. Everything starts fine and I'm able to execute this for example

curl--location --request GET 'http://localhost:9027/fhir/Person?identifier=http://intellicentrics.com/alternateIdentifier/wso2Username%7CPatientqa22,http://intellicentrics.com/alternateIdentifier/wso2Username%7CPatientqa24'

However if I execute a curl with my custom operation

curl 'http://localhost:9027/fhir/Observation/$lastn'

I get this error

}~ $ curl 'http://localhost:9027/fhir/Observation/$lastn'
{
"resourceType": "OperationOutcome",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h1>Operation Outcome</h1><table border=\"0\"><tr><td style=\"font-weight: bold;\">ERROR</td><td>[]</td><td><pre>LastN operation is not enabled on this service, can not process this request</pre></td>\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t</tr>\n\t\t</table>\n\t</div>"
},
"issue": [ {
"severity": "error",
"code": "processing",
"diagnostics": "LastN operation is not enabled on this service, can not process this request"
} ]
}

And on another custom operation I get this error

curl 'http://localhost:9027/fhir/Observation/$quickStats?careteam-member-identifier=http://intellicentrics.com/alternateIdentifier/wso2Username%7Chcp.camelia.coleman%40yopmail.com&careteam-member-type=Practitioner&statistic=average&date=gt2020-12-02T06:00:00.

"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h1>Operation Outcome</h1><table border=\"0\"><tr><td style=\"font-weight: bold;\">ERROR</td><td>[]</td><td><pre>Invalid request: The FHIR endpoint on this server does not know how to handle GET operation[Observation/$quickStats] with parameters [[date, careteam-member-identifier, statistic, _count, code, filterExpired, careteam-member-type]]</pre></td>\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t</tr>\n\t\t</table>\n\t</div>"

},
"issue": [ {
"severity": "error",
"code": "processing",
"diagnostics": "Invalid request: The FHIR endpoint on this server does not know how to handle GET operation[Observation/$quickStats] with parameters [[date, careteam-member-identifier, statistic, _count, code, filterExpired, careteam-member-type]]"
} ]
}

What do I need to do to register these custom operations?

Here's a code sample of the first one "lastN" that's failing

@Service
public class ObservationResourceLatestObsProvider implements IResourceProvider {

@Autowired
private ResourceLinkResolverService linkResolverService;

@Autowired
private ResourceDao resourceDao;

@Autowired
private ResourceParameterSearchService resourceParameterSearchService;

@Autowired
private PartitionSettings partitionSettings;

protected static final Logger LOGGER = LoggerFactory.getLogger(ObservationResourceLatestObsProvider.class);

@Operation(name = "$lastn", idempotent = true)
public Parameters latestObservationsByPractitioner(
        javax.servlet.http.HttpServletRequest theServletRequest,
        javax.servlet.http.HttpServletResponse theServletResponse,
        ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails,
        @Description(shortDefinition = "The code of the observation type") @OptionalParam(name = "code") TokenAndListParam code,
        @Description(shortDefinition = "Patient's nominated general practitioner, not the organization that manages the record") @OperationParam(name = "general-practitioner") TokenParam practitioner,
        @Description(shortDefinition = "The subject that the observation is about") @OperationParam(name = "subject-identifier") TokenParam subjectIdentifier,
        @Description(shortDefinition = "The maximum number of observations to return") @OperationParam(name = "max") NumberParam max) {

    validateParameters(code, practitioner);

    List<TokenParam> codeParams = ParameterUtil.buildObservationCodeParamList(code);

Thanks,

Neil


Last updated: Apr 12 2022 at 19:14 UTC