Skip to content
Snippets Groups Projects
Commit 20dc238e authored by emelko's avatar emelko
Browse files

Replacing mucus default with secondarySymptom

parent 1c2c45f8
No related branches found
No related tags found
No related merge requests found
...@@ -16,7 +16,10 @@ export default function getSymptoThermalStatus(cycleInfo) { ...@@ -16,7 +16,10 @@ export default function getSymptoThermalStatus(cycleInfo) {
// if there was no first higher measurement in the previous cycle, // if there was no first higher measurement in the previous cycle,
// no infertile pre-ovulatory phase may be assumed // no infertile pre-ovulatory phase may be assumed
if (previousCycle) { if (previousCycle) {
const statusForLast = getSymptoThermalStatus({ cycle: previousCycle }) const statusForLast = getSymptoThermalStatus({
cycle: previousCycle,
secondarySymptom: secondarySymptom
})
if (statusForLast.temperatureShift) { if (statusForLast.temperatureShift) {
const preOvuPhase = getPreOvulatoryPhase( const preOvuPhase = getPreOvulatoryPhase(
cycle, cycle,
......
...@@ -12,7 +12,7 @@ export default function(cycle, previousCycles) { ...@@ -12,7 +12,7 @@ export default function(cycle, previousCycles) {
const maybePreOvuDays = cycle.slice(0, preOvuPhaseLength).filter(d => { const maybePreOvuDays = cycle.slice(0, preOvuPhaseLength).filter(d => {
return d.date <= preOvuEndDate 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 mucus occurs on the 1st cycle day, there is no pre-ovu phase
if (!preOvulatoryDays.length) return null if (!preOvulatoryDays.length) return null
...@@ -34,13 +34,17 @@ export default function(cycle, previousCycles) { ...@@ -34,13 +34,17 @@ export default function(cycle, previousCycles) {
} }
} }
function getDaysUntilFertileMucus(days) { function getDaysUntilFertileSecondarySymptom(days, secondarySymptom) {
const firstFertileMucusDayIndex = days.findIndex(day => { const firstFertileSecondarySymptomDayIndex = days.findIndex(day => {
return day.mucus && day.mucus.value > 1 if (secondarySymptom === 'mucus') {
return day.mucus && day.mucus.value > 1
} else if (secondarySymptom === 'cervix') {
return day.cervix && !day.cervix.isClosedAndHard
}
}) })
if (firstFertileMucusDayIndex > -1) { if (firstFertileSecondarySymptomDayIndex > -1) {
return days.slice(0, firstFertileMucusDayIndex) return days.slice(0, firstFertileSecondarySymptomDayIndex)
} }
return days return days
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment