Skip to content
Snippets Groups Projects
Commit d5aa903d authored by Julia Friesel's avatar Julia Friesel
Browse files

Check for fhm according to nfp, not just temp shift

parent 93ff7a0f
No related branches found
No related tags found
No related merge requests found
...@@ -4,19 +4,18 @@ import getPreOvulatoryPhase from './pre-ovulatory' ...@@ -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
......
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