Improving cervix:

* adding tempEvalEnd value to cervix tests
* more comments in code for cervix sympto
* better description in cervix temp tests
* take out cervix.value
This commit is contained in:
emelko
2018-09-13 09:54:13 +02:00
parent 3f5c86086d
commit 76056e1db0
5 changed files with 141 additions and 56 deletions
+18 -7
View File
@@ -1,15 +1,26 @@
export default function (cycleDays, tempEvalEndIndex) {
const cervixDays = cycleDays.filter(day => day.cervix && !day.cervix.exclude)
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
// * be followed by at least 3 days
// these 3 following days must all show infertile cervix values
// if everything applies we must check the days until the end of temperature evaluation
// during these relevantDays no fertile cervix must occur
for (let i = 0; i < cervixDays.length; i++) {
const day = cervixDays[i]
if (isClosedAndHard(day.cervix)) continue
// the three following days must be with closed and hard cervix
// AND no other cervix value may occur until temperature evaluation has
// been completed
// the three following days must be with closed and hard cervix (indicating an infertile cervix)
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)
})
@@ -33,9 +44,9 @@ export default function (cycleDays, tempEvalEndIndex) {
}
}
return { detected: false }
return notDetected
}
function isClosedAndHard (cervix) {
return cervix.value.opening === 0 && cervix.value.firmness === 0
function isClosedAndHard (cervixDay) {
return cervixDay.opening === 0 && cervixDay.firmness === 0
}