Ignore secondary symptom peak after end of temperature evaluation

This commit is contained in:
Julia Friesel
2018-09-28 08:45:52 +02:00
parent 9029be081f
commit fa3a6fb2e7
7 changed files with 145 additions and 49 deletions
+7 -3
View File
@@ -2,7 +2,6 @@ export default function (cycleDays, tempEvalEndIndex) {
const notDetected = { detected: false }
const cervixDays = cycleDays
.filter(day => day.cervix && !day.cervix.exclude)
.filter(day => typeof day.cervix.opening === 'number' && typeof day.cervix.firmness === 'number')
// we search for the day of cervix peak, which must:
// * have fertile cervix values
@@ -19,14 +18,19 @@ export default function (cycleDays, tempEvalEndIndex) {
const threeFollowingDays = cervixDays.slice(i + 1, i + 4)
if (threeFollowingDays.length < 3) continue
// no other fertile cervix value may occur until temperature evaluation has
// been completed
const fertileCervixOccursIn3FollowingDays = threeFollowingDays.some(day => {
return !isClosedAndHard(day.cervix)
})
if (fertileCervixOccursIn3FollowingDays) continue
const cycleDayIndex = cycleDays.indexOf(day)
// if temperature evaluation has been completed an we still haven't found
// a candidate, there is no cervix shift
if (cycleDayIndex > tempEvalEndIndex) return notDetected
// no other fertile cervix value may occur until temperature evaluation has
// been completed
const relevantDays = cycleDays
.slice(cycleDayIndex + 1, tempEvalEndIndex + 1)
.filter(day => day.cervix && !day.cervix.exclude)
+7 -2
View File
@@ -16,8 +16,6 @@ export default function (cycleDays, tempEvalEndIndex) {
if (day.mucus.value !== currentBestQuality) continue
// the three following days must be of lower quality
// AND no best quality day may occur until temperature evaluation has
// been completed
const threeFollowingDays = mucusDays.slice(i + 1, i + 4)
if (threeFollowingDays.length < 3) continue
@@ -27,6 +25,13 @@ export default function (cycleDays, tempEvalEndIndex) {
if (bestQualityOccursIn3FollowingDays) continue
const cycleDayIndex = cycleDays.indexOf(day)
// if temperature evaluation has been completed an we still haven't found
// a candidate, there is no cervix shift
if (cycleDayIndex > tempEvalEndIndex) return notDetected
// no best quality day may occur until temperature evaluation has
// been completed
const relevantDays = cycleDays
.slice(cycleDayIndex + 1, tempEvalEndIndex + 1)
.filter(day => day.mucus && !day.mucus.exclude)