![]() |
VOOZH | about |
dotnet add package DoenaSoft.PillRefresh --version 1.0.5
NuGet\Install-Package DoenaSoft.PillRefresh -Version 1.0.5
<PackageReference Include="DoenaSoft.PillRefresh" Version="1.0.5" />
<PackageVersion Include="DoenaSoft.PillRefresh" Version="1.0.5" />Directory.Packages.props
<PackageReference Include="DoenaSoft.PillRefresh" />Project file
paket add DoenaSoft.PillRefresh --version 1.0.5
#r "nuget: DoenaSoft.PillRefresh, 1.0.5"
#:package DoenaSoft.PillRefresh@1.0.5
#addin nuget:?package=DoenaSoft.PillRefresh&version=1.0.5Install as a Cake Addin
#tool nuget:?package=DoenaSoft.PillRefresh&version=1.0.5Install as a Cake Tool
A .NET library for calculating medication supply duration and generating calendar reminders with automatic weekend and holiday avoidance.
PillRefreshLib provides core functionality for managing medication schedules by calculating when prescriptions need to be refilled. The library automatically adjusts reminder dates to avoid weekends and regional holidays, ensuring reminders occur on business days when prescriptions can actually be filled.
Install via NuGet Package Manager:
Install-Package DoenaSoft.PillRefresh
Or via .NET CLI:
dotnet add package DoenaSoft.PillRefresh
This library supports:
using DoenaSoft.PillRefresh;
// Implement the IInteraction interface for your application
public class ConsoleInteraction : IInteraction
{
public void WriteLine(string message = null)
{
Console.WriteLine(message);
}
public string ReadLine()
{
return Console.ReadLine();
}
}
// Use the PillCalculator
var interaction = new ConsoleInteraction();
var calculator = new PillCalculator(interaction);
// Get user input
double pillCount = calculator.GetPillCount();
double dailyDosage = calculator.GetDosageCount();
// Calculate final day
DateTime finalDay = DateTime.Now.Date.AddDays(Math.Floor(pillCount / dailyDosage) - 1);
// Get reminder day (adjusted for holidays and weekends)
DateTime reminderDay = calculator.GetReminderDay(finalDay, "us", "California");
// Get event name
string eventName = calculator.GetEventName();
// Create calendar event
string icsFilePath = calculator.CreateEvent(finalDay, reminderDay, eventName);
// The .ics file is now ready to be imported into any calendar application
For GUI or web applications, implement the IInteraction interface to match your UI framework:
public class WpfInteraction : IInteraction
{
private readonly TextBox outputTextBox;
private readonly Func<string> inputProvider;
public WpfInteraction(TextBox output, Func<string> inputFunc)
{
outputTextBox = output;
inputProvider = inputFunc;
}
public void WriteLine(string message = null)
{
outputTextBox.AppendText(message + Environment.NewLine);
}
public string ReadLine()
{
return inputProvider();
}
}
For testing or automated workflows, create a mock interaction:
public class MockInteraction : IInteraction
{
private readonly Queue<string> responses;
private readonly List<string> output;
public MockInteraction(params string[] inputResponses)
{
responses = new Queue<string>(inputResponses);
output = new List<string>();
}
public void WriteLine(string message = null)
{
output.Add(message);
}
public string ReadLine()
{
return responses.Dequeue();
}
public IReadOnlyList<string> Output => output;
}
// Usage in tests
var mock = new MockInteraction("30", "2", "7", "Refill Medication");
var calculator = new PillCalculator(mock);
// ... perform calculations
public interface IInteraction
{
void WriteLine(string message = null);
string ReadLine();
}
Implement this interface to integrate the library with your application's UI framework.
public PillCalculator(IInteraction interaction)
Creates a new instance of the PillCalculator with the specified interaction interface.
Parameters:
interaction: Implementation of IInteraction for user communicationpublic string Calculate(string countryCode, string administrativeDivision)
Performs a complete pill supply calculation workflow: prompts for pill count and dosage, calculates the final day, determines the optimal reminder day (avoiding weekends and holidays), gets the event name, and creates the calendar file.
Parameters:
countryCode: ISO 3166-1 alpha-2 country code for holiday lookup (e.g., "us", "de", "gb", "ch", "ca"). Used to identify regional holidaysadministrativeDivision: The administrative division within the country (state, province, canton, region). Examples:
Returns: The file path to the generated iCalendar (.ics) file
public double GetPillCount()
Prompts the user for the number of pills remaining.
Returns: The number of pills left (decimal value allowed)
public double GetDosageCount()
Prompts the user for the daily dosage.
Returns: The number of pills taken per day (decimal value allowed)
public DateTime CalculateFinalDay(double pills, double dosage)
Calculates the final day when the pill supply will run out based on current count and daily dosage.
Parameters:
pills: The current number of pills availabledosage: The number of pills taken per dayReturns: The date when the pills will run out
public DateTime GetReminderDay(DateTime finalDay, string countryCode, string administrativeDivision)
Calculates the reminder day, automatically avoiding weekends and holidays.
Parameters:
finalDay: The date when pills will run outcountryCode: ISO 3166-1 alpha-2 country code for holiday lookup (e.g., "us", "de", "gb", "ch", "ca")administrativeDivision: The administrative division within the country (state, province, canton, region). Examples:
Returns: The calculated reminder date, adjusted for weekends and regional holidays
public string GetEventName()
Prompts the user for the reminder event name.
Returns: The name for the calendar event
public string CreateEvent(DateTime finalDay, DateTime reminderDay, string eventName)
Creates an iCalendar (.ics) file with an event and reminder.
Parameters:
finalDay: The date when the pills will run outreminderDay: The date for the reminder alarmeventName: The name/summary of the calendar eventReturns: The file path to the generated .ics file (created in system temp directory)
public bool GetDoAnotherCalculation()
Prompts the user whether they want to perform another calculation.
Returns: true if the user wants another calculation; otherwise, false
The library uses the mitoSoft.Holidays package to support holidays for numerous countries and regions.
Country Codes use ISO 3166-1 alpha-2 standard. Common country codes include:
de - Germanyus - United Statesgb - United Kingdomfr - Francech - Switzerlandat - Austriaca - Canadait - Italyes - SpainAn administrative division is a geographical subdivision within a country that has its own regional holidays in addition to national holidays. Different countries use different terms for these divisions:
Administrative Division Examples by Country:
| Country | Term Used | Examples | Notes |
|---|---|---|---|
| United States | State | California, Texas, NewYork, Florida |
50 states with varying regional holidays |
| Germany | Bundesland (Federal State) | Bayern (Bavaria), RheinlandPfalz, Berlin, Hessen, Sachsen |
16 states, each with unique holidays |
| Switzerland | Canton | Zurich, Geneva, Bern, Basel, Lucerne |
26 cantons with different holiday calendars |
| Canada | Province/Territory | Ontario, Quebec, BritishColumbia, Alberta |
10 provinces and 3 territories |
| Austria | Bundesland | Wien (Vienna), Tirol, Salzburg, Steiermark |
9 federal states |
| France | Region/Department | IleDeFrance, Alsace, Provence |
Some regional variations |
Different regions within the same country often observe different public holidays. For example:
The library uses this information to ensure reminder dates don't fall on regional holidays when medical offices might be closed.
// Example for California, United States
DateTime reminderDay = calculator.GetReminderDay(finalDay, "us", "California");
// Example for Bavaria, Germany
DateTime reminderDay = calculator.GetReminderDay(finalDay, "de", "Bayern");
// Example for Zurich, Switzerland
DateTime reminderDay = calculator.GetReminderDay(finalDay, "ch", "Zurich");
If no holiday calendar is found for the specified country or administrative division, the library will:
IInteraction interfaceThis ensures the application remains functional even for regions without comprehensive holiday data.
Generated .ics files are compatible with:
The events are created with:
The library includes built-in support for multiple languages through resource files:
Add additional languages by including culture-specific resource files in your application.
var calculator = new PillCalculator(interaction);
double pills = 60;
double dosage = 2.5;
int daysLeft = (int)Math.Floor(pills / dosage) - 1;
DateTime refillDate = DateTime.Now.Date.AddDays(daysLeft);
// Use a preset interaction or mock
var finalDay = DateTime.Now.AddDays(20);
var reminderDay = calculator.GetReminderDay(finalDay, "de", "Bayern");
string icsFile = calculator.CreateEvent(finalDay, reminderDay, "Medication Refill");
The PillCalculator class is not thread-safe. Create separate instances for concurrent operations.
This library is licensed under the MIT License. See LICENSE file for details.
Copyright (c) 2022 DJ Doena
For issues, questions, or feature requests, please visit: https://github.com/DJDoena/PillRefresh
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 is compatible. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
Initial release with core functionality for medication supply calculation and calendar event generation.