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

EA-209 fix date comparison in getMothersAndChildren() to determine wh… #252

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

chibongho
Copy link
Contributor

…ether child is born during mother's visit

See: https://openmrs.atlassian.net/browse/EA-209

and year(child.birthdate) >= year(motherVisit.startDatetime)
and month(child.birthdate) >= month(motherVisit.startDatetime)
and day(child.birthdate) >= day(motherVisit.startDatetime)) > 0)
and (year(child.birthdate)||'-'||month(child.birthdate)||'-'||day(child.birthdate)) >=
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't like this manual concatenation, but I can't find a DATE() function in hql like in mysql.

Copy link
Member

@mseaton mseaton left a comment

Choose a reason for hiding this comment

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

Ick, ugly, but it was also ugly before.

@mseaton mseaton merged commit 9a6fa43 into master Nov 7, 2024
1 check passed
@mseaton mseaton deleted the EA-209 branch November 7, 2024 13:50
@chibongho
Copy link
Contributor Author

A bit moot, but looks like later version of hql has something saner:

extract(date from child.birthdate)

https://docs.jboss.org/hibernate/orm/6.6/userguide/html_single/Hibernate_User_Guide.html

@mogoodrich
Copy link
Member

Oh, thanks @chibongho , yeah, whoops, bug on my part, nice catch. The string concanetation is ugly, but if we are assured that the greater than test will always work correctly, I guess we are okay.

The other option would be to be more explicit about the day/month/year comparisions, we could do this, right (admittedly "wordy", and I probably have my parathesis wrong, hard to match up outside of an editor)?

and (year(child.birthdate) >= year(motherVisit.startDatetime) or 

(year(child.birthdate) == year(motherVisit.startDatetime) and month(child.birthdate) >= month(motherVisit.startDatetime)) or

(year(child.birthdate) == year(motherVisit.startDatetime) and month(child.birthdate) == month(motherVisit.startDatetime)) and day(child.birthdate) >= day(motherVisit.startDatetime)) 

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