josephbate
(joseph ssegujja)
October 16, 2023, 9:47am
1
hello folks
iam working on the ticket [RESTWS-817] ConceptResource to GET concepts of a given class - OpenMRS Issues , trying to filter concepts by concept uuid and also name&conceptClass uuid
i have successfuly achieved some progress as we can now filter concepts by class
/openmrs/ws/rest/v1/concept?class=8d490dfc-c2cc-11de-8d13-0010c6dffd0f
we can also flitler with parameters name and conceptClass however this can only be achieved if concept names are fully specified that is instead of ASP we use Aspirin
my challenge now is get both of the two to work fine even when the name parameter is not fully specified
here is my pullrequest for this ticket; RESTWS-817: ConceptResource to GET concepts of a given class by josephbate · Pull Request #583 · openmrs/openmrs-module-webservices.rest · GitHub
any guidance from the community will be appreciated
josephbate
(joseph ssegujja)
October 16, 2023, 9:50am
2
this is what i have implimented
if (conceptClass != null) {
List<Locale> locales = new ArrayList<Locale>(LocaleUtility.getLocalesInOrder());
List<ConceptClass> classes = null;
ConceptClass responseConceptClass = conceptService.getConceptClassByUuid(conceptClass);
if (responseConceptClass != null) {
classes = Arrays.asList(responseConceptClass);
}
List<ConceptSearchResult> searchResults = conceptService.getConcepts(name, locales, context.getIncludeAll(),
classes, null, null, null, null, context.getStartIndex(), context.getLimit());
List<Concept> results = new ArrayList<Concept>(searchResults.size());
for (ConceptSearchResult csr : searchResults) {
results.add(csr.getConcept());
}
return new NeedsPaging<Concept>(results, context);
}
any suggestions to achieve better results are welcome
josephbate
(joseph ssegujja)
October 17, 2023, 4:54am
3
hello i welcome any suggestion on how to approach this
cc. @dkayiwa @ibacher @ruhanga @mozzy @mksd