Adding secondarySymptom
* so calculating preOvuPhase with cervix is possible
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { LocalDate } from "js-joda"
|
||||
import apply8DayRule from './minus-8-day-rule'
|
||||
|
||||
export default function(cycle, previousCycles) {
|
||||
export default function(cycle, previousCycles, secondarySymptom) {
|
||||
let preOvuPhaseLength = 5
|
||||
|
||||
const minus8DayRuleResult = apply8DayRule(previousCycles)
|
||||
const minus8DayRuleResult = apply8DayRule(previousCycles, secondarySymptom)
|
||||
if (minus8DayRuleResult) preOvuPhaseLength = minus8DayRuleResult
|
||||
|
||||
const startDate = LocalDate.parse(cycle[0].date)
|
||||
@@ -12,7 +12,7 @@ export default function(cycle, previousCycles) {
|
||||
const maybePreOvuDays = cycle.slice(0, preOvuPhaseLength).filter(d => {
|
||||
return d.date <= preOvuEndDate
|
||||
})
|
||||
const preOvulatoryDays = getDaysUntilFertileSecondarySymptom(maybePreOvuDays)
|
||||
const preOvulatoryDays = getDaysUntilFertileSecondarySymptom(maybePreOvuDays, secondarySymptom)
|
||||
// if fertile mucus or cervix occurs on the 1st cycle day, there is no pre-ovu phase
|
||||
if (!preOvulatoryDays.length) return null
|
||||
|
||||
@@ -39,7 +39,8 @@ function getDaysUntilFertileSecondarySymptom(days, secondarySymptom = 'mucus') {
|
||||
if (secondarySymptom === 'mucus') {
|
||||
return day.mucus && day.mucus.value > 1
|
||||
} else if (secondarySymptom === 'cervix') {
|
||||
return day.cervix && !day.cervix.isClosedAndHard
|
||||
return day.cervix && day.cervix.opening > 0
|
||||
|| day.cervix && day.cervix.firmness > 0
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user