Dosage

public class Dosage

The domain object representing a medicine dosage within a pill regimen.

Constructors

Dosage

public Dosage()

Constructs an instance without setting any fields.

Dosage

public Dosage(Time dosageTime, Set<Medicine> medicines)

Creates a dosage using a medicine and a time of day for taking the medicines.

Parameters:
  • dosageTime – the time of day at which this dosage should be taken
  • medicines – all medicines that are part of this dosage

Methods

getDosageTime

public Time getDosageTime()
Returns:the time of day at which this dosage should be taken

getEndDate

public LocalDate getEndDate()

Gets the end date for taking this dosage. It will check all the medicines for the latest end date.

Returns:the end date for taking this dosage, or null if there are no medicines with end dates

getId

public Long getId()
Returns:the unique dosage identifier

getMedicines

public Set<Medicine> getMedicines()
Returns:all medicines that are part of this dosage

getResponseLastCapturedDate

public LocalDate getResponseLastCapturedDate()
Returns:the last captured date when the patient reported taking this dosage

getStartDate

public LocalDate getStartDate()

Gets the start date for taking this dosage. It will check all the medicines for the earliest start date.

Returns:the start date for taking this dosage

isTodaysDosageResponseCaptured

public boolean isTodaysDosageResponseCaptured()

Checks if there is a patient response captured for the last dosage time. This will check if the response was made today or yesterday, provided it’s still before today’s dosage time.

Returns:true if the response was captured, false otherwise

setDosageTime

public void setDosageTime(Time dosageTime)
Parameters:
  • dosageTime – the time of day at which this dosage should be taken

setId

public void setId(Long id)
Parameters:
  • id – the unique dosage identifier

setMedicines

public void setMedicines(Set<Medicine> medicines)
Parameters:
  • medicines – all medicines that are part of this dosage

setResponseLastCapturedDate

public void setResponseLastCapturedDate(LocalDate responseLastCapturedDate)
Parameters:
  • responseLastCapturedDate – the last captured date when the patient reported taking this dosage

todaysDosageTime

public DateTime todaysDosageTime()

Returns a datetime for the dosage that should be taken today, by combining the today date and the dosage time.

Returns:a datetime for the dosage of today

updateResponseLastCapturedDate

public void updateResponseLastCapturedDate(LocalDate lastCapturedDate)

Update this dosage with a new response date from the patient. If the provided date is null or before the currently set last capture date, it will be ignored.

Parameters:
  • lastCapturedDate – the date on which the response was captured

validate

public void validate()

Validates this dosage by calling Medicine.validate() on all medicines for this dosage.

Throws: