Basic working version that includes period products

This commit is contained in:
Liv
2023-11-20 12:13:42 +01:00
parent c432edbbaf
commit 503ce6e82d
5 changed files with 314 additions and 53 deletions
+1 -2
View File
@@ -25,7 +25,6 @@ const SymptomEditView = ({ date, onClose, symptom, symptomData }) => {
const [shouldShowInfo, setShouldShowInfo] = useState(false) const [shouldShowInfo, setShouldShowInfo] = useState(false)
const getParsedData = () => JSON.parse(JSON.stringify(data)) const getParsedData = () => JSON.parse(JSON.stringify(data))
const onPressLearnMore = () => setShouldShowInfo(!shouldShowInfo) const onPressLearnMore = () => setShouldShowInfo(!shouldShowInfo)
const onEditNote = (note) => { const onEditNote = (note) => {
const parsedData = getParsedData() const parsedData = getParsedData()
@@ -135,7 +134,7 @@ const SymptomEditView = ({ date, onClose, symptom, symptomData }) => {
<Segment key={group.key} style={styles.segmentBorder}> <Segment key={group.key} style={styles.segmentBorder}>
<AppText style={styles.title}>{group.title}</AppText> <AppText style={styles.title}>{group.title}</AppText>
<SelectTabGroup <SelectTabGroup
activeButton={data[group.key]} activeButton={data[group.key]} //this is supposed to be a number
buttons={group.options} buttons={group.options}
onSelect={(value) => onSelectTab(group, value)} onSelect={(value) => onSelectTab(group, value)}
/> />
+57 -10
View File
@@ -23,9 +23,17 @@ const noteDescription = labels.noteExplainer
const painLabels = labels.pain.categories const painLabels = labels.pain.categories
const sexLabels = labels.sex.categories const sexLabels = labels.sex.categories
const temperatureLabels = labels.temperature const temperatureLabels = labels.temperature
const productLabels = labels.products.categories
const minutes = ChronoUnit.MINUTES const minutes = ChronoUnit.MINUTES
const getOptionsFromCategories = (categories) => {
return Object.keys(categories).map((key, _) => ({
label: categories[key],
value: key, // or index, depending on what you want to use as the value
}))
}
const isNumber = (value) => typeof value === 'number' const isNumber = (value) => typeof value === 'number'
export const shouldShow = (value) => (value !== null ? true : false) export const shouldShow = (value) => (value !== null ? true : false)
@@ -56,6 +64,13 @@ export const blank = {
bleeding: { bleeding: {
exclude: false, exclude: false,
value: null, value: null,
pad: null,
tampon: null,
underwear: null,
cup: null,
softTampon: null,
none: null,
other: null,
}, },
cervix: { cervix: {
exclude: false, exclude: false,
@@ -125,7 +140,6 @@ export const symtomPage = {
bleeding: { bleeding: {
excludeText: labels.bleeding.exclude.explainer, excludeText: labels.bleeding.exclude.explainer,
note: null, note: null,
selectBoxGroups: null,
selectTabGroups: [ selectTabGroups: [
{ {
key: 'value', key: 'value',
@@ -133,6 +147,13 @@ export const symtomPage = {
title: labels.bleeding.heaviness.explainer, title: labels.bleeding.heaviness.explainer,
}, },
], ],
selectBoxGroups: [
{
key: 'products',
options: productLabels,
title: 'Product',
},
],
}, },
cervix: { cervix: {
excludeText: cervixLabels.excludeExplainer, excludeText: cervixLabels.excludeExplainer,
@@ -242,12 +263,12 @@ export const symtomPage = {
export const save = { export const save = {
bleeding: (data, date, shouldDeleteData) => { bleeding: (data, date, shouldDeleteData) => {
const { exclude, value } = data //const { exclude, value, products } = data
const isDataEntered = isNumber(value) //const isDataEntered = isNumber(value)
const valuesToSave = //const valuesToSave =
shouldDeleteData || !isDataEntered ? null : { value, exclude } // shouldDeleteData || !isDataEntered ? null : { value, exclude, products }
saveSymptom('bleeding', date, valuesToSave) saveBoxSymptom(data, date, shouldDeleteData, 'bleeding')
}, },
cervix: (data, date, shouldDeleteData) => { cervix: (data, date, shouldDeleteData) => {
const { opening, firmness, position, exclude } = data const { opening, firmness, position, exclude } = data
@@ -325,10 +346,36 @@ const saveBoxSymptom = (data, date, shouldDeleteData, symptom) => {
} }
const label = { const label = {
bleeding: ({ value, exclude }) => { bleeding: (bleeding) => {
if (isNumber(value)) { bleeding = mapRealmObjToJsObj(bleeding)
const bleedingLabel = bleedingLabels[value] console.log(bleeding)
return exclude ? `(${bleedingLabel})` : bleedingLabel const bleedingLabel = []
if (bleeding && Object.values({ ...bleeding }).some((val) => val)) {
Object.keys(bleeding).forEach((key) => {
if (key == 'value') {
console.log(bleedingLabel)
bleedingLabel.push(bleedingLabels[bleeding[key]])
}
if (
bleeding[key] &&
key !== 'other' &&
key !== 'note' &&
key != 'value' &&
key != 'exclude'
) {
console.log(bleedingLabel)
bleedingLabel.push(bleedingLabels[key] || productLabels[key])
}
if (key === 'other' && bleeding.other) {
let label = productLabels[key]
if (bleeding.note) {
label = `${label} (${bleeding.note})`
}
console.log(bleedingLabel)
bleedingLabel.push(label)
}
})
return bleedingLabel.join(', ')
} }
}, },
temperature: ({ value, time, exclude }) => { temperature: ({ value, time, exclude }) => {
+192
View File
@@ -0,0 +1,192 @@
const TemperatureSchema = {
name: 'Temperature',
properties: {
value: 'double',
exclude: 'bool',
time: {
type: 'string',
optional: true,
},
note: {
type: 'string',
optional: true,
},
},
}
const BleedingSchema = {
name: 'Bleeding',
properties: {
value: 'int',
exclude: 'bool',
pad: { type: 'bool', optional: true },
tampon: { type: 'bool', optional: true },
underwear: { type: 'bool', optional: true },
cup: { type: 'bool', optional: true },
softTampon: { type: 'bool', optional: true },
none: { type: 'bool', optional: true },
other: { type: 'bool', optional: true },
},
}
const MucusSchema = {
name: 'Mucus',
properties: {
feeling: { type: 'int', optional: true },
texture: { type: 'int', optional: true },
value: { type: 'int', optional: true },
exclude: 'bool',
},
}
const CervixSchema = {
name: 'Cervix',
properties: {
opening: { type: 'int', optional: true },
firmness: { type: 'int', optional: true },
position: { type: 'int', optional: true },
exclude: 'bool',
},
}
const NoteSchema = {
name: 'Note',
properties: {
value: 'string',
},
}
const DesireSchema = {
name: 'Desire',
properties: {
value: 'int',
},
}
const SexSchema = {
name: 'Sex',
properties: {
solo: { type: 'bool', optional: true },
partner: { type: 'bool', optional: true },
condom: { type: 'bool', optional: true },
pill: { type: 'bool', optional: true },
iud: { type: 'bool', optional: true },
patch: { type: 'bool', optional: true },
ring: { type: 'bool', optional: true },
implant: { type: 'bool', optional: true },
diaphragm: { type: 'bool', optional: true },
none: { type: 'bool', optional: true },
other: { type: 'bool', optional: true },
note: { type: 'string', optional: true },
},
}
const PainSchema = {
name: 'Pain',
properties: {
cramps: { type: 'bool', optional: true },
ovulationPain: { type: 'bool', optional: true },
headache: { type: 'bool', optional: true },
backache: { type: 'bool', optional: true },
nausea: { type: 'bool', optional: true },
tenderBreasts: { type: 'bool', optional: true },
migraine: { type: 'bool', optional: true },
other: { type: 'bool', optional: true },
note: { type: 'string', optional: true },
},
}
const MoodSchema = {
name: 'Mood',
properties: {
happy: { type: 'bool', optional: true },
sad: { type: 'bool', optional: true },
stressed: { type: 'bool', optional: true },
balanced: { type: 'bool', optional: true },
fine: { type: 'bool', optional: true },
anxious: { type: 'bool', optional: true },
energetic: { type: 'bool', optional: true },
fatigue: { type: 'bool', optional: true },
angry: { type: 'bool', optional: true },
other: { type: 'bool', optional: true },
note: { type: 'string', optional: true },
},
}
const CycleDaySchema = {
name: 'CycleDay',
primaryKey: 'date',
properties: {
date: 'string',
temperature: {
type: 'Temperature',
optional: true,
},
isCycleStart: 'bool',
bleeding: {
type: 'Bleeding',
optional: true,
},
mucus: {
type: 'Mucus',
optional: true,
},
cervix: {
type: 'Cervix',
optional: true,
},
note: {
type: 'Note',
optional: true,
},
desire: {
type: 'Desire',
optional: true,
},
sex: {
type: 'Sex',
optional: true,
},
pain: {
type: 'Pain',
optional: true,
},
mood: {
type: 'Mood',
optional: true,
},
},
}
export default {
schema: [
CycleDaySchema,
TemperatureSchema,
BleedingSchema,
MucusSchema,
CervixSchema,
NoteSchema,
DesireSchema,
SexSchema,
PainSchema,
MoodSchema,
],
schemaVersion: 5,
migration: (oldRealm, newRealm) => {
if (oldRealm.schemaVersion < 5) {
const oldObjects = oldRealm.objects('Bleeding')
const newObjects = newRealm.objects('Bleeding')
// loop through all objects and assign a default value for new properties
for (let i = 0; i < oldObjects.length; i++) {
newObjects[i].pad = false
newObjects[i].tampon = false
newObjects[i].underwear = false
newObjects[i].cup = false
newObjects[i].softTampon = false
newObjects[i].none = false
newObjects[i].other = false
}
}
},
}
+2 -1
View File
@@ -3,5 +3,6 @@ import schema1 from './1.js'
import schema2 from './2.js' import schema2 from './2.js'
import schema3 from './3.js' import schema3 from './3.js'
import schema4 from './4.js' import schema4 from './4.js'
import schema5 from './5.js'
export default [schema0, schema1, schema2, schema3, schema4] export default [schema0, schema1, schema2, schema3, schema4, schema5]
+62 -40
View File
@@ -4,70 +4,87 @@ export const intensity = ['low', 'medium', 'high']
export const bleeding = { export const bleeding = {
labels: ['spotting', 'light', 'medium', 'heavy'], labels: ['spotting', 'light', 'medium', 'heavy'],
heaviness: { heaviness: {
header: "Heaviness", header: 'Heaviness',
explainer: "How heavy is the bleeding?", explainer: 'How heavy is the bleeding?',
}, },
exclude: { exclude: {
header: "Exclude", header: 'Exclude',
explainer: "You can exclude this value if it's not menstrual bleeding" explainer: "You can exclude this value if it's not menstrual bleeding",
} },
}
export const products = {
categories: {
pad: 'pad',
tampon: 'tampon',
underwear: 'underwear',
cup: 'cup',
softTampon: 'soft tampon',
none: 'none',
other: 'other',
},
header: 'period products',
explainer: 'Did you use period products?',
} }
export const cervix = { export const cervix = {
subcategories: { subcategories: {
opening: 'opening', opening: 'opening',
firmness: 'firmness', firmness: 'firmness',
position: 'position' position: 'position',
}, },
opening: { opening: {
categories: ['closed', 'medium', 'open'], categories: ['closed', 'medium', 'open'],
explainer: 'Is your cervix open or closed?' explainer: 'Is your cervix open or closed?',
}, },
firmness: { firmness: {
categories: ['hard', 'soft'], categories: ['hard', 'soft'],
explainer: "When it's hard, it might feel like the tip of your nose" explainer: "When it's hard, it might feel like the tip of your nose",
}, },
position: { position: {
categories: ['low', 'medium', 'high'], categories: ['low', 'medium', 'high'],
explainer: 'How high up in the vagina is the cervix?' explainer: 'How high up in the vagina is the cervix?',
}, },
excludeExplainer: "You can exclude this value if you don't want to use it for fertility detection.", excludeExplainer:
actionHint: 'Choose values for at least "Opening" and "Firmness" to save.' "You can exclude this value if you don't want to use it for fertility detection.",
actionHint: 'Choose values for at least "Opening" and "Firmness" to save.',
} }
export const mucus = { export const mucus = {
subcategories: { subcategories: {
feeling: 'feeling', feeling: 'feeling',
texture: 'texture' texture: 'texture',
}, },
feeling: { feeling: {
categories: ['dry', 'nothing', 'wet', 'slippery'], categories: ['dry', 'nothing', 'wet', 'slippery'],
explainer: 'What does your vaginal entrance feel like?' explainer: 'What does your vaginal entrance feel like?',
}, },
texture: { texture: {
categories: ['nothing', 'creamy', 'egg white'], categories: ['nothing', 'creamy', 'egg white'],
explainer: "Looking at and touching your cervical mucus, which describes it best?" 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", excludeExplainer:
actionHint: 'Choose values for both "Feeling" and "Texture" to save.' "You can exclude this value if you don't want to use it for fertility detection",
actionHint: 'Choose values for both "Feeling" and "Texture" to save.',
} }
export const desire = { export const desire = {
header: 'Intensity', header: 'Intensity',
explainer: 'How would you rate your sexual desire?' explainer: 'How would you rate your sexual desire?',
} }
export const sex = { export const sex = {
categories:{ categories: {
solo: 'solo', solo: 'solo',
partner: 'partner', partner: 'partner',
}, },
header: "Activity", header: 'Activity',
explainer: 'Were you sexually active today?', explainer: 'Were you sexually active today?',
} }
export const contraceptives = { export const contraceptives = {
categories:{ categories: {
condom: 'condom', condom: 'condom',
pill: 'pill', pill: 'pill',
iud: 'iud', iud: 'iud',
@@ -78,8 +95,8 @@ export const contraceptives = {
none: 'none', none: 'none',
other: 'other', other: 'other',
}, },
header: "Contraceptives", header: 'Contraceptives',
explainer: 'Did you use contraceptives?' explainer: 'Did you use contraceptives?',
} }
export const pain = { export const pain = {
@@ -91,9 +108,9 @@ export const pain = {
nausea: 'nausea', nausea: 'nausea',
tenderBreasts: 'tender breasts', tenderBreasts: 'tender breasts',
migraine: 'migraine', migraine: 'migraine',
other: 'other' other: 'other',
}, },
explainer: 'How did your body feel today?' explainer: 'How did your body feel today?',
} }
export const mood = { export const mood = {
@@ -107,37 +124,42 @@ export const mood = {
energetic: 'energetic', energetic: 'energetic',
fatigue: 'fatigue', fatigue: 'fatigue',
angry: 'angry', angry: 'angry',
other: 'other' other: 'other',
}, },
explainer: 'How did you feel today?' explainer: 'How did you feel today?',
} }
export const temperature = { export const temperature = {
// disabled temporarily, TODO https://gitlab.com/bloodyhealth/drip/-/issues/545 */} // disabled temporarily, TODO https://gitlab.com/bloodyhealth/drip/-/issues/545 */}
// 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.',
outOfRangeWarning: 'This temperature value is too high or low to be shown on the temperature chart.', outOfRangeWarning:
outOfAbsoluteRangeWarning: 'This temperature value is too high or low to be shown on the temperature chart.', '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: { temperature: {
header: "Temperature", header: 'Temperature',
explainer: 'Take your temperature right after waking up, before getting out of bed' explainer:
'Take your temperature right after waking up, before getting out of bed',
}, },
time: "Time", time: 'Time',
note: { note: {
header: "Note", header: 'Note',
explainer: 'Is there anything that could have influenced this value, such as bad sleep or alcohol consumption?' explainer:
'Is there anything that could have influenced this value, such as bad sleep or alcohol consumption?',
}, },
exclude: { exclude: {
header: "Exclude", header: 'Exclude',
explainer: "You can exclude this value if you don't want to use it for fertility detection" explainer:
} "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?" export const noteExplainer = 'Anything you want to add for the day?'
export const general = { export const general = {
cycleDayNumber: "Cycle day ", cycleDayNumber: 'Cycle day ',
today: "Today" today: 'Today',
} }
export const sharedDialogs = { export const sharedDialogs = {
@@ -147,5 +169,5 @@ export const sharedDialogs = {
reallyDeleteData: 'Yes, I am sure', reallyDeleteData: 'Yes, I am sure',
save: 'Save', save: 'Save',
delete: 'Delete', delete: 'Delete',
disabledInfo: 'There is some data missing' disabledInfo: 'There is some data missing',
} }