Adding secondarySymptom
* so calculating preOvuPhase with cervix is possible
This commit is contained in:
+2
-1
@@ -23,7 +23,8 @@ export default function getSymptoThermalStatus(cycleInfo) {
|
|||||||
if (statusForLast.temperatureShift) {
|
if (statusForLast.temperatureShift) {
|
||||||
const preOvuPhase = getPreOvulatoryPhase(
|
const preOvuPhase = getPreOvulatoryPhase(
|
||||||
cycle,
|
cycle,
|
||||||
[previousCycle, ...earlierCycles]
|
[previousCycle, ...earlierCycles],
|
||||||
|
secondarySymptom
|
||||||
)
|
)
|
||||||
if (preOvuPhase) {
|
if (preOvuPhase) {
|
||||||
status.phases.preOvulatory = preOvuPhase
|
status.phases.preOvulatory = preOvuPhase
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { LocalDate } from 'js-joda'
|
import { LocalDate } from 'js-joda'
|
||||||
import getNfpStatus from './index'
|
import getNfpStatus from './index'
|
||||||
|
|
||||||
export default function (previousCycles) {
|
export default function (previousCycles, secondarySymptom) {
|
||||||
const fhms = previousCycles
|
const fhms = previousCycles
|
||||||
.map(cycle => {
|
.map(cycle => {
|
||||||
const status = getNfpStatus({ cycle })
|
const status = getNfpStatus({ cycle, secondarySymptom })
|
||||||
if (status.temperatureShift) {
|
if (status.temperatureShift) {
|
||||||
const day = status.temperatureShift.firstHighMeasurementDay
|
const day = status.temperatureShift.firstHighMeasurementDay
|
||||||
const firstCycleDayDate = LocalDate.parse(cycle[0].date)
|
const firstCycleDayDate = LocalDate.parse(cycle[0].date)
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { LocalDate } from "js-joda"
|
import { LocalDate } from "js-joda"
|
||||||
import apply8DayRule from './minus-8-day-rule'
|
import apply8DayRule from './minus-8-day-rule'
|
||||||
|
|
||||||
export default function(cycle, previousCycles) {
|
export default function(cycle, previousCycles, secondarySymptom) {
|
||||||
let preOvuPhaseLength = 5
|
let preOvuPhaseLength = 5
|
||||||
|
|
||||||
const minus8DayRuleResult = apply8DayRule(previousCycles)
|
const minus8DayRuleResult = apply8DayRule(previousCycles, secondarySymptom)
|
||||||
if (minus8DayRuleResult) preOvuPhaseLength = minus8DayRuleResult
|
if (minus8DayRuleResult) preOvuPhaseLength = minus8DayRuleResult
|
||||||
|
|
||||||
const startDate = LocalDate.parse(cycle[0].date)
|
const startDate = LocalDate.parse(cycle[0].date)
|
||||||
@@ -12,7 +12,7 @@ export default function(cycle, previousCycles) {
|
|||||||
const maybePreOvuDays = cycle.slice(0, preOvuPhaseLength).filter(d => {
|
const maybePreOvuDays = cycle.slice(0, preOvuPhaseLength).filter(d => {
|
||||||
return d.date <= preOvuEndDate
|
return d.date <= preOvuEndDate
|
||||||
})
|
})
|
||||||
const preOvulatoryDays = getDaysUntilFertileSecondarySymptom(maybePreOvuDays)
|
const preOvulatoryDays = getDaysUntilFertileSecondarySymptom(maybePreOvuDays, secondarySymptom)
|
||||||
// if fertile mucus or cervix occurs on the 1st cycle day, there is no pre-ovu phase
|
// if fertile mucus or cervix occurs on the 1st cycle day, there is no pre-ovu phase
|
||||||
if (!preOvulatoryDays.length) return null
|
if (!preOvulatoryDays.length) return null
|
||||||
|
|
||||||
@@ -39,7 +39,8 @@ function getDaysUntilFertileSecondarySymptom(days, secondarySymptom = 'mucus') {
|
|||||||
if (secondarySymptom === 'mucus') {
|
if (secondarySymptom === 'mucus') {
|
||||||
return day.mucus && day.mucus.value > 1
|
return day.mucus && day.mucus.value > 1
|
||||||
} else if (secondarySymptom === 'cervix') {
|
} else if (secondarySymptom === 'cervix') {
|
||||||
return day.cervix && !day.cervix.isClosedAndHard
|
return day.cervix && day.cervix.opening > 0
|
||||||
|
|| day.cervix && day.cervix.firmness > 0
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user