Angular Obs resource: how to void an observation?

Hi guys !

One quick question:

I would like to void an observation using the Obs resource, or the ObsService available in UI Commons’ obsService.js

Doing:

Obs.save({
	uuid: "1ca42d3f-b93a-4e4e-b787-e72917aa58a1",
	voided: true
})

correctly voids the given obs, but also creates a new copy of it (!!).

I want to just void the obs.

Q: What is the right way to void an observation?

Thanks

The right way to void data is to use the DELETE operation (docs), so you’ll need to do something like:

curl -u admin:Admin123 \
     -X DELETE \
     'http://localhost:8080/openmrs/ws/rest/v1/obs/1ca42d3f-b93a-4e4e-b787-e72917aa58a1`

EDIT: Looks like you’ll need to write a new JavaScript method that uses the DELETE verb.

Thanks @pascal

Yeah I’ve seen that in the doc. But here, I am in a AngularJS context.

Is it possible to do it using the obsService.js, or encounterService.js ?

I don’t see any methods in those files using DELETE, so you’ll have to submit a PR.

EDIT: Actually ngResource implements a delete method, see the docs here.

Yes, with obsService.js you should be able to do:

Obs.delete({
  uuid: obs.uuid
});
2 Likes

Yes, that works ! Thanks @mksd

1 Like