Skip to content

Commit

Permalink
O3-2446 - Queue Backend should support concept global properties that…
Browse files Browse the repository at this point in the history
… refer to either uuid, mapping, or name.
  • Loading branch information
mseaton committed Jan 2, 2024
1 parent 24bd4e8 commit 2705eed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,13 @@ public Concept getConcept(String conceptRef) {
return c;
}
}
//handle name
List<Concept> concepts = getConceptService().getConceptsByName(conceptRef);
if (concepts.size() == 1) {
return concepts.get(0);
} else if (concepts.size() > 1) {
throw new IllegalArgumentException("More than one concept is found with name: " + conceptRef);
//handle name. this isn't ideal, as core will just log a warning if there are 2 concepts with the same name
//but there are no alternative suitable methods to get a List of Concepts that exactly match a given name
c = getConceptService().getConceptByName(conceptRef);
if (c == null) {
throw new IllegalArgumentException("Unable to find concept: " + conceptRef);
}
throw new IllegalArgumentException("Unable to find concept: " + conceptRef);
return c;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.openmrs.Concept;
import org.openmrs.api.context.Context;
import org.openmrs.module.queue.QueueModuleConstants;
import org.openmrs.module.queue.api.QueueServicesWrapper;
import org.openmrs.module.queue.model.QueueEntry;
import org.springframework.validation.Errors;

Expand All @@ -35,8 +36,12 @@ public static boolean isAMember(@NotNull Concept concept, @NotNull String proper
throw new IllegalArgumentException("Please configure concept set name for " + concept.getDisplayString()
+ " via the global property " + property);
}
Concept conceptByName = Context.getConceptService().getConceptByName(value);
return Context.getConceptService().getConceptsByConceptSet(conceptByName).contains(concept);
QueueServicesWrapper servicesWrapper = Context.getRegisteredComponents(QueueServicesWrapper.class).get(0);
Concept conceptSet = servicesWrapper.getConcept(value);
if (conceptSet == null) {
throw new IllegalArgumentException("Invalid concept '" + value + "' specified for property: " + property);
}
return servicesWrapper.getConceptService().getConceptsByConceptSet(conceptSet).contains(concept);
}

public static void validateQueueEntry(QueueEntry queueEntry, Errors errors) {
Expand Down

0 comments on commit 2705eed

Please sign in to comment.