Uploaded image for project: 'Attachments Module'
  1. Attachments Module
  2. ATT-32

Do not attach document to active visit if no encounter type is configured

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Code Review (Post-Commit)
    • Priority: TBD
    • Resolution: Unresolved
    • Affects Version/s: 2.1.0
    • Fix Version/s: 2.2.0
    • Labels:
      None
    • Complexity:
      Low

      Description

      Our PIH EMR system is not configured to have a attachments.encounterTypeUuid global property. The documents uploads work fine when there is no active visit, but when we have an active visit, the upload fails with the following stacktrace:

      // ERROR - BaseRestController.handleException(115) |2019-09-04 10:31:20,411| 'Encounter: [(no ID) Wed Sep 04 10:31:20 EDT 2019 (no Type) Reforma 37 (no Form) num Obs: [] num Order
      s: 0 ]' failed to validate with reason: encounterType: Encounter type is Required
      org.openmrs.api.ValidationException: 'Encounter: [(no ID) Wed Sep 04 10:31:20 EDT 2019 (no Type) Reforma 37 (no Form) num Obs: [] num Orders: 0 ]' failed to validate with reaso
      n: encounterType: Encounter type is Required
      	at org.openmrs.validator.ValidateUtil.validate(ValidateUtil.java:82)
      	at org.openmrs.aop.RequiredDataAdvice.before(RequiredDataAdvice.java:127)
      	at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:51)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      	at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
      	at com.sun.proxy.$Proxy179.saveEncounter(Unknown Source)
      	at org.openmrs.module.attachments.AttachmentsContext.getAttachmentEncounter(AttachmentsContext.java:164)
      	at org.openmrs.module.attachments.rest.AttachmentResource1_10.upload(AttachmentResource1_10.java:127)
      	at org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceController.upload(MainResourceController.java:104)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:177)
      	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:446)
      	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:434)
      	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)
      	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
      	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
      	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
      	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      	at org.openmrs.module.web.filter.ForcePasswordChangeFilter.doFilter(ForcePasswordChangeFilter.java:60)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      	at org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:73)
      	at org.openmrs.web.filter.GZIPFilter.doFilterInternal(GZIPFilter.java:65)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      	at org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:71)
      	at org.openmrs.module.webservices.rest.web.filter.AuthorizationFilter.doFilter(AuthorizationFilter.java:105)
      	at org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:71)
      	at org.openmrs.module.webservices.rest.web.filter.ContentTypeFilter.doFilter(ContentTypeFilter.java:64)
      	at org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:71)
      	at org.springframework.web.filter.ShallowEtagHeaderFilter.doFilterInternal(ShallowEtagHeaderFilter.java:82)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      	at org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:71)
      	at org.openmrs.module.owa.filter.OwaFilter.doFilter(OwaFilter.java:93)
      	at org.openmrs.module.owa.filter.OwaFilter.doFilter(OwaFilter.java:61)
      	at org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:71)
      	at org.openmrs.module.mirebalais.RequestMonitoringFilter.doFilter(RequestMonitoringFilter.java:76)
      	at org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:71)
      	at org.openmrs.module.web.filter.ModuleFilter.doFilter(ModuleFilter.java:57)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      	at org.openmrs.web.filter.OpenmrsFilter.doFilterInternal(OpenmrsFilter.java:109)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      	at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:150)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      	at org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:107)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      	at org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:107)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      	at org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:107)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:221)
      	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
      	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
      	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
      	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
      	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
      	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
      	at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:190)
      	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
      	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      	at java.lang.Thread.run(Thread.java:748)
      

      I think the problem is at this line:

      https://github.com/openmrs/openmrs-module-attachments/blob/master/omod/src/main/java/org/openmrs/module/attachments/web/controller/AttachmentsController.java#L78

      If there is no encounter specified, then we should not attach a visit either? I will issue a PR for this simple fix. Thanks.

        Attachments

          Activity

            People

            Assignee:
            mogoodrich Mark Goodrich
            Reporter:
            cioan Cosmin Ioan
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated: