missilen
(Tim Nguyen)
January 12, 2017, 9:24pm
1
Application Name: OpenMRS Standalone
Version Number: 2.5
Question:
using Encounter REST API. I need to retrieve all encounters with specific encounter type using the encounter type query from the below screen but none of my encounter values (uuids returned from encounterType api) work with the api. so what is the proper value I need to pass to the encounterType parm
darius
(Darius Jazayeri)
January 12, 2017, 9:34pm
2
Peeking at the code, I do not think it’s possible to search by (only) encounter type via REST.
You can search by patient and encounter type (and optional date range).
You can search by free text (I don’t know what this does, actually, but it calls the underlying Java API to search for encounter by String…
missilen
(Tim Nguyen)
January 12, 2017, 10:01pm
3
Thanks. I tried to enter some text in the q parm but it did not do anything.
dkayiwa
(Daniel Kayiwa)
January 16, 2017, 6:57pm
4
@missilen can you try it here? int-refapp.openmrs.org
Go ahead and share with us which patient uuid and text for the q param, that you are testing with on this server.
missilen
(Tim Nguyen)
January 23, 2017, 10:36pm
5
Hi, sorry for the late reply. Here is uuid for patient: 65428e94-8500-4704-9657-6d04c7d14d21
when q = smith, it did returned something.
when q = vitals, it did not return anything
i tried vitals or visit note together with the patient but in both cases, it returned something but did not filter out the result.
when using encounter type with the patient, it worked.
when using encounter type only, got the below error:
{
“error”: {
“message”: “[getCountOfEncounters failed]”,
“code”: “org.openmrs.module.webservices.rest.web.resource.impl.ServiceSearcher:98”,
“detail”: “java.lang.RuntimeException: getCountOfEncounters failed\n\tat org.openmrs.module.webservices.rest.web.resource.impl.ServiceSearcher.doCount(ServiceSearcher.java:98)\n\tat org.openmrs.module.webservices.rest.web.resource.impl.ServiceSearcher.search(ServiceSearcher.java:53)\n\tat org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.EncounterResource1_8.doSearch(EncounterResource1_8.java:217)\n\tat org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource.search(DelegatingCrudResource.java:183)\n\tat org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceController.get(MainResourceController.java:193)\n\tat sun.reflect.GeneratedMethodAccessor1198.invoke(Unknown Source)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:498)\n\tat org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:177)\n\tat org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:446)\n\tat org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:434)\n\tat org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)\n\tat org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)\n\tat org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)\n\tat org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:624)\n\tat org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:731)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n\tat org.openmrs.module.web.filter.ForcePasswordChangeFilter.doFilter(ForcePasswordChangeFilter.java:60)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n\tat org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n\tat org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:72)\n\tat org.openmrs.web.filter.GZIPFilter.doFilterInternal(GZIPFilter.java:64)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\n\tat org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:70)\n\tat org.openmrs.module.webservices.rest.web.filter.AuthorizationFilter.doFilter(AuthorizationFilter.java:104)\n\tat org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:70)\n\tat org.springframework.web.filter.ShallowEtagHeaderFilter.doFilterInternal(ShallowEtagHeaderFilter.java:82)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\n\tat org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:70)\n\tat org.openmrs.module.owa.filter.OwaFilter.doFilter(OwaFilter.java:57)\n\tat org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:70)\n\tat org.openmrs.module.xforms.web.XformsFilter.doFilter(XformsFilter.java:69)\n\tat org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:70)\n\tat org.openmrs.module.web.filter.ModuleFilter.doFilter(ModuleFilter.java:54)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n\tat org.openmrs.web.filter.OpenmrsFilter.doFilterInternal(OpenmrsFilter.java:108)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n\tat org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:150)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n\tat org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:105)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n\tat org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:105)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n\tat org.openmrs.web.filter.StartupFilter.doFilter(StartupFilter.java:105)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n\tat org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n\tat org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)\n\tat org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)\n\tat org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)\n\tat org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)\n\tat org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)\n\tat org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)\n\tat org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)\n\tat org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442)\n\tat org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1082)\n\tat org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:623)\n\tat org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\n\tat org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)\n\tat java.lang.Thread.run(Thread.java:745)\nCaused by: java.lang.reflect.InvocationTargetException\n\tat sun.reflect.GeneratedMethodAccessor1209.invoke(Unknown Source)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:498)\n\tat org.openmrs.module.webservices.rest.web.resource.impl.ServiceSearcher.invokeCountMethod(ServiceSearcher.java:184)\n\tat org.openmrs.module.webservices.rest.web.resource.impl.ServiceSearcher.doCount(ServiceSearcher.java:93)\n\t… 77 more\nCaused by: java.lang.IllegalArgumentException: query must not be null\n\tat org.openmrs.api.db.hibernate.PatientSearchCriteria.getQueryParts(PatientSearchCriteria.java:441)\n\tat org.openmrs.api.db.hibernate.PatientSearchCriteria.prepareCriterionForName(PatientSearchCriteria.java:387)\n\tat org.openmrs.api.db.hibernate.PatientSearchCriteria.prepareCriterionForName(PatientSearchCriteria.java:429)\n\tat org.openmrs.api.db.hibernate.PatientSearchCriteria.prepareCriteria(PatientSearchCriteria.java:104)\n\tat org.openmrs.api.db.hibernate.HibernateEncounterDAO.createEncounterByQueryCriteria(HibernateEncounterDAO.java:430)\n\tat org.openmrs.api.db.hibernate.HibernateEncounterDAO.getCountOfEncounters(HibernateEncounterDAO.java:354)\n\tat org.openmrs.api.impl.EncounterServiceImpl.getCountOfEncounters(EncounterServiceImpl.java:591)\n\tat sun.reflect.GeneratedMethodAccessor1209.invoke(Unknown Source)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:498)\n\tat org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)\n\tat org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)\n\tat org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)\n\tat org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)\n\tat org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)\n\tat com.sun.proxy.$Proxy168.getCountOfEncounters(Unknown Source)\n\tat sun.reflect.GeneratedMethodAccessor1209.invoke(Unknown Source)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:498)\n\tat org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)\n\tat org.openmrs.aop.LoggingAdvice.invoke(LoggingAdvice.java:121)\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)\n\tat org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52)\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)\n\tat org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52)\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)\n\tat org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)\n\tat com.sun.proxy.$Proxy169.getCountOfEncounters(Unknown Source)\n\t… 82 more\n”
}
}
dkayiwa
(Daniel Kayiwa)
January 24, 2017, 10:22am
6
@missilen as Darius said before, you cannot search using encounter type alone. You need the patient too.
femi
(Femi Oladeji)
March 8, 2017, 11:13am
7
@dkayiwa please what exactly does the q param stand for. I entered “a” and I got some results but I don’t know if it’s searching a specific field in the database. I’ve also seen it in other endpoints but I don’t know how to make full use of it. Thanks
femi
(Femi Oladeji)
March 8, 2017, 1:52pm
9
For the /encounter
resource. So the request uri was like this http://localhost:8081/openmrs-standalone/ws/rest/v1/encounter?q=a&v=full
. It got the results for me but I don’t know how q
is being used and it’s impact on the result. I’m trying to use the endpoint to make searches for the new “cohortBuilder”
dkayiwa
(Daniel Kayiwa)
March 8, 2017, 7:38pm
10
In your case, q represents the patient identifier or patient name. Similar to using this screen: http://qa-refapp.openmrs.org/openmrs/admin/encounters/index.htm
femi
(Femi Oladeji)
March 9, 2017, 9:49am
11
On a more broader note, are the API endpoints sufficient enough to use for search purposes in the cohort Builder, I know the current cohortBuilder didn’t make use of those endpoints but my team is trying to use those API endpoints to perform search in the new cohortBuilder. Is this possible and feasible?
dkayiwa
(Daniel Kayiwa)
March 9, 2017, 10:19am
12
The strategy is to use those that already exist. When you later on come across any missing ones, you will add them. Does this make sense?
We’re trying to do the various types of searches. It’s not immediately obvious which endpoints to call. Maybe we’re missing something. Could you direct us?
dkayiwa
(Daniel Kayiwa)
March 9, 2017, 12:06pm
14
Your question is still too general. Deal with it on a case by case basis. When you need an end point, take a look at this and see if it exists. localhost:8080/openmrs/module/webservices/rest/apiDocs.htm
If you fail to find anything useful, then ask what exactly is the end point that you are looking for, supposed to do. That way you will get more specific responses.
femi
(Femi Oladeji)
March 9, 2017, 1:11pm
15
Alright, for the patient attributes search where you specify fields like gender, age and birthdate and you want to retrieve patients with those attributes.
The image above shows the current view of what we have. On click of search, we want to make an API call to http://localhost:8081/openmrs-standalone/ws/rest/v1/patient?q=male&v=full with the hope of retrieving only male patients but this only returned patients that have “male” in their names.
The image above shows the documentation for the GET /patient endpoint, there is nothing in the query parameters that will allow us specify age or date of birth. So we want to know if we’re missing something or we’re looking in the wrong place.
darius
(Darius Jazayeri)
March 9, 2017, 1:41pm
16
The API endpoints in the REST webservices module are definitely not
sufficient for cohort builder. You will need to use queries from the
Reporting module, accessed via the reportingrest module. This is not
documented well (or at all?).
-Darius (by phone)