Handle cycle with mucus on first cycle day
This commit is contained in:
+9
-3
@@ -16,9 +16,15 @@ export default function getSymptoThermalStatus({ cycle, previousCycle, earlierCy
|
|||||||
if (previousCycle) {
|
if (previousCycle) {
|
||||||
const statusForLast = getSymptoThermalStatus({ cycle: previousCycle })
|
const statusForLast = getSymptoThermalStatus({ cycle: previousCycle })
|
||||||
if (statusForLast.temperatureShift) {
|
if (statusForLast.temperatureShift) {
|
||||||
status.phases.preOvulatory = getPreOvulatoryPhase(cycle, [previousCycle, ...earlierCycles])
|
const preOvuPhase = getPreOvulatoryPhase(
|
||||||
if (status.phases.preOvulatory.cycleDays.length === cycle.length) {
|
cycle,
|
||||||
return status
|
[previousCycle, ...earlierCycles]
|
||||||
|
)
|
||||||
|
if (preOvuPhase) {
|
||||||
|
status.phases.preOvulatory = preOvuPhase
|
||||||
|
if (status.phases.preOvulatory.cycleDays.length === cycle.length) {
|
||||||
|
return status
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ export default function(cycle, previousCycles) {
|
|||||||
return d.date <= preOvuEndDate
|
return d.date <= preOvuEndDate
|
||||||
})
|
})
|
||||||
const preOvulatoryDays = getDaysUntilFertileMucus(maybePreOvuDays)
|
const preOvulatoryDays = getDaysUntilFertileMucus(maybePreOvuDays)
|
||||||
|
// if mucus occurs on the 1st cycle day, there is no pre-ovu phase
|
||||||
|
if (!preOvulatoryDays.length) return null
|
||||||
|
|
||||||
let endDate
|
let endDate
|
||||||
if (preOvulatoryDays.length === maybePreOvuDays.length) {
|
if (preOvulatoryDays.length === maybePreOvuDays.length) {
|
||||||
endDate = preOvuEndDate
|
endDate = preOvuEndDate
|
||||||
|
|||||||
@@ -100,6 +100,29 @@ export const cycleWithEarlyMucus = [
|
|||||||
{ date: '2018-06-27', temperature: 36.9, mucus: 4 }
|
{ date: '2018-06-27', temperature: 36.9, mucus: 4 }
|
||||||
].map(convertToSymptoFormat)
|
].map(convertToSymptoFormat)
|
||||||
|
|
||||||
|
export const cycleWithMucusOnFirstDay = [
|
||||||
|
{ date: '2018-06-01', temperature: 36.6, bleeding: 2, mucus: 3},
|
||||||
|
{ date: '2018-06-02', temperature: 36.65, mucus: 3 },
|
||||||
|
{ date: '2018-06-05', temperature: 36.55 },
|
||||||
|
{ date: '2018-06-06', temperature: 36.7, mucus: 0 },
|
||||||
|
{ date: '2018-06-08', temperature: 36.45, mucus: 1 },
|
||||||
|
{ date: '2018-06-09', temperature: 36.5, mucus: 4 },
|
||||||
|
{ date: '2018-06-10', temperature: 36.4, mucus: 2 },
|
||||||
|
{ date: '2018-06-11', temperature: 36.5, mucus: 3 },
|
||||||
|
{ date: '2018-06-13', temperature: 36.45, mucus: 3 },
|
||||||
|
{ date: '2018-06-14', temperature: 36.5, mucus: 4 },
|
||||||
|
{ date: '2018-06-15', temperature: 36.55, mucus: 4 },
|
||||||
|
{ date: '2018-06-16', temperature: 36.7, mucus: 3 },
|
||||||
|
{ date: '2018-06-17', temperature: 36.65, mucus: 3 },
|
||||||
|
{ date: '2018-06-18', temperature: 36.75, mucus: 4 },
|
||||||
|
{ date: '2018-06-19', temperature: 36.8, mucus: 4 },
|
||||||
|
{ date: '2018-06-20', temperature: 36.85, mucus: 4 },
|
||||||
|
{ date: '2018-06-23', temperature: 36.9, mucus: 3 },
|
||||||
|
{ date: '2018-06-24', temperature: 36.85, mucus: 4 },
|
||||||
|
{ date: '2018-06-26', temperature: 36.8, mucus: 4 },
|
||||||
|
{ date: '2018-06-27', temperature: 36.9, mucus: 4 }
|
||||||
|
].map(convertToSymptoFormat)
|
||||||
|
|
||||||
export const cycleWithoutAnyShifts = [
|
export const cycleWithoutAnyShifts = [
|
||||||
{ date: '2018-06-01', temperature: 36.6, bleeding: 2 },
|
{ date: '2018-06-01', temperature: 36.6, bleeding: 2 },
|
||||||
{ date: '2018-06-02', temperature: 36.65 },
|
{ date: '2018-06-02', temperature: 36.65 },
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
cycleWithoutAnyShifts,
|
cycleWithoutAnyShifts,
|
||||||
fiveDayCycle,
|
fiveDayCycle,
|
||||||
cycleWithEarlyMucus,
|
cycleWithEarlyMucus,
|
||||||
|
cycleWithMucusOnFirstDay,
|
||||||
mucusPeakAndFhmOnSameDay,
|
mucusPeakAndFhmOnSameDay,
|
||||||
fhmTwoDaysBeforeMucusPeak,
|
fhmTwoDaysBeforeMucusPeak,
|
||||||
fhm5DaysAfterMucusPeak,
|
fhm5DaysAfterMucusPeak,
|
||||||
@@ -453,6 +454,23 @@ describe('sympto', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('shortens the pre-ovu phase if mucus occurs even on the first day', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: cycleWithMucusOnFirstDay,
|
||||||
|
previousCycle: fhmOnDay12,
|
||||||
|
earlierCycles: Array(10).fill(fhmOnDay12)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(1)
|
||||||
|
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-01' },
|
||||||
|
cycleDays: cycleWithMucusOnFirstDay
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
it('lengthens the pre-ovu phase if >= 12 cycles with fhm > 13', () => {
|
it('lengthens the pre-ovu phase if >= 12 cycles with fhm > 13', () => {
|
||||||
const status = getSensiplanStatus({
|
const status = getSensiplanStatus({
|
||||||
cycle: longAndComplicatedCycle,
|
cycle: longAndComplicatedCycle,
|
||||||
|
|||||||
Reference in New Issue
Block a user