Merge branch 'master' into '150-apply-design-to-chart'
# Conflicts: # components/calendar.js # components/chart/y-axis.js
@@ -54,3 +54,10 @@ buck-out/
|
|||||||
|
|
||||||
# Bundle artifact
|
# Bundle artifact
|
||||||
*.jsbundle
|
*.jsbundle
|
||||||
|
|
||||||
|
# RN android release
|
||||||
|
android/app/bin/
|
||||||
|
android/app/release/
|
||||||
|
android/app/src/main/assets/index.android.bundle
|
||||||
|
android/.project
|
||||||
|
android/app/.project
|
||||||
|
|||||||
@@ -25,3 +25,6 @@ You can run the tests with `npm test`.
|
|||||||
## Debugging
|
## Debugging
|
||||||
When running into an old version of the app try to run the following command first:
|
When running into an old version of the app try to run the following command first:
|
||||||
`react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res`
|
`react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res`
|
||||||
|
|
||||||
|
## NFP rules
|
||||||
|
More information about how the app calculates fertility status and bleeding predictions in the [wiki on Gitlab](https://gitlab.com/bloodyhealth/drip/wikis/home)
|
||||||
|
|||||||
@@ -108,6 +108,16 @@ android {
|
|||||||
abiFilters "armeabi-v7a", "x86"
|
abiFilters "armeabi-v7a", "x86"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
signingConfigs {
|
||||||
|
release {
|
||||||
|
if (project.hasProperty('DRIP_RELEASE_STORE_FILE')) {
|
||||||
|
storeFile file(DRIP_RELEASE_STORE_FILE)
|
||||||
|
storePassword DRIP_RELEASE_STORE_PASSWORD
|
||||||
|
keyAlias DRIP_RELEASE_KEY_ALIAS
|
||||||
|
keyPassword DRIP_RELEASE_KEY_PASSWORD
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
splits {
|
splits {
|
||||||
abi {
|
abi {
|
||||||
reset()
|
reset()
|
||||||
@@ -120,6 +130,7 @@ android {
|
|||||||
release {
|
release {
|
||||||
minifyEnabled enableProguardInReleaseBuilds
|
minifyEnabled enableProguardInReleaseBuilds
|
||||||
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
|
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
|
||||||
|
signingConfig signingConfigs.release
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// applicationVariants are e.g. debug, release
|
// applicationVariants are e.g. debug, release
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 430 B |
|
Before Width: | Height: | Size: 216 B |
|
Before Width: | Height: | Size: 214 B |
|
Before Width: | Height: | Size: 134 B |
|
Before Width: | Height: | Size: 327 B |
|
Before Width: | Height: | Size: 100 B |
|
Before Width: | Height: | Size: 659 B |
|
Before Width: | Height: | Size: 642 B |
|
Before Width: | Height: | Size: 232 B |
|
Before Width: | Height: | Size: 239 B |
|
Before Width: | Height: | Size: 134 B |
|
Before Width: | Height: | Size: 879 B |
|
Before Width: | Height: | Size: 328 B |
|
Before Width: | Height: | Size: 332 B |
|
Before Width: | Height: | Size: 167 B |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 388 B |
|
Before Width: | Height: | Size: 394 B |
|
Before Width: | Height: | Size: 207 B |
@@ -18,3 +18,4 @@
|
|||||||
# org.gradle.parallel=true
|
# org.gradle.parallel=true
|
||||||
|
|
||||||
android.useDeprecatedNdk=true
|
android.useDeprecatedNdk=true
|
||||||
|
android.enableAapt2=false
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import React, { Component } from 'react'
|
||||||
|
import { Text } from 'react-native'
|
||||||
|
import styles from "../styles"
|
||||||
|
|
||||||
|
export class AppText extends Component {
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<Text style={[styles.appText, this.props.style]}>
|
||||||
|
{this.props.children}
|
||||||
|
</Text>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class SymptomSectionHeader extends Component {
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<AppText style={styles.symptomViewHeading}>
|
||||||
|
{this.props.children}
|
||||||
|
</AppText>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import { View, FlatList, Text } from 'react-native'
|
import { View, FlatList } from 'react-native'
|
||||||
import range from 'date-range'
|
import range from 'date-range'
|
||||||
import { LocalDate } from 'js-joda'
|
import { LocalDate } from 'js-joda'
|
||||||
import { makeYAxisLabels, normalizeToScale, makeHorizontalGrid } from './y-axis'
|
import { makeYAxisLabels, normalizeToScale, makeHorizontalGrid } from './y-axis'
|
||||||
@@ -9,6 +9,7 @@ import { getCycleDay, cycleDaysSortedByDate, getAmountOfCycleDays } from '../../
|
|||||||
import styles from './styles'
|
import styles from './styles'
|
||||||
import { scaleObservable } from '../../local-storage'
|
import { scaleObservable } from '../../local-storage'
|
||||||
import config from '../../config'
|
import config from '../../config'
|
||||||
|
import { AppText } from '../app-text'
|
||||||
|
|
||||||
export default class CycleChart extends Component {
|
export default class CycleChart extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -126,7 +127,7 @@ export default class CycleChart extends Component {
|
|||||||
>
|
>
|
||||||
{!this.state.chartLoaded &&
|
{!this.state.chartLoaded &&
|
||||||
<View style={{width: '100%', justifyContent: 'center', alignItems: 'center'}}>
|
<View style={{width: '100%', justifyContent: 'center', alignItems: 'center'}}>
|
||||||
<Text>Loading...</Text>
|
<AppText>Loading...</AppText>
|
||||||
</View>
|
</View>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -182,4 +182,4 @@ export default class DayColumn extends Component {
|
|||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Text, View } from 'react-native'
|
import { View } from 'react-native'
|
||||||
import config from '../../config'
|
import config from '../../config'
|
||||||
import styles from './styles'
|
import styles from './styles'
|
||||||
import { scaleObservable, unitObservable } from '../../local-storage'
|
import { scaleObservable, unitObservable } from '../../local-storage'
|
||||||
|
import { AppText } from '../app-text'
|
||||||
|
|
||||||
export function makeYAxisLabels(columnHeight) {
|
export function makeYAxisLabels(columnHeight) {
|
||||||
const units = unitObservable.value
|
const units = unitObservable.value
|
||||||
@@ -25,11 +26,11 @@ export function makeYAxisLabels(columnHeight) {
|
|||||||
// support percentage values for transforms, which we'd need
|
// support percentage values for transforms, which we'd need
|
||||||
// to reliably place the label vertically centered to the grid
|
// to reliably place the label vertically centered to the grid
|
||||||
return (
|
return (
|
||||||
<Text
|
<AppText
|
||||||
style={[style, {top: y - 8}, tickBold]}
|
style={[style, {top: y - 8}, tickBold]}
|
||||||
key={i}>
|
key={i}>
|
||||||
{showTick && tickLabel}
|
{showTick && tickLabel}
|
||||||
</Text>
|
</AppText>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import React, { Component } from 'react'
|
|||||||
import {
|
import {
|
||||||
ScrollView,
|
ScrollView,
|
||||||
View,
|
View,
|
||||||
Text,
|
|
||||||
TouchableOpacity,
|
TouchableOpacity,
|
||||||
Dimensions
|
Dimensions
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
@@ -12,18 +11,18 @@ import { getOrCreateCycleDay } from '../../db'
|
|||||||
import cycleModule from '../../lib/cycle'
|
import cycleModule from '../../lib/cycle'
|
||||||
import Icon from 'react-native-vector-icons/FontAwesome'
|
import Icon from 'react-native-vector-icons/FontAwesome'
|
||||||
import styles, { iconStyles } from '../../styles'
|
import styles, { iconStyles } from '../../styles'
|
||||||
import {
|
import * as labels from './labels/labels'
|
||||||
bleeding as bleedingLabels,
|
import { AppText } from '../app-text'
|
||||||
mucusFeeling as feelingLabels,
|
|
||||||
mucusTexture as textureLabels,
|
const bleedingLabels = labels.bleeding
|
||||||
mucusNFP as computeSensiplanMucusLabels,
|
const feelingLabels = labels.mucus.feeling.categories
|
||||||
cervixOpening as openingLabels,
|
const textureLabels = labels.mucus.texture.categories
|
||||||
cervixFirmness as firmnessLabels,
|
const openingLabels = labels.cervix.opening.categories
|
||||||
cervixPosition as positionLabels,
|
const firmnessLabels = labels.cervix.firmness.categories
|
||||||
intensity as intensityLabels,
|
const positionLabels = labels.cervix.position.categories
|
||||||
pain as painLabels,
|
const intensityLabels = labels.intensity
|
||||||
sex as sexLabels
|
const sexLabels = labels.sex
|
||||||
} from './labels/labels'
|
const painLabels = labels.pain.categories
|
||||||
|
|
||||||
export default class CycleDayOverView extends Component {
|
export default class CycleDayOverView extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -51,7 +50,9 @@ export default class CycleDayOverView extends Component {
|
|||||||
const cycleDay = this.state.cycleDay
|
const cycleDay = this.state.cycleDay
|
||||||
const getCycleDayNumber = cycleModule().getCycleDayNumber
|
const getCycleDayNumber = cycleModule().getCycleDayNumber
|
||||||
const cycleDayNumber = getCycleDayNumber(cycleDay.date)
|
const cycleDayNumber = getCycleDayNumber(cycleDay.date)
|
||||||
const dateInFuture = LocalDate.now().isBefore(LocalDate.parse(this.state.cycleDay.date))
|
const dateInFuture = LocalDate
|
||||||
|
.now()
|
||||||
|
.isBefore(LocalDate.parse(this.state.cycleDay.date))
|
||||||
return (
|
return (
|
||||||
<View style={{ flex: 1 }}>
|
<View style={{ flex: 1 }}>
|
||||||
<Header
|
<Header
|
||||||
@@ -98,16 +99,16 @@ export default class CycleDayOverView extends Component {
|
|||||||
data={getLabel('sex', cycleDay.sex)}
|
data={getLabel('sex', cycleDay.sex)}
|
||||||
disabled={dateInFuture}
|
disabled={dateInFuture}
|
||||||
/>
|
/>
|
||||||
<SymptomBox
|
|
||||||
title='Note'
|
|
||||||
onPress={() => this.navigate('NoteEditView')}
|
|
||||||
data={getLabel('note', cycleDay.note)}
|
|
||||||
/>
|
|
||||||
<SymptomBox
|
<SymptomBox
|
||||||
title='Pain'
|
title='Pain'
|
||||||
onPress={() => this.navigate('PainEditView')}
|
onPress={() => this.navigate('PainEditView')}
|
||||||
data={getLabel('pain', cycleDay.pain)}
|
data={getLabel('pain', cycleDay.pain)}
|
||||||
/>
|
/>
|
||||||
|
<SymptomBox
|
||||||
|
title='Note'
|
||||||
|
onPress={() => this.navigate('NoteEditView')}
|
||||||
|
data={getLabel('note', cycleDay.note)}
|
||||||
|
/>
|
||||||
{/* this is just to make the last row adhere to the grid
|
{/* this is just to make the last row adhere to the grid
|
||||||
(and) because there are no pseudo properties in RN */}
|
(and) because there are no pseudo properties in RN */}
|
||||||
<FillerBoxes />
|
<FillerBoxes />
|
||||||
@@ -119,7 +120,7 @@ export default class CycleDayOverView extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getLabel(symptomName, symptom) {
|
function getLabel(symptomName, symptom) {
|
||||||
const labels = {
|
const l = {
|
||||||
bleeding: bleeding => {
|
bleeding: bleeding => {
|
||||||
if (typeof bleeding.value === 'number') {
|
if (typeof bleeding.value === 'number') {
|
||||||
let bleedingLabel = `${bleedingLabels[bleeding.value]}`
|
let bleedingLabel = `${bleedingLabels[bleeding.value]}`
|
||||||
@@ -140,7 +141,7 @@ function getLabel(symptomName, symptom) {
|
|||||||
const categories = ['feeling', 'texture', 'value']
|
const categories = ['feeling', 'texture', 'value']
|
||||||
if (categories.every(c => typeof mucus[c] === 'number')) {
|
if (categories.every(c => typeof mucus[c] === 'number')) {
|
||||||
let mucusLabel = [feelingLabels[mucus.feeling], textureLabels[mucus.texture]].join(', ')
|
let mucusLabel = [feelingLabels[mucus.feeling], textureLabels[mucus.texture]].join(', ')
|
||||||
mucusLabel += `\n${computeSensiplanMucusLabels[mucus.value]}`
|
mucusLabel += `\n${labels.mucusNFP[mucus.value]}`
|
||||||
if (mucus.exclude) mucusLabel = `(${mucusLabel})`
|
if (mucus.exclude) mucusLabel = `(${mucusLabel})`
|
||||||
return mucusLabel
|
return mucusLabel
|
||||||
}
|
}
|
||||||
@@ -210,7 +211,7 @@ function getLabel(symptomName, symptom) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!symptom) return
|
if (!symptom) return
|
||||||
const label = labels[symptomName](symptom)
|
const label = l[symptomName](symptom)
|
||||||
if (label.length < 45) return label
|
if (label.length < 45) return label
|
||||||
return label.slice(0, 42) + '...'
|
return label.slice(0, 42) + '...'
|
||||||
}
|
}
|
||||||
@@ -221,21 +222,28 @@ class SymptomBox extends Component {
|
|||||||
const d = this.props.data
|
const d = this.props.data
|
||||||
const boxActive = d ? styles.symptomBoxActive : {}
|
const boxActive = d ? styles.symptomBoxActive : {}
|
||||||
const iconActive = d ? iconStyles.symptomBoxActive : {}
|
const iconActive = d ? iconStyles.symptomBoxActive : {}
|
||||||
const iconStyle = Object.assign({}, iconStyles.symptomBox, iconActive, disabledStyle)
|
const iconStyle = Object.assign(
|
||||||
|
{}, iconStyles.symptomBox, iconActive, disabledStyle
|
||||||
|
)
|
||||||
const textActive = d ? styles.symptomTextActive : {}
|
const textActive = d ? styles.symptomTextActive : {}
|
||||||
const disabledStyle = this.props.disabled ? styles.symptomInFuture : {}
|
const disabledStyle = this.props.disabled ? styles.symptomInFuture : {}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity onPress={this.props.onPress} disabled={this.props.disabled}>
|
<TouchableOpacity
|
||||||
|
onPress={this.props.onPress}
|
||||||
|
disabled={this.props.disabled}
|
||||||
|
>
|
||||||
<View style={[styles.symptomBox, boxActive, disabledStyle]}>
|
<View style={[styles.symptomBox, boxActive, disabledStyle]}>
|
||||||
<Icon
|
<Icon
|
||||||
name='thermometer'
|
name='thermometer'
|
||||||
{...iconStyle}
|
{...iconStyle}
|
||||||
/>
|
/>
|
||||||
<Text style={[textActive, disabledStyle]}>{this.props.title}</Text>
|
<AppText style={[textActive, disabledStyle]}>
|
||||||
|
{this.props.title}
|
||||||
|
</AppText>
|
||||||
</View>
|
</View>
|
||||||
<View style={[styles.symptomDataBox, disabledStyle]}>
|
<View style={[styles.symptomDataBox, disabledStyle]}>
|
||||||
<Text style={styles.symptomDataText}>{this.props.data}</Text>
|
<AppText style={styles.symptomDataText}>{this.props.data}</AppText>
|
||||||
</View>
|
</View>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,11 +1,39 @@
|
|||||||
export const bleeding = ['spotting', 'light', 'medium', 'heavy']
|
export const bleeding = ['spotting', 'light', 'medium', 'heavy']
|
||||||
export const mucusFeeling = ['dry', 'nothing', 'wet', 'slippery']
|
|
||||||
export const mucusTexture = ['nothing', 'creamy', 'egg white']
|
|
||||||
export const mucusNFP = ['t', 'Ø', 'f', 'S', 'S+']
|
export const mucusNFP = ['t', 'Ø', 'f', 'S', 'S+']
|
||||||
export const cervixOpening = ['closed', 'medium', 'open']
|
|
||||||
export const cervixFirmness = ['hard', 'soft']
|
|
||||||
export const cervixPosition = ['low', 'medium', 'high']
|
|
||||||
export const intensity = ['low', 'medium', 'high']
|
export const intensity = ['low', 'medium', 'high']
|
||||||
|
|
||||||
|
export const cervix = {
|
||||||
|
opening: {
|
||||||
|
categories: ['closed', 'medium', 'open'],
|
||||||
|
explainer: 'Is your cervix open or closed?'
|
||||||
|
},
|
||||||
|
firmness: {
|
||||||
|
categories: ['hard', 'soft'],
|
||||||
|
explainer: "When it's hard it might feel like the tip of your nose"
|
||||||
|
},
|
||||||
|
position: {
|
||||||
|
categories: ['low', 'medium', 'high'],
|
||||||
|
explainer: 'How high up in the vagina is the cervix?'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const mucus = {
|
||||||
|
feeling: {
|
||||||
|
categories: ['dry', 'nothing', 'wet', 'slippery'],
|
||||||
|
explainer: 'What does your vaginal entrance feel like?'
|
||||||
|
},
|
||||||
|
texture: {
|
||||||
|
categories: ['nothing', 'creamy', 'egg white'],
|
||||||
|
explainer: "Looking at and touching your cervical mucus, which describes it best?"
|
||||||
|
},
|
||||||
|
excludeExplainer: "You can exclude this value if you don't want to use it for fertility detection"
|
||||||
|
}
|
||||||
|
|
||||||
|
export const desire = {
|
||||||
|
header: 'Intensity',
|
||||||
|
explainer: 'How would you rate your sexual desire?'
|
||||||
|
}
|
||||||
|
|
||||||
export const sex = {
|
export const sex = {
|
||||||
solo: 'Solo',
|
solo: 'Solo',
|
||||||
partner: 'Partner',
|
partner: 'Partner',
|
||||||
@@ -15,19 +43,24 @@ export const sex = {
|
|||||||
patch: 'Patch',
|
patch: 'Patch',
|
||||||
ring: 'Ring',
|
ring: 'Ring',
|
||||||
implant: 'Implant',
|
implant: 'Implant',
|
||||||
other: 'Other'
|
other: 'Other',
|
||||||
|
activityExplainer: 'Were you sexually active today?',
|
||||||
|
contraceptiveExplainer: 'Did you use contraceptives?'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const pain = {
|
export const pain = {
|
||||||
cramps: 'Cramps',
|
categories: {
|
||||||
ovulationPain: 'Ovulation pain',
|
cramps: 'Cramps',
|
||||||
headache: 'Headache',
|
ovulationPain: 'Ovulation pain',
|
||||||
backache: 'Backache',
|
headache: 'Headache',
|
||||||
nausea: 'Nausea',
|
backache: 'Backache',
|
||||||
tenderBreasts: 'Tender breasts',
|
nausea: 'Nausea',
|
||||||
migraine: 'Migraine',
|
tenderBreasts: 'Tender breasts',
|
||||||
other: 'Other',
|
migraine: 'Migraine',
|
||||||
note: 'Note'
|
other: 'Other',
|
||||||
|
note: 'Note',
|
||||||
|
},
|
||||||
|
explainer: 'How did your body feel today?'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fertilityStatus = {
|
export const fertilityStatus = {
|
||||||
@@ -40,5 +73,14 @@ export const fertilityStatus = {
|
|||||||
export const temperature = {
|
export const temperature = {
|
||||||
outOfRangeWarning: 'This temperature value is out of the current range for the temperature chart. You can change the range in the settings.',
|
outOfRangeWarning: 'This temperature value is out of the current range for the temperature chart. You can change the range in the settings.',
|
||||||
outOfAbsoluteRangeWarning: 'This temperature value is too high or low to be shown on the temperature chart.',
|
outOfAbsoluteRangeWarning: 'This temperature value is too high or low to be shown on the temperature chart.',
|
||||||
saveAnyway: 'Save anyway'
|
saveAnyway: 'Save anyway',
|
||||||
|
temperature: {
|
||||||
|
explainer: 'Take your temperature right after waking up, before getting out of bed'
|
||||||
|
},
|
||||||
|
note: {
|
||||||
|
explainer: 'Is there anything that could have influenced this value, such as bad sleep or alcohol consumption?'
|
||||||
|
},
|
||||||
|
excludeExplainer: "You can exclude this value if you don't want to use it for fertility detection"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const noteExplainer = "Anything you want to add for the day?"
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import React, { Component } from 'react'
|
||||||
|
import {
|
||||||
|
View,
|
||||||
|
TouchableOpacity,
|
||||||
|
} from 'react-native'
|
||||||
|
import styles from '../../styles'
|
||||||
|
import { AppText } from '../app-text'
|
||||||
|
|
||||||
|
export default class SelectBoxGroup extends Component {
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<View style={styles.selectBoxSection}>
|
||||||
|
{this.props.data.map(({ label, stateKey }) => {
|
||||||
|
const style = [styles.selectBox]
|
||||||
|
const textStyle = []
|
||||||
|
if (this.props.optionsState[stateKey]) {
|
||||||
|
style.push(styles.selectBoxActive)
|
||||||
|
textStyle.push(styles.selectBoxTextActive)
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<TouchableOpacity
|
||||||
|
onPress={() => this.props.onSelect(stateKey)}
|
||||||
|
key={stateKey}
|
||||||
|
>
|
||||||
|
<View style={style}>
|
||||||
|
<AppText style={textStyle}>{label}</AppText>
|
||||||
|
</View>
|
||||||
|
</TouchableOpacity>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import React, { Component } from 'react'
|
||||||
|
import {
|
||||||
|
View,
|
||||||
|
TouchableOpacity,
|
||||||
|
} from 'react-native'
|
||||||
|
import styles from '../../styles'
|
||||||
|
import { AppText } from '../app-text'
|
||||||
|
|
||||||
|
export default class SelectTabGroup extends Component {
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<View style={styles.selectTabGroup}>
|
||||||
|
{
|
||||||
|
this.props.buttons.map(({ label, value }, i) => {
|
||||||
|
let firstOrLastStyle
|
||||||
|
if (i === this.props.buttons.length - 1) {
|
||||||
|
firstOrLastStyle = styles.selectTabLast
|
||||||
|
} else if (i === 0) {
|
||||||
|
firstOrLastStyle = styles.selectTabFirst
|
||||||
|
}
|
||||||
|
let activeStyle
|
||||||
|
const isActive = value === this.props.active
|
||||||
|
if (isActive) activeStyle = styles.selectTabActive
|
||||||
|
return (
|
||||||
|
<TouchableOpacity
|
||||||
|
onPress={() => this.props.onSelect(value)}
|
||||||
|
key={i}
|
||||||
|
activeOpacity={1}
|
||||||
|
>
|
||||||
|
<View style={styles.radioButtonTextGroup}>
|
||||||
|
<View style={[
|
||||||
|
styles.selectTab,
|
||||||
|
firstOrLastStyle,
|
||||||
|
activeStyle
|
||||||
|
]}>
|
||||||
|
<AppText style={activeStyle}>{label}</AppText>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</TouchableOpacity>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import {
|
import {
|
||||||
View,
|
View,
|
||||||
Text,
|
|
||||||
Switch,
|
Switch,
|
||||||
ScrollView
|
ScrollView
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import RadioForm from 'react-native-simple-radio-button'
|
|
||||||
import styles from '../../../styles'
|
import styles from '../../../styles'
|
||||||
import { saveSymptom } from '../../../db'
|
import { saveSymptom } from '../../../db'
|
||||||
import { bleeding as labels } from '../labels/labels'
|
import { bleeding as labels } from '../labels/labels'
|
||||||
import ActionButtonFooter from './action-button-footer'
|
import ActionButtonFooter from './action-button-footer'
|
||||||
|
import SelectTabGroup from '../select-tab-group'
|
||||||
|
import SymptomSection from './symptom-section'
|
||||||
|
|
||||||
export default class Bleeding extends Component {
|
export default class Bleeding extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -35,30 +35,29 @@ export default class Bleeding extends Component {
|
|||||||
]
|
]
|
||||||
return (
|
return (
|
||||||
<View style={{ flex: 1 }}>
|
<View style={{ flex: 1 }}>
|
||||||
<ScrollView>
|
<ScrollView style={styles.page}>
|
||||||
<View>
|
<SymptomSection
|
||||||
<View style={styles.radioButtonRow}>
|
header="Heaviness"
|
||||||
<RadioForm
|
explainer="How heavy is the bleeding?"
|
||||||
radio_props={bleedingRadioProps}
|
>
|
||||||
initial={this.state.currentValue}
|
<SelectTabGroup
|
||||||
formHorizontal={true}
|
buttons={bleedingRadioProps}
|
||||||
labelHorizontal={false}
|
active={this.state.currentValue}
|
||||||
labelStyle={styles.radioButton}
|
onSelect={val => this.setState({ currentValue: val })}
|
||||||
onPress={(itemValue) => {
|
/>
|
||||||
this.setState({ currentValue: itemValue })
|
</SymptomSection>
|
||||||
}}
|
<SymptomSection
|
||||||
/>
|
header="Exclude"
|
||||||
</View>
|
explainer="You can exclude this value if it's not menstrual bleeding"
|
||||||
<View style={styles.symptomViewRowInline}>
|
inline={true}
|
||||||
<Text style={styles.symptomDayView}>Exclude</Text>
|
>
|
||||||
<Switch
|
<Switch
|
||||||
onValueChange={(val) => {
|
onValueChange={(val) => {
|
||||||
this.setState({ exclude: val })
|
this.setState({ exclude: val })
|
||||||
}}
|
}}
|
||||||
value={this.state.exclude}
|
value={this.state.exclude}
|
||||||
/>
|
/>
|
||||||
</View>
|
</SymptomSection>
|
||||||
</View>
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<ActionButtonFooter
|
<ActionButtonFooter
|
||||||
symptom='bleeding'
|
symptom='bleeding'
|
||||||
|
|||||||
@@ -1,19 +1,15 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import {
|
import {
|
||||||
View,
|
View,
|
||||||
Text,
|
|
||||||
Switch,
|
Switch,
|
||||||
ScrollView
|
ScrollView
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import RadioForm from 'react-native-simple-radio-button'
|
|
||||||
import styles from '../../../styles'
|
import styles from '../../../styles'
|
||||||
import { saveSymptom } from '../../../db'
|
import { saveSymptom } from '../../../db'
|
||||||
import {
|
import { cervix as labels } from '../labels/labels'
|
||||||
cervixOpening as openingLabels,
|
|
||||||
cervixFirmness as firmnessLabels,
|
|
||||||
cervixPosition as positionLabels
|
|
||||||
} from '../labels/labels'
|
|
||||||
import ActionButtonFooter from './action-button-footer'
|
import ActionButtonFooter from './action-button-footer'
|
||||||
|
import SelectTabGroup from '../select-tab-group'
|
||||||
|
import SymptomSection from './symptom-section'
|
||||||
|
|
||||||
export default class Cervix extends Component {
|
export default class Cervix extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -36,72 +32,64 @@ export default class Cervix extends Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const cervixOpeningRadioProps = [
|
const cervixOpeningRadioProps = [
|
||||||
{label: openingLabels[0], value: 0},
|
{ label: labels.opening.categories[0], value: 0 },
|
||||||
{label: openingLabels[1], value: 1},
|
{ label: labels.opening.categories[1], value: 1 },
|
||||||
{label: openingLabels[2], value: 2}
|
{ label: labels.opening.categories[2], value: 2 }
|
||||||
]
|
]
|
||||||
const cervixFirmnessRadioProps = [
|
const cervixFirmnessRadioProps = [
|
||||||
{label: firmnessLabels[0], value: 0 },
|
{ label: labels.firmness.categories[0], value: 0 },
|
||||||
{label: firmnessLabels[1], value: 1 }
|
{ label: labels.firmness.categories[1], value: 1 }
|
||||||
]
|
]
|
||||||
const cervixPositionRadioProps = [
|
const cervixPositionRadioProps = [
|
||||||
{label: positionLabels[0], value: 0 },
|
{ label: labels.position.categories[0], value: 0 },
|
||||||
{label: positionLabels[1], value: 1 },
|
{ label: labels.position.categories[1], value: 1 },
|
||||||
{ label: positionLabels[2], value: 2 }
|
{ label: labels.position.categories[2], value: 2 }
|
||||||
]
|
]
|
||||||
return (
|
return (
|
||||||
<View style={{ flex: 1 }}>
|
<View style={{ flex: 1 }}>
|
||||||
<ScrollView>
|
<ScrollView style={styles.page}>
|
||||||
<View>
|
<SymptomSection
|
||||||
<Text style={styles.symptomDayView}>Opening</Text>
|
header="Opening"
|
||||||
<View style={styles.radioButtonRow}>
|
explainer={labels.opening.explainer}
|
||||||
<RadioForm
|
>
|
||||||
radio_props={cervixOpeningRadioProps}
|
<SelectTabGroup
|
||||||
initial={this.state.opening}
|
buttons={cervixOpeningRadioProps}
|
||||||
formHorizontal={true}
|
active={this.state.opening}
|
||||||
labelHorizontal={false}
|
onSelect={val => this.setState({ opening: val })}
|
||||||
labelStyle={styles.radioButton}
|
/>
|
||||||
onPress={(itemValue) => {
|
</SymptomSection>
|
||||||
this.setState({ opening: itemValue })
|
<SymptomSection
|
||||||
}}
|
header="Firmness"
|
||||||
/>
|
explainer={labels.firmness.explainer}
|
||||||
</View>
|
>
|
||||||
<Text style={styles.symptomDayView}>Firmness</Text>
|
<SelectTabGroup
|
||||||
<View style={styles.radioButtonRow}>
|
buttons={cervixFirmnessRadioProps}
|
||||||
<RadioForm
|
active={this.state.firmness}
|
||||||
radio_props={cervixFirmnessRadioProps}
|
onSelect={val => this.setState({ firmness: val })}
|
||||||
initial={this.state.firmness}
|
/>
|
||||||
formHorizontal={true}
|
</SymptomSection>
|
||||||
labelHorizontal={false}
|
<SymptomSection
|
||||||
labelStyle={styles.radioButton}
|
header="Position"
|
||||||
onPress={(itemValue) => {
|
explainer={labels.position.explainer}
|
||||||
this.setState({ firmness: itemValue })
|
>
|
||||||
}}
|
<SelectTabGroup
|
||||||
/>
|
buttons={cervixPositionRadioProps}
|
||||||
</View>
|
active={this.state.position}
|
||||||
<Text style={styles.symptomDayView}>Position</Text>
|
onSelect={val => this.setState({ position: val })}
|
||||||
<View style={styles.radioButtonRow}>
|
/>
|
||||||
<RadioForm
|
</SymptomSection>
|
||||||
radio_props={cervixPositionRadioProps}
|
<SymptomSection
|
||||||
initial={this.state.position}
|
header="Exclude"
|
||||||
formHorizontal={true}
|
explainer="You can exclude this value if you don't want to use it for fertility detection"
|
||||||
labelHorizontal={false}
|
inline={true}
|
||||||
labelStyle={styles.radioButton}
|
>
|
||||||
onPress={(itemValue) => {
|
<Switch
|
||||||
this.setState({ position: itemValue })
|
onValueChange={(val) => {
|
||||||
}}
|
this.setState({ exclude: val })
|
||||||
/>
|
}}
|
||||||
</View>
|
value={this.state.exclude}
|
||||||
<View style={styles.symptomViewRowInline}>
|
/>
|
||||||
<Text style={styles.symptomDayView}>Exclude</Text>
|
</SymptomSection>
|
||||||
<Switch
|
|
||||||
onValueChange={(val) => {
|
|
||||||
this.setState({ exclude: val })
|
|
||||||
}}
|
|
||||||
value={this.state.exclude}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<ActionButtonFooter
|
<ActionButtonFooter
|
||||||
symptom='cervix'
|
symptom='cervix'
|
||||||
|
|||||||
@@ -3,11 +3,12 @@ import {
|
|||||||
View,
|
View,
|
||||||
ScrollView
|
ScrollView
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import RadioForm from 'react-native-simple-radio-button'
|
|
||||||
import styles from '../../../styles'
|
import styles from '../../../styles'
|
||||||
import { saveSymptom } from '../../../db'
|
import { saveSymptom } from '../../../db'
|
||||||
import { intensity as labels } from '../labels/labels'
|
import { intensity, desire } from '../labels/labels'
|
||||||
import ActionButtonFooter from './action-button-footer'
|
import ActionButtonFooter from './action-button-footer'
|
||||||
|
import SelectTabGroup from '../select-tab-group'
|
||||||
|
import SymptomSection from './symptom-section'
|
||||||
|
|
||||||
export default class Desire extends Component {
|
export default class Desire extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -23,27 +24,23 @@ export default class Desire extends Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const desireRadioProps = [
|
const desireRadioProps = [
|
||||||
{ label: labels[0], value: 0 },
|
{ label: intensity[0], value: 0 },
|
||||||
{ label: labels[1], value: 1 },
|
{ label: intensity[1], value: 1 },
|
||||||
{ label: labels[2], value: 2 }
|
{ label: intensity[2], value: 2 }
|
||||||
]
|
]
|
||||||
return (
|
return (
|
||||||
<View style={{ flex: 1 }}>
|
<View style={{ flex: 1 }}>
|
||||||
<ScrollView>
|
<ScrollView style={styles.page}>
|
||||||
<View>
|
<SymptomSection
|
||||||
<View style={styles.radioButtonRow}>
|
header={desire.header}
|
||||||
<RadioForm
|
explainer={desire.explainer}
|
||||||
radio_props={desireRadioProps}
|
>
|
||||||
initial={this.state.currentValue}
|
<SelectTabGroup
|
||||||
formHorizontal={true}
|
buttons={desireRadioProps}
|
||||||
labelHorizontal={false}
|
active={this.state.currentValue}
|
||||||
labelStyle={styles.radioButton}
|
onSelect={val => this.setState({ currentValue: val })}
|
||||||
onPress={(itemValue) => {
|
/>
|
||||||
this.setState({ currentValue: itemValue })
|
</SymptomSection>
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<ActionButtonFooter
|
<ActionButtonFooter
|
||||||
symptom='desire'
|
symptom='desire'
|
||||||
|
|||||||
@@ -1,19 +1,16 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import {
|
import {
|
||||||
View,
|
View,
|
||||||
Text,
|
|
||||||
Switch,
|
Switch,
|
||||||
ScrollView
|
ScrollView
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import RadioForm from 'react-native-simple-radio-button'
|
|
||||||
import styles from '../../../styles'
|
import styles from '../../../styles'
|
||||||
import { saveSymptom } from '../../../db'
|
import { saveSymptom } from '../../../db'
|
||||||
import {
|
import { mucus as labels } from '../labels/labels'
|
||||||
mucusFeeling as feelingLabels,
|
|
||||||
mucusTexture as textureLabels
|
|
||||||
} from '../labels/labels'
|
|
||||||
import computeSensiplanValue from '../../../lib/sensiplan-mucus'
|
import computeSensiplanValue from '../../../lib/sensiplan-mucus'
|
||||||
import ActionButtonFooter from './action-button-footer'
|
import ActionButtonFooter from './action-button-footer'
|
||||||
|
import SelectTabGroup from '../select-tab-group'
|
||||||
|
import SymptomSection from './symptom-section'
|
||||||
|
|
||||||
|
|
||||||
export default class Mucus extends Component {
|
export default class Mucus extends Component {
|
||||||
@@ -36,66 +33,63 @@ export default class Mucus extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const mucusFeelingRadioProps = [
|
const mucusFeeling = [
|
||||||
{ label: feelingLabels[0], value: 0 },
|
{ label: labels.feeling.categories[0], value: 0 },
|
||||||
{ label: feelingLabels[1], value: 1 },
|
{ label: labels.feeling.categories[1], value: 1 },
|
||||||
{ label: feelingLabels[2], value: 2 },
|
{ label: labels.feeling.categories[2], value: 2 },
|
||||||
{ label: feelingLabels[3], value: 3 }
|
{ label: labels.feeling.categories[3], value: 3 }
|
||||||
]
|
]
|
||||||
const mucusTextureRadioProps = [
|
const mucusTexture = [
|
||||||
{ label: textureLabels[0], value: 0 },
|
{ label: labels.texture.categories[0], value: 0 },
|
||||||
{ label: textureLabels[1], value: 1 },
|
{ label: labels.texture.categories[1], value: 1 },
|
||||||
{ label: textureLabels[2], value: 2 }
|
{ label: labels.texture.categories[2], value: 2 }
|
||||||
]
|
]
|
||||||
return (
|
return (
|
||||||
<View style={{ flex: 1 }}>
|
<View style={{ flex: 1 }}>
|
||||||
<ScrollView>
|
<ScrollView style={styles.page}>
|
||||||
<View>
|
<SymptomSection
|
||||||
<Text style={styles.symptomDayView}>Feeling</Text>
|
header='Feeling'
|
||||||
<View style={styles.radioButtonRow}>
|
explainer={labels.feeling.explainer}
|
||||||
<RadioForm
|
>
|
||||||
radio_props={mucusFeelingRadioProps}
|
<SelectTabGroup
|
||||||
initial={this.state.feeling}
|
buttons={mucusFeeling}
|
||||||
formHorizontal={true}
|
onSelect={val => this.setState({ feeling: val })}
|
||||||
labelHorizontal={false}
|
active={this.state.feeling}
|
||||||
labelStyle={styles.radioButton}
|
/>
|
||||||
onPress={(itemValue) => {
|
</SymptomSection>
|
||||||
this.setState({ feeling: itemValue })
|
<SymptomSection
|
||||||
}}
|
header='Texture'
|
||||||
/>
|
explainer={labels.texture.explainer}
|
||||||
</View>
|
>
|
||||||
<Text style={styles.symptomDayView}>Texture</Text>
|
<SelectTabGroup
|
||||||
<View style={styles.radioButtonRow}>
|
buttons={mucusTexture}
|
||||||
<RadioForm
|
onSelect={val => this.setState({ texture: val })}
|
||||||
radio_props={mucusTextureRadioProps}
|
active={this.state.texture}
|
||||||
initial={this.state.texture}
|
/>
|
||||||
formHorizontal={true}
|
</SymptomSection>
|
||||||
labelHorizontal={false}
|
<SymptomSection
|
||||||
labelStyle={styles.radioButton}
|
header="Exclude"
|
||||||
onPress={(itemValue) => {
|
explainer={labels.excludeExplainer}
|
||||||
this.setState({ texture: itemValue })
|
inline={true}
|
||||||
}}
|
>
|
||||||
/>
|
<Switch
|
||||||
</View>
|
onValueChange={(val) => {
|
||||||
<View style={styles.symptomViewRowInline}>
|
this.setState({ exclude: val })
|
||||||
<Text style={styles.symptomDayView}>Exclude</Text>
|
}}
|
||||||
<Switch
|
value={this.state.exclude}
|
||||||
onValueChange={(val) => {
|
/>
|
||||||
this.setState({ exclude: val })
|
</SymptomSection>
|
||||||
}}
|
|
||||||
value={this.state.exclude}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<ActionButtonFooter
|
<ActionButtonFooter
|
||||||
symptom='mucus'
|
symptom='mucus'
|
||||||
cycleDay={this.cycleDay}
|
cycleDay={this.cycleDay}
|
||||||
saveAction={() => {
|
saveAction={() => {
|
||||||
|
const feeling = this.state.feeling
|
||||||
|
const texture = this.state.texture
|
||||||
saveSymptom('mucus', this.cycleDay, {
|
saveSymptom('mucus', this.cycleDay, {
|
||||||
feeling: this.state.feeling,
|
feeling,
|
||||||
texture: this.state.texture,
|
texture,
|
||||||
value: computeSensiplanValue(this.state.feeling, this.state.texture),
|
value: computeSensiplanValue(feeling, texture),
|
||||||
exclude: this.state.exclude
|
exclude: this.state.exclude
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import {
|
|||||||
import styles from '../../../styles'
|
import styles from '../../../styles'
|
||||||
import { saveSymptom } from '../../../db'
|
import { saveSymptom } from '../../../db'
|
||||||
import ActionButtonFooter from './action-button-footer'
|
import ActionButtonFooter from './action-button-footer'
|
||||||
|
import SymptomSection from './symptom-section'
|
||||||
|
import { noteExplainer } from '../labels/labels'
|
||||||
|
|
||||||
export default class Note extends Component {
|
export default class Note extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -24,8 +26,10 @@ export default class Note extends Component {
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<View style={{ flex: 1 }}>
|
<View style={{ flex: 1 }}>
|
||||||
<ScrollView>
|
<ScrollView style={styles.page}>
|
||||||
<View style={styles.symptomViewRow}>
|
<SymptomSection
|
||||||
|
explainer={noteExplainer}
|
||||||
|
>
|
||||||
<TextInput
|
<TextInput
|
||||||
autoFocus={!this.state.currentValue}
|
autoFocus={!this.state.currentValue}
|
||||||
multiline={true}
|
multiline={true}
|
||||||
@@ -35,7 +39,7 @@ export default class Note extends Component {
|
|||||||
}}
|
}}
|
||||||
value={this.state.currentValue}
|
value={this.state.currentValue}
|
||||||
/>
|
/>
|
||||||
</View>
|
</SymptomSection>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<ActionButtonFooter
|
<ActionButtonFooter
|
||||||
symptom='note'
|
symptom='note'
|
||||||
|
|||||||
@@ -1,17 +1,42 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import {
|
import {
|
||||||
CheckBox,
|
|
||||||
ScrollView,
|
ScrollView,
|
||||||
Text,
|
|
||||||
TextInput,
|
TextInput,
|
||||||
View
|
View
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import styles from '../../../styles'
|
|
||||||
import { saveSymptom } from '../../../db'
|
import { saveSymptom } from '../../../db'
|
||||||
import {
|
import { pain as labels } from '../labels/labels'
|
||||||
pain as painLabels
|
|
||||||
} from '../labels/labels'
|
|
||||||
import ActionButtonFooter from './action-button-footer'
|
import ActionButtonFooter from './action-button-footer'
|
||||||
|
import SelectBoxGroup from '../select-box-group'
|
||||||
|
import SymptomSection from './symptom-section'
|
||||||
|
import styles from '../../../styles'
|
||||||
|
|
||||||
|
const categories = labels.categories
|
||||||
|
const boxes = [{
|
||||||
|
label: categories.cramps,
|
||||||
|
stateKey: 'cramps'
|
||||||
|
}, {
|
||||||
|
label: categories.ovulationPain,
|
||||||
|
stateKey: 'ovulationPain'
|
||||||
|
}, {
|
||||||
|
label: categories.headache,
|
||||||
|
stateKey: 'headache'
|
||||||
|
}, {
|
||||||
|
label: categories.backache,
|
||||||
|
stateKey: 'backache'
|
||||||
|
}, {
|
||||||
|
label: categories.nausea,
|
||||||
|
stateKey: 'nausea'
|
||||||
|
}, {
|
||||||
|
label: categories.tenderBreasts,
|
||||||
|
stateKey: 'tenderBreasts'
|
||||||
|
}, {
|
||||||
|
label: categories.migraine,
|
||||||
|
stateKey: 'migraine'
|
||||||
|
}, {
|
||||||
|
label: categories.other,
|
||||||
|
stateKey: 'other'
|
||||||
|
}]
|
||||||
|
|
||||||
export default class Pain extends Component {
|
export default class Pain extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -26,92 +51,26 @@ export default class Pain extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleState = (key) => {
|
||||||
|
const curr = this.state[key]
|
||||||
|
this.setState({[key]: !curr})
|
||||||
|
if (key === 'other' && !curr) {
|
||||||
|
this.setState({focusTextArea: true})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<View style={{ flex: 1 }}>
|
<View style={{ flex: 1 }}>
|
||||||
<ScrollView>
|
<ScrollView style={styles.page}>
|
||||||
<View>
|
<SymptomSection
|
||||||
<View style={styles.symptomViewRowInline}>
|
explainer={labels.explainer}
|
||||||
<Text style={styles.symptomDayView}>{painLabels.cramps}</Text>
|
>
|
||||||
<CheckBox
|
<SelectBoxGroup
|
||||||
value={this.state.cramps}
|
data={boxes}
|
||||||
onValueChange={(val) => {
|
onSelect={this.toggleState}
|
||||||
this.setState({cramps: val})
|
optionsState={this.state}
|
||||||
}}
|
/>
|
||||||
/>
|
|
||||||
<Text style={styles.symptomDayView}>
|
|
||||||
{painLabels.ovulationPain}
|
|
||||||
</Text>
|
|
||||||
<CheckBox
|
|
||||||
value={this.state.ovulationPain}
|
|
||||||
onValueChange={(val) => {
|
|
||||||
this.setState({ovulationPain: val})
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
<View style={styles.symptomViewRowInline}>
|
|
||||||
<Text style={styles.symptomDayView}>
|
|
||||||
{painLabels.headache}
|
|
||||||
</Text>
|
|
||||||
<CheckBox
|
|
||||||
value={this.state.headache}
|
|
||||||
onValueChange={(val) => {
|
|
||||||
this.setState({headache: val})
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Text style={styles.symptomDayView}>
|
|
||||||
{painLabels.backache}
|
|
||||||
</Text>
|
|
||||||
<CheckBox
|
|
||||||
value={this.state.backache}
|
|
||||||
onValueChange={(val) => {
|
|
||||||
this.setState({backache: val})
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
<View style={styles.symptomViewRowInline}>
|
|
||||||
<Text style={styles.symptomDayView}>
|
|
||||||
{painLabels.nausea}
|
|
||||||
</Text>
|
|
||||||
<CheckBox
|
|
||||||
value={this.state.nausea}
|
|
||||||
onValueChange={(val) => {
|
|
||||||
this.setState({nausea: val})
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Text style={styles.symptomDayView}>
|
|
||||||
{painLabels.tenderBreasts}
|
|
||||||
</Text>
|
|
||||||
<CheckBox
|
|
||||||
value={this.state.tenderBreasts}
|
|
||||||
onValueChange={(val) => {
|
|
||||||
this.setState({tenderBreasts: val})
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
<View style={styles.symptomViewRowInline}>
|
|
||||||
<Text style={styles.symptomDayView}>
|
|
||||||
{painLabels.migraine}
|
|
||||||
</Text>
|
|
||||||
<CheckBox
|
|
||||||
value={this.state.migraine}
|
|
||||||
onValueChange={(val) => {
|
|
||||||
this.setState({migraine: val})
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Text style={styles.symptomDayView}>
|
|
||||||
{painLabels.other}
|
|
||||||
</Text>
|
|
||||||
<CheckBox
|
|
||||||
value={this.state.other}
|
|
||||||
onValueChange={(val) => {
|
|
||||||
this.setState({
|
|
||||||
other: val,
|
|
||||||
focusTextArea: true
|
|
||||||
})
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
{ this.state.other &&
|
{ this.state.other &&
|
||||||
<TextInput
|
<TextInput
|
||||||
autoFocus={this.state.focusTextArea}
|
autoFocus={this.state.focusTextArea}
|
||||||
@@ -123,7 +82,7 @@ export default class Pain extends Component {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
</View>
|
</SymptomSection>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<ActionButtonFooter
|
<ActionButtonFooter
|
||||||
symptom='pain'
|
symptom='pain'
|
||||||
|
|||||||
@@ -1,15 +1,46 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import {
|
import {
|
||||||
CheckBox,
|
|
||||||
Text,
|
|
||||||
TextInput,
|
TextInput,
|
||||||
View,
|
View,
|
||||||
ScrollView
|
ScrollView
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import styles from '../../../styles'
|
import styles from '../../../styles'
|
||||||
import { saveSymptom } from '../../../db'
|
import { saveSymptom } from '../../../db'
|
||||||
import { sex as sexLabels } from '../labels/labels'
|
import { sex as labels } from '../labels/labels'
|
||||||
import ActionButtonFooter from './action-button-footer'
|
import ActionButtonFooter from './action-button-footer'
|
||||||
|
import SelectBoxGroup from '../select-box-group'
|
||||||
|
import SymptomSection from './symptom-section'
|
||||||
|
|
||||||
|
const sexBoxes = [{
|
||||||
|
label: labels.solo,
|
||||||
|
stateKey: 'solo'
|
||||||
|
}, {
|
||||||
|
label: labels.partner,
|
||||||
|
stateKey: 'partner'
|
||||||
|
}]
|
||||||
|
|
||||||
|
const contraceptiveBoxes = [{
|
||||||
|
label: labels.condom,
|
||||||
|
stateKey: 'condom'
|
||||||
|
}, {
|
||||||
|
label: labels.pill,
|
||||||
|
stateKey: 'pill'
|
||||||
|
}, {
|
||||||
|
label: labels.iud,
|
||||||
|
stateKey: 'iud'
|
||||||
|
}, {
|
||||||
|
label: labels.patch,
|
||||||
|
stateKey: 'patch'
|
||||||
|
}, {
|
||||||
|
label: labels.ring,
|
||||||
|
stateKey: 'ring'
|
||||||
|
}, {
|
||||||
|
label: labels.implant,
|
||||||
|
stateKey: 'implant'
|
||||||
|
}, {
|
||||||
|
label: labels.other,
|
||||||
|
stateKey: 'other'
|
||||||
|
}]
|
||||||
|
|
||||||
export default class Sex extends Component {
|
export default class Sex extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -26,117 +57,50 @@ export default class Sex extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
toggleState = (key) => {
|
||||||
|
const curr = this.state[key]
|
||||||
|
this.setState({[key]: !curr})
|
||||||
|
if (key === 'other' && !curr) {
|
||||||
|
this.setState({focusTextArea: true})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
return (
|
return (
|
||||||
<View style={{ flex: 1 }}>
|
<View style={{ flex: 1 }}>
|
||||||
<ScrollView>
|
<ScrollView style={styles.page}>
|
||||||
<View>
|
<SymptomSection
|
||||||
<View style={styles.symptomViewRowInline}>
|
header="Activity"
|
||||||
<Text style={styles.symptomDayView}>{sexLabels.solo}</Text>
|
explainer={labels.activityExplainer}
|
||||||
<CheckBox
|
>
|
||||||
value={this.state.solo}
|
<SelectBoxGroup
|
||||||
onValueChange={(val) => {
|
data={sexBoxes}
|
||||||
this.setState({ solo: val })
|
onSelect={this.toggleState}
|
||||||
}}
|
optionsState={this.state}
|
||||||
/>
|
/>
|
||||||
<Text style={styles.symptomDayView}>
|
</SymptomSection>
|
||||||
{sexLabels.partner}
|
<SymptomSection
|
||||||
</Text>
|
header="Contraceptives"
|
||||||
<CheckBox
|
explainer={labels.contraceptiveExplainer}
|
||||||
value={this.state.partner}
|
>
|
||||||
onValueChange={(val) => {
|
<SelectBoxGroup
|
||||||
this.setState({ partner: val })
|
data={contraceptiveBoxes}
|
||||||
}}
|
onSelect={this.toggleState}
|
||||||
/>
|
optionsState={this.state}
|
||||||
</View>
|
/>
|
||||||
<Text style={styles.symptomDayView}>CONTRACEPTIVES</Text>
|
</SymptomSection>
|
||||||
<View style={styles.symptomViewRowInline}>
|
|
||||||
<Text style={styles.symptomDayView}>
|
{this.state.other &&
|
||||||
{sexLabels.condom}
|
<TextInput
|
||||||
</Text>
|
autoFocus={this.state.focusTextArea}
|
||||||
<CheckBox
|
multiline={true}
|
||||||
value={this.state.condom}
|
placeholder="Enter"
|
||||||
onValueChange={(val) => {
|
value={this.state.note}
|
||||||
this.setState({ condom: val })
|
onChangeText={(val) => {
|
||||||
}}
|
this.setState({ note: val })
|
||||||
/>
|
}}
|
||||||
<Text style={styles.symptomDayView}>
|
/>
|
||||||
{sexLabels.pill}
|
}
|
||||||
</Text>
|
|
||||||
<CheckBox
|
|
||||||
value={this.state.pill}
|
|
||||||
onValueChange={(val) => {
|
|
||||||
this.setState({ pill: val })
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
<View style={styles.symptomViewRowInline}>
|
|
||||||
<Text style={styles.symptomDayView}>
|
|
||||||
{sexLabels.iud}
|
|
||||||
</Text>
|
|
||||||
<CheckBox
|
|
||||||
value={this.state.iud}
|
|
||||||
onValueChange={(val) => {
|
|
||||||
this.setState({ iud: val })
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Text style={styles.symptomDayView}>
|
|
||||||
{sexLabels.patch}
|
|
||||||
</Text>
|
|
||||||
<CheckBox
|
|
||||||
value={this.state.patch}
|
|
||||||
onValueChange={(val) => {
|
|
||||||
this.setState({ patch: val })
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
<View style={styles.symptomViewRowInline}>
|
|
||||||
<Text style={styles.symptomDayView}>
|
|
||||||
{sexLabels.ring}
|
|
||||||
</Text>
|
|
||||||
<CheckBox
|
|
||||||
value={this.state.ring}
|
|
||||||
onValueChange={(val) => {
|
|
||||||
this.setState({ ring: val })
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Text style={styles.symptomDayView}>
|
|
||||||
{sexLabels.implant}
|
|
||||||
</Text>
|
|
||||||
<CheckBox
|
|
||||||
value={this.state.implant}
|
|
||||||
onValueChange={(val) => {
|
|
||||||
this.setState({ implant: val })
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
<View style={styles.symptomViewRowInline}>
|
|
||||||
<Text style={styles.symptomDayView}>
|
|
||||||
{sexLabels.other}
|
|
||||||
</Text>
|
|
||||||
<CheckBox
|
|
||||||
value={this.state.other}
|
|
||||||
onValueChange={(val) => {
|
|
||||||
this.setState({
|
|
||||||
other: val,
|
|
||||||
focusTextArea: true
|
|
||||||
})
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
{this.state.other &&
|
|
||||||
<TextInput
|
|
||||||
autoFocus={this.state.focusTextArea}
|
|
||||||
multiline={true}
|
|
||||||
placeholder="Enter"
|
|
||||||
value={this.state.note}
|
|
||||||
onChangeText={(val) => {
|
|
||||||
this.setState({ note: val })
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
</View>
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<ActionButtonFooter
|
<ActionButtonFooter
|
||||||
symptom='sex'
|
symptom='sex'
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import React, { Component } from 'react'
|
||||||
|
import { View } from 'react-native'
|
||||||
|
import { SymptomSectionHeader, AppText } from '../../app-text'
|
||||||
|
|
||||||
|
export default class SymptomSection extends Component {
|
||||||
|
render() {
|
||||||
|
const p = this.props
|
||||||
|
let placeHeadingInline
|
||||||
|
if (!p.explainer && p.inline) {
|
||||||
|
placeHeadingInline = {
|
||||||
|
flexDirection: 'row',
|
||||||
|
alignItems: "center"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<View style={placeHeadingInline}>
|
||||||
|
<SymptomSectionHeader flex={1}>{p.header}</SymptomSectionHeader>
|
||||||
|
<View
|
||||||
|
flexDirection={p.inline ? 'row' : null}
|
||||||
|
flex={1}
|
||||||
|
alignItems={p.inline ? 'center' : null}
|
||||||
|
>
|
||||||
|
<View flex={1}>
|
||||||
|
<AppText>{p.explainer}</AppText>
|
||||||
|
</View>
|
||||||
|
{p.children}
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import {
|
import {
|
||||||
View,
|
View,
|
||||||
Text,
|
|
||||||
TextInput,
|
TextInput,
|
||||||
Switch,
|
Switch,
|
||||||
Keyboard,
|
Keyboard,
|
||||||
@@ -13,11 +12,12 @@ import DateTimePicker from 'react-native-modal-datetime-picker-nevo'
|
|||||||
import { getPreviousTemperature, saveSymptom } from '../../../db'
|
import { getPreviousTemperature, saveSymptom } from '../../../db'
|
||||||
import styles from '../../../styles'
|
import styles from '../../../styles'
|
||||||
import { LocalTime, ChronoUnit } from 'js-joda'
|
import { LocalTime, ChronoUnit } from 'js-joda'
|
||||||
import { temperature as tempLabels } from '../labels/labels'
|
import { temperature as labels } from '../labels/labels'
|
||||||
import { scaleObservable } from '../../../local-storage'
|
import { scaleObservable } from '../../../local-storage'
|
||||||
import { shared } from '../../labels'
|
import { shared } from '../../labels'
|
||||||
import ActionButtonFooter from './action-button-footer'
|
import ActionButtonFooter from './action-button-footer'
|
||||||
import config from '../../../config'
|
import config from '../../../config'
|
||||||
|
import SymptomSection from './symptom-section'
|
||||||
|
|
||||||
const minutes = ChronoUnit.MINUTES
|
const minutes = ChronoUnit.MINUTES
|
||||||
|
|
||||||
@@ -72,9 +72,9 @@ export default class Temp extends Component {
|
|||||||
const scale = scaleObservable.value
|
const scale = scaleObservable.value
|
||||||
let warningMsg
|
let warningMsg
|
||||||
if (value < absolute.min || value > absolute.max) {
|
if (value < absolute.min || value > absolute.max) {
|
||||||
warningMsg = tempLabels.outOfAbsoluteRangeWarning
|
warningMsg = labels.outOfAbsoluteRangeWarning
|
||||||
} else if (value < scale.min || value > scale.max) {
|
} else if (value < scale.min || value > scale.max) {
|
||||||
warningMsg = tempLabels.outOfRangeWarning
|
warningMsg = labels.outOfRangeWarning
|
||||||
}
|
}
|
||||||
|
|
||||||
if (warningMsg) {
|
if (warningMsg) {
|
||||||
@@ -96,18 +96,23 @@ export default class Temp extends Component {
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<View style={{ flex: 1 }}>
|
<View style={{ flex: 1 }}>
|
||||||
<ScrollView>
|
<ScrollView style={styles.page}>
|
||||||
<View>
|
<View>
|
||||||
<View style={styles.symptomViewRowInline}>
|
<SymptomSection
|
||||||
<Text style={styles.symptomDayView}>Temperature (°C)</Text>
|
header="Temperature (°C)"
|
||||||
|
explainer={labels.temperature.explainer}
|
||||||
|
inline={true}
|
||||||
|
>
|
||||||
<TempInput
|
<TempInput
|
||||||
value={this.state.temperature}
|
value={this.state.temperature}
|
||||||
setState={(val) => this.setState(val)}
|
setState={(val) => this.setState(val)}
|
||||||
isSuggestion={this.state.isSuggestion}
|
isSuggestion={this.state.isSuggestion}
|
||||||
/>
|
/>
|
||||||
</View>
|
</SymptomSection>
|
||||||
<View style={styles.symptomViewRowInline}>
|
<SymptomSection
|
||||||
<Text style={styles.symptomDayView}>Time</Text>
|
header="Time"
|
||||||
|
inline={true}
|
||||||
|
>
|
||||||
<TextInput
|
<TextInput
|
||||||
style={styles.temperatureTextInput}
|
style={styles.temperatureTextInput}
|
||||||
onFocus={() => {
|
onFocus={() => {
|
||||||
@@ -116,42 +121,44 @@ export default class Temp extends Component {
|
|||||||
}}
|
}}
|
||||||
value={this.state.time}
|
value={this.state.time}
|
||||||
/>
|
/>
|
||||||
</View>
|
<DateTimePicker
|
||||||
<DateTimePicker
|
mode="time"
|
||||||
mode="time"
|
isVisible={this.state.isTimePickerVisible}
|
||||||
isVisible={this.state.isTimePickerVisible}
|
onConfirm={jsDate => {
|
||||||
onConfirm={jsDate => {
|
this.setState({
|
||||||
this.setState({
|
time: `${jsDate.getHours()}:${jsDate.getMinutes()}`,
|
||||||
time: `${jsDate.getHours()}:${jsDate.getMinutes()}`,
|
isTimePickerVisible: false
|
||||||
isTimePickerVisible: false
|
})
|
||||||
})
|
}}
|
||||||
}}
|
onCancel={() => this.setState({ isTimePickerVisible: false })}
|
||||||
onCancel={() => this.setState({ isTimePickerVisible: false })}
|
/>
|
||||||
/>
|
</SymptomSection>
|
||||||
<View style={styles.symptomViewRowInline}>
|
<SymptomSection
|
||||||
<Text style={styles.symptomDayView}>Note</Text>
|
header="Note"
|
||||||
</View>
|
explainer={labels.note.explainer}
|
||||||
<View>
|
>
|
||||||
<TextInput
|
<TextInput
|
||||||
style={styles.temperatureTextInput}
|
|
||||||
multiline={true}
|
multiline={true}
|
||||||
autoFocus={this.state.focusTextArea}
|
autoFocus={this.state.focusTextArea}
|
||||||
placeholder="enter"
|
placeholder="Enter"
|
||||||
value={this.state.note}
|
value={this.state.note}
|
||||||
onChangeText={(val) => {
|
onChangeText={(val) => {
|
||||||
this.setState({ note: val })
|
this.setState({ note: val })
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</View>
|
</SymptomSection>
|
||||||
<View style={styles.symptomViewRowInline}>
|
<SymptomSection
|
||||||
<Text style={styles.symptomDayView}>Exclude</Text>
|
header="Exclude"
|
||||||
|
explainer={labels.excludeExplainer}
|
||||||
|
inline={true}
|
||||||
|
>
|
||||||
<Switch
|
<Switch
|
||||||
onValueChange={(val) => {
|
onValueChange={(val) => {
|
||||||
this.setState({ exclude: val })
|
this.setState({ exclude: val })
|
||||||
}}
|
}}
|
||||||
value={this.state.exclude}
|
value={this.state.exclude}
|
||||||
/>
|
/>
|
||||||
</View>
|
</SymptomSection>
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<ActionButtonFooter
|
<ActionButtonFooter
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
import { LocalDate, ChronoUnit } from 'js-joda'
|
import { LocalDate, ChronoUnit } from 'js-joda'
|
||||||
import styles from '../styles/index'
|
import styles from '../styles/index'
|
||||||
import cycleModule from '../lib/cycle'
|
import cycleModule from '../lib/cycle'
|
||||||
import { getOrCreateCycleDay, bleedingDaysSortedByDate, fillWithDummyData, deleteAll } from '../db'
|
import { getOrCreateCycleDay, bleedingDaysSortedByDate, fillWithMucusDummyData, fillWithCervixDummyData, deleteAll } from '../db'
|
||||||
import {bleedingPrediction as labels} from './labels'
|
import {bleedingPrediction as labels} from './labels'
|
||||||
|
|
||||||
const getCycleDayNumber = cycleModule().getCycleDayNumber
|
const getCycleDayNumber = cycleModule().getCycleDayNumber
|
||||||
@@ -62,8 +62,14 @@ export default class Home extends Component {
|
|||||||
</View>
|
</View>
|
||||||
<View style={styles.homeButton}>
|
<View style={styles.homeButton}>
|
||||||
<Button
|
<Button
|
||||||
onPress={() => fillWithDummyData()}
|
onPress={() => fillWithMucusDummyData()}
|
||||||
title="fill with example data">
|
title="fill with example data for mucus&temp">
|
||||||
|
</Button>
|
||||||
|
</View>
|
||||||
|
<View style={styles.homeButton}>
|
||||||
|
<Button
|
||||||
|
onPress={() => fillWithCervixDummyData()}
|
||||||
|
title="fill with example data for cervix&temp">
|
||||||
</Button>
|
</Button>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.homeButton}>
|
<View style={styles.homeButton}>
|
||||||
@@ -107,4 +113,4 @@ function determinePredictionText() {
|
|||||||
} else {
|
} else {
|
||||||
return labels.predictionStartedXDaysLeft(daysToEnd)
|
return labels.predictionStartedXDaysLeft(daysToEnd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import {
|
|||||||
TouchableOpacity,
|
TouchableOpacity,
|
||||||
ScrollView,
|
ScrollView,
|
||||||
Alert,
|
Alert,
|
||||||
Text,
|
|
||||||
Switch
|
Switch
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import DateTimePicker from 'react-native-modal-datetime-picker-nevo'
|
import DateTimePicker from 'react-native-modal-datetime-picker-nevo'
|
||||||
@@ -23,6 +22,7 @@ import {
|
|||||||
tempReminderObservable,
|
tempReminderObservable,
|
||||||
saveTempReminder
|
saveTempReminder
|
||||||
} from '../local-storage'
|
} from '../local-storage'
|
||||||
|
import { AppText } from './app-text'
|
||||||
|
|
||||||
export default class Settings extends Component {
|
export default class Settings extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -35,36 +35,36 @@ export default class Settings extends Component {
|
|||||||
<ScrollView>
|
<ScrollView>
|
||||||
<TempReminderPicker/>
|
<TempReminderPicker/>
|
||||||
<View style={styles.settingsSegment}>
|
<View style={styles.settingsSegment}>
|
||||||
<Text style={styles.settingsSegmentTitle}>
|
<AppText style={styles.settingsSegmentTitle}>
|
||||||
{labels.tempScale.segmentTitle}
|
{labels.tempScale.segmentTitle}
|
||||||
</Text>
|
</AppText>
|
||||||
<Text>{labels.tempScale.segmentExplainer}</Text>
|
<AppText>{labels.tempScale.segmentExplainer}</AppText>
|
||||||
<TempSlider/>
|
<TempSlider/>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.settingsSegment}>
|
<View style={styles.settingsSegment}>
|
||||||
<Text style={styles.settingsSegmentTitle}>
|
<AppText style={styles.settingsSegmentTitle}>
|
||||||
{labels.export.button}
|
{labels.export.button}
|
||||||
</Text>
|
</AppText>
|
||||||
<Text>{labels.export.segmentExplainer}</Text>
|
<AppText>{labels.export.segmentExplainer}</AppText>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={openShareDialogAndExport}
|
onPress={openShareDialogAndExport}
|
||||||
style={styles.settingsButton}>
|
style={styles.settingsButton}>
|
||||||
<Text style={styles.settingsButtonText}>
|
<AppText style={styles.settingsButtonText}>
|
||||||
{labels.export.button}
|
{labels.export.button}
|
||||||
</Text>
|
</AppText>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.settingsSegment}>
|
<View style={styles.settingsSegment}>
|
||||||
<Text style={styles.settingsSegmentTitle}>
|
<AppText style={styles.settingsSegmentTitle}>
|
||||||
{labels.import.button}
|
{labels.import.button}
|
||||||
</Text>
|
</AppText>
|
||||||
<Text>{labels.import.segmentExplainer}</Text>
|
<AppText>{labels.import.segmentExplainer}</AppText>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={openImportDialogAndImport}
|
onPress={openImportDialogAndImport}
|
||||||
style={styles.settingsButton}>
|
style={styles.settingsButton}>
|
||||||
<Text style={styles.settingsButtonText}>
|
<AppText style={styles.settingsButtonText}>
|
||||||
{labels.import.button}
|
{labels.import.button}
|
||||||
</Text>
|
</AppText>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
@@ -84,15 +84,15 @@ class TempReminderPicker extends Component {
|
|||||||
style={styles.settingsSegment}
|
style={styles.settingsSegment}
|
||||||
onPress={() => this.setState({ isTimePickerVisible: true })}
|
onPress={() => this.setState({ isTimePickerVisible: true })}
|
||||||
>
|
>
|
||||||
<Text style={styles.settingsSegmentTitle}>
|
<AppText style={styles.settingsSegmentTitle}>
|
||||||
{labels.tempReminder.title}
|
{labels.tempReminder.title}
|
||||||
</Text>
|
</AppText>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
<View style={{ flex: 1 }}>
|
<View style={{ flex: 1 }}>
|
||||||
{this.state.time && this.state.enabled ?
|
{this.state.time && this.state.enabled ?
|
||||||
<Text>{labels.tempReminder.timeSet(this.state.time)}</Text>
|
<AppText>{labels.tempReminder.timeSet(this.state.time)}</AppText>
|
||||||
:
|
:
|
||||||
<Text>{labels.tempReminder.noTimeSet}</Text>
|
<AppText>{labels.tempReminder.noTimeSet}</AppText>
|
||||||
}
|
}
|
||||||
</View>
|
</View>
|
||||||
<Switch
|
<Switch
|
||||||
@@ -104,7 +104,6 @@ class TempReminderPicker extends Component {
|
|||||||
}
|
}
|
||||||
if (!switchOn) saveTempReminder({ enabled: false })
|
if (!switchOn) saveTempReminder({ enabled: false })
|
||||||
}}
|
}}
|
||||||
onTintColor={secondaryColor}
|
|
||||||
/>
|
/>
|
||||||
<DateTimePicker
|
<DateTimePicker
|
||||||
mode="time"
|
mode="time"
|
||||||
@@ -160,8 +159,8 @@ class TempSlider extends Component {
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<View style={{ alignItems: 'center' }}>
|
<View style={{ alignItems: 'center' }}>
|
||||||
<Text>{`${labels.tempScale.min} ${this.state.min}`}</Text>
|
<AppText>{`${labels.tempScale.min} ${this.state.min}`}</AppText>
|
||||||
<Text>{`${labels.tempScale.max} ${this.state.max}`}</Text>
|
<AppText>{`${labels.tempScale.max} ${this.state.max}`}</AppText>
|
||||||
<Slider
|
<Slider
|
||||||
values={[this.state.min, this.state.max]}
|
values={[this.state.min, this.state.max]}
|
||||||
min={config.temperatureScale.min}
|
min={config.temperatureScale.min}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import {
|
import {
|
||||||
Text,
|
|
||||||
View,
|
View,
|
||||||
ScrollView
|
ScrollView
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
@@ -9,6 +8,7 @@ import styles from '../styles/index'
|
|||||||
import cycleModule from '../lib/cycle'
|
import cycleModule from '../lib/cycle'
|
||||||
import {getCycleLengthStats as getCycleInfo} from '../lib/cycle-length'
|
import {getCycleLengthStats as getCycleInfo} from '../lib/cycle-length'
|
||||||
import {stats as labels} from './labels'
|
import {stats as labels} from './labels'
|
||||||
|
import { AppText } from './app-text'
|
||||||
|
|
||||||
export default class Stats extends Component {
|
export default class Stats extends Component {
|
||||||
render() {
|
render() {
|
||||||
@@ -28,32 +28,32 @@ export default class Stats extends Component {
|
|||||||
<ScrollView>
|
<ScrollView>
|
||||||
<View>
|
<View>
|
||||||
{!atLeastOneCycle &&
|
{!atLeastOneCycle &&
|
||||||
<Text style={styles.statsIntro}>{labels.emptyStats}</Text>
|
<AppText style={styles.statsIntro}>{labels.emptyStats}</AppText>
|
||||||
}
|
}
|
||||||
{atLeastOneCycle && numberOfCycles === 1 &&
|
{atLeastOneCycle && numberOfCycles === 1 &&
|
||||||
<Text style={styles.statsIntro}>
|
<AppText style={styles.statsIntro}>
|
||||||
{labels.oneCycleStats(cycleLengths[0])}
|
{labels.oneCycleStats(cycleLengths[0])}
|
||||||
</Text>
|
</AppText>
|
||||||
}
|
}
|
||||||
{atLeastOneCycle && numberOfCycles > 1 && <View>
|
{atLeastOneCycle && numberOfCycles > 1 && <View>
|
||||||
<Text style={styles.statsIntro}>
|
<AppText style={styles.statsIntro}>
|
||||||
{labels.getBasisOfStats(numberOfCycles)}
|
{labels.getBasisOfStats(numberOfCycles)}
|
||||||
</Text>
|
</AppText>
|
||||||
<View style={styles.statsRow}>
|
<View style={styles.statsRow}>
|
||||||
<Text style={styles.statsLabelLeft}>{labels.averageLabel}</Text>
|
<AppText style={styles.statsLabelLeft}>{labels.averageLabel}</AppText>
|
||||||
<Text style={styles.statsLabelRight}>{cycleInfo.mean + ' ' + labels.daysLabel}</Text>
|
<AppText style={styles.statsLabelRight}>{cycleInfo.mean + ' ' + labels.daysLabel}</AppText>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.statsRow}>
|
<View style={styles.statsRow}>
|
||||||
<Text style={styles.statsLabelLeft}>{labels.minLabel}</Text>
|
<AppText style={styles.statsLabelLeft}>{labels.minLabel}</AppText>
|
||||||
<Text style={styles.statsLabelRight}>{cycleInfo.minimum + ' ' + labels.daysLabel}</Text>
|
<AppText style={styles.statsLabelRight}>{cycleInfo.minimum + ' ' + labels.daysLabel}</AppText>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.statsRow}>
|
<View style={styles.statsRow}>
|
||||||
<Text style={styles.statsLabelLeft}>{labels.maxLabel}</Text>
|
<AppText style={styles.statsLabelLeft}>{labels.maxLabel}</AppText>
|
||||||
<Text style={styles.statsLabelRight}>{cycleInfo.maximum + ' ' + labels.daysLabel}</Text>
|
<AppText style={styles.statsLabelRight}>{cycleInfo.maximum + ' ' + labels.daysLabel}</AppText>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.statsRow}>
|
<View style={styles.statsRow}>
|
||||||
<Text style={styles.statsLabelLeft}>{labels.stdLabel}</Text>
|
<AppText style={styles.statsLabelLeft}>{labels.stdLabel}</AppText>
|
||||||
<Text style={styles.statsLabelRight}>{cycleInfo.stdDeviation + ' ' + labels.daysLabel}</Text>
|
<AppText style={styles.statsLabelRight}>{cycleInfo.stdDeviation + ' ' + labels.daysLabel}</AppText>
|
||||||
</View>
|
</View>
|
||||||
</View>}
|
</View>}
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
function convertToSymptoFormat(val) {
|
function convertToSymptoFormat(val) {
|
||||||
const sympto = { date: val.date }
|
const sympto = { date: val.date }
|
||||||
if (val.temperature) sympto.temperature = { value: val.temperature, exclude: false }
|
if (val.temperature) sympto.temperature = {
|
||||||
|
value: val.temperature,
|
||||||
|
exclude: false
|
||||||
|
}
|
||||||
if (val.mucus) sympto.mucus = {
|
if (val.mucus) sympto.mucus = {
|
||||||
value: val.mucus,
|
value: val.mucus,
|
||||||
exclude: false,
|
exclude: false,
|
||||||
@@ -11,7 +14,7 @@ function convertToSymptoFormat(val) {
|
|||||||
return sympto
|
return sympto
|
||||||
}
|
}
|
||||||
|
|
||||||
export const cycleWithFhm = [
|
export const cycleWithFhmMucus = [
|
||||||
{ date: '2018-07-01', bleeding: 2 },
|
{ date: '2018-07-01', bleeding: 2 },
|
||||||
{ date: '2018-07-02', bleeding: 1 },
|
{ date: '2018-07-02', bleeding: 1 },
|
||||||
{ date: '2018-07-06', temperature: 36.2},
|
{ date: '2018-07-06', temperature: 36.2},
|
||||||
@@ -26,7 +29,7 @@ export const cycleWithFhm = [
|
|||||||
{ date: '2018-07-18', temperature: 36.9, mucus: 2 }
|
{ date: '2018-07-18', temperature: 36.9, mucus: 2 }
|
||||||
].map(convertToSymptoFormat).reverse()
|
].map(convertToSymptoFormat).reverse()
|
||||||
|
|
||||||
export const longAndComplicatedCycle = [
|
export const longAndComplicatedCycleWithMucus = [
|
||||||
{ date: '2018-06-01', temperature: 36.6, bleeding: 2 },
|
{ date: '2018-06-01', temperature: 36.6, bleeding: 2 },
|
||||||
{ date: '2018-06-02', temperature: 36.65 },
|
{ date: '2018-06-02', temperature: 36.65 },
|
||||||
{ date: '2018-06-04', temperature: 36.6 },
|
{ date: '2018-06-04', temperature: 36.6 },
|
||||||
@@ -70,4 +73,71 @@ export const cycleWithTempAndNoMucusShift = [
|
|||||||
{ date: '2018-05-24', temperature: 36.85, mucus: 4 },
|
{ date: '2018-05-24', temperature: 36.85, mucus: 4 },
|
||||||
{ date: '2018-05-26', temperature: 36.8, mucus: 4 },
|
{ date: '2018-05-26', temperature: 36.8, mucus: 4 },
|
||||||
{ date: '2018-05-27', temperature: 36.9, mucus: 4 }
|
{ date: '2018-05-27', temperature: 36.9, mucus: 4 }
|
||||||
].map(convertToSymptoFormat).reverse()
|
].map(convertToSymptoFormat).reverse()
|
||||||
|
|
||||||
|
export const cycleWithFhmCervix = [
|
||||||
|
{ date: '2018-08-01', bleeding: 2 },
|
||||||
|
{ date: '2018-08-02', bleeding: 1 },
|
||||||
|
{ date: '2018-08-03', bleeding: 0 },
|
||||||
|
{ date: '2018-08-04', bleeding: 0 },
|
||||||
|
{ date: '2018-08-05', temperature: 36.07 },
|
||||||
|
{ date: '2018-08-06', temperature: 36.2 },
|
||||||
|
{ date: '2018-08-07', temperature: 36.35 },
|
||||||
|
{ date: '2018-08-08', temperature: 36.4 },
|
||||||
|
{ date: '2018-08-09', temperature: 36.3 },
|
||||||
|
{ date: '2018-08-10', temperature: 36.45 },
|
||||||
|
{ date: '2018-08-11', temperature: 36.45 },
|
||||||
|
{ date: '2018-08-12', temperature: 36.7, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-08-13', temperature: 36.8, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-08-14', temperature: 36.75, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-08-15', temperature: 36.9, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-08-16', temperature: 36.95, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-08-17', temperature: 36.9, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-08-18', temperature: 36.9, cervix: { opening: 1, firmness: 0 } }
|
||||||
|
].map(convertToSymptoFormat).reverse()
|
||||||
|
|
||||||
|
export const longAndComplicatedCycleWithCervix = [
|
||||||
|
{ date: '2018-06-01', temperature: 36.6, bleeding: 2 },
|
||||||
|
{ date: '2018-06-02', temperature: 36.65 },
|
||||||
|
{ date: '2018-06-04', temperature: 36.6 },
|
||||||
|
{ date: '2018-06-05', temperature: 36.55 },
|
||||||
|
{ date: '2018-06-06', temperature: 36.7, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-09', temperature: 36.5, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-10', temperature: 36.4, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-13', temperature: 36.45, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-14', temperature: 36.5, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-15', temperature: 36.55, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-06-16', temperature: 36.7, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-06-17', temperature: 36.65, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-18', temperature: 36.75, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-06-19', temperature: 36.8, cervix: { opening: 1, firmness: 0 } },
|
||||||
|
{ date: '2018-06-20', temperature: 36.85, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-06-21', temperature: 36.8, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-06-22', temperature: 36.9, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-06-25', temperature: 36.9, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-06-26', temperature: 36.8, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-27', temperature: 36.9, cervix: { opening: 1, firmness: 1 } }
|
||||||
|
].map(convertToSymptoFormat).reverse()
|
||||||
|
|
||||||
|
export const cycleWithTempAndNoCervixShift = [
|
||||||
|
{ date: '2018-07-01', temperature: 36.6, bleeding: 2 },
|
||||||
|
{ date: '2018-07-02', temperature: 36.65 },
|
||||||
|
{ date: '2018-07-05', temperature: 36.55 },
|
||||||
|
{ date: '2018-07-06', temperature: 36.7, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-07-08', temperature: 36.45, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-07-09', temperature: 36.5, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-07-10', temperature: 36.4, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-07-11', temperature: 36.5, cervix: { opening: 0, firmness: 1 } },
|
||||||
|
{ date: '2018-07-13', temperature: 36.45, cervix: { opening: 0, firmness: 1 } },
|
||||||
|
{ date: '2018-07-14', temperature: 36.5, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-07-15', temperature: 36.55, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-07-16', temperature: 36.7, cervix: { opening: 0, firmness: 1 } },
|
||||||
|
{ date: '2018-07-17', temperature: 36.65, cervix: { opening: 0, firmness: 1 } },
|
||||||
|
{ date: '2018-07-18', temperature: 36.75, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-07-19', temperature: 36.8, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-07-20', temperature: 36.85, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-07-23', temperature: 36.9, cervix: { opening: 0, firmness: 1 } },
|
||||||
|
{ date: '2018-07-24', temperature: 36.85, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-07-26', temperature: 36.8, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-07-27', temperature: 36.9, cervix: { opening: 1, firmness: 1 } }
|
||||||
|
].map(convertToSymptoFormat).reverse()
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import Realm from 'realm'
|
import Realm from 'realm'
|
||||||
import { LocalDate, ChronoUnit } from 'js-joda'
|
import { LocalDate, ChronoUnit } from 'js-joda'
|
||||||
import {
|
import {
|
||||||
|
cycleWithFhmMucus,
|
||||||
|
longAndComplicatedCycleWithMucus,
|
||||||
cycleWithTempAndNoMucusShift,
|
cycleWithTempAndNoMucusShift,
|
||||||
cycleWithFhm,
|
cycleWithFhmCervix,
|
||||||
longAndComplicatedCycle
|
longAndComplicatedCycleWithCervix,
|
||||||
|
cycleWithTempAndNoCervixShift
|
||||||
} from './fixtures'
|
} from './fixtures'
|
||||||
|
|
||||||
const TemperatureSchema = {
|
const TemperatureSchema = {
|
||||||
@@ -179,10 +182,10 @@ function getCycleDay(localDate) {
|
|||||||
return db.objectForPrimaryKey('CycleDay', localDate)
|
return db.objectForPrimaryKey('CycleDay', localDate)
|
||||||
}
|
}
|
||||||
|
|
||||||
function fillWithDummyData() {
|
function fillWithMucusDummyData() {
|
||||||
const dummyCycles = [
|
const dummyCycles = [
|
||||||
cycleWithFhm,
|
cycleWithFhmMucus,
|
||||||
longAndComplicatedCycle,
|
longAndComplicatedCycleWithMucus,
|
||||||
cycleWithTempAndNoMucusShift
|
cycleWithTempAndNoMucusShift
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -204,6 +207,32 @@ function fillWithDummyData() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fillWithCervixDummyData() {
|
||||||
|
const dummyCycles = [
|
||||||
|
cycleWithFhmCervix,
|
||||||
|
longAndComplicatedCycleWithCervix,
|
||||||
|
cycleWithTempAndNoCervixShift
|
||||||
|
]
|
||||||
|
|
||||||
|
db.write(() => {
|
||||||
|
db.deleteAll()
|
||||||
|
dummyCycles.forEach(cycle => {
|
||||||
|
cycle.forEach(day => {
|
||||||
|
const existing = getCycleDay(day.date)
|
||||||
|
if (existing) {
|
||||||
|
Object.keys(day).forEach(key => {
|
||||||
|
if (key === 'date') return
|
||||||
|
existing[key] = day[key]
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
db.create('CycleDay', day)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function deleteAll() {
|
function deleteAll() {
|
||||||
db.write(() => {
|
db.write(() => {
|
||||||
db.deleteAll()
|
db.deleteAll()
|
||||||
@@ -266,7 +295,8 @@ export {
|
|||||||
bleedingDaysSortedByDate,
|
bleedingDaysSortedByDate,
|
||||||
temperatureDaysSortedByDate,
|
temperatureDaysSortedByDate,
|
||||||
cycleDaysSortedByDate,
|
cycleDaysSortedByDate,
|
||||||
fillWithDummyData,
|
fillWithMucusDummyData,
|
||||||
|
fillWithCervixDummyData,
|
||||||
deleteAll,
|
deleteAll,
|
||||||
getPreviousTemperature,
|
getPreviousTemperature,
|
||||||
getCycleDay,
|
getCycleDay,
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
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
|
||||||
|
// * 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 (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)
|
||||||
|
})
|
||||||
|
if (fertileCervixOccursIn3FollowingDays) continue
|
||||||
|
|
||||||
|
const cycleDayIndex = cycleDays.indexOf(day)
|
||||||
|
const relevantDays = cycleDays
|
||||||
|
.slice(cycleDayIndex + 1, tempEvalEndIndex + 1)
|
||||||
|
.filter(day => day.cervix && !day.cervix.exclude)
|
||||||
|
|
||||||
|
const onlyClosedAndHardUntilEndOfTempEval = relevantDays.every(day => {
|
||||||
|
return isClosedAndHard(day.cervix)
|
||||||
|
})
|
||||||
|
|
||||||
|
if (onlyClosedAndHardUntilEndOfTempEval) {
|
||||||
|
return {
|
||||||
|
detected: true,
|
||||||
|
cervixPeakBeforeShift: day,
|
||||||
|
evaluationCompleteDay: threeFollowingDays[threeFollowingDays.length - 1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return notDetected
|
||||||
|
}
|
||||||
|
|
||||||
|
function isClosedAndHard (cervixDay) {
|
||||||
|
return cervixDay.opening === 0 && cervixDay.firmness === 0
|
||||||
|
}
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
import getTemperatureShift from './temperature'
|
import getTemperatureShift from './temperature'
|
||||||
import getMucusShift from './mucus'
|
import getMucusShift from './mucus'
|
||||||
|
import getCervixShift from './cervix'
|
||||||
import getPreOvulatoryPhase from './pre-ovulatory'
|
import getPreOvulatoryPhase from './pre-ovulatory'
|
||||||
import { LocalDate } from 'js-joda'
|
import { LocalDate } from 'js-joda'
|
||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
|
|
||||||
export default function getSymptoThermalStatus(cycles) {
|
export default function getSymptoThermalStatus(cycleInfo) {
|
||||||
const { cycle, previousCycle, earlierCycles = [] } = cycles
|
const { cycle, previousCycle, earlierCycles = [], secondarySymptom = 'mucus' } = cycleInfo
|
||||||
throwIfArgsAreNotInRequiredFormat([cycle, ...earlierCycles])
|
throwIfArgsAreNotInRequiredFormat([cycle, ...earlierCycles])
|
||||||
|
|
||||||
const status = {
|
const status = {
|
||||||
@@ -15,7 +16,10 @@ export default function getSymptoThermalStatus(cycles) {
|
|||||||
// if there was no first higher measurement in the previous cycle,
|
// if there was no first higher measurement in the previous cycle,
|
||||||
// no infertile pre-ovulatory phase may be assumed
|
// no infertile pre-ovulatory phase may be assumed
|
||||||
if (previousCycle) {
|
if (previousCycle) {
|
||||||
const statusForLast = getSymptoThermalStatus({ cycle: previousCycle })
|
const statusForLast = getSymptoThermalStatus({
|
||||||
|
cycle: previousCycle,
|
||||||
|
secondarySymptom: secondarySymptom
|
||||||
|
})
|
||||||
if (statusForLast.temperatureShift) {
|
if (statusForLast.temperatureShift) {
|
||||||
const preOvuPhase = getPreOvulatoryPhase(
|
const preOvuPhase = getPreOvulatoryPhase(
|
||||||
cycle,
|
cycle,
|
||||||
@@ -48,20 +52,28 @@ export default function getSymptoThermalStatus(cycles) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const temperatureShift = getTemperatureShift(cycle)
|
const temperatureShift = getTemperatureShift(cycle)
|
||||||
|
|
||||||
if (!temperatureShift.detected) return status
|
if (!temperatureShift.detected) return status
|
||||||
|
|
||||||
const tempEvalEndIndex = cycle.indexOf(temperatureShift.evaluationCompleteDay)
|
const tempEvalEndIndex = cycle.indexOf(temperatureShift.evaluationCompleteDay)
|
||||||
const mucusShift = getMucusShift(cycle, tempEvalEndIndex)
|
|
||||||
if (!mucusShift.detected) return status
|
let secondaryShift
|
||||||
|
if (secondarySymptom === 'mucus') {
|
||||||
|
secondaryShift = getMucusShift(cycle, tempEvalEndIndex)
|
||||||
|
} else if (secondarySymptom === 'cervix') {
|
||||||
|
secondaryShift = getCervixShift(cycle, tempEvalEndIndex)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!secondaryShift.detected) return status
|
||||||
|
|
||||||
let periOvulatoryEnd
|
let periOvulatoryEnd
|
||||||
const tempOver = temperatureShift.evaluationCompleteDay.date
|
const tempOver = temperatureShift.evaluationCompleteDay.date
|
||||||
const mucusOver = mucusShift.evaluationCompleteDay.date
|
const secondarySymptomOver = secondaryShift.evaluationCompleteDay.date
|
||||||
|
|
||||||
if (tempOver > mucusOver) {
|
if (tempOver >= secondarySymptomOver) {
|
||||||
periOvulatoryEnd = temperatureShift.evaluationCompleteDay
|
periOvulatoryEnd = temperatureShift.evaluationCompleteDay
|
||||||
} else {
|
} else if (secondarySymptom > tempOver) {
|
||||||
periOvulatoryEnd = mucusShift.evaluationCompleteDay
|
periOvulatoryEnd = secondaryShift.evaluationCompleteDay
|
||||||
}
|
}
|
||||||
|
|
||||||
const previousPeriDays = periPhase.cycleDays
|
const previousPeriDays = periPhase.cycleDays
|
||||||
@@ -78,7 +90,12 @@ export default function getSymptoThermalStatus(cycles) {
|
|||||||
periPhase.cycleDays = previousPeriDays.slice(0, previousPeriEndIndex + 1)
|
periPhase.cycleDays = previousPeriDays.slice(0, previousPeriEndIndex + 1)
|
||||||
periPhase.end = status.phases.postOvulatory.start
|
periPhase.end = status.phases.postOvulatory.start
|
||||||
|
|
||||||
status.mucusShift = mucusShift
|
if (secondarySymptom === 'mucus') {
|
||||||
|
status.mucusShift = secondaryShift
|
||||||
|
} else if (secondarySymptom === 'cervix') {
|
||||||
|
status.cervixShift = secondaryShift
|
||||||
|
}
|
||||||
|
|
||||||
status.temperatureShift = temperatureShift
|
status.temperatureShift = temperatureShift
|
||||||
|
|
||||||
return status
|
return status
|
||||||
@@ -86,18 +103,23 @@ export default function getSymptoThermalStatus(cycles) {
|
|||||||
|
|
||||||
function throwIfArgsAreNotInRequiredFormat(cycles) {
|
function throwIfArgsAreNotInRequiredFormat(cycles) {
|
||||||
cycles.forEach(cycle => {
|
cycles.forEach(cycle => {
|
||||||
assert.ok(Array.isArray(cycle))
|
assert.ok(Array.isArray(cycle), "Cycles must be arrays.")
|
||||||
assert.ok(cycle.length > 0)
|
assert.ok(cycle.length > 0, "Cycle must not be empty.")
|
||||||
assert.ok(cycle[0].bleeding !== null)
|
assert.ok(cycle[0].bleeding !== null, "First cycle day should have bleeding.")
|
||||||
assert.equal(typeof cycle[0].bleeding, 'object')
|
assert.equal(typeof cycle[0].bleeding, 'object', "First cycle day must contain bleeding value.")
|
||||||
assert.equal(typeof cycle[0].bleeding.value, 'number')
|
assert.equal(typeof cycle[0].bleeding.value, 'number', "First cycle day bleeding value must be a number.")
|
||||||
cycle.forEach(day => {
|
cycle.forEach(day => {
|
||||||
assert.equal(typeof day.date, 'string')
|
assert.equal(typeof day.date, 'string', "Date must be given as a string.")
|
||||||
assert.doesNotThrow(() => LocalDate.parse(day.date))
|
assert.doesNotThrow(() => LocalDate.parse(day.date), "Date must be given in right string format.")
|
||||||
if (day.temperature) assert.equal(typeof day.temperature.value, 'number')
|
if (day.temperature) assert.equal(typeof day.temperature.value, 'number', "Temperature value must be a number.")
|
||||||
if (day.mucus) assert.equal(typeof day.mucus.value, 'number')
|
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)
|
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 < 5)
|
if (day.mucus) assert.ok(day.mucus.value <= 4, "Mucus value must be below 5.")
|
||||||
|
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")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ 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 = getDaysUntilFertileMucus(maybePreOvuDays)
|
const preOvulatoryDays = getDaysUntilFertileSecondarySymptom(maybePreOvuDays)
|
||||||
// if mucus 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
|
||||||
|
|
||||||
let endDate
|
let endDate
|
||||||
@@ -34,13 +34,17 @@ export default function(cycle, previousCycles) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDaysUntilFertileMucus(days) {
|
function getDaysUntilFertileSecondarySymptom(days, secondarySymptom = 'mucus') {
|
||||||
const firstFertileMucusDayIndex = days.findIndex(day => {
|
const firstFertileSecondarySymptomDayIndex = days.findIndex(day => {
|
||||||
return day.mucus && day.mucus.value > 1
|
if (secondarySymptom === 'mucus') {
|
||||||
|
return day.mucus && day.mucus.value > 1
|
||||||
|
} else if (secondarySymptom === 'cervix') {
|
||||||
|
return day.cervix && !day.cervix.isClosedAndHard
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if (firstFertileMucusDayIndex > -1) {
|
if (firstFertileSecondarySymptomDayIndex > -1) {
|
||||||
return days.slice(0, firstFertileMucusDayIndex)
|
return days.slice(0, firstFertileSecondarySymptomDayIndex)
|
||||||
}
|
}
|
||||||
return days
|
return days
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,18 +39,18 @@ function checkIfFirstHighMeasurement(temp, i, temperatureDays, ltl) {
|
|||||||
if (i > temperatureDays.length - 3) {
|
if (i > temperatureDays.length - 3) {
|
||||||
return { detected: false }
|
return { detected: false }
|
||||||
}
|
}
|
||||||
const nextDays = temperatureDays.slice(i + 1, i + 4)
|
const nextDaysAfterPotentialFhm = temperatureDays.slice(i + 1, i + 4)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
getResultForRegularRule(nextDays, ltl)) ||
|
getResultForRegularRule(nextDaysAfterPotentialFhm, ltl)) ||
|
||||||
getResultForFirstExceptionRule(nextDays, ltl) ||
|
getResultForFirstExceptionRule(nextDaysAfterPotentialFhm, ltl) ||
|
||||||
getResultForSecondExceptionRule(nextDays, ltl) ||
|
getResultForSecondExceptionRule(nextDaysAfterPotentialFhm, ltl) ||
|
||||||
{ detected: false }
|
{ detected: false }
|
||||||
}
|
}
|
||||||
|
|
||||||
function getResultForRegularRule(nextDays, ltl) {
|
function getResultForRegularRule(nextDaysAfterPotentialFhm, ltl) {
|
||||||
if (!nextDays.every(day => day.temp > ltl)) return false
|
if (!nextDaysAfterPotentialFhm.every(day => day.temp > ltl)) return false
|
||||||
const thirdDay = nextDays[1]
|
const thirdDay = nextDaysAfterPotentialFhm[1]
|
||||||
if (rounded(thirdDay.temp - ltl, 0.1) < 0.2) return false
|
if (rounded(thirdDay.temp - ltl, 0.1) < 0.2) return false
|
||||||
return {
|
return {
|
||||||
detected: true,
|
detected: true,
|
||||||
@@ -60,10 +60,10 @@ function getResultForRegularRule(nextDays, ltl) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getResultForFirstExceptionRule(nextDays, ltl) {
|
function getResultForFirstExceptionRule(nextDaysAfterPotentialFhm, ltl) {
|
||||||
if (nextDays.length < 3) return false
|
if (nextDaysAfterPotentialFhm.length < 3) return false
|
||||||
if (!nextDays.every(day => day.temp > ltl)) return false
|
if (!nextDaysAfterPotentialFhm.every(day => day.temp > ltl)) return false
|
||||||
const fourthDay = nextDays[2]
|
const fourthDay = nextDaysAfterPotentialFhm[2]
|
||||||
if (fourthDay.temp <= ltl) return false
|
if (fourthDay.temp <= ltl) return false
|
||||||
return {
|
return {
|
||||||
detected: true,
|
detected: true,
|
||||||
@@ -73,10 +73,10 @@ function getResultForFirstExceptionRule(nextDays, ltl) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getResultForSecondExceptionRule(nextDays, ltl) {
|
function getResultForSecondExceptionRule(nextDaysAfterPotentialFhm, ltl) {
|
||||||
if (nextDays.length < 3) return false
|
if (nextDaysAfterPotentialFhm.length < 3) return false
|
||||||
if (secondOrThirdTempIsAtOrBelowLtl(nextDays, ltl)) {
|
if (secondOrThirdTempIsAtOrBelowLtl(nextDaysAfterPotentialFhm, ltl)) {
|
||||||
const fourthDay = nextDays[2]
|
const fourthDay = nextDaysAfterPotentialFhm[2]
|
||||||
if (rounded(fourthDay.temp - ltl, 0.1) >= 0.2) {
|
if (rounded(fourthDay.temp - ltl, 0.1) >= 0.2) {
|
||||||
return {
|
return {
|
||||||
detected: true,
|
detected: true,
|
||||||
@@ -89,9 +89,9 @@ function getResultForSecondExceptionRule(nextDays, ltl) {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
function secondOrThirdTempIsAtOrBelowLtl(nextDays, ltl) {
|
function secondOrThirdTempIsAtOrBelowLtl(nextDaysAfterPotentialFhm, ltl) {
|
||||||
const secondIsLow = nextDays[0].temp <= ltl
|
const secondIsLow = nextDaysAfterPotentialFhm[0].temp <= ltl
|
||||||
const thirdIsLow = nextDays[1].temp <= ltl
|
const thirdIsLow = nextDaysAfterPotentialFhm[1].temp <= ltl
|
||||||
if ((secondIsLow || thirdIsLow) && !(secondIsLow && thirdIsLow)) {
|
if ((secondIsLow || thirdIsLow) && !(secondIsLow && thirdIsLow)) {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -33,11 +33,8 @@
|
|||||||
"react-native-modal-datetime-picker-nevo": "^4.11.0",
|
"react-native-modal-datetime-picker-nevo": "^4.11.0",
|
||||||
"react-native-push-notification": "^3.1.1",
|
"react-native-push-notification": "^3.1.1",
|
||||||
"react-native-share": "^1.1.0",
|
"react-native-share": "^1.1.0",
|
||||||
"react-native-simple-radio-button": "^2.7.1",
|
|
||||||
"react-native-vector-icons": "^5.0.0",
|
"react-native-vector-icons": "^5.0.0",
|
||||||
"react-navigation": "^2.0.4",
|
"realm": "^2.7.1"
|
||||||
"realm": "^2.7.1",
|
|
||||||
"uuid": "^3.2.1"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/register": "^7.0.0-beta.55",
|
"@babel/register": "^7.0.0-beta.55",
|
||||||
@@ -47,8 +44,7 @@
|
|||||||
"dirty-chai": "^2.0.1",
|
"dirty-chai": "^2.0.1",
|
||||||
"eslint": "^4.19.1",
|
"eslint": "^4.19.1",
|
||||||
"eslint-plugin-react": "^7.8.2",
|
"eslint-plugin-react": "^7.8.2",
|
||||||
"mocha": "^5.2.0",
|
"mocha": "^5.2.0"
|
||||||
"react-test-renderer": "16.3.1"
|
|
||||||
},
|
},
|
||||||
"description": "A menstrual cycle tracking app that's open-source and leaves your data on your phone. Use it to track your menstrual cycle or for fertility awareness!",
|
"description": "A menstrual cycle tracking app that's open-source and leaves your data on your phone. Use it to track your menstrual cycle or for fertility awareness!",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ export const shadesOfRed = ['#ffcbbf', '#ffb19f', '#ff977e', '#ff7e5f'] // light
|
|||||||
export const shadesOfGrey = ['#e5e5e5', '#cccccc'] // [lighter, darker]
|
export const shadesOfGrey = ['#e5e5e5', '#cccccc'] // [lighter, darker]
|
||||||
|
|
||||||
export default StyleSheet.create({
|
export default StyleSheet.create({
|
||||||
|
appText: {
|
||||||
|
color: 'black'
|
||||||
|
},
|
||||||
welcome: {
|
welcome: {
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
margin: 30,
|
margin: 30,
|
||||||
@@ -25,20 +28,15 @@ export default StyleSheet.create({
|
|||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
marginLeft: 15
|
marginLeft: 15
|
||||||
},
|
},
|
||||||
symptomDayView: {
|
symptomViewHeading: {
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
textAlignVertical: 'center'
|
color: 'black',
|
||||||
|
marginBottom: 5
|
||||||
},
|
},
|
||||||
symptomBoxImage: {
|
symptomBoxImage: {
|
||||||
width: 50,
|
width: 50,
|
||||||
height: 50
|
height: 50
|
||||||
},
|
},
|
||||||
radioButton: {
|
|
||||||
fontSize: 18,
|
|
||||||
margin: 8,
|
|
||||||
textAlign: 'center',
|
|
||||||
textAlignVertical: 'center'
|
|
||||||
},
|
|
||||||
symptomBoxesView: {
|
symptomBoxesView: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
flexWrap: 'wrap',
|
flexWrap: 'wrap',
|
||||||
@@ -85,17 +83,6 @@ export default StyleSheet.create({
|
|||||||
symptomDataText: {
|
symptomDataText: {
|
||||||
fontSize: 12
|
fontSize: 12
|
||||||
},
|
},
|
||||||
symptomEditRow: {
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
marginBottom: 10,
|
|
||||||
},
|
|
||||||
symptomViewRowInline: {
|
|
||||||
flexDirection: 'row',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
marginBottom: 10,
|
|
||||||
alignItems: 'center',
|
|
||||||
height: 50
|
|
||||||
},
|
|
||||||
header: {
|
header: {
|
||||||
backgroundColor: primaryColor,
|
backgroundColor: primaryColor,
|
||||||
paddingHorizontal: 15,
|
paddingHorizontal: 15,
|
||||||
@@ -152,11 +139,6 @@ export default StyleSheet.create({
|
|||||||
symptomEditButton: {
|
symptomEditButton: {
|
||||||
width: 130
|
width: 130
|
||||||
},
|
},
|
||||||
radioButtonRow: {
|
|
||||||
marginTop: 15,
|
|
||||||
marginLeft: 'auto',
|
|
||||||
marginRight: 'auto'
|
|
||||||
},
|
|
||||||
statsIntro: {
|
statsIntro: {
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
margin: 10,
|
margin: 10,
|
||||||
@@ -200,6 +182,57 @@ export default StyleSheet.create({
|
|||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
color: fontOnPrimaryColor
|
color: fontOnPrimaryColor
|
||||||
},
|
},
|
||||||
|
selectBox: {
|
||||||
|
backgroundColor: 'lightgrey',
|
||||||
|
marginRight: 7,
|
||||||
|
marginVertical: 5,
|
||||||
|
paddingHorizontal: 15,
|
||||||
|
paddingVertical: 10,
|
||||||
|
borderRadius: 10
|
||||||
|
},
|
||||||
|
selectBoxActive: {
|
||||||
|
backgroundColor: secondaryColor,
|
||||||
|
color: fontOnPrimaryColor
|
||||||
|
},
|
||||||
|
selectBoxTextActive: {
|
||||||
|
color: fontOnPrimaryColor
|
||||||
|
},
|
||||||
|
selectBoxSection: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
flexWrap: 'wrap',
|
||||||
|
marginVertical: 10,
|
||||||
|
},
|
||||||
|
selectTabGroup: {
|
||||||
|
marginVertical: 10,
|
||||||
|
flexDirection: 'row'
|
||||||
|
},
|
||||||
|
selectTab: {
|
||||||
|
backgroundColor: 'lightgrey',
|
||||||
|
borderStyle: 'solid',
|
||||||
|
borderLeftWidth: 1,
|
||||||
|
paddingVertical: 10,
|
||||||
|
paddingHorizontal: 15,
|
||||||
|
borderColor: 'white',
|
||||||
|
marginBottom: 3,
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center'
|
||||||
|
},
|
||||||
|
selectTabActive: {
|
||||||
|
backgroundColor: secondaryColor,
|
||||||
|
color: fontOnPrimaryColor
|
||||||
|
},
|
||||||
|
selectTabLast: {
|
||||||
|
borderTopRightRadius: 10,
|
||||||
|
borderBottomRightRadius: 10,
|
||||||
|
},
|
||||||
|
selectTabFirst: {
|
||||||
|
borderTopLeftRadius: 10,
|
||||||
|
borderBottomLeftRadius: 10,
|
||||||
|
borderLeftWidth: null
|
||||||
|
},
|
||||||
|
page: {
|
||||||
|
marginHorizontal: 10
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
export const iconStyles = {
|
export const iconStyles = {
|
||||||
@@ -219,5 +252,5 @@ export const iconStyles = {
|
|||||||
},
|
},
|
||||||
menuIconInactive: {
|
menuIconInactive: {
|
||||||
color: 'lightgrey'
|
color: 'lightgrey'
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,188 @@
|
|||||||
|
function convertToSymptoFormat(val) {
|
||||||
|
const sympto = { date: val.date }
|
||||||
|
if (val.temperature) sympto.temperature = {
|
||||||
|
value: val.temperature,
|
||||||
|
exclude: false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (val.cervix && typeof val.cervix.opening === 'number' && typeof val.cervix.firmness === 'number') sympto.cervix = {
|
||||||
|
opening: val.cervix.opening,
|
||||||
|
firmness: val.cervix.firmness,
|
||||||
|
exclude: false
|
||||||
|
}
|
||||||
|
if (val.bleeding) sympto.bleeding = {
|
||||||
|
value: val.bleeding,
|
||||||
|
exclude: false
|
||||||
|
}
|
||||||
|
return sympto
|
||||||
|
}
|
||||||
|
|
||||||
|
export const cervixShiftAndFhmOnSameDay = [
|
||||||
|
{ date: '2018-08-01', bleeding: 1, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-08-02', bleeding: 2, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-08-03', temperature: 36.6, bleeding: 2, cervix: { opening: 2, firmness: 1 } },
|
||||||
|
{ date: '2018-08-04', temperature: 36.55, bleeding: 1, cervix: { opening: 2, firmness: 0 } },
|
||||||
|
{ date: '2018-08-05', temperature: 36.6, cervix: { opening: 0, firmness: 1 } },
|
||||||
|
{ date: '2018-08-06', temperature: 36.65, cervix: { opening: 0, firmness: 1 } },
|
||||||
|
{ date: '2018-08-07', temperature: 36.71, cervix: { opening: 1, firmness: 0 } },
|
||||||
|
{ date: '2018-08-08', temperature: 36.69, cervix: { opening: 1, firmness: 0 } },
|
||||||
|
{ date: '2018-08-09', temperature: 36.64, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-08-10', temperature: 36.66, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-08-11', temperature: 36.61, cervix: { opening: 1, firmness: 0 } },
|
||||||
|
{ date: '2018-08-12', temperature: 36.6, cervix: { opening: 0, firmness: 1 } },
|
||||||
|
{ date: '2018-08-13', temperature: 36.8, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-08-14', temperature: 36.85, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-08-15', temperature: 36.9, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-08-16', temperature: 36.95, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-08-17', temperature: 36.95, cervix: { opening: 0, firmness: 0 } }
|
||||||
|
].map(convertToSymptoFormat)
|
||||||
|
|
||||||
|
export const cycleWithFhmNoCervixShift = [
|
||||||
|
{ date: '2018-08-01', bleeding: 1 },
|
||||||
|
{ date: '2018-08-02', bleeding: 2 },
|
||||||
|
{ date: '2018-08-03', temperature: 36.6, bleeding: 2 },
|
||||||
|
{ date: '2018-08-04', temperature: 36.55, bleeding: 1 },
|
||||||
|
{ date: '2018-08-05', temperature: 36.6 },
|
||||||
|
{ date: '2018-08-06', temperature: 36.65, cervix: { opening: 0, firmness: 1 } },
|
||||||
|
{ date: '2018-08-07', temperature: 36.7, cervix: { opening: 1, firmness: 0 } },
|
||||||
|
{ date: '2018-08-08', temperature: 36.6, cervix: { opening: 0, firmness: 1 } },
|
||||||
|
{ date: '2018-08-09', temperature: 36.8, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-08-10', temperature: 36.85, cervix: { opening: 2, firmness: 0 } },
|
||||||
|
{ date: '2018-08-11', temperature: 36.9, cervix: { opening: 1, firmness: 0 } },
|
||||||
|
{ date: '2018-08-12', temperature: 36.95, cervix: { opening: 0, firmness: 1 } },
|
||||||
|
{ date: '2018-08-13', temperature: 36.95, cervix: { opening: 0, firmness: 0 } }
|
||||||
|
].map(convertToSymptoFormat)
|
||||||
|
|
||||||
|
export const cycleWithoutFhmNoCervixShift = [
|
||||||
|
{ date: '2018-06-02', temperature: 36.6, bleeding: 2 },
|
||||||
|
{ date: '2018-06-03', temperature: 36.65 },
|
||||||
|
{ date: '2018-06-04', temperature: 36.6 },
|
||||||
|
{ date: '2018-06-05', temperature: 36.55 },
|
||||||
|
{ date: '2018-06-06', temperature: 36.7, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-06-09', temperature: 36.8 },
|
||||||
|
{ date: '2018-06-10', temperature: 36.9, cervix: { opening: 2, firmness: 0 } },
|
||||||
|
{ date: '2018-06-13', temperature: 36.9, cervix: { opening: 1, firmness: 1 } }
|
||||||
|
].map(convertToSymptoFormat)
|
||||||
|
|
||||||
|
export const longCycleWithoutAnyShifts = [
|
||||||
|
{ date: '2018-07-01', temperature: 36.65, bleeding: 1 },
|
||||||
|
{ date: '2018-07-02', temperature: 36.45 },
|
||||||
|
{ date: '2018-07-03', temperature: 36.65 },
|
||||||
|
{ date: '2018-07-04', temperature: 36.65 },
|
||||||
|
{ date: '2018-07-05', temperature: 36.65, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-07-06', temperature: 36.85, cervix: { opening: 0, firmness: 1 } },
|
||||||
|
{ date: '2018-07-07', temperature: 36.65, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-07-08', temperature: 36.65, cervix: { opening: 2, firmness: 1 } },
|
||||||
|
{ date: '2018-07-09', temperature: 36.65, cervix: { opening: 2, firmness: 1 } },
|
||||||
|
{ date: '2018-07-10', temperature: 36.65, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-07-11', temperature: 36.35, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-07-12', temperature: 36.65, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-07-13', temperature: 36.25, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-07-14', temperature: 36.65, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-07-15', temperature: 36.65, cervix: { opening: 2, firmness: 0 } },
|
||||||
|
{ date: '2018-07-16', temperature: 36.15, cervix: { opening: 2, firmness: 1 } },
|
||||||
|
{ date: '2018-07-17', temperature: 36.65, cervix: { opening: 0, firmness: 1 } },
|
||||||
|
{ date: '2018-07-18', temperature: 36.25, cervix: { opening: 2, firmness: 1 } },
|
||||||
|
{ date: '2018-07-19', temperature: 36.65, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-07-20', temperature: 36.45, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-07-21', temperature: 36.52, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-07-22', temperature: 36.65, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-07-23', temperature: 36.75, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-07-24', temperature: 36.65, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-07-25', temperature: 36.65, cervix: { opening: 0, firmness: 1 } },
|
||||||
|
{ date: '2018-07-26', temperature: 36.65, cervix: { opening: 2, firmness: 1 } },
|
||||||
|
].map(convertToSymptoFormat)
|
||||||
|
|
||||||
|
export const longAndComplicatedCycle = [
|
||||||
|
{ date: '2018-06-01', temperature: 36.6, bleeding: 2 },
|
||||||
|
{ date: '2018-06-02', temperature: 36.65 },
|
||||||
|
{ date: '2018-06-04', temperature: 36.6 },
|
||||||
|
{ date: '2018-06-05', temperature: 36.55 },
|
||||||
|
{ date: '2018-06-06', temperature: 36.7, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-06-09', temperature: 36.5, cervix: { opening: 2, firmness: 1 } },
|
||||||
|
{ date: '2018-06-10', temperature: 36.4, cervix: { opening: 2, firmness: 1 } },
|
||||||
|
{ date: '2018-06-13', temperature: 36.45, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-14', temperature: 36.5, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-15', temperature: 36.55, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-16', temperature: 36.7, cervix: { opening: 2, firmness: 1 } },
|
||||||
|
{ date: '2018-06-17', temperature: 36.65, cervix: { opening: 2, firmness: 1 } },
|
||||||
|
{ date: '2018-06-18', temperature: 36.75, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-19', temperature: 36.8, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-06-20', temperature: 36.85, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-21', temperature: 36.8, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-06-22', temperature: 36.9, cervix: { opening: 2, firmness: 1 } },
|
||||||
|
{ date: '2018-06-25', temperature: 36.9, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-06-26', temperature: 36.8, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-06-27', temperature: 36.9, cervix: { opening: 0, firmness: 0 } }
|
||||||
|
].map(convertToSymptoFormat)
|
||||||
|
|
||||||
|
export const tempShift3DaysAfterCervixShift = [
|
||||||
|
{ date: '2018-05-08', bleeding: 3 },
|
||||||
|
{ date: '2018-05-09', bleeding: 2 },
|
||||||
|
{ date: '2018-05-10', bleeding: 2 },
|
||||||
|
{ date: '2018-05-11', bleeding: 1 },
|
||||||
|
{ date: '2018-05-12', temperature: 36.3 },
|
||||||
|
{ date: '2018-05-13', temperature: 36.4, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-05-14', temperature: 36.3, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-05-15', temperature: 36.2, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-05-16', temperature: 36.3, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-05-17', temperature: 36.3, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-05-18', temperature: 36.35, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-05-19', temperature: 36.65, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-05-20', temperature: 36.7, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-05-21', temperature: 36.6, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-05-22', temperature: 36.85, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-05-23', temperature: 36.8, cervix: { opening: 1, firmness: 0 } },
|
||||||
|
{ date: '2018-05-24', temperature: 36.85, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-05-25', temperature: 36.95, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-05-26', temperature: 36.85, cervix: { opening: 0, firmness: 1 } },
|
||||||
|
{ date: '2018-05-27', temperature: 36.8, cervix: { opening: 1, firmness: 0 } },
|
||||||
|
{ date: '2018-05-28', temperature: 36.6, cervix: { opening: 1, firmness: 0 } },
|
||||||
|
{ date: '2018-05-29', bleeding: 2 }
|
||||||
|
].map(convertToSymptoFormat)
|
||||||
|
|
||||||
|
export const cervixShift2DaysAfterTempShift = [
|
||||||
|
{ date: '2018-04-05', bleeding: 3 },
|
||||||
|
{ date: '2018-04-06', bleeding: 2 },
|
||||||
|
{ date: '2018-04-07', bleeding: 2 },
|
||||||
|
{ date: '2018-04-08', bleeding: 1 },
|
||||||
|
{ date: '2018-04-09', temperature: 36.5 },
|
||||||
|
{ date: '2018-04-10', temperature: 36.5, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-04-11', temperature: 36.55, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-04-12', temperature: 36.5, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-04-13', temperature: 36.35, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-04-14', temperature: 36.35, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-04-15', temperature: 36.6, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-04-16', temperature: 36.8, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-04-17', temperature: 36.8, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-04-18', temperature: 36.8, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-04-19', temperature: 36.85, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-04-20', temperature: 37.0, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-04-22', temperature: 36.9, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-04-23', temperature: 37.1, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-04-24', temperature: 36.75, cervix: { opening: 0, firmness: 0 } }
|
||||||
|
].map(convertToSymptoFormat)
|
||||||
|
|
||||||
|
export const noOvulationDetected = [
|
||||||
|
{ date: '2018-03-08', bleeding: 3 },
|
||||||
|
{ date: '2018-03-09', bleeding: 3 },
|
||||||
|
{ date: '2018-03-10', bleeding: 3 },
|
||||||
|
{ date: '2018-03-11', bleeding: 3 },
|
||||||
|
{ date: '2018-03-12', temperature: 36.3, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-03-13', temperature: 36.5, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-03-14', temperature: 36.45, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-03-15', temperature: 36.4, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-03-16', temperature: 36.2, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-03-17', temperature: 36.5, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-03-18', temperature: 36.6, cervix: { opening: 1, firmness: 1 } },
|
||||||
|
{ date: '2018-03-19', temperature: 36.35, cervix: { opening: 1, firmness: 0 } },
|
||||||
|
{ date: '2018-03-20', temperature: 36.8, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-03-21', temperature: 36.7, cervix: { opening: 0, firmness: 0 } },
|
||||||
|
{ date: '2018-03-22', temperature: 36.7, cervix: { opening: 0, firmness: 1 } },
|
||||||
|
{ date: '2018-03-23', temperature: 36.7, cervix: { opening: 0, firmness: 0 } }
|
||||||
|
].map(convertToSymptoFormat)
|
||||||
|
|
||||||
|
export const fiveDayCycle = [
|
||||||
|
{ date: '2018-08-01', bleeding: 2 },
|
||||||
|
{ date: '2018-08-03', bleeding: 3 }
|
||||||
|
].map(convertToSymptoFormat)
|
||||||
@@ -0,0 +1,221 @@
|
|||||||
|
import chai from 'chai'
|
||||||
|
import getSensiplanStatus from '../../lib/sympto'
|
||||||
|
import {
|
||||||
|
cervixShiftAndFhmOnSameDay,
|
||||||
|
cycleWithFhmNoCervixShift,
|
||||||
|
cycleWithoutFhm,
|
||||||
|
longCycleWithoutAnyShifts,
|
||||||
|
tempShift3DaysAfterCervixShift,
|
||||||
|
cervixShift2DaysAfterTempShift,
|
||||||
|
noOvulationDetected,
|
||||||
|
fiveDayCycle
|
||||||
|
} from './cervix-temp-fixtures'
|
||||||
|
|
||||||
|
const expect = chai.expect
|
||||||
|
|
||||||
|
describe('sympto', () => {
|
||||||
|
describe('combining temperature and cervix tracking', () => {
|
||||||
|
describe('with no previous higher temp measurement', () => {
|
||||||
|
it('with no temp or cervix shifts detects only peri-ovulatory', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: longCycleWithoutAnyShifts,
|
||||||
|
previousCycle: cycleWithoutFhm,
|
||||||
|
secondarySymptom: 'cervix'
|
||||||
|
})
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(1)
|
||||||
|
expect(status).to.eql({
|
||||||
|
phases: {
|
||||||
|
periOvulatory: {
|
||||||
|
start: { date: '2018-07-01' },
|
||||||
|
cycleDays: longCycleWithoutAnyShifts
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('with temp but no cervix shift detects only peri-ovulatory', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: cycleWithFhmNoCervixShift,
|
||||||
|
previousCycle: cycleWithoutFhm,
|
||||||
|
secondarySymptom: 'cervix'
|
||||||
|
})
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(1)
|
||||||
|
expect(status).to.eql({
|
||||||
|
phases: {
|
||||||
|
periOvulatory: {
|
||||||
|
start: { date: '2018-08-01' },
|
||||||
|
cycleDays: cycleWithFhmNoCervixShift
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('with temp and cervix shifts at the same day an no previous cycle detects only peri- and post-ovulatory phases', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: cervixShiftAndFhmOnSameDay,
|
||||||
|
secondarySymptom: 'cervix'
|
||||||
|
})
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(2)
|
||||||
|
expect(status.temperatureShift.evaluationCompleteDay.date).to.eql('2018-08-15')
|
||||||
|
expect(status.cervixShift.evaluationCompleteDay.date).to.eql('2018-08-15')
|
||||||
|
expect(status.temperatureShift.rule).to.eql(0)
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
start: { date: '2018-08-01' },
|
||||||
|
end: { date: '2018-08-15', time: '18:00' },
|
||||||
|
cycleDays: cervixShiftAndFhmOnSameDay
|
||||||
|
.filter(({date}) => date <= '2018-08-15')
|
||||||
|
})
|
||||||
|
expect(status.phases.postOvulatory).to.eql({
|
||||||
|
start: { date: '2018-08-15', time: '18:00' },
|
||||||
|
cycleDays: cervixShiftAndFhmOnSameDay
|
||||||
|
.filter(({date}) => date >= '2018-08-15')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
describe('with previous higher temp measurement', () => {
|
||||||
|
it('with no shifts in 5-day long cycle detects only peri-ovulatory according to 5-day rule', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: fiveDayCycle,
|
||||||
|
previousCycle: cervixShiftAndFhmOnSameDay,
|
||||||
|
secondarySymptom: 'cervix'
|
||||||
|
})
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(1)
|
||||||
|
expect(status.phases.preOvulatory).to.eql({
|
||||||
|
cycleDays: fiveDayCycle,
|
||||||
|
start: { date: '2018-08-01' },
|
||||||
|
end: { date: '2018-08-05' }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('with no shifts in long cycle detects pre- and peri-ovulatory phase according to 5-day-rule', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: longCycleWithoutAnyShifts,
|
||||||
|
previousCycle: cervixShiftAndFhmOnSameDay,
|
||||||
|
secondarySymptom: 'cervix'
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(2)
|
||||||
|
expect(status.phases.preOvulatory).to.eql({
|
||||||
|
cycleDays: longCycleWithoutAnyShifts
|
||||||
|
.filter(({date}) => date <= '2018-07-05'),
|
||||||
|
start: { date: '2018-07-01' },
|
||||||
|
end: { date: '2018-07-05' }
|
||||||
|
})
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
cycleDays: longCycleWithoutAnyShifts
|
||||||
|
.filter(({date}) => date >= '2018-07-06'),
|
||||||
|
start: { date: '2018-07-06' }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('with temperature and cervix evaluation end on same day detects all 3 phases', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: cervixShiftAndFhmOnSameDay,
|
||||||
|
previousCycle: cervixShiftAndFhmOnSameDay,
|
||||||
|
secondarySymptom: 'cervix'
|
||||||
|
})
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(3)
|
||||||
|
expect(status.temperatureShift.evaluationCompleteDay.date).to.eql('2018-08-15')
|
||||||
|
expect(status.cervixShift.evaluationCompleteDay.date).to.eql('2018-08-15')
|
||||||
|
|
||||||
|
expect(status.phases.preOvulatory).to.eql({
|
||||||
|
start: { date: '2018-08-01' },
|
||||||
|
end: { date: '2018-08-05' },
|
||||||
|
cycleDays: cervixShiftAndFhmOnSameDay
|
||||||
|
.filter(({date}) => date <= '2018-08-05')
|
||||||
|
})
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
start: { date: '2018-08-06' },
|
||||||
|
end: { date: '2018-08-15', time: '18:00' },
|
||||||
|
cycleDays: cervixShiftAndFhmOnSameDay
|
||||||
|
.filter(({date}) => {
|
||||||
|
return date > '2018-08-05' && date <= '2018-08-15'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
expect(status.phases.postOvulatory).to.eql({
|
||||||
|
start: { date: '2018-08-15', time: '18:00' },
|
||||||
|
cycleDays: cervixShiftAndFhmOnSameDay
|
||||||
|
.filter(({date}) => date >= '2018-08-15')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('with temperature shift 3 days after cervix shift detects all 3 phases', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: tempShift3DaysAfterCervixShift,
|
||||||
|
previousCycle: cervixShiftAndFhmOnSameDay,
|
||||||
|
secondarySymptom: 'cervix'
|
||||||
|
})
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(3)
|
||||||
|
expect(status.cervixShift).to.be.an('object')
|
||||||
|
expect(status.temperatureShift).to.be.an('object')
|
||||||
|
expect(status.cervixShift.evaluationCompleteDay.date).to.eql('2018-05-18')
|
||||||
|
expect(status.temperatureShift.evaluationCompleteDay.date).to.eql('2018-05-21')
|
||||||
|
|
||||||
|
expect(status.phases.preOvulatory).to.eql({
|
||||||
|
start: { date: '2018-05-08' },
|
||||||
|
end: { date: '2018-05-12' },
|
||||||
|
cycleDays: tempShift3DaysAfterCervixShift
|
||||||
|
.filter(({date}) => date <= '2018-05-12')
|
||||||
|
})
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
start: { date:'2018-05-13'},
|
||||||
|
end: { date: '2018-05-21', time: '18:00' },
|
||||||
|
cycleDays: tempShift3DaysAfterCervixShift
|
||||||
|
.filter(({date}) => {
|
||||||
|
return date >= '2018-05-13' && date <= '2018-05-21'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
expect(status.phases.postOvulatory).to.eql({
|
||||||
|
start: { date: '2018-05-21', time: '18:00' },
|
||||||
|
cycleDays: tempShift3DaysAfterCervixShift
|
||||||
|
.filter(({date}) => date >= '2018-05-21')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('with cervix shift 2 days after temperature shift detects all 3 phases', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: cervixShift2DaysAfterTempShift,
|
||||||
|
previousCycle: cervixShiftAndFhmOnSameDay,
|
||||||
|
secondarySymptom: 'cervix'
|
||||||
|
})
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(3)
|
||||||
|
expect(status.temperatureShift.rule).to.eql(0)
|
||||||
|
expect(status.temperatureShift.evaluationCompleteDay.date).to.eql('2018-04-17')
|
||||||
|
expect(status.cervixShift.evaluationCompleteDay.date).to.eql('2018-04-19')
|
||||||
|
|
||||||
|
expect(status.phases.preOvulatory).to.eql({
|
||||||
|
cycleDays: cervixShift2DaysAfterTempShift
|
||||||
|
.filter(({date}) => date <= '2018-04-09'),
|
||||||
|
start: { date: '2018-04-05' },
|
||||||
|
end: { date: '2018-04-09' }
|
||||||
|
})
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
cycleDays: cervixShift2DaysAfterTempShift
|
||||||
|
.filter(({date}) => {
|
||||||
|
return date >= '2018-04-10' && date <= '2018-04-19'
|
||||||
|
}),
|
||||||
|
start: { date: '2018-04-10' },
|
||||||
|
end: { date: '2018-04-19', time: '18:00' }
|
||||||
|
})
|
||||||
|
expect(status.phases.postOvulatory).to.eql({
|
||||||
|
cycleDays: cervixShift2DaysAfterTempShift
|
||||||
|
.filter(({date}) => date >= '2018-04-19'),
|
||||||
|
start: { date: '2018-04-19', time: '18:00' }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('with no shifts no ovulation is found detects only pre and peri-ovulatory phase', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: noOvulationDetected,
|
||||||
|
previousCycle: cervixShiftAndFhmOnSameDay,
|
||||||
|
secondarySymptom: 'cervix'
|
||||||
|
})
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(2)
|
||||||
|
expect(status.phases.preOvulatory).to.eql({
|
||||||
|
cycleDays: noOvulationDetected
|
||||||
|
.filter(({date}) => date <= '2018-03-12'),
|
||||||
|
start: { date: '2018-03-08' },
|
||||||
|
end: { date: '2018-03-12' }
|
||||||
|
})
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
cycleDays: noOvulationDetected
|
||||||
|
.filter(({date}) => date > '2018-03-12'),
|
||||||
|
start: { date: '2018-03-13' }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,165 @@
|
|||||||
|
import chai from 'chai'
|
||||||
|
import getCervixStatus from '../../lib/sympto/cervix'
|
||||||
|
|
||||||
|
const expect = chai.expect
|
||||||
|
|
||||||
|
function turnIntoCycleDayObject(value, fakeDate) {
|
||||||
|
const hardAndClosed = {
|
||||||
|
opening: 0,
|
||||||
|
firmness: 0
|
||||||
|
}
|
||||||
|
const hardAndOpen = {
|
||||||
|
opening: 1,
|
||||||
|
firmness: 0
|
||||||
|
}
|
||||||
|
const softAndClosed = {
|
||||||
|
opening: 0,
|
||||||
|
firmness: 1
|
||||||
|
}
|
||||||
|
const softAndOpen = {
|
||||||
|
opening: 1,
|
||||||
|
firmness: 1
|
||||||
|
}
|
||||||
|
const cervixStates = [hardAndClosed, hardAndOpen, softAndClosed, softAndOpen]
|
||||||
|
return {
|
||||||
|
date: fakeDate,
|
||||||
|
cervix: {
|
||||||
|
opening: cervixStates[value].opening,
|
||||||
|
firmness: cervixStates[value].firmness,
|
||||||
|
exclude: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('sympto', () => {
|
||||||
|
describe('detects cervix shift', () => {
|
||||||
|
it('when shift happens at day 13 with consistent following days of infertile cervix until tempEvalEnd', () => {
|
||||||
|
const values = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0]
|
||||||
|
.map(turnIntoCycleDayObject)
|
||||||
|
const status = getCervixStatus(values, 16)
|
||||||
|
expect(status).to.eql({
|
||||||
|
detected: true,
|
||||||
|
cervixPeakBeforeShift: {
|
||||||
|
date: 10,
|
||||||
|
cervix: {
|
||||||
|
opening: 1,
|
||||||
|
firmness: 1,
|
||||||
|
exclude: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
evaluationCompleteDay: {
|
||||||
|
date: 13,
|
||||||
|
cervix: {
|
||||||
|
opening: 0,
|
||||||
|
firmness: 0,
|
||||||
|
exclude: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('right at the start of cycle days even if later shift happens again because tempEvalEnd happened before second potential shift', () => {
|
||||||
|
const values = [2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||||
|
.map(turnIntoCycleDayObject)
|
||||||
|
const status = getCervixStatus(values, 5)
|
||||||
|
expect(status).to.eql({
|
||||||
|
detected: true,
|
||||||
|
cervixPeakBeforeShift: {
|
||||||
|
date: 0,
|
||||||
|
cervix: {
|
||||||
|
opening: 0,
|
||||||
|
firmness: 1,
|
||||||
|
exclude: false
|
||||||
|
},
|
||||||
|
},
|
||||||
|
evaluationCompleteDay: {
|
||||||
|
date: 3,
|
||||||
|
cervix: {
|
||||||
|
opening: 0,
|
||||||
|
firmness: 0,
|
||||||
|
exclude: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('at day 6 although right at the start of cycle days a potential shift happened but because tempEvalEnd happens after second shift', () => {
|
||||||
|
const values = [2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||||
|
.map(turnIntoCycleDayObject)
|
||||||
|
const status = getCervixStatus(values, 10)
|
||||||
|
expect(status).to.eql({
|
||||||
|
detected: true,
|
||||||
|
cervixPeakBeforeShift: {
|
||||||
|
date: 6,
|
||||||
|
cervix: {
|
||||||
|
opening: 1,
|
||||||
|
firmness: 0,
|
||||||
|
exclude: false
|
||||||
|
},
|
||||||
|
},
|
||||||
|
evaluationCompleteDay: {
|
||||||
|
date: 9,
|
||||||
|
cervix: {
|
||||||
|
opening: 0,
|
||||||
|
firmness: 0,
|
||||||
|
exclude: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('when the cervix shift is happening after tempEvalEnd', () => {
|
||||||
|
const values = [1,1,1,1,1,2,3,3,3,3,1,1,1,1,0,0,0,0,0,0,0]
|
||||||
|
.map(turnIntoCycleDayObject)
|
||||||
|
const status = getCervixStatus(values, 10)
|
||||||
|
expect(status).to.eql({
|
||||||
|
detected: true,
|
||||||
|
cervixPeakBeforeShift: {
|
||||||
|
date: 13,
|
||||||
|
cervix: {
|
||||||
|
opening: 1,
|
||||||
|
firmness: 0,
|
||||||
|
exclude: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
evaluationCompleteDay: {
|
||||||
|
date: 16,
|
||||||
|
cervix: {
|
||||||
|
opening: 0,
|
||||||
|
firmness: 0,
|
||||||
|
exclude: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('detects no cervix shift', () => {
|
||||||
|
it('if there are less than 3 days closed and hard cervix', () => {
|
||||||
|
const values = [0, 0, 0, 1, 1, 1, 2, 0, 3, 3, 3, 1, 1, 1, 0, 0, 2, 0]
|
||||||
|
.map(turnIntoCycleDayObject)
|
||||||
|
const status = getCervixStatus(values, 15)
|
||||||
|
expect(status).to.eql({ detected: false })
|
||||||
|
})
|
||||||
|
it('if cycleDays have not enough cervix values to detect valid cervix shift', () => {
|
||||||
|
const values = [2,0,0]
|
||||||
|
.map(turnIntoCycleDayObject)
|
||||||
|
const status = getCervixStatus(values, 17)
|
||||||
|
expect(status).to.eql({ detected: false })
|
||||||
|
})
|
||||||
|
it('if no days indicate fertile cervix which could be cervix peak', () => {
|
||||||
|
const values = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]
|
||||||
|
.map(turnIntoCycleDayObject)
|
||||||
|
const status = getCervixStatus(values, 12)
|
||||||
|
expect(status).to.eql({ detected: false })
|
||||||
|
})
|
||||||
|
it('if all days indicate infertile cervix values', () => {
|
||||||
|
const values = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
|
||||||
|
.map(turnIntoCycleDayObject)
|
||||||
|
const status = getCervixStatus(values, 9)
|
||||||
|
expect(status).to.eql({ detected: false })
|
||||||
|
})
|
||||||
|
it('if there are no cervix values', () => {
|
||||||
|
const values = [].map(turnIntoCycleDayObject)
|
||||||
|
const status = getCervixStatus(values, 15)
|
||||||
|
expect(status).to.eql({ detected: false })
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -1,660 +0,0 @@
|
|||||||
import chai from 'chai'
|
|
||||||
import getSensiplanStatus from '../../lib/sympto'
|
|
||||||
import { AssertionError } from 'assert'
|
|
||||||
import {
|
|
||||||
cycleWithoutFhm,
|
|
||||||
longAndComplicatedCycle,
|
|
||||||
cycleWithTempAndNoMucusShift,
|
|
||||||
cycleWithFhm,
|
|
||||||
cycleWithoutAnyShifts,
|
|
||||||
fiveDayCycle,
|
|
||||||
cycleWithEarlyMucus,
|
|
||||||
cycleWithMucusOnFirstDay,
|
|
||||||
mucusPeakAndFhmOnSameDay,
|
|
||||||
fhmTwoDaysBeforeMucusPeak,
|
|
||||||
fhm5DaysAfterMucusPeak,
|
|
||||||
mucusPeak5DaysAfterFhm,
|
|
||||||
mucusPeakTwoDaysBeforeFhm,
|
|
||||||
fhmOnDay12,
|
|
||||||
fhmOnDay15,
|
|
||||||
mucusPeakSlightlyBeforeTempShift,
|
|
||||||
highestMucusQualityAfterEndOfEval
|
|
||||||
} from './fixtures'
|
|
||||||
|
|
||||||
const expect = chai.expect
|
|
||||||
|
|
||||||
describe('sympto', () => {
|
|
||||||
describe('with no previous higher measurement', () => {
|
|
||||||
it('with no shifts detects only peri-ovulatory', function () {
|
|
||||||
const status = getSensiplanStatus({
|
|
||||||
cycle: cycleWithoutAnyShifts,
|
|
||||||
previousCycle: cycleWithoutFhm
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(status).to.eql({
|
|
||||||
|
|
||||||
phases: {
|
|
||||||
periOvulatory: {
|
|
||||||
start: { date: '2018-06-01' },
|
|
||||||
cycleDays: cycleWithoutAnyShifts
|
|
||||||
}
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
it('with shifts detects only peri-ovulatory and post-ovulatory', () => {
|
|
||||||
const status = getSensiplanStatus({
|
|
||||||
cycle: longAndComplicatedCycle,
|
|
||||||
previousCycle: cycleWithoutFhm
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(status.temperatureShift).to.be.an('object')
|
|
||||||
expect(status.mucusShift).to.be.an('object')
|
|
||||||
|
|
||||||
expect(Object.keys(status.phases).length).to.eql(2)
|
|
||||||
expect(status.phases.periOvulatory).to.eql({
|
|
||||||
start: { date: '2018-06-01' },
|
|
||||||
end: { date: '2018-06-21', time: '18:00' },
|
|
||||||
cycleDays: longAndComplicatedCycle
|
|
||||||
.filter(({date}) => date <= '2018-06-21')
|
|
||||||
})
|
|
||||||
expect(status.phases.postOvulatory).to.eql({
|
|
||||||
start: {
|
|
||||||
date: '2018-06-21',
|
|
||||||
time: '18:00'
|
|
||||||
},
|
|
||||||
cycleDays: longAndComplicatedCycle
|
|
||||||
.filter(({date}) => date >= '2018-06-21')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
describe('with previous higher measurement', () => {
|
|
||||||
describe('with no shifts detects pre-ovulatory phase', function () {
|
|
||||||
it('according to 5-day-rule', function () {
|
|
||||||
const status = getSensiplanStatus({
|
|
||||||
cycle: fiveDayCycle,
|
|
||||||
previousCycle: cycleWithFhm
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(Object.keys(status.phases).length).to.eql(1)
|
|
||||||
|
|
||||||
expect(status.phases.preOvulatory).to.eql({
|
|
||||||
cycleDays: fiveDayCycle,
|
|
||||||
start: { date: '2018-06-01' },
|
|
||||||
end: { date: '2018-06-05' }
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
})
|
|
||||||
describe('with no shifts detects pre- and peri-ovulatory phase', () => {
|
|
||||||
it('according to 5-day-rule', function () {
|
|
||||||
const status = getSensiplanStatus({
|
|
||||||
cycle: cycleWithTempAndNoMucusShift,
|
|
||||||
previousCycle: cycleWithFhm
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(Object.keys(status.phases).length).to.eql(2)
|
|
||||||
|
|
||||||
expect(status.phases.preOvulatory).to.eql({
|
|
||||||
cycleDays: cycleWithTempAndNoMucusShift
|
|
||||||
.filter(({date}) => date <= '2018-06-05'),
|
|
||||||
start: { date: '2018-06-01' },
|
|
||||||
end: { date: '2018-06-05' }
|
|
||||||
})
|
|
||||||
expect(status.phases.periOvulatory).to.eql({
|
|
||||||
cycleDays: cycleWithTempAndNoMucusShift
|
|
||||||
.filter(({date}) => date > '2018-06-05'),
|
|
||||||
start: { date: '2018-06-06' }
|
|
||||||
})
|
|
||||||
})
|
|
||||||
it('according to 5-day-rule with shortened pre-phase', function () {
|
|
||||||
const status = getSensiplanStatus({
|
|
||||||
cycle: cycleWithEarlyMucus,
|
|
||||||
previousCycle: cycleWithFhm
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(Object.keys(status.phases).length).to.eql(2)
|
|
||||||
|
|
||||||
expect(status.phases.preOvulatory).to.eql({
|
|
||||||
cycleDays: [cycleWithEarlyMucus[0]],
|
|
||||||
start: { date: '2018-06-01' },
|
|
||||||
end: { date: '2018-06-01' }
|
|
||||||
})
|
|
||||||
expect(status.phases.periOvulatory).to.eql({
|
|
||||||
cycleDays: cycleWithEarlyMucus.slice(1),
|
|
||||||
start: { date: '2018-06-02' }
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
describe('with shifts detects pre- and peri-ovulatory phase', function () {
|
|
||||||
it('according to 5-day-rule', function () {
|
|
||||||
const status = getSensiplanStatus({
|
|
||||||
cycle: longAndComplicatedCycle,
|
|
||||||
previousCycle: cycleWithFhm
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(Object.keys(status.phases).length).to.eql(3)
|
|
||||||
|
|
||||||
expect(status.phases.preOvulatory).to.eql({
|
|
||||||
cycleDays: longAndComplicatedCycle
|
|
||||||
.filter(({date}) => date <= '2018-06-05'),
|
|
||||||
start: { date: '2018-06-01' },
|
|
||||||
end: { date: '2018-06-05' }
|
|
||||||
})
|
|
||||||
expect(status.phases.periOvulatory).to.eql({
|
|
||||||
cycleDays: longAndComplicatedCycle
|
|
||||||
.filter(({date}) => date > '2018-06-05' && date <= '2018-06-21'),
|
|
||||||
start: { date: '2018-06-06' },
|
|
||||||
end: { date: '2018-06-21', time: '18:00'}
|
|
||||||
})
|
|
||||||
expect(status.phases.postOvulatory).to.eql({
|
|
||||||
cycleDays: longAndComplicatedCycle
|
|
||||||
.filter(({date}) => date >= '2018-06-21'),
|
|
||||||
start: { date: '2018-06-21', time: '18:00'}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('combining first higher measurment and mucus peak', () => {
|
|
||||||
it('with fhM + mucus peak on same day finds start of postovu phase', () => {
|
|
||||||
const status = getSensiplanStatus({
|
|
||||||
cycle: mucusPeakAndFhmOnSameDay,
|
|
||||||
previousCycle: cycleWithFhm
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(status.temperatureShift).to.be.an('object')
|
|
||||||
expect(status.mucusShift).to.be.an('object')
|
|
||||||
|
|
||||||
expect(Object.keys(status.phases).length).to.eql(3)
|
|
||||||
expect(status.phases.preOvulatory).to.eql({
|
|
||||||
start: { date: '2018-06-01' },
|
|
||||||
end: { date: '2018-06-05' },
|
|
||||||
cycleDays: mucusPeakAndFhmOnSameDay
|
|
||||||
.filter(({date}) => date <= '2018-06-05')
|
|
||||||
})
|
|
||||||
expect(status.phases.periOvulatory).to.eql({
|
|
||||||
start: { date: '2018-06-06' },
|
|
||||||
end: { date: '2018-06-21', time: '18:00' },
|
|
||||||
cycleDays: mucusPeakAndFhmOnSameDay
|
|
||||||
.filter(({date}) => {
|
|
||||||
return date > '2018-06-05' && date <= '2018-06-21'
|
|
||||||
})
|
|
||||||
})
|
|
||||||
expect(status.phases.postOvulatory).to.eql({
|
|
||||||
start: {
|
|
||||||
date: '2018-06-21',
|
|
||||||
time: '18:00'
|
|
||||||
},
|
|
||||||
cycleDays: mucusPeakAndFhmOnSameDay
|
|
||||||
.filter(({date}) => date >= '2018-06-21')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
it('with fhM 2 days before mucus peak waits for end of mucus eval', () => {
|
|
||||||
const status = getSensiplanStatus({
|
|
||||||
cycle: fhmTwoDaysBeforeMucusPeak,
|
|
||||||
previousCycle: cycleWithFhm
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(status.temperatureShift).to.be.an('object')
|
|
||||||
expect(status.mucusShift).to.be.an('object')
|
|
||||||
|
|
||||||
expect(Object.keys(status.phases).length).to.eql(3)
|
|
||||||
expect(status.phases.preOvulatory).to.eql({
|
|
||||||
start: { date: '2018-06-01' },
|
|
||||||
end: { date: '2018-06-05' },
|
|
||||||
cycleDays: fhmTwoDaysBeforeMucusPeak
|
|
||||||
.filter(({date}) => date <= '2018-06-05')
|
|
||||||
})
|
|
||||||
expect(status.phases.periOvulatory).to.eql({
|
|
||||||
start: { date: '2018-06-06' },
|
|
||||||
end: { date: '2018-06-26', time: '18:00' },
|
|
||||||
cycleDays: fhmTwoDaysBeforeMucusPeak
|
|
||||||
.filter(({date}) => {
|
|
||||||
return date > '2018-06-05' && date <= '2018-06-26'
|
|
||||||
})
|
|
||||||
})
|
|
||||||
expect(status.phases.postOvulatory).to.eql({
|
|
||||||
start: {
|
|
||||||
date: '2018-06-26',
|
|
||||||
time: '18:00'
|
|
||||||
},
|
|
||||||
cycleDays: fhmTwoDaysBeforeMucusPeak
|
|
||||||
.filter(({date}) => date >= '2018-06-26')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
it('another example for mucus peak before temp shift', () => {
|
|
||||||
const status = getSensiplanStatus({
|
|
||||||
cycle: mucusPeakSlightlyBeforeTempShift,
|
|
||||||
previousCycle: cycleWithFhm
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(status.temperatureShift).to.be.an('object')
|
|
||||||
expect(status.mucusShift).to.be.an('object')
|
|
||||||
|
|
||||||
expect(Object.keys(status.phases).length).to.eql(3)
|
|
||||||
expect(status.phases.preOvulatory).to.eql({
|
|
||||||
start: { date: '2018-06-01' },
|
|
||||||
end: { date: '2018-06-05' },
|
|
||||||
cycleDays: mucusPeakSlightlyBeforeTempShift
|
|
||||||
.filter(({date}) => date <= '2018-06-05')
|
|
||||||
})
|
|
||||||
expect(status.phases.periOvulatory).to.eql({
|
|
||||||
start: { date: '2018-06-06' },
|
|
||||||
end: { date: '2018-06-17', time: '18:00' },
|
|
||||||
cycleDays: mucusPeakSlightlyBeforeTempShift
|
|
||||||
.filter(({date}) => {
|
|
||||||
return date > '2018-06-05' && date <= '2018-06-17'
|
|
||||||
})
|
|
||||||
})
|
|
||||||
expect(status.phases.postOvulatory).to.eql({
|
|
||||||
start: {
|
|
||||||
date: '2018-06-17',
|
|
||||||
time: '18:00'
|
|
||||||
},
|
|
||||||
cycleDays: mucusPeakSlightlyBeforeTempShift
|
|
||||||
.filter(({date}) => date >= '2018-06-17')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
it('with another mucus peak 5 days after fHM ignores it', () => {
|
|
||||||
const status = getSensiplanStatus({
|
|
||||||
cycle: mucusPeak5DaysAfterFhm,
|
|
||||||
previousCycle: cycleWithFhm
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(status.temperatureShift).to.be.an('object')
|
|
||||||
expect(status.mucusShift).to.be.an('object')
|
|
||||||
|
|
||||||
expect(Object.keys(status.phases).length).to.eql(3)
|
|
||||||
expect(status.phases.preOvulatory).to.eql({
|
|
||||||
start: { date: '2018-06-01' },
|
|
||||||
end: { date: '2018-06-01' },
|
|
||||||
cycleDays: mucusPeak5DaysAfterFhm
|
|
||||||
.filter(({date}) => date <= '2018-06-01')
|
|
||||||
})
|
|
||||||
expect(status.phases.periOvulatory).to.eql({
|
|
||||||
start: { date: '2018-06-02' },
|
|
||||||
end: { date: '2018-06-22', time: '18:00' },
|
|
||||||
cycleDays: mucusPeak5DaysAfterFhm
|
|
||||||
.filter(({date}) => {
|
|
||||||
return date > '2018-06-01' && date <= '2018-06-22'
|
|
||||||
})
|
|
||||||
})
|
|
||||||
expect(status.phases.postOvulatory).to.eql({
|
|
||||||
start: {
|
|
||||||
date: '2018-06-22',
|
|
||||||
time: '18:00'
|
|
||||||
},
|
|
||||||
cycleDays: mucusPeak5DaysAfterFhm
|
|
||||||
.filter(({date}) => date >= '2018-06-22')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
it('with mucus peak 2 days before fhM waits for end of temp eval', () => {
|
|
||||||
const status = getSensiplanStatus({
|
|
||||||
cycle: mucusPeakTwoDaysBeforeFhm,
|
|
||||||
previousCycle: cycleWithFhm
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(status.temperatureShift).to.be.an('object')
|
|
||||||
expect(status.mucusShift).to.be.an('object')
|
|
||||||
|
|
||||||
expect(Object.keys(status.phases).length).to.eql(3)
|
|
||||||
expect(status.phases.preOvulatory).to.eql({
|
|
||||||
start: { date: '2018-06-01' },
|
|
||||||
end: { date: '2018-06-04' },
|
|
||||||
cycleDays: mucusPeakTwoDaysBeforeFhm
|
|
||||||
.filter(({date}) => date <= '2018-06-04')
|
|
||||||
})
|
|
||||||
expect(status.phases.periOvulatory).to.eql({
|
|
||||||
start: { date: '2018-06-05' },
|
|
||||||
end: { date: '2018-07-03', time: '18:00' },
|
|
||||||
cycleDays: mucusPeakTwoDaysBeforeFhm
|
|
||||||
.filter(({date}) => {
|
|
||||||
return date > '2018-06-04' && date <= '2018-07-03'
|
|
||||||
})
|
|
||||||
})
|
|
||||||
expect(status.phases.postOvulatory).to.eql({
|
|
||||||
start: {
|
|
||||||
date: '2018-07-03',
|
|
||||||
time: '18:00'
|
|
||||||
},
|
|
||||||
cycleDays: mucusPeakTwoDaysBeforeFhm
|
|
||||||
.filter(({date}) => date >= '2018-07-03')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
it('with mucus peak 5 days before fhM waits for end of temp eval', () => {
|
|
||||||
const status = getSensiplanStatus({
|
|
||||||
cycle: fhm5DaysAfterMucusPeak,
|
|
||||||
previousCycle: cycleWithFhm
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(status.temperatureShift).to.be.an('object')
|
|
||||||
expect(status.mucusShift).to.be.an('object')
|
|
||||||
|
|
||||||
expect(Object.keys(status.phases).length).to.eql(3)
|
|
||||||
expect(status.phases.preOvulatory).to.eql({
|
|
||||||
start: { date: '2018-06-01' },
|
|
||||||
end: { date: '2018-06-05' },
|
|
||||||
cycleDays: fhm5DaysAfterMucusPeak
|
|
||||||
.filter(({date}) => date <= '2018-06-05')
|
|
||||||
})
|
|
||||||
expect(status.phases.periOvulatory).to.eql({
|
|
||||||
start: { date: '2018-06-06' },
|
|
||||||
end: { date: '2018-06-21', time: '18:00' },
|
|
||||||
cycleDays: fhm5DaysAfterMucusPeak
|
|
||||||
.filter(({date}) => {
|
|
||||||
return date > '2018-06-05' && date <= '2018-06-21'
|
|
||||||
})
|
|
||||||
})
|
|
||||||
expect(status.phases.postOvulatory).to.eql({
|
|
||||||
start: {
|
|
||||||
date: '2018-06-21',
|
|
||||||
time: '18:00'
|
|
||||||
},
|
|
||||||
cycleDays: fhm5DaysAfterMucusPeak
|
|
||||||
.filter(({date}) => date >= '2018-06-21')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
it('with highest quality after end of eval', () => {
|
|
||||||
const status = getSensiplanStatus({
|
|
||||||
cycle: highestMucusQualityAfterEndOfEval,
|
|
||||||
previousCycle: cycleWithFhm
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(status.temperatureShift).to.be.an('object')
|
|
||||||
expect(status.mucusShift).to.be.an('object')
|
|
||||||
|
|
||||||
expect(Object.keys(status.phases).length).to.eql(3)
|
|
||||||
expect(status.phases.preOvulatory).to.eql({
|
|
||||||
start: { date: '2018-06-01' },
|
|
||||||
end: { date: '2018-06-05' },
|
|
||||||
cycleDays: highestMucusQualityAfterEndOfEval
|
|
||||||
.filter(({date}) => date <= '2018-06-05')
|
|
||||||
})
|
|
||||||
expect(status.phases.periOvulatory).to.eql({
|
|
||||||
start: { date: '2018-06-06' },
|
|
||||||
end: { date: '2018-06-17', time: '18:00' },
|
|
||||||
cycleDays: highestMucusQualityAfterEndOfEval
|
|
||||||
.filter(({date}) => {
|
|
||||||
return date > '2018-06-05' && date <= '2018-06-17'
|
|
||||||
})
|
|
||||||
})
|
|
||||||
expect(status.phases.postOvulatory).to.eql({
|
|
||||||
start: {
|
|
||||||
date: '2018-06-17',
|
|
||||||
time: '18:00'
|
|
||||||
},
|
|
||||||
cycleDays: highestMucusQualityAfterEndOfEval
|
|
||||||
.filter(({date}) => date >= '2018-06-17')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('applying the minus-8 rule', () => {
|
|
||||||
it('shortens the pre-ovu phase if there is a previous <13 fhm', () => {
|
|
||||||
const status = getSensiplanStatus({
|
|
||||||
cycle: longAndComplicatedCycle,
|
|
||||||
previousCycle: fhmOnDay15,
|
|
||||||
earlierCycles: [fhmOnDay12, ...Array(10).fill(fhmOnDay15)]
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(status.temperatureShift).to.be.an('object')
|
|
||||||
expect(status.mucusShift).to.be.an('object')
|
|
||||||
|
|
||||||
expect(Object.keys(status.phases).length).to.eql(3)
|
|
||||||
expect(status.phases.preOvulatory).to.eql({
|
|
||||||
start: { date: '2018-06-01' },
|
|
||||||
end: { date: '2018-06-04' },
|
|
||||||
cycleDays: longAndComplicatedCycle
|
|
||||||
.filter(({date}) => date <= '2018-06-04')
|
|
||||||
})
|
|
||||||
expect(status.phases.periOvulatory).to.eql({
|
|
||||||
start: { date: '2018-06-05' },
|
|
||||||
end: { date: '2018-06-21', time: '18:00' },
|
|
||||||
cycleDays: longAndComplicatedCycle
|
|
||||||
.filter(({date}) => {
|
|
||||||
return date > '2018-06-04' && date <= '2018-06-21'
|
|
||||||
})
|
|
||||||
})
|
|
||||||
expect(status.phases.postOvulatory).to.eql({
|
|
||||||
start: {
|
|
||||||
date: '2018-06-21',
|
|
||||||
time: '18:00'
|
|
||||||
},
|
|
||||||
cycleDays: longAndComplicatedCycle
|
|
||||||
.filter(({date}) => date >= '2018-06-21')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
it('shortens pre-ovu phase with prev <13 fhm even with <12 cycles', () => {
|
|
||||||
const status = getSensiplanStatus({
|
|
||||||
cycle: longAndComplicatedCycle,
|
|
||||||
previousCycle: fhmOnDay12,
|
|
||||||
earlierCycles: Array(10).fill(fhmOnDay12)
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(status.temperatureShift).to.be.an('object')
|
|
||||||
expect(status.mucusShift).to.be.an('object')
|
|
||||||
|
|
||||||
expect(Object.keys(status.phases).length).to.eql(3)
|
|
||||||
expect(status.phases.preOvulatory).to.eql({
|
|
||||||
start: { date: '2018-06-01' },
|
|
||||||
end: { date: '2018-06-04' },
|
|
||||||
cycleDays: longAndComplicatedCycle
|
|
||||||
.filter(({date}) => date <= '2018-06-04')
|
|
||||||
})
|
|
||||||
expect(status.phases.periOvulatory).to.eql({
|
|
||||||
start: { date: '2018-06-05' },
|
|
||||||
end: { date: '2018-06-21', time: '18:00' },
|
|
||||||
cycleDays: longAndComplicatedCycle
|
|
||||||
.filter(({date}) => {
|
|
||||||
return date > '2018-06-04' && date <= '2018-06-21'
|
|
||||||
})
|
|
||||||
})
|
|
||||||
expect(status.phases.postOvulatory).to.eql({
|
|
||||||
start: {
|
|
||||||
date: '2018-06-21',
|
|
||||||
time: '18:00'
|
|
||||||
},
|
|
||||||
cycleDays: longAndComplicatedCycle
|
|
||||||
.filter(({date}) => date >= '2018-06-21')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
it('shortens the pre-ovu phase if mucus occurs', () => {
|
|
||||||
const status = getSensiplanStatus({
|
|
||||||
cycle: cycleWithEarlyMucus,
|
|
||||||
previousCycle: fhmOnDay12,
|
|
||||||
earlierCycles: Array(10).fill(fhmOnDay12)
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
expect(Object.keys(status.phases).length).to.eql(2)
|
|
||||||
expect(status.phases.preOvulatory).to.eql({
|
|
||||||
start: { date: '2018-06-01' },
|
|
||||||
end: { date: '2018-06-01' },
|
|
||||||
cycleDays: cycleWithEarlyMucus
|
|
||||||
.filter(({date}) => date <= '2018-06-01')
|
|
||||||
})
|
|
||||||
expect(status.phases.periOvulatory).to.eql({
|
|
||||||
start: { date: '2018-06-02' },
|
|
||||||
cycleDays: cycleWithEarlyMucus
|
|
||||||
.filter(({date}) => {
|
|
||||||
return date > '2018-06-01'
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
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,
|
|
||||||
previousCycle: fhmOnDay15,
|
|
||||||
earlierCycles: Array(11).fill(fhmOnDay15)
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
expect(Object.keys(status.phases).length).to.eql(3)
|
|
||||||
expect(status.phases.preOvulatory).to.eql({
|
|
||||||
start: { date: '2018-06-01' },
|
|
||||||
end: { date: '2018-06-07' },
|
|
||||||
cycleDays: longAndComplicatedCycle
|
|
||||||
.filter(({date}) => date <= '2018-06-07')
|
|
||||||
})
|
|
||||||
expect(status.phases.periOvulatory).to.eql({
|
|
||||||
start: { date: '2018-06-08' },
|
|
||||||
end: { date: '2018-06-21', time: '18:00' },
|
|
||||||
cycleDays: longAndComplicatedCycle
|
|
||||||
.filter(({date}) => {
|
|
||||||
return date > '2018-06-07' && date <= '2018-06-21'
|
|
||||||
})
|
|
||||||
})
|
|
||||||
expect(status.phases.postOvulatory).to.eql({
|
|
||||||
start: {
|
|
||||||
date: '2018-06-21',
|
|
||||||
time: '18:00'
|
|
||||||
},
|
|
||||||
cycleDays: longAndComplicatedCycle
|
|
||||||
.filter(({date}) => date >= '2018-06-21')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
it('does not lengthen the pre-ovu phase if < 12 cycles', () => {
|
|
||||||
const status = getSensiplanStatus({
|
|
||||||
cycle: longAndComplicatedCycle,
|
|
||||||
previousCycle: fhmOnDay15,
|
|
||||||
earlierCycles: Array(10).fill(fhmOnDay15)
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
expect(Object.keys(status.phases).length).to.eql(3)
|
|
||||||
expect(status.phases.preOvulatory).to.eql({
|
|
||||||
start: { date: '2018-06-01' },
|
|
||||||
end: { date: '2018-06-05' },
|
|
||||||
cycleDays: longAndComplicatedCycle
|
|
||||||
.filter(({date}) => date <= '2018-06-05')
|
|
||||||
})
|
|
||||||
expect(status.phases.periOvulatory).to.eql({
|
|
||||||
start: { date: '2018-06-06' },
|
|
||||||
end: { date: '2018-06-21', time: '18:00' },
|
|
||||||
cycleDays: longAndComplicatedCycle
|
|
||||||
.filter(({date}) => {
|
|
||||||
return date > '2018-06-05' && date <= '2018-06-21'
|
|
||||||
})
|
|
||||||
})
|
|
||||||
expect(status.phases.postOvulatory).to.eql({
|
|
||||||
start: {
|
|
||||||
date: '2018-06-21',
|
|
||||||
time: '18:00'
|
|
||||||
},
|
|
||||||
cycleDays: longAndComplicatedCycle
|
|
||||||
.filter(({date}) => date >= '2018-06-21')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
it('does not detect any pre-ovu phase if prev cycle had no fhm', () => {
|
|
||||||
const status = getSensiplanStatus({
|
|
||||||
cycle: longAndComplicatedCycle,
|
|
||||||
previousCycle: cycleWithoutFhm,
|
|
||||||
earlierCycles: [...Array(12).fill(fhmOnDay15)]
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
expect(Object.keys(status.phases).length).to.eql(2)
|
|
||||||
expect(status.phases.periOvulatory).to.eql({
|
|
||||||
start: { date: '2018-06-01' },
|
|
||||||
end: { date: '2018-06-21', time: '18:00' },
|
|
||||||
cycleDays: longAndComplicatedCycle
|
|
||||||
.filter(({date}) => {
|
|
||||||
return date >= '2018-06-01' && date <= '2018-06-21'
|
|
||||||
})
|
|
||||||
})
|
|
||||||
expect(status.phases.postOvulatory).to.eql({
|
|
||||||
start: {
|
|
||||||
date: '2018-06-21',
|
|
||||||
time: '18:00'
|
|
||||||
},
|
|
||||||
cycleDays: longAndComplicatedCycle
|
|
||||||
.filter(({date}) => date >= '2018-06-21')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('when args are wrong', () => {
|
|
||||||
it('throws when arg object is not in right format', () => {
|
|
||||||
const wrongObject = { hello: 'world' }
|
|
||||||
expect(() => getSensiplanStatus(wrongObject)).to.throw(AssertionError)
|
|
||||||
})
|
|
||||||
it('throws if cycle array is empty', () => {
|
|
||||||
expect(() => getSensiplanStatus({cycle: []})).to.throw(AssertionError)
|
|
||||||
})
|
|
||||||
it('throws if cycle days are not in right format', () => {
|
|
||||||
expect(() => getSensiplanStatus({
|
|
||||||
cycle: [{
|
|
||||||
hello: 'world',
|
|
||||||
bleeding: { value: 0 }
|
|
||||||
}],
|
|
||||||
earlierCycles: [[{
|
|
||||||
date: '1992-09-09',
|
|
||||||
bleeding: { value: 0 }
|
|
||||||
}]]
|
|
||||||
})).to.throw(AssertionError)
|
|
||||||
expect(() => getSensiplanStatus({
|
|
||||||
cycle: [{
|
|
||||||
date: '2018-04-13',
|
|
||||||
temperature: {value: '35'},
|
|
||||||
bleeding: { value: 0 }
|
|
||||||
}],
|
|
||||||
earlierCycles: [[{
|
|
||||||
date: '1992-09-09',
|
|
||||||
bleeding: { value: 0 }
|
|
||||||
}]]
|
|
||||||
})).to.throw(AssertionError)
|
|
||||||
expect(() => getSensiplanStatus({
|
|
||||||
cycle: [{
|
|
||||||
date: '09-14-2017',
|
|
||||||
bleeding: { value: 0 }
|
|
||||||
}],
|
|
||||||
earlierCycles: [[{
|
|
||||||
date: '1992-09-09',
|
|
||||||
bleeding: { value: 0 }
|
|
||||||
}]]
|
|
||||||
})).to.throw(AssertionError)
|
|
||||||
})
|
|
||||||
it('throws if first cycle day does not have bleeding value', () => {
|
|
||||||
expect(() => getSensiplanStatus({
|
|
||||||
cycle: [{
|
|
||||||
date: '2017-01-01',
|
|
||||||
bleeding: {
|
|
||||||
value: 'medium'
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
earlierCycles: [[
|
|
||||||
{
|
|
||||||
date: '2017-09-23',
|
|
||||||
}
|
|
||||||
]]
|
|
||||||
})).to.throw(AssertionError)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@@ -1,9 +1,17 @@
|
|||||||
|
|
||||||
function convertToSymptoFormat(val) {
|
function convertToSymptoFormat(val) {
|
||||||
const sympto = { date: val.date }
|
const sympto = { date: val.date }
|
||||||
if (val.temperature) sympto.temperature = { value: val.temperature }
|
if (val.temperature) sympto.temperature = {
|
||||||
if (val.mucus) sympto.mucus = { value: val.mucus }
|
value: val.temperature,
|
||||||
if (val.bleeding) sympto.bleeding = { value: val.bleeding }
|
exclude: false
|
||||||
|
}
|
||||||
|
if (val.mucus) sympto.mucus = {
|
||||||
|
value: val.mucus,
|
||||||
|
exclude: false
|
||||||
|
}
|
||||||
|
if (val.bleeding) sympto.bleeding = {
|
||||||
|
value: val.bleeding,
|
||||||
|
exclude: false
|
||||||
|
}
|
||||||
return sympto
|
return sympto
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -15,7 +23,7 @@ export const cycleWithFhm = [
|
|||||||
{ date: '2018-06-06', temperature: 36.7, mucus: 0 },
|
{ date: '2018-06-06', temperature: 36.7, mucus: 0 },
|
||||||
{ date: '2018-06-13', temperature: 36.8, mucus: 4 },
|
{ date: '2018-06-13', temperature: 36.8, mucus: 4 },
|
||||||
{ date: '2018-06-15', temperature: 36.9, mucus: 2 },
|
{ date: '2018-06-15', temperature: 36.9, mucus: 2 },
|
||||||
{ date: '2018-06-17', temperature: 36.9, mucus: 2 },
|
{ date: '2018-06-16', temperature: 36.9, mucus: 2 },
|
||||||
{ date: '2018-06-17', temperature: 36.9, mucus: 2 },
|
{ date: '2018-06-17', temperature: 36.9, mucus: 2 },
|
||||||
{ date: '2018-06-18', temperature: 36.9, mucus: 2 }
|
{ date: '2018-06-18', temperature: 36.9, mucus: 2 }
|
||||||
].map(convertToSymptoFormat)
|
].map(convertToSymptoFormat)
|
||||||
@@ -227,6 +235,31 @@ export const mucusPeak5DaysAfterFhm = [
|
|||||||
{ date: '2018-07-02', temperature: 36.9, mucus: 1 }
|
{ date: '2018-07-02', temperature: 36.9, mucus: 1 }
|
||||||
].map(convertToSymptoFormat)
|
].map(convertToSymptoFormat)
|
||||||
|
|
||||||
|
export const highestMucusQualityAfterEndOfEval = [
|
||||||
|
{ date: '2018-06-01', temperature: 36.6, bleeding: 2 },
|
||||||
|
{ date: '2018-06-02', temperature: 36.65, mucus: 2 },
|
||||||
|
{ date: '2018-06-04', temperature: 36.6 },
|
||||||
|
{ date: '2018-06-05', temperature: 36.55 },
|
||||||
|
{ date: '2018-06-06', temperature: 36.7, mucus: 0 },
|
||||||
|
{ date: '2018-06-09', temperature: 36.5, mucus: 1 },
|
||||||
|
{ date: '2018-06-10', temperature: 36.4, mucus: 2 },
|
||||||
|
{ date: '2018-06-13', temperature: 36.45, mucus: 3 },
|
||||||
|
{ date: '2018-06-14', temperature: 36.5, mucus: 3 },
|
||||||
|
{ date: '2018-06-15', temperature: 36.55, mucus: 3 },
|
||||||
|
{ date: '2018-06-16', temperature: 36.7, mucus: 3 },
|
||||||
|
{ date: '2018-06-17', temperature: 36.65, mucus: 3 },
|
||||||
|
{ date: '2018-06-18', temperature: 36.60, mucus: 2 },
|
||||||
|
{ date: '2018-06-19', temperature: 36.8, mucus: 3 },
|
||||||
|
{ date: '2018-06-20', temperature: 36.85, mucus: 3 },
|
||||||
|
{ date: '2018-06-21', temperature: 36.8, mucus: 3 },
|
||||||
|
{ date: '2018-06-22', temperature: 36.9, mucus: 1 },
|
||||||
|
{ date: '2018-06-25', temperature: 36.9, mucus: 1 },
|
||||||
|
{ date: '2018-06-26', temperature: 36.8, mucus: 1 },
|
||||||
|
{ date: '2018-06-30', temperature: 36.9, mucus: 1 },
|
||||||
|
{ date: '2018-07-01', temperature: 36.9, mucus: 4 },
|
||||||
|
{ date: '2018-07-02', temperature: 36.9, mucus: 1 }
|
||||||
|
].map(convertToSymptoFormat)
|
||||||
|
|
||||||
export const fhm5DaysAfterMucusPeak = [
|
export const fhm5DaysAfterMucusPeak = [
|
||||||
{ date: '2018-06-01', temperature: 36.6, bleeding: 2 },
|
{ date: '2018-06-01', temperature: 36.6, bleeding: 2 },
|
||||||
{ date: '2018-06-02', temperature: 36.65 },
|
{ date: '2018-06-02', temperature: 36.65 },
|
||||||
@@ -299,26 +332,3 @@ export const mucusPeakSlightlyBeforeTempShift = [
|
|||||||
{ date: '2018-06-21', temperature: 36.8, mucus: 1},
|
{ date: '2018-06-21', temperature: 36.8, mucus: 1},
|
||||||
{ date: '2018-06-22', temperature: 36.8, mucus: 1}
|
{ date: '2018-06-22', temperature: 36.8, mucus: 1}
|
||||||
].map(convertToSymptoFormat)
|
].map(convertToSymptoFormat)
|
||||||
|
|
||||||
|
|
||||||
export const highestMucusQualityAfterEndOfEval = [
|
|
||||||
{ date: '2018-06-01', temperature: 36.6, bleeding: 2 },
|
|
||||||
{ date: '2018-06-02', temperature: 36.65 },
|
|
||||||
{ date: '2018-06-04', temperature: 36.6 },
|
|
||||||
{ date: '2018-06-07', temperature: 36.4, mucus: 1 },
|
|
||||||
{ date: '2018-06-08', temperature: 36.35, mucus: 2},
|
|
||||||
{ date: '2018-06-09', temperature: 36.4, mucus: 2},
|
|
||||||
{ date: '2018-06-10', temperature: 36.45, mucus: 2},
|
|
||||||
{ date: '2018-06-11', temperature: 36.4, mucus: 2},
|
|
||||||
{ date: '2018-06-12', temperature: 36.45, mucus: 2},
|
|
||||||
{ date: '2018-06-13', temperature: 36.45, mucus: 3},
|
|
||||||
{ date: '2018-06-14', temperature: 36.55, mucus: 2},
|
|
||||||
{ date: '2018-06-15', temperature: 36.6, mucus: 2},
|
|
||||||
{ date: '2018-06-16', temperature: 36.6, mucus: 2},
|
|
||||||
{ date: '2018-06-17', temperature: 36.55, mucus: 2},
|
|
||||||
{ date: '2018-06-18', temperature: 36.6, mucus: 1},
|
|
||||||
{ date: '2018-06-19', temperature: 36.7, mucus: 4},
|
|
||||||
{ date: '2018-06-20', temperature: 36.75, mucus: 1},
|
|
||||||
{ date: '2018-06-21', temperature: 36.8, mucus: 1},
|
|
||||||
{ date: '2018-06-22', temperature: 36.8, mucus: 1}
|
|
||||||
].map(convertToSymptoFormat)
|
|
||||||
@@ -0,0 +1,594 @@
|
|||||||
|
import chai from 'chai'
|
||||||
|
import getSensiplanStatus from '../../lib/sympto'
|
||||||
|
import { AssertionError } from 'assert'
|
||||||
|
import {
|
||||||
|
cycleWithoutFhm,
|
||||||
|
longAndComplicatedCycle,
|
||||||
|
cycleWithTempAndNoMucusShift,
|
||||||
|
cycleWithFhm,
|
||||||
|
cycleWithoutAnyShifts,
|
||||||
|
fiveDayCycle,
|
||||||
|
cycleWithEarlyMucus,
|
||||||
|
cycleWithMucusOnFirstDay,
|
||||||
|
mucusPeakAndFhmOnSameDay,
|
||||||
|
fhmTwoDaysBeforeMucusPeak,
|
||||||
|
fhm5DaysAfterMucusPeak,
|
||||||
|
mucusPeak5DaysAfterFhm,
|
||||||
|
mucusPeakTwoDaysBeforeFhm,
|
||||||
|
fhmOnDay12,
|
||||||
|
fhmOnDay15,
|
||||||
|
mucusPeakSlightlyBeforeTempShift
|
||||||
|
} from './mucus-temp-fixtures'
|
||||||
|
|
||||||
|
const expect = chai.expect
|
||||||
|
|
||||||
|
describe('sympto', () => {
|
||||||
|
describe('combining temperature and mucus tracking', () => {
|
||||||
|
describe('with no previous higher temp measurement', () => {
|
||||||
|
it('with no shifts detects only peri-ovulatory', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: cycleWithoutAnyShifts,
|
||||||
|
previousCycle: cycleWithoutFhm
|
||||||
|
})
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-01' },
|
||||||
|
cycleDays: cycleWithoutAnyShifts
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('with temp and mucus shifts detects only peri-ovulatory and post-ovulatory', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: longAndComplicatedCycle,
|
||||||
|
previousCycle: cycleWithoutFhm
|
||||||
|
})
|
||||||
|
expect(status.temperatureShift).to.be.an('object')
|
||||||
|
expect(status.mucusShift).to.be.an('object')
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(2)
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-01' },
|
||||||
|
end: { date: '2018-06-21', time: '18:00' },
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => date <= '2018-06-21')
|
||||||
|
})
|
||||||
|
expect(status.phases.postOvulatory).to.eql({
|
||||||
|
start: {
|
||||||
|
date: '2018-06-21',
|
||||||
|
time: '18:00'
|
||||||
|
},
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => date >= '2018-06-21')
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
})
|
||||||
|
describe('with previous higher measurement', () => {
|
||||||
|
describe('with no shifts detects pre-ovulatory phase', () => {
|
||||||
|
it('according to 5-day-rule', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: fiveDayCycle,
|
||||||
|
previousCycle: cycleWithFhm
|
||||||
|
})
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(1)
|
||||||
|
expect(status.phases.preOvulatory).to.eql({
|
||||||
|
cycleDays: fiveDayCycle,
|
||||||
|
start: { date: '2018-06-01' },
|
||||||
|
end: { date: '2018-06-05' }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
describe('with no shifts detects pre- and peri-ovulatory phase', () => {
|
||||||
|
it('according to 5-day-rule', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: cycleWithTempAndNoMucusShift,
|
||||||
|
previousCycle: cycleWithFhm
|
||||||
|
})
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(2)
|
||||||
|
expect(status.phases.preOvulatory).to.eql({
|
||||||
|
cycleDays: cycleWithTempAndNoMucusShift
|
||||||
|
.filter(({date}) => date <= '2018-06-05'),
|
||||||
|
start: { date: '2018-06-01' },
|
||||||
|
end: { date: '2018-06-05' }
|
||||||
|
})
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
cycleDays: cycleWithTempAndNoMucusShift
|
||||||
|
.filter(({date}) => date > '2018-06-05'),
|
||||||
|
start: { date: '2018-06-06' }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('according to 5-day-rule with shortened pre-phase', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: cycleWithEarlyMucus,
|
||||||
|
previousCycle: cycleWithFhm
|
||||||
|
})
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(2)
|
||||||
|
expect(status.phases.preOvulatory).to.eql({
|
||||||
|
cycleDays: [cycleWithEarlyMucus[0]],
|
||||||
|
start: { date: '2018-06-01' },
|
||||||
|
end: { date: '2018-06-01' }
|
||||||
|
})
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
cycleDays: cycleWithEarlyMucus.slice(1),
|
||||||
|
start: { date: '2018-06-02' }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
describe('with shifts detects pre- and peri-ovulatory phase', () => {
|
||||||
|
it('according to 5-day-rule', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: longAndComplicatedCycle,
|
||||||
|
previousCycle: cycleWithFhm
|
||||||
|
})
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(3)
|
||||||
|
expect(status.phases.preOvulatory).to.eql({
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => date <= '2018-06-05'),
|
||||||
|
start: { date: '2018-06-01' },
|
||||||
|
end: { date: '2018-06-05' }
|
||||||
|
})
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => date > '2018-06-05' && date <= '2018-06-21'),
|
||||||
|
start: { date: '2018-06-06' },
|
||||||
|
end: { date: '2018-06-21', time: '18:00'}
|
||||||
|
})
|
||||||
|
expect(status.phases.postOvulatory).to.eql({
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => date >= '2018-06-21'),
|
||||||
|
start: { date: '2018-06-21', time: '18:00'}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
describe('combining first higher measurment and mucus peak', () => {
|
||||||
|
it('with fhM + mucus peak on same day finds start of postovu phase', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: mucusPeakAndFhmOnSameDay,
|
||||||
|
previousCycle: cycleWithFhm
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(status.temperatureShift).to.be.an('object')
|
||||||
|
expect(status.mucusShift).to.be.an('object')
|
||||||
|
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(3)
|
||||||
|
expect(status.phases.preOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-01' },
|
||||||
|
end: { date: '2018-06-05' },
|
||||||
|
cycleDays: mucusPeakAndFhmOnSameDay
|
||||||
|
.filter(({date}) => date <= '2018-06-05')
|
||||||
|
})
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-06' },
|
||||||
|
end: { date: '2018-06-21', time: '18:00' },
|
||||||
|
cycleDays: mucusPeakAndFhmOnSameDay
|
||||||
|
.filter(({date}) => {
|
||||||
|
return date > '2018-06-05' && date <= '2018-06-21'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
expect(status.phases.postOvulatory).to.eql({
|
||||||
|
start: {
|
||||||
|
date: '2018-06-21',
|
||||||
|
time: '18:00'
|
||||||
|
},
|
||||||
|
cycleDays: mucusPeakAndFhmOnSameDay
|
||||||
|
.filter(({date}) => date >= '2018-06-21')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('with fhM 2 days before mucus peak waits for end of mucus eval', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: fhmTwoDaysBeforeMucusPeak,
|
||||||
|
previousCycle: cycleWithFhm
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(status.temperatureShift).to.be.an('object')
|
||||||
|
expect(status.mucusShift).to.be.an('object')
|
||||||
|
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(3)
|
||||||
|
expect(status.phases.preOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-01' },
|
||||||
|
end: { date: '2018-06-05' },
|
||||||
|
cycleDays: fhmTwoDaysBeforeMucusPeak
|
||||||
|
.filter(({date}) => date <= '2018-06-05')
|
||||||
|
})
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-06' },
|
||||||
|
end: { date: '2018-06-26', time: '18:00' },
|
||||||
|
cycleDays: fhmTwoDaysBeforeMucusPeak
|
||||||
|
.filter(({date}) => {
|
||||||
|
return date > '2018-06-05' && date <= '2018-06-26'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
expect(status.phases.postOvulatory).to.eql({
|
||||||
|
start: {
|
||||||
|
date: '2018-06-26',
|
||||||
|
time: '18:00'
|
||||||
|
},
|
||||||
|
cycleDays: fhmTwoDaysBeforeMucusPeak
|
||||||
|
.filter(({date}) => date >= '2018-06-26')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('another example for mucus peak before temp shift', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: mucusPeakSlightlyBeforeTempShift,
|
||||||
|
previousCycle: cycleWithFhm
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(status.temperatureShift).to.be.an('object')
|
||||||
|
expect(status.mucusShift).to.be.an('object')
|
||||||
|
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(3)
|
||||||
|
expect(status.phases.preOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-01' },
|
||||||
|
end: { date: '2018-06-05' },
|
||||||
|
cycleDays: mucusPeakSlightlyBeforeTempShift
|
||||||
|
.filter(({date}) => date <= '2018-06-05')
|
||||||
|
})
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-06' },
|
||||||
|
end: { date: '2018-06-17', time: '18:00' },
|
||||||
|
cycleDays: mucusPeakSlightlyBeforeTempShift
|
||||||
|
.filter(({date}) => {
|
||||||
|
return date > '2018-06-05' && date <= '2018-06-17'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
expect(status.phases.postOvulatory).to.eql({
|
||||||
|
start: {
|
||||||
|
date: '2018-06-17',
|
||||||
|
time: '18:00'
|
||||||
|
},
|
||||||
|
cycleDays: mucusPeakSlightlyBeforeTempShift
|
||||||
|
.filter(({date}) => date >= '2018-06-17')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('with another mucus peak 5 days after fHM ignores it', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: mucusPeak5DaysAfterFhm,
|
||||||
|
previousCycle: cycleWithFhm
|
||||||
|
})
|
||||||
|
expect(status.temperatureShift).to.be.an('object')
|
||||||
|
expect(status.mucusShift).to.be.an('object')
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(3)
|
||||||
|
expect(status.phases.preOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-01' },
|
||||||
|
end: { date: '2018-06-01' },
|
||||||
|
cycleDays: mucusPeak5DaysAfterFhm
|
||||||
|
.filter(({date}) => date <= '2018-06-01')
|
||||||
|
})
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-02' },
|
||||||
|
end: { date: '2018-06-22', time: '18:00' },
|
||||||
|
cycleDays: mucusPeak5DaysAfterFhm
|
||||||
|
.filter(({date}) => {
|
||||||
|
return date > '2018-06-01' && date <= '2018-06-22'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
expect(status.phases.postOvulatory).to.eql({
|
||||||
|
start: {
|
||||||
|
date: '2018-06-22',
|
||||||
|
time: '18:00'
|
||||||
|
},
|
||||||
|
cycleDays: mucusPeak5DaysAfterFhm
|
||||||
|
.filter(({date}) => date >= '2018-06-22')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('with mucus peak 2 days before fhM waits for end of temp eval', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: mucusPeakTwoDaysBeforeFhm,
|
||||||
|
previousCycle: cycleWithFhm
|
||||||
|
})
|
||||||
|
expect(status.temperatureShift).to.be.an('object')
|
||||||
|
expect(status.mucusShift).to.be.an('object')
|
||||||
|
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(3)
|
||||||
|
expect(status.phases.preOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-01' },
|
||||||
|
end: { date: '2018-06-04' },
|
||||||
|
cycleDays: mucusPeakTwoDaysBeforeFhm
|
||||||
|
.filter(({date}) => date <= '2018-06-04')
|
||||||
|
})
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-05' },
|
||||||
|
end: { date: '2018-07-03', time: '18:00' },
|
||||||
|
cycleDays: mucusPeakTwoDaysBeforeFhm
|
||||||
|
.filter(({date}) => {
|
||||||
|
return date > '2018-06-04' && date <= '2018-07-03'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
expect(status.phases.postOvulatory).to.eql({
|
||||||
|
start: {
|
||||||
|
date: '2018-07-03',
|
||||||
|
time: '18:00'
|
||||||
|
},
|
||||||
|
cycleDays: mucusPeakTwoDaysBeforeFhm
|
||||||
|
.filter(({date}) => date >= '2018-07-03')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('with mucus peak 5 days before fhM waits for end of temp eval', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: fhm5DaysAfterMucusPeak,
|
||||||
|
previousCycle: cycleWithFhm
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(status.temperatureShift).to.be.an('object')
|
||||||
|
expect(status.mucusShift).to.be.an('object')
|
||||||
|
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(3)
|
||||||
|
expect(status.phases.preOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-01' },
|
||||||
|
end: { date: '2018-06-05' },
|
||||||
|
cycleDays: fhm5DaysAfterMucusPeak
|
||||||
|
.filter(({date}) => date <= '2018-06-05')
|
||||||
|
})
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-06' },
|
||||||
|
end: { date: '2018-06-21', time: '18:00' },
|
||||||
|
cycleDays: fhm5DaysAfterMucusPeak
|
||||||
|
.filter(({date}) => {
|
||||||
|
return date > '2018-06-05' && date <= '2018-06-21'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
expect(status.phases.postOvulatory).to.eql({
|
||||||
|
start: {
|
||||||
|
date: '2018-06-21',
|
||||||
|
time: '18:00'
|
||||||
|
},
|
||||||
|
cycleDays: fhm5DaysAfterMucusPeak
|
||||||
|
.filter(({date}) => date >= '2018-06-21')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
describe('applying the minus-8 rule', () => {
|
||||||
|
it('shortens the pre-ovu phase if there is a previous <13 fhm', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: longAndComplicatedCycle,
|
||||||
|
previousCycle: fhmOnDay15,
|
||||||
|
earlierCycles: [fhmOnDay12, ...Array(10).fill(fhmOnDay15)]
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(status.temperatureShift).to.be.an('object')
|
||||||
|
expect(status.mucusShift).to.be.an('object')
|
||||||
|
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(3)
|
||||||
|
expect(status.phases.preOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-01' },
|
||||||
|
end: { date: '2018-06-04' },
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => date <= '2018-06-04')
|
||||||
|
})
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-05' },
|
||||||
|
end: { date: '2018-06-21', time: '18:00' },
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => {
|
||||||
|
return date > '2018-06-04' && date <= '2018-06-21'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
expect(status.phases.postOvulatory).to.eql({
|
||||||
|
start: {
|
||||||
|
date: '2018-06-21',
|
||||||
|
time: '18:00'
|
||||||
|
},
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => date >= '2018-06-21')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('shortens pre-ovu phase with prev <13 fhm even with <12 cycles', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: longAndComplicatedCycle,
|
||||||
|
previousCycle: fhmOnDay12,
|
||||||
|
earlierCycles: Array(10).fill(fhmOnDay12)
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(status.temperatureShift).to.be.an('object')
|
||||||
|
expect(status.mucusShift).to.be.an('object')
|
||||||
|
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(3)
|
||||||
|
expect(status.phases.preOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-01' },
|
||||||
|
end: { date: '2018-06-04' },
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => date <= '2018-06-04')
|
||||||
|
})
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-05' },
|
||||||
|
end: { date: '2018-06-21', time: '18:00' },
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => {
|
||||||
|
return date > '2018-06-04' && date <= '2018-06-21'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
expect(status.phases.postOvulatory).to.eql({
|
||||||
|
start: {
|
||||||
|
date: '2018-06-21',
|
||||||
|
time: '18:00'
|
||||||
|
},
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => date >= '2018-06-21')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('shortens the pre-ovu phase if mucus occurs', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: cycleWithEarlyMucus,
|
||||||
|
previousCycle: fhmOnDay12,
|
||||||
|
earlierCycles: Array(10).fill(fhmOnDay12)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(2)
|
||||||
|
expect(status.phases.preOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-01' },
|
||||||
|
end: { date: '2018-06-01' },
|
||||||
|
cycleDays: cycleWithEarlyMucus
|
||||||
|
.filter(({date}) => date <= '2018-06-01')
|
||||||
|
})
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-02' },
|
||||||
|
cycleDays: cycleWithEarlyMucus
|
||||||
|
.filter(({date}) => {
|
||||||
|
return date > '2018-06-01'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
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,
|
||||||
|
previousCycle: fhmOnDay15,
|
||||||
|
earlierCycles: Array(11).fill(fhmOnDay15)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(3)
|
||||||
|
expect(status.phases.preOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-01' },
|
||||||
|
end: { date: '2018-06-07' },
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => date <= '2018-06-07')
|
||||||
|
})
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-08' },
|
||||||
|
end: { date: '2018-06-21', time: '18:00' },
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => {
|
||||||
|
return date > '2018-06-07' && date <= '2018-06-21'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
expect(status.phases.postOvulatory).to.eql({
|
||||||
|
start: {
|
||||||
|
date: '2018-06-21',
|
||||||
|
time: '18:00'
|
||||||
|
},
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => date >= '2018-06-21')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('does not lengthen the pre-ovu phase if < 12 cycles', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: longAndComplicatedCycle,
|
||||||
|
previousCycle: fhmOnDay15,
|
||||||
|
earlierCycles: Array(10).fill(fhmOnDay15)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(3)
|
||||||
|
expect(status.phases.preOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-01' },
|
||||||
|
end: { date: '2018-06-05' },
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => date <= '2018-06-05')
|
||||||
|
})
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-06' },
|
||||||
|
end: { date: '2018-06-21', time: '18:00' },
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => {
|
||||||
|
return date > '2018-06-05' && date <= '2018-06-21'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
expect(status.phases.postOvulatory).to.eql({
|
||||||
|
start: {
|
||||||
|
date: '2018-06-21',
|
||||||
|
time: '18:00'
|
||||||
|
},
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => date >= '2018-06-21')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
it('does not detect any pre-ovu phase if prev cycle had no fhm', () => {
|
||||||
|
const status = getSensiplanStatus({
|
||||||
|
cycle: longAndComplicatedCycle,
|
||||||
|
previousCycle: cycleWithoutFhm,
|
||||||
|
earlierCycles: [...Array(12).fill(fhmOnDay15)]
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
expect(Object.keys(status.phases).length).to.eql(2)
|
||||||
|
expect(status.phases.periOvulatory).to.eql({
|
||||||
|
start: { date: '2018-06-01' },
|
||||||
|
end: { date: '2018-06-21', time: '18:00' },
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => {
|
||||||
|
return date >= '2018-06-01' && date <= '2018-06-21'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
expect(status.phases.postOvulatory).to.eql({
|
||||||
|
start: {
|
||||||
|
date: '2018-06-21',
|
||||||
|
time: '18:00'
|
||||||
|
},
|
||||||
|
cycleDays: longAndComplicatedCycle
|
||||||
|
.filter(({date}) => date >= '2018-06-21')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
describe('when args are wrong', () => {
|
||||||
|
it('throws when arg object is not in right format', () => {
|
||||||
|
const wrongObject = { hello: 'world' }
|
||||||
|
expect(() => getSensiplanStatus(wrongObject)).to.throw(AssertionError)
|
||||||
|
})
|
||||||
|
it('throws if cycle array is empty', () => {
|
||||||
|
expect(() => getSensiplanStatus({cycle: []})).to.throw(AssertionError)
|
||||||
|
})
|
||||||
|
it('throws if cycle days are not in right format', () => {
|
||||||
|
expect(() => getSensiplanStatus({
|
||||||
|
cycle: [{
|
||||||
|
hello: 'world',
|
||||||
|
bleeding: { value: 0 }
|
||||||
|
}],
|
||||||
|
earlierCycles: [[{
|
||||||
|
date: '1992-09-09',
|
||||||
|
bleeding: { value: 0 }
|
||||||
|
}]]
|
||||||
|
})).to.throw(AssertionError)
|
||||||
|
expect(() => getSensiplanStatus({
|
||||||
|
cycle: [{
|
||||||
|
date: '2018-04-13',
|
||||||
|
temperature: {value: '35'},
|
||||||
|
bleeding: { value: 0 }
|
||||||
|
}],
|
||||||
|
earlierCycles: [[{
|
||||||
|
date: '1992-09-09',
|
||||||
|
bleeding: { value: 0 }
|
||||||
|
}]]
|
||||||
|
})).to.throw(AssertionError)
|
||||||
|
expect(() => getSensiplanStatus({
|
||||||
|
cycle: [{
|
||||||
|
date: '09-14-2017',
|
||||||
|
bleeding: { value: 0 }
|
||||||
|
}],
|
||||||
|
earlierCycles: [[{
|
||||||
|
date: '1992-09-09',
|
||||||
|
bleeding: { value: 0 }
|
||||||
|
}]]
|
||||||
|
})).to.throw(AssertionError)
|
||||||
|
})
|
||||||
|
it('throws if first cycle day does not have bleeding value', () => {
|
||||||
|
expect(() => getSensiplanStatus({
|
||||||
|
cycle: [{
|
||||||
|
date: '2017-01-01',
|
||||||
|
bleeding: {
|
||||||
|
value: 'medium'
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
earlierCycles: [[
|
||||||
|
{
|
||||||
|
date: '2017-09-23',
|
||||||
|
}
|
||||||
|
]]
|
||||||
|
})).to.throw(AssertionError)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||