Currently, the available implementation with the OpenMRS Rest API module creates patients but using two different endpoints
/ws/rest/v1/person for a person and then /ws/rest/v1/patient to add he patient attributes, so need to call two different endpoints for a single operation.
Is there a way I can create a patient but using one endpoint providing all the details required for patient registration for example
{
"names":[
{
"givenName":"Solomon",
"middleName":"Baluku",
"familyName":"Ssevvume",
"preferred":true
}
],
"gender":"M",
"age":29,
"birthdateEstimated":true,
"dead":false,
"addresses":[
{
"preferred":true,
"address1":"Uganda",
"address2":"Mityana",
"cityVillage":"string",
"stateProvince":"string",
"country":"string",
"postalCode":"string",
"countyDistrict":"string",
"address3":"string",
"address4":"string",
"address5":"string"
}
]
}
{
"person":"71075074-f02e-4270-89a3-f2dcda436f70",
"identifiers":[
{
"identifier":" 103VWY7",
"identifierType":"05a29f94-c0ed-11e2-94be-8c13b969e334",
"location":"629d78e9-93e5-43b0-ad8a-48313fd99117",
"preferred":false
}
]
}
1 Like
dkayiwa
(Daniel Kayiwa)
February 14, 2022, 12:42pm
#2
@dkayiwa thank you for this feedback, I have tried the approach suggested and here is my post body.
{
"identifiers":[
{
"identifier":"103VWY7",
"identifierType":"71075074-f02e-4270-89a3-f2dcda436f70",
"location":"9356400c-a5a2-4532-8f2b-2361b3446eb8",
"preferred":true
}
],
"person":{
"gender":"M",
"age":47,
"birthdate":"1970-01-01T00:00:00.000+0100",
"birthdateEstimated":false,
"dead":false,
"deathDate":null,
"causeOfDeath":null,
"names":[
{
"givenName":"Thomas",
"familyName":"Smith"
}
]
}
}
Unfortunately the body is not being posted. This is the error that i get
"message": "[identifiers on class org.openmrs.Patient]",
I am using the patient endpoint.
dkayiwa
(Daniel Kayiwa)
February 14, 2022, 1:59pm
#4
Check your server side log for the actual cause of the failure.
@dkayiwa this is the error log i am getting
gistfile1.txt
"message": "[identifiers on class org.openmrs.Patient]",
"code": "org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource:805",
"detail": "org.openmrs.module.webservices.rest.web.response.ConversionException: identifiers on class org.openmrs.Patient\n\tat org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource.setProperty(BaseDelegatingResource.java:805)\n\tat org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource.setConvertedProperties(BaseDelegatingResource.java:672)\n\tat org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PatientResource1_8.getPatient(PatientResource1_8.java:241)\n\tat org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PatientResource1_8.create(PatientResource1_8.java:221)\n\tat org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceController.create(MainResourceController.java:92)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\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.doPost(FrameworkServlet.java:868)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:647)\n\tat org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:728)\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.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:73)\n\tat org.openmrs.web.filter.GZIPFilter.doFilterInternal(GZIPFilter.java:65)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\n\tat org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:71)\n\tat org.openmrs.module.webservices.rest.web.filter.AuthorizationFilter.doFilter(AuthorizationFilter.java:105)\n\tat org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:71)\n\tat org.openmrs.module.webservices.rest.web.filter.ContentTypeFilter.doFilter(ContentTypeFilter.java:64)\n\tat org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:71)\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:71)\n\tat org.openmrs.module.owa.filter.OwaFilter.doFilter(OwaFilter.java:57)\n\tat org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:71)\n\tat org.openmrs.module.xforms.web.XformsFilter.doFilter(XformsFilter.java:69)\n\tat org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:71)\n\tat org.openmrs.module.referenceapplication.filter.RequireLoginLocationFilter.doFilter(RequireLoginLocationFilter.java:93)\n\tat org.openmrs.module.web.filter.ModuleFilterChain.doFilter(ModuleFilterChain.java:71)\n\tat org.openmrs.module.web.filter.ModuleFilter.doFilter(ModuleFilter.java:57)\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:109)\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: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: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: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.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:219)\n\tat org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)\n\tat org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:492)\n\tat org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:165)\n\tat org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)\n\tat org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)\n\tat org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452)\n\tat org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1201)\n\tat org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:654)\n\tat org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:317)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\n\tat org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)\n\tat java.lang.Thread.run(Thread.java:748)\nCaused by: org.openmrs.module.webservices.rest.web.response.ConversionException: identifierType on class org.openmrs.PatientIdentifier\n\tat org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource.setProperty(BaseDelegatingResource.java:805)\n\tat org.openmrs.module.webservices.rest.web.ConversionUtil.convertMap(ConversionUtil.java:323)\n\tat org.openmrs.module.webservices.rest.web.ConversionUtil.convert(ConversionUtil.java:273)\n\tat org.openmrs.module.webservices.rest.web.ConversionUtil.convert(ConversionUtil.java:213)\n\tat org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource.setProperty(BaseDelegatingResource.java:791)\n\t... 78 more\nCaused by: java.lang.reflect.InvocationTargetException\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\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.BaseDelegatingResource.setProperty(BaseDelegatingResource.java:792)\n\t... 82 more\nCaused by: java.lang.NullPointerException\n\tat org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PatientIdentifierResource1_8.setIdentifierType(PatientIdentifierResource1_8.java:98)\n\t... 87 more\n"
}
}
dkayiwa
(Daniel Kayiwa)
February 15, 2022, 8:23am
#6
You do not have a patient identifier type matching the uuid that you have given.
@dkayiwa thank you so much for the help, the location type uuid was the one missing out, setting it to the correct uuid works fine.
Now on to the issue of dealing with duplicates. How can i ensure that we do not register a patient from the mobile app that already be existing in the system.
Is it also possible to change the documentation here OpenMRS Docs so as to reflect how a patient can be created along with a Person object?
dkayiwa
(Daniel Kayiwa)
February 15, 2022, 9:19am
#8
Can you create a ticket for this?
How do you tell that a patient already exists? When the family name matches? Age? Gender? Or what?
@dkayiwa the ticket has been created here [RESTWS-883] Documentation for the Patient Rest API end point - OpenMRS Issues
As for patient duplicity, we are wondering whether some form of pattern matching in the names can be done as it is done withing OpenMRS.
dkayiwa
(Daniel Kayiwa)
February 15, 2022, 2:07pm
#10
1 Like
Thank @dkayiwa this will help us greatly.
I have taken up this ticket on JIRA. I have a few questions:
What exactly is an identifier. Is it is an unique id given to a patient? What is location and identifier type?
How is POST /patient/:target_patient_uuid/identifier
a create Patient endpoint? Shouldn’t it be an update Patient endpoint? Am i missing something here.
If the endpoint in 2 is also a way to create a patient, Is the method of Creating a patient and a person simultaneously a third way to create a new patient?
What endpoint did u POST to? is it . POST /patient
Thank you. One more question before I can update the docs.
The end point /ws/rest/v1/patient
has 2 ways in which data can be passed to it.
One way is as described in the current documentation, where we convert an existing person into a patient.
The other way is as described in this topic where, The post body can have both the person and patient details.
Am I Correct?
How do I update the documentation? Is there an article / topic where I can find the steps that I need to follow to get access to updating the documentation?
@ganeshdagadi the steps to get started on this process are documented on the github repo here GitHub - openmrs/openmrs-contrib-rest-api-docs: OpenMRS REST API documentation . Create a pull request that will be reviewed and then merged once it has been approved.
I tried to follow the readme.md file on the github repo to serve a local version of the documentation. However, when I run the command
docker run --rm --name slate -v $(pwd)/build:/srv/slate/build -v $(pwd)/source/index.html.md:/srv/slate/source/index.html.md -v $(pwd)/source/includes:/srv/slate/source/includes -v $(pwd)/source/images/logo.png:/srv/slate/source/images/logo.png -p 4567:4567 slatedocs/slate serve
as instructed, I get an error stating
docker: invalid reference format: repository name must be lowercase.
See 'docker run --help'.
I have cloned the repository.
Docker seems to be working fine, as I checked it using the hello-world docker example.
Am I missing something or is there something wrong with the command?
In this case, @dkayiwa can help in getting you started.
A small update. I tried to fix the problem and was able to start the server, but the default slate documentation is being displayed and not the OpenMRS version. More details in this topic
This is my first time working with JIRA. I have opened a Pull request, set the status to code review and designated @solemabrothers as the designated reviewer. @solemabrothers reviewed my PR and gave a suggestion, which I have updated. What is the next procedure? Should I set status to committed code? Whom should I designate as the committer?
Thanks.
sharif
(Sharif Magembe)
April 12, 2022, 8:47am
#20
Click code review for any reviewer to check the pull request . Dont forget to attach the pull request on the ticket.