Check for fhm according to nfp, not just temp shift

This commit is contained in:
Julia Friesel
2018-07-13 06:44:23 +02:00
parent 93ff7a0f8f
commit d5aa903da4
+2 -3
View File
@@ -4,19 +4,18 @@ import getPreOvulatoryPhase from './pre-ovulatory'
import { LocalDate } from 'js-joda' import { LocalDate } from 'js-joda'
import assert from 'assert' import assert from 'assert'
export default function ({ cycle, previousCycles = [] }) { export default function getSymptoThermalStatus({ cycle, previousCycles = [] }) {
throwIfArgsAreNotInRequiredFormat(cycle, previousCycles) throwIfArgsAreNotInRequiredFormat(cycle, previousCycles)
const status = { const status = {
assumeFertility: true, assumeFertility: true,
phases: {} phases: {}
} }
// TODO handle no previous cycles
// 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
const lastCycle = previousCycles[previousCycles.length - 1] const lastCycle = previousCycles[previousCycles.length - 1]
if (getTemperatureShift(lastCycle).detected && !cycle[0].mucus) { if (lastCycle && getSymptoThermalStatus({cycle: lastCycle}).temperatureShift) {
status.phases.preOvulatory = getPreOvulatoryPhase(cycle, previousCycles) status.phases.preOvulatory = getPreOvulatoryPhase(cycle, previousCycles)
if (status.phases.preOvulatory.cycleDays.length === cycle.length) { if (status.phases.preOvulatory.cycleDays.length === cycle.length) {
status.assumeFertility = false status.assumeFertility = false