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:
+18
-7
@@ -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
|
||||
}
|
||||
|
||||
+4
-4
@@ -115,10 +115,10 @@ function throwIfArgsAreNotInRequiredFormat(cycles) {
|
||||
if (day.mucus) assert.equal(typeof day.mucus.value, 'number', "Mucus value must be a number.")
|
||||
if (day.mucus) assert.ok(day.mucus.value >= 0, "Mucus value must greater or equal to 0.")
|
||||
if (day.mucus) assert.ok(day.mucus.value <= 4, "Mucus value must be below 5.")
|
||||
if (day.cervix) assert.ok(day.cervix.value.opening >= 0, "Cervix opening value must be 0 or bigger")
|
||||
if (day.cervix) assert.ok(day.cervix.value.opening <= 2, "Cervix opening value must be 2 or smaller")
|
||||
if (day.cervix) assert.ok(day.cervix.value.firmness >= 0, "Cervix firmness value must be 0 or bigger")
|
||||
if (day.cervix) assert.ok(day.cervix.value.firmness <= 1, "Cervix firmness value must be 1 or smaller")
|
||||
if (day.cervix) assert.ok(day.cervix.opening >= 0, "Cervix opening value must be 0 or bigger")
|
||||
if (day.cervix) assert.ok(day.cervix.opening <= 2, "Cervix opening value must be 2 or smaller")
|
||||
if (day.cervix) assert.ok(day.cervix.firmness >= 0, "Cervix firmness value must be 0 or bigger")
|
||||
if (day.cervix) assert.ok(day.cervix.firmness <= 1, "Cervix firmness value must be 1 or smaller")
|
||||
assert.equal(typeof cycle[0].bleeding.value, 'number', "Bleeding value must be a number")
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user