Creating new API in openmrs-core and using it in Attachment module

I have created a new method i.e getAllAttachments in obsServiceImpl in openmrs-core and trying to use it in attachment module but not able to access it in attachment controller. What should i do to get openmrs-core method accessible to attachment module.

Thanks in advance.

1 Like

you simply install that very version of core as dependence and depend on it from any other module ,

But that doesnt sound like the natural place for it . why not add it in the attachments module directly

so you mean that i should create new method into attachment module instead of openmrs-core ?

Obviously it makes more sense there

1 Like

@mozzy correct. And @pratikbiz24, this is getting all attachments for the patient already:

AttachmentsService#getAttachments(Patient, boolean);
2 Likes

Thats true @mksd .
i thought of pointing out to him that method , but then i thought of a weird scenario where some one would want to return all the attachments at ago :blush:
not sure whether its very good practice anyway

1 Like

@mksd thanks for the suggestion, but actually i want all attachments of all patients in one go. That’s why i am creating a new method.

Thanks for the help @mozzy and @mksd :innocent:

But that should be used with care , in case of a million Attachments , it may affect the server performance

Yes you are right. I will take care of that. Actually i am creating an admin page where i can review attachments of all the patients.

@mozzy @mksd i thought of returning all attachments with a query that allows pagination so as to achieve @pratikbiz24’s requirements with less effects to the server

ya , that makes more sense

@pratikbiz24 getting data across multiple patients like that looks like a report. I’m saying this because it will be hard to sell the addition of such method in the existing service, which just returns patient-level data (as the REST of the OpenMRS API does, except through reporting or when manipulating cohorts/groups.)

It would help to know what the final use case is to point you the appropriate solution. Are you needing this for maintenance purpose, for data intelligence purpose, … etc?

2 Likes

Yeah actually i need this method on admin side where a person can analyse the attachments of all the patients. I also look around the openmrs apis which can return all attachments in one go but there is no such api present.

Yes for maintenance purpose.

@pratikbiz24 and what kind of maintenance tasks are envisioned? Can you provide more details as to the user stories that you are willing to develop?

1 Like