Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

O3-2446 - Queue module service, status, and priority configuration #49

Merged
merged 3 commits into from
Jan 4, 2024

Conversation

mseaton
Copy link
Member

@mseaton mseaton commented Jan 2, 2024

See: https://openmrs.atlassian.net/browse/O3-2446

  • Updates the global properties that configure the available/default services, priorities, and statuses for queues to allow configuration by uuid or mapping:code in addition to the ( currently supported ) concept name.
  • Adds new priorityConceptSet and serviceConceptSet to the Queue object and data model
  • Adds new services to retrieve the allowed priorities and services for a given queue, first using any specific concept set configured on the queue, and defaulting to what is configured in the (existing) global property
  • Updates the validators to respect this new configuration
  • Updates the REST endpoint for Queue to support these new properties and to add a convenience property to retrieve the allowed priorities and statuses for a given Queue.

… and statusConceptSet properties, and also to retrieve the allowedPriorities and allowedStatuses concepts.
@mseaton mseaton changed the title O3-2446 - Queue Backend should support concept global properties that… O3-2446 - Queue module service, status, and priority configuration Jan 3, 2024
//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);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I discovered in testing that the method I was previously using (getConceptService().getConceptsByName(conceptRef)) does a fuzzy-match (eg. partial match) rather than an exact match, so it was matching on too many concepts. Unfortunately, there is no public method in the ConceptService to get back all Concepts that exactly match a particular name, and the one above that I am using will just log a warning if multiple names are found and return the first one, which really isn't ideal, but given that it is also what is used in the new Core 2.6 method that accomplishes the same as the above, I went with it. We likely should address this in core, and provide some additional (better) options.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, the method in core was basically pulled straight from HTMLFormEntry and similarly didn't want to mess with what already worked. I agree having something like getConceptsByExactName() in core would actually be really, really useful for these cases where we're using concept names as concept identifiers.

}
Location isExistentLocation = Context.getLocationService().getLocationByUuid(location.getUuid());
return isExistentLocation != null;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seemed rather pointless. We already check for null earlier in the method, and we don't typically check whether a nested property is actually saved or not, so I removed this check.

Per my added comment above, we do probably want to validate that the location is actually tagged as a Queue Location, but I'll leave that for a separate ticket if desired.

@PropertyGetter("allowedStatuses")
public Object getAllowedStatuses(Queue delegate) {
return services.getAllowedStatuses(delegate);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure if this is the right way to support this, but adding these to the Queue resource seems the most straightforward and helpful.

Copy link
Member

@ibacher ibacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks @mseaton!

//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);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, the method in core was basically pulled straight from HTMLFormEntry and similarly didn't want to mess with what already worked. I agree having something like getConceptsByExactName() in core would actually be really, really useful for these cases where we're using concept names as concept identifiers.

@mseaton mseaton merged commit bb92c45 into main Jan 4, 2024
1 check passed
@mseaton mseaton deleted the O3-2446 branch January 4, 2024 15:39
@lluismf
Copy link

lluismf commented Jan 9, 2024

It's kind of weird to throw IllegalArgumentException if the concept does not exist.
I'd rather throw ObjectNotFoundException or return null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants