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) {
|
||||
const statusForLast = getSymptoThermalStatus({ cycle: previousCycle })
|
||||
if (statusForLast.temperatureShift) {
|
||||
status.phases.preOvulatory = getPreOvulatoryPhase(cycle, [previousCycle, ...earlierCycles])
|
||||
if (status.phases.preOvulatory.cycleDays.length === cycle.length) {
|
||||
return status
|
||||
const preOvuPhase = getPreOvulatoryPhase(
|
||||
cycle,
|
||||
[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
|
||||
})
|
||||
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
|
||||
if (preOvulatoryDays.length === maybePreOvuDays.length) {
|
||||
endDate = preOvuEndDate
|
||||
|
||||
@@ -100,6 +100,29 @@ export const cycleWithEarlyMucus = [
|
||||
{ date: '2018-06-27', temperature: 36.9, mucus: 4 }
|
||||
].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 = [
|
||||
{ date: '2018-06-01', temperature: 36.6, bleeding: 2 },
|
||||
{ date: '2018-06-02', temperature: 36.65 },
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
cycleWithoutAnyShifts,
|
||||
fiveDayCycle,
|
||||
cycleWithEarlyMucus,
|
||||
cycleWithMucusOnFirstDay,
|
||||
mucusPeakAndFhmOnSameDay,
|
||||
fhmTwoDaysBeforeMucusPeak,
|
||||
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', () => {
|
||||
const status = getSensiplanStatus({
|
||||
cycle: longAndComplicatedCycle,
|
||||
|
||||
Reference in New Issue
Block a user