ObsService.getComplexObs() .. deprecated?

I am little confused about ComplexObs. If I see the ObsService.getComplexObs(…), I see that its marked as deprecated and the documentation of the method suggests that I can ObsService.getObs() instead. However, looking into the implementation of ObsServiceImpl.getObs(int), it seems just a simple call to ObsDao, and does not invoke the handlers to get complexdata.
Is it supposed to be this way? Or just the documentation is wrong? I would assume that the getObs(int) method, if would need to work seamlessly with complex obs type, then there ought to be code to invoke the corresponding handler?

I am just modifying the test on ObsServiceTest. getComplexObs_shouldFillInComplexDataObjectForComplexObs() and checking.

Or am I completely in wrong direction or understanding?

This looks like a good catch! :slight_smile:

ObsServiceImpl.getObs(int) was supposed to also have this:

if (obs != null && obs.isComplex()) { return getHandler(obs).getObs(obs, ComplexObsHandler.RAW_VIEW); }

Then the unit test you pointed to needs to be changed from: Obs complexObs = os.getComplexObs(44, ComplexObsHandler.RAW_VIEW) to: Obs complexObs = os.geObs(44)

I will send out a pull request. Will this be merged and patched for 2.1?

Why not? :smile:

Btw, this does not work on the aggregate Encounter object right? Would we look to do that when calling get methods EncounterService? Right now, I do not see provision of that. So, if I just call EncounterService, I would just get the raw data from obs.

Same seem to the case with EMR API EncounterTransaction apis. For handling complex obs, through EMR API Encounter transaction api, handler.saveObs() is invokved but I do not see the usage of handler.getObs().
@darius, @mseaton, @mogoodrich - can you guys comment? Is there some obvious step I am missing to get obs data?

@angshuonline I haven’t actually ever worked with complex obs myself, but I would expect that we only support working with them singly, not as a batch, because they are potentially expensive (could be videos, large images, etc).

I do think it makes sense to add a new service method like this (I haven’t thought about what its return type would be) ObsService.getAllComplexObs(Encounter, String view).

So the standard Java and REST calls to get an encounter would continue to function as they currently do, but if one wants to get the complex obs data that’s just one more call, and if we wanted to include this in the encounter transaction API we could do this.

I had a deeper look into the rest calls, I am little confused with the intention and design. Please see this link. Thought its appropriate to post against and cross link to the original thread

I have created an issue for this.

Will create a pull request for this.

Btw, I feel we should also modify the ObsService.getObsByUuid(string) should also behave the same way. I can do both of them in the single PR. Let me know.

Please find the PR. https://github.com/openmrs/openmrs-core/pull/2233