Can anyone provide me with an information on how to perform REST operations on visits of a patient with a given uuid?
In the uitestframework such operations are needed when deleting patient by uuid via REST to delete all his visits.
Can anyone provide me with an information on how to perform REST operations on visits of a patient with a given uuid?
In the uitestframework such operations are needed when deleting patient by uuid via REST to delete all his visits.
To get visits of a patient
ws/rest/v1/visit?patient={uuid}
To purge the individual visits see https://wiki.openmrs.org/display/docs/REST+Web+Service+Resources+in+OpenMRS+1.9#RESTWebServiceResourcesinOpenMRS1.9-Visit
@tmueller see http://devtest02.openmrs.org:8080/openmrs/ws/rest/v1/visit?patient=69e4f3f7-4c09-426a-8b11-a467cbdd311d
It returns all non-voided visits of the given patient.
Hi @raff, nice to see you here again after your holiday
The example you provided does seem to work in browser but when I try changing code to run delete(String restPath, String columns) method in with e.g: “visit?patient=12a6e936-f7ac-4cf0-8b04-fa004bdcf7c7” as restPath, I get the following error:
javax.ws.rs.NotAllowedException: HTTP 405 Method Not Allowed
at org.glassfish.jersey.client.JerseyInvocation.convertToException(JerseyInvocation.java:916)
at org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:770)
at org.glassfish.jersey.client.JerseyInvocation.access$500(JerseyInvocation.java:90)
at org.glassfish.jersey.client.JerseyInvocation$2.call(JerseyInvocation.java:671)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:422)
at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:667)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:396)
at org.glassfish.jersey.client.JerseyInvocation$Builder.delete(JerseyInvocation.java:341)
at org.openmrs.uitestframework.test.RestClient.delete(RestClient.java:84)
The exception you pasted does not correspond to the code you linked. org.openmrs.uitestframework.test.RestClient.delete(RestClient.java:84) the line 84 is commented out.
Looking at the code alone:
WebTarget target = newClient().target(getWebAppUrl()).path(REST_ROOT + restPath);
if (columns != null) {
target = target.queryParam("v", "custom:(" + columns + ")");
}
String jsonString = target.request().delete(String.class);
First custom representations do not work for deletions. Next I’m just guessing that you are trying to call delete on /visit?patient=12a6e936-f7ac-4cf0-8b04-fa004bdcf7c7
, which will not work, because you first have to call get and then iterate over the results calling delete on each visit e.g. /visit/43b0aae8-e7b5-41cc-80d6-80772d84aedf
When I call get on the same url I get error:
javax.ws.rs.InternalServerErrorException: HTTP 500 Internal Server Error
at org.glassfish.jersey.client.JerseyInvocation.convertToException(JerseyInvocation.java:925)
at org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:770)
at org.glassfish.jersey.client.JerseyInvocation.access$500(JerseyInvocation.java:90)
at org.glassfish.jersey.client.JerseyInvocation$2.call(JerseyInvocation.java:671)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:422)
at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:667)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:396)
at org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:296)
at org.openmrs.uitestframework.test.RestClient.get(RestClient.java:35)
at org.openmrs.uitestframework.test.RestClient.get(RestClient.java:26)
It is thrown on String jsonString = target.request().get(String.class);
line
Please provide a link to the code you run.
I run the deletePatient function using