Bean Autowire throwing NPE

Am doing some work in attachment Module. And at this line https://github.com/openmrs/openmrs-module-attachments/pull/37/commits/01cfbb094ea2f3f7ff940791e46074f2557bd9af#diff-493f0a3d8c5aa07953f4b231373443d1L167 I keep hitting a null pointer exception which seems to be due to the ComplexViewHelper bean not being autowired when I use this https://github.com/openmrs/openmrs-module-attachments/pull/37/commits/01cfbb094ea2f3f7ff940791e46074f2557bd9af#diff-493f0a3d8c5aa07953f4b231373443d1R37 I tried using the module’s context to get it by doing this https://github.com/openmrs/openmrs-module-attachments/commit/7d0466fa3043f25f7bcee7a2d2f879a79573c856#diff-9918bc0ed46e0854b89c4344345bd069L32 and then call the bean as https://github.com/openmrs/openmrs-module-attachments/commit/7d0466fa3043f25f7bcee7a2d2f879a79573c856#diff-9918bc0ed46e0854b89c4344345bd069R49 but without much success.When i hardcord the beans by instantiating them everything works well which suggests the problem is autowire. What might I be missing? @dkayiwa @mksd @ibacher

@reagan I implemented the fix for ATT-33, could you try building that branch and testing the output OMOD locally on your end? See this branch.

All Spring tests are fine, but it would be great if you could QA it against Ref App 2.10 (and hence Core 2.3.0).

As for the autowiring of ComplexViewHelper, it’s done here: https://github.com/openmrs/openmrs-module-attachments/blob/18d02c2957905d84d0708969085b87ff33dafdc3/api/src/main/java/org/openmrs/module/attachments/obs/AbstractAttachmentHandler.java#L41-L43

3 Likes

Locally everything works fine on Ref App 2.10…Screenshot below of an image and file attachments. @mksd

Thanks @reagan, that’s already an important piece tested.

However what ATT-33 is really about is attachments that were created outside of the module and that should however be handled by it.

For testing this you need to be able to create a complex obs (say an image) outside of Attachments API, and then verify that the Attachments page can handle it. For example an HFE form that can upload an image. Is that something you would be in a position to test?

1 Like

Could you point me to a form or atleast a tag that can be used to upload an image using the HFE to be able to test this out…Otherwise checking this Tool to upload patient images and annotate them? I cant gather much.

Yes you can use the Drawing Module indeed.

So using the Drawing module.It does attach documents onto different encounters. And so I tested out different scenarios.

  1. Adding the image to an encounter that doesn’t use the Attachment Api like Visit Note Form I end up with only the concept name and value
  2. When I use an encounter that relies on the Attachment module then I can see the attachment However am not able to open it except download(but even when I download it: It is empty). But this could be an issue with the drawingHandler because it is the same outcome when I use the legacyui
  3. Despite using any of those encounters, I dont see the attachments on the clinicianFacingDashboard(only attachment that were created using the attachment module appear)

@mksd Perhaps you can understand better what is happening than I do.

I think the bug in the drawing module is part of what is mentioned here. https://issues.openmrs.org/browse/ERR-652

@reagan thanks a lot for your feedback.

For the Attachments page accessed through the dashboard, you need to tell Attachments to query for further concepts complex by listing them in the ad-hoc GP, see here.

By default it only fetches the default concepts complex listed above.

  1. Adding the image to an encounter that doesn’t use the Attachment Api like Visit Note Form I end up with only the concept name and value

That’s normal.

  1. When I use an encounter that relies on the Attachment module then I can see the attachment However am not able to open it except download(but even when I download it: It is empty). But this could be an issue with the drawingHandler because it is the same outcome when I use the legacyui

That one I don’t understand. Did you use the Drawing module or Attachments? Can you clarify?

  1. Despite using any of those encounters, I dont see the attachments on the clinicianFacingDashboard(only attachment that were created using the attachment module appear)

I responded here above.

The clinicianDashBoard is now able to display after adding the UUID

This was using the Drawing Module.

And so I think the problem is addressed in this ticket

Thanks @reagan, ok so it all makes sense.

The final check is to compare the behaviour with the images coming out of the Drawing module between the following two branches:

  • master
  • ATT-33

If the behaviour is the same then we’re good, in the sense that no regressions are introduced.

However those .png should display, we will have to investigate why they don’t.

1 Like

@mksd I am getting similar results for both master and ATT-33. Unfortunately following this path C:/Users/<user>/AppData/Roaming/OpenMRS/: the folder is empty.

But you’ve been able to test?

Could you investigate why the Drawing module-generated .png can’t seem to be displayed?

7 posts were split to a new topic: Attachments: Problem rendering complex obs created outside of module