Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Drip
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
backup
Drip
Commits
0179c458
Commit
0179c458
authored
6 years ago
by
Julia Friesel
Browse files
Options
Downloads
Patches
Plain Diff
Detect pre- and postovulatory phase with no previous higher measurement
parent
77ad491d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/sympto/index.js
+49
-24
49 additions, 24 deletions
lib/sympto/index.js
test/sympto/index.spec.js
+106
-36
106 additions, 36 deletions
test/sympto/index.spec.js
with
155 additions
and
60 deletions
lib/sympto/index.js
+
49
−
24
View file @
0179c458
import
getTemperatureShift
from
'
./temperature
'
import
getMucusShift
from
'
./mucus
'
export
default
function
(
cycleDays
)
{
const
assumeFertileStatus
=
{
assumeFertility
:
true
}
// TODO second phase calculation
if
(
cycleDays
.
length
)
assumeFertileStatus
.
phases
=
[
{
startDate
:
cycleDays
[
0
].
date
,
startTime
:
'
00:00
'
},
'
TODO
'
]
const
temperatureShift
=
getTemperatureShift
(
cycleDays
)
if
(
!
temperatureShift
.
detected
)
return
assumeFertileStatus
export
default
function
({
cycle
,
previousCycle
})
{
// TODO check for basic stuff, throw if nonexistent
const
status
=
{
assumeFertility
:
true
,
phases
:
{
periOvulatory
:
{
start
:
{
date
:
null
,
time
:
'
00:00
'
},
cycleDays
:
null
}
}
}
const
tempEvalEndIndex
=
cycleDays
.
indexOf
(
temperatureShift
.
evaluationCompleteDay
)
const
mucusShift
=
getMucusShift
(
cycleDays
,
tempEvalEndIndex
)
if
(
!
mucusShift
.
detected
)
return
assumeFertileStatus
// if there was no first higher measurement in the previous cycle,
// no infertile preovulatory phase may be assumed
const
phase2
=
{
startDate
:
temperatureShift
.
evaluationCompleteDay
.
date
,
startTime
:
'
18:00
'
if
(
getTemperatureShift
(
previousCycle
).
detected
)
{
// add preOvulatory phase
}
else
{
const
first
=
cycle
[
0
]
status
.
phases
.
periOvulatory
.
start
.
date
=
first
.
date
status
.
phases
.
periOvulatory
.
cycleDays
=
[...
cycle
]
}
return
{
assumeFertility
:
false
,
temperatureShift
,
mucusShift
,
phases
:
assumeFertileStatus
.
phases
.
concat
(
phase2
)
const
temperatureShift
=
getTemperatureShift
(
cycle
)
if
(
!
temperatureShift
.
detected
)
return
status
const
tempEvalEndIndex
=
cycle
.
indexOf
(
temperatureShift
.
evaluationCompleteDay
)
const
mucusShift
=
getMucusShift
(
cycle
,
tempEvalEndIndex
)
if
(
!
mucusShift
.
detected
)
return
status
const
periOvulatoryEnd
=
temperatureShift
.
evaluationCompleteDay
.
date
>
mucusShift
.
evaluationCompleteDay
.
date
?
temperatureShift
.
evaluationCompleteDay
:
mucusShift
.
evaluationCompleteDay
const
prevPeriOvulatoryDays
=
status
.
phases
.
periOvulatory
.
cycleDays
const
periOvulatoryEndIndex
=
prevPeriOvulatoryDays
.
indexOf
(
periOvulatoryEnd
)
status
.
phases
.
postOvulatory
=
{
start
:
{
date
:
periOvulatoryEnd
.
date
,
time
:
'
18:00
'
},
cycleDays
:
prevPeriOvulatoryDays
.
slice
(
periOvulatoryEndIndex
)
}
status
.
phases
.
periOvulatory
.
cycleDays
=
prevPeriOvulatoryDays
.
slice
(
0
,
periOvulatoryEndIndex
+
1
)
status
.
mucusShift
=
mucusShift
status
.
temperatureShift
=
temperatureShift
return
status
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
test/sympto/index.spec.js
+
106
−
36
View file @
0179c458
...
...
@@ -11,48 +11,117 @@ function convertToSymptoFormat(val, i) {
return
sympto
}
const
cycleWithTempShift
=
[
36.6
,
36.6
,
36.6
,
36.6
,
36.6
,
36.6
,
36.8
,
36.8
,
36.8
]
.
map
(
num
=>
({
temperature
:
num
}))
.
map
(
convertToSymptoFormat
)
const
cycleWithoutTempShift
=
[
36.6
,
36.6
,
36.6
,
36.6
,
36.6
,
36.6
,
36.8
,
36.8
]
.
map
(
num
=>
({
temperature
:
num
}))
.
map
(
convertToSymptoFormat
)
const
cycleWithTempAndMucusShift
=
[
{
temperature
:
36.6
,
bleeding
:
2
},
{
temperature
:
36.65
},
{
temperature
:
36.5
},
{
temperature
:
36.6
},
{
temperature
:
36.55
},
{
temperature
:
36.7
,
mucus
:
0
},
{
temperature
:
36.75
,
mucus
:
0
},
{
temperature
:
36.45
,
mucus
:
1
},
{
temperature
:
36.5
,
mucus
:
4
},
{
temperature
:
36.4
,
mucus
:
2
},
{
temperature
:
36.5
,
mucus
:
3
},
{
temperature
:
36.55
,
mucus
:
3
},
{
temperature
:
36.45
,
mucus
:
3
},
{
temperature
:
36.5
,
mucus
:
4
},
{
temperature
:
36.55
,
mucus
:
4
},
{
temperature
:
36.7
,
mucus
:
3
},
{
temperature
:
36.65
,
mucus
:
3
},
{
temperature
:
36.75
,
mucus
:
4
},
{
temperature
:
36.8
,
mucus
:
1
},
{
temperature
:
36.85
,
mucus
:
2
},
{
temperature
:
36.8
,
mucus
:
2
},
{
temperature
:
36.9
,
mucus
:
2
},
{
temperature
:
36.9
,
mucus
:
1
},
{
temperature
:
36.85
,
mucus
:
1
},
{
temperature
:
36.9
,
mucus
:
1
},
{
temperature
:
36.8
,
mucus
:
1
},
{
temperature
:
36.9
,
mucus
:
1
}
].
map
(
convertToSymptoFormat
)
describe
(
'
sympto
'
,
()
=>
{
describe
(
'
evaluating mucus and temperature shift together
'
,
()
=>
{
it
(
'
reports fertile when mucus reaches best quality again within temperature evaluation phase
'
,
function
()
{
const
values
=
[
{
temperature
:
36.6
,
bleeding
:
2
},
{
temperature
:
36.65
},
{
temperature
:
36.5
},
{
temperature
:
36.6
},
{
temperature
:
36.55
},
{
temperature
:
36.7
,
mucus
:
0
},
{
temperature
:
36.75
,
mucus
:
0
},
{
temperature
:
36.45
,
mucus
:
1
},
{
temperature
:
36.5
,
mucus
:
4
},
{
temperature
:
36.4
,
mucus
:
2
},
{
temperature
:
36.5
,
mucus
:
3
},
{
temperature
:
36.55
,
mucus
:
3
},
{
temperature
:
36.45
,
mucus
:
3
},
{
temperature
:
36.5
,
mucus
:
4
},
{
temperature
:
36.55
,
mucus
:
4
},
{
temperature
:
36.7
,
mucus
:
3
},
{
temperature
:
36.65
,
mucus
:
3
},
{
temperature
:
36.75
,
mucus
:
4
},
{
temperature
:
36.8
,
mucus
:
1
},
{
temperature
:
36.85
,
mucus
:
2
},
{
temperature
:
36.8
,
mucus
:
2
},
{
temperature
:
36.9
,
mucus
:
2
},
{
temperature
:
36.9
,
mucus
:
1
},
{
temperature
:
36.85
,
mucus
:
1
},
{
temperature
:
36.9
,
mucus
:
1
},
{
temperature
:
36.8
,
mucus
:
1
},
{
temperature
:
36.9
,
mucus
:
1
}
]
describe
(
'
with no previous higher measurement
'
,
()
=>
{
it
(
'
with no shifts detects only periovulatory
'
,
function
()
{
const
values
=
[
{
temperature
:
36.6
,
bleeding
:
2
},
{
temperature
:
36.65
},
{
temperature
:
36.5
},
{
temperature
:
36.6
},
{
temperature
:
36.55
},
{
temperature
:
36.7
,
mucus
:
0
},
{
temperature
:
36.75
,
mucus
:
0
},
{
temperature
:
36.45
,
mucus
:
1
}
]
const
cycle
=
values
.
map
(
convertToSymptoFormat
)
const
status
=
getSensiplanStatus
({
cycle
,
previousCycle
:
cycleWithoutTempShift
})
expect
(
status
).
to
.
eql
({
assumeFertility
:
true
,
phases
:
{
periOvulatory
:
{
start
:
{
date
:
0
,
time
:
'
00:00
'
},
cycleDays
:
cycle
}
},
})
})
it
(
'
with shifts detects only periovulatory and postovulatory
'
,
function
()
{
const
status
=
getSensiplanStatus
({
cycle
:
cycleWithTempAndMucusShift
,
previousCycle
:
cycleWithoutTempShift
})
const
temperatures
=
values
.
map
(
convertToSymptoFormat
)
expect
(
status
.
temperatureShift
).
to
.
be
.
an
(
'
object
'
)
expect
(
status
.
mucusShift
).
to
.
be
.
an
(
'
object
'
)
expect
(
status
.
assumeFertility
).
to
.
be
.
true
()
expect
(
Object
.
keys
(
status
.
phases
)).
to
.
eql
([
'
periOvulatory
'
,
'
postOvulatory
'
])
expect
(
status
.
phases
.
periOvulatory
).
to
.
eql
({
start
:
{
date
:
0
,
time
:
'
00:00
'
},
cycleDays
:
cycleWithTempAndMucusShift
.
slice
(
0
,
21
)
})
expect
(
status
.
phases
.
postOvulatory
).
to
.
eql
({
start
:
{
date
:
20
,
time
:
'
18:00
'
},
cycleDays
:
cycleWithTempAndMucusShift
.
slice
(
20
)
})
})
})
})
describe
(
'
with shifts
'
,
()
=>
{
it
.
skip
(
'
reports fertile when mucus reaches best quality again within temperature evaluation phase
'
,
function
()
{
const
status
=
getSensiplanStatus
(
temperatures
)
expect
(
status
).
to
.
eql
({
assumeFertility
:
false
,
phases
:
[
{
startDate
:
0
,
startTime
:
'
00:00
'
},
'
TODO
'
,
{
startDate
:
17
,
startTime
:
'
18:00
'
}
],
phases
:
{
preOvulatory
:
{
startDate
:
0
,
startTime
:
'
00:00
'
},
periOvulatory
:
'
TODO
'
,
postOvulatory
:
{
startDate
:
17
,
startTime
:
'
18:00
'
}
},
temperatureShift
:
{
detected
:
true
,
ltl
:
36.55
,
...
...
@@ -78,5 +147,6 @@ describe('sympto', () => {
}
})
})
})
})
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment