--
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+unsubscribe@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/1d84355b-fdca-4c55-8e4f-32d26ad41886%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
The error "The FHIR endpoint on this server does not know how to handle OPTIONS operation[Patient] with parameters [[]]" would indicate that they are making an HTTP OPTIONS request instead of a POST.This could either indicate that you have a CORS issue and need to add a CORS interceptor/filter, or it could indicate that your client has a bug.Cheers,James
On Fri, Dec 8, 2017 at 9:57 AM, Stan Zajdel <c62...@gmail.com> wrote:
Hi All,I'm new to FHIR and HAPI FHIR and I'm tasked with building a CDR which is a relational database of tables that address most of the FHIR resources (DSTU 3). So for instance, from a Patient Resource, we have a series of tables (one to many) that house patient contacts, patient identifiers, patient languages, patient addresses, etc and I have built DAOs that access those tables. Our front ends will be mobile apps, web apps and otther channels that will be consuming the HAPI FHIR-based APIs (REST services) that I am developing. As of now, all of my Reads and Searches are working beautifully and returning all data per the JSON format as specified in the FHIR spec (using the HAPI Resource classes). However, I cannot get a Create or Update to work and I've been reading the HAPI docs but not having much luck.According to the docs, the Create and Update expect a ResourceParam of the resourvce that needs to be added or updated. It also allows for the raw data to be sent as well. I am getting the following error no matter what I try:2017-12-08 08:10:40,697 WARN [ca.uhn.fhir.rest.server.interceptor.ExceptionHandlingInterceptor] (default task-2) Failure during REST processing: ca.uhn.fhir.rest.server.exceptions.InvalidRequestException: Invalid request: The FHIR endpoint on this server does not know how to handle OPTIONS operation[Patient] with parameters [[]]2017-12-08 08:10:40,698 INFO [cdrfhir.RequestLogger] (default task-2) ERROR - - PatientI have no idea how to get this to work. Also, is it possible to only send in the raw data and not the actual resource to a Create or Update? The reason being is that from a mobile app, a patient address may be created or updated and the app may not be able to send the entire Patient JSON back to the server. I would much rather parse the raw data myself and create/update what is requested so is there any way to do that?Any help on this would be GREATLY appreciated and if you need any more details from me then please let me know.Thanks,Stan
--
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 unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+unsubscribe@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/1f46addb-0e0e-45b3-b65c-4e73762795c1%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+unsubscribe@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/27193192-8c38-489d-bfae-e9d8c73600e1%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/CAKowd8nD%2BH8f4n%3DEPqXSs9pcWdt675Sm_9aBXydc6cQa3_cECA%40mail.gmail.com.
import ca.uhn.fhir.rest.server.RestfulServer;
import ca.uhn.fhir.rest.server.interceptor.CorsInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.web.cors.CorsConfiguration;
import java.util.Arrays;
@Configuration
public class CorsFhirRestfulServerCustomizer implements FhirRestfulServerCustomizer {
@Override
public void customize(RestfulServer server) {
/* http://hapifhir.io/doc_cors.html#_toc_hapi_fhir_server_interceptor */
CorsConfiguration config = new CorsConfiguration();
//config.applyPermitDefaultValues();
config.addAllowedMethod("*");
//config.setAllowedMethods(Arrays.asList(HttpMethod.GET.name(), HttpMethod.POST.name(), HttpMethod.PUT.name(), HttpMethod.DELETE.name(), HttpMethod.OPTIONS.name(), HttpMethod.PATCH.name(), HttpMethod.TRACE.name())); //"GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"));
// purposely ignoring //config.addAllowedOrigin("*");
// purposely ignoring //config.addAllowedHeader("*"); // * throws an exception
/*
config.addAllowedHeader("x-fhir-starter");
config.addAllowedHeader("Origin");
config.addAllowedHeader("Accept");
config.addAllowedHeader("X-Requested-With");
config.addAllowedHeader("Content-Type");
config.addAllowedOrigin("*");
config.addExposedHeader("Location");
config.addExposedHeader("Content-Location");
config.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"));
*/
// Create the interceptor and register it
CorsInterceptor interceptor = new CorsInterceptor(config);
server.registerInterceptor(interceptor);
}
}
private /*final*/ List<FhirRestfulServerCustomizer> customizers;
public FhirRestfulServerConfiguration(
FhirProperties properties,
FhirContext fhirContext,
ObjectProvider<List<IResourceProvider>> resourceProviders,
ObjectProvider<IPagingProvider> pagingProvider,
ObjectProvider<List<IServerInterceptor>> interceptors,
ObjectProvider<List<FhirRestfulServerCustomizer>> customizers) {
this.properties = properties;
this.fhirContext = fhirContext;
this.resourceProviders = resourceProviders.getIfAvailable();
this.pagingProvider = pagingProvider.getIfAvailable();
this.interceptors = interceptors.getIfAvailable();
this.customizers = customizers.getIfAvailable();
if(null==this.customizers)
{
this.customizers = new ArrayList<>();
}
this.customizers.add(new CorsFhirRestfulServerCustomizer());
}
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class CorsCustomConfig implements WebMvcConfigurer {
private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(CorsCustomConfig.class);
//private final FhirProperties properties;
public CorsCustomConfig() { //(FhirProperties properties) {
//this.properties = properties;
}
@Override
public void addCorsMappings(CorsRegistry registry) {
String mp = “/**”; //this.properties.getCors().getMappingPath();
String aos = “*”; //this.properties.getCors().getAllowedOrigins();
String ams = “*”; //this.properties.getCors().getAllowedMethods();
String ahs = “*”; //this.properties.getCors().getAllowedHeaders();
if (logger.isInfoEnabled()) {
String logMsg = String.format("addCorsMappings fired. (addMapping='%1$s', allowedOrigins='%2$s', allowedMethods='%3$s', allowedHeaders='%4$s')",
mp, aos, ams, ahs);
logger.info(logMsg);
}
registry.addMapping(mp)
.allowedOrigins(aos)
.allowedMethods(ams)
.allowedHeaders(ahs);
}
}
the above did NOT work
......
I tried the hapi fhir "way"
http://hapifhir.io/doc_cors.html#_toc_hapi_fhir_server_interceptor
the above did NOT work.
......
finally I wrote a filter
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import org.springframework.http.HttpMethod;
import org.springframework.web.filter.OncePerRequestFilter;
public class HapiFhirCutOffsFilter extends OncePerRequestFilter implements Filter {
private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(HapiFhirCutOffsFilter.class);
public HapiFhirCutOffsFilter() {
//Empty Constructor
}
@Override
protected void doFilterInternal(HttpServletRequest servletRequest, HttpServletResponse servletResponse, FilterChain filterChain)
throws ServletException, IOException {
HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse resp = (HttpServletResponse) servletResponse;
// Http Request Method
String requestMethod = request.getMethod();
// URI that the request was sent to
String requestURI = servletRequest.getRequestURI();
// For HTTP OPTIONS verb/method reply with ACCEPTED status code -- per CORS handshake
if (requestMethod.equals(HttpMethod.OPTIONS.name())) {
logger.info("HapiFhirCutOffsFilter has intercepted an OPTIONS request and is short cutting and returning HttpServletResponse.SC_ACCEPTED");
resp.setStatus(HttpServletResponse.SC_ACCEPTED);
return;
}
// pass the request along the filter chain
filterChain.doFilter(request, servletResponse);
}
}And I wired mine with applicationContext.xml<bean id="zzzHapiFhirCutOffsFilterBean"
class="com.mycompany.springbootfhirserver.filters.HapiFhirCutOffsFilter">
</bean>
<bean id="filterRegistrationBean2"
class="org.springframework.boot.web.servlet.FilterRegistrationBean">
<property name="filter" ref="zzzHapiFhirCutOffsFilterBean">
</property>
<property name="urlPatterns" value="/*">
</property>
</bean>