diff --git a/lib/sympto/index.js b/lib/sympto/index.js index c50fcbb286b1aec8cbeaca07542d234a48ff6d5f..f93ecace09bc4a5ad7690c39b6f97582ab4f673d 100644 --- a/lib/sympto/index.js +++ b/lib/sympto/index.js @@ -16,7 +16,10 @@ export default function getSymptoThermalStatus(cycleInfo) { // if there was no first higher measurement in the previous cycle, // no infertile pre-ovulatory phase may be assumed if (previousCycle) { - const statusForLast = getSymptoThermalStatus({ cycle: previousCycle }) + const statusForLast = getSymptoThermalStatus({ + cycle: previousCycle, + secondarySymptom: secondarySymptom + }) if (statusForLast.temperatureShift) { const preOvuPhase = getPreOvulatoryPhase( cycle, diff --git a/lib/sympto/pre-ovulatory.js b/lib/sympto/pre-ovulatory.js index b1e76981c105b536912e3ef3de2cd7e74a2de145..c2501428c3f215e011e368f779e8222fe44bb84e 100644 --- a/lib/sympto/pre-ovulatory.js +++ b/lib/sympto/pre-ovulatory.js @@ -12,7 +12,7 @@ export default function(cycle, previousCycles) { const maybePreOvuDays = cycle.slice(0, preOvuPhaseLength).filter(d => { return d.date <= preOvuEndDate }) - const preOvulatoryDays = getDaysUntilFertileMucus(maybePreOvuDays) + const preOvulatoryDays = getDaysUntilFertileSecondarySymptom(maybePreOvuDays) // if mucus occurs on the 1st cycle day, there is no pre-ovu phase if (!preOvulatoryDays.length) return null @@ -34,13 +34,17 @@ export default function(cycle, previousCycles) { } } -function getDaysUntilFertileMucus(days) { - const firstFertileMucusDayIndex = days.findIndex(day => { - return day.mucus && day.mucus.value > 1 +function getDaysUntilFertileSecondarySymptom(days, secondarySymptom) { + const firstFertileSecondarySymptomDayIndex = days.findIndex(day => { + if (secondarySymptom === 'mucus') { + return day.mucus && day.mucus.value > 1 + } else if (secondarySymptom === 'cervix') { + return day.cervix && !day.cervix.isClosedAndHard + } }) - if (firstFertileMucusDayIndex > -1) { - return days.slice(0, firstFertileMucusDayIndex) + if (firstFertileSecondarySymptomDayIndex > -1) { + return days.slice(0, firstFertileSecondarySymptomDayIndex) } return days } \ No newline at end of file