Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions docs/domain/value_objects/medication_frequency.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# `MedicationFrequency` -> `src/domain/value_objects/medication_frequency.rs`

A value object representing how often a medication should be taken.

---

## Invariants

- This follow an enum pattern with variants like `OnceDaily`, `TwiceDaily`, `EveryXHours(u8) or Custom(String)`.
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

Grammar: “This follow” should be “This follows”.

Suggested change
- This follow an enum pattern with variants like `OnceDaily`, `TwiceDaily`, `EveryXHours(u8) or Custom(String)`.
- This follows an enum pattern with variants like `OnceDaily`, `TwiceDaily`, `EveryXHours(u8) or Custom(String)`.

Copilot uses AI. Check for mistakes.
Comment on lines +3 to +9
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

This doc is much shorter than other value-object docs in this repo (which typically include sections like Constructor/Methods/Usage/Related). To keep documentation consistent and actionable, consider adding at least the constructor/methods (if any) and a Related section similar to the other files in docs/domain/value_objects/.

Copilot uses AI. Check for mistakes.
- For `EveryXHours`, the number of hours must be between 1 and 24


## Usage

```rust
use bitpill::domain::value_objects::medication_frequency::MedicationFrequency;

let freq1 = MedicationFrequency::OnceDaily;
let freq2 = MedicationFrequency::EveryXHours(8);
let freq3 = MedicationFrequency::Custom("Every Monday".to_string());

assert_eq!(freq1.to_string(), "Once daily");
assert_eq!(freq2.to_string(), "Every 8 hours");
assert_eq!(freq3.to_string(), "Every Monday");
```

`MedicationFrequency` is used as a field in the [`Medication`](../entities/medication.md) entity to specify how often the medication should be taken.

## Methods

### `as_str() -> String`