Recall Interval

For complex topics that regular users would not be interested in. For power users and database administrators.
Post Reply
Mifa
Posts: 141
Joined: Wed Nov 21, 2007 6:52 pm
Location: Saint-Bruno, QC, Canada
Contact:

Recall Interval

Post by Mifa » Tue Jun 16, 2015 11:28 am

What's the equation behind the RecallInterval field? The documentation says "The Interval struct combines years, months, weeks, and days into a single integer value." I would like to present the values in this field in a more readable format in one of my custom reports.

Thanks.

User avatar
jsalmon
Posts: 1551
Joined: Tue Nov 30, 2010 12:33 pm
Contact:

Re: Recall Interval

Post by jsalmon » Tue Jun 16, 2015 1:41 pm

It's easiest to think of it in binary. We split day, week, month, and year into 4 vectors of a 32bit integer. Each vector has a max value of 255. We do limit the year vector to 127, but this should not affect your algorithm.
With that in mind, an interval of 127y 200m 150w 100d is represented as 2143852132 in the database.
Break that number into binary and you'll get: 0111 1111, 1100 1000, 1001 0110, 0110 0100
0111 1111: year - 127
1100 1000: month - 200
1001 0110: week - 150
0110 0100: days - 100
The best thing about a boolean is even if you are wrong, you are only off by a bit.

Jason Salmon
Open Dental Software
http://www.opendental.com

Mifa
Posts: 141
Joined: Wed Nov 21, 2007 6:52 pm
Location: Saint-Bruno, QC, Canada
Contact:

Re: Recall Interval

Post by Mifa » Tue Jun 16, 2015 2:10 pm

Thanks Jason!

nathansparks
Posts: 172
Joined: Mon Aug 04, 2008 12:39 pm

Re: Recall Interval

Post by nathansparks » Tue Oct 04, 2016 2:35 pm

Mifa, I know it has been a while, but in case you still care, this will pull your values,

for recall type table

SELECT
DefaultInterval,
(DefaultInterval>> 24) AS Years,
(DefaultInterval>>16<<16)-(DefaultInterval>>24<<24)>>16 AS Months,
(DefaultInterval>>8<<8)-(DefaultInterval>>16<<16)>>8 AS Weeks,
DefaultInterval-(DefaultInterval>>8<<8) AS Days
FROM recalltype;

Or if you are looking at the recall table

SELECT
PatNum,
RecallInterval,
(RecallInterval>> 24) AS Years,
(RecallInterval>>16<<16)-(RecallInterval>>24<<24)>>16 AS Months,
(RecallInterval>>8<<8)-(RecallInterval>>16<<16)>>8 AS Weeks,
RecallInterval-(RecallInterval>>8<<8) AS Days
FROM recall;

Mifa
Posts: 141
Joined: Wed Nov 21, 2007 6:52 pm
Location: Saint-Bruno, QC, Canada
Contact:

Re: Recall Interval

Post by Mifa » Tue Oct 04, 2016 5:07 pm

Thanks Nathan, I appreciate the feedback. I have implemented the solution suggested by Jason and it works just fine, so far! And you know the saying: if it's not broken, don't fix it! :D

Post Reply