Skip to content

Commit 6da3c8b

Browse files
committed
changing variations schema
1 parent d3f35a4 commit 6da3c8b

10 files changed

Lines changed: 142 additions & 64 deletions

File tree

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,18 @@ body-weight:
115115
streamId: body-weight # the parents structures of streams is given by the default streams structure
116116
variations: # Variations of this measure
117117
eventType: # Reserved key for variation by EventType
118-
mass/kg:
119-
label: Kg
120-
hl7fhir:
121-
unit: kg
122-
code: kg
123-
mass/lb:
124-
label: Lbs
125-
hl7fhir:
126-
unit: lb
127-
code: "[lb_av]"
118+
label: Unit
119+
options:
120+
- value: mass/kg
121+
label: Kg
122+
hl7fhir:
123+
unit: kg
124+
code: kg
125+
- value: mass/lb
126+
label: Lbs
127+
hl7fhir:
128+
unit: lb
129+
code: "[lb_av]"
128130
measure-detail: # Free-from key for variation
129131
default: # Reserved keywork for default selection when none is provided
130132
label:

definitions/items/body.yaml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ body-weight:
99
streamId: body-weight
1010
type: number
1111
variations:
12-
eventType:
13-
mass/kg:
14-
label: Kg
15-
mass/lb:
16-
label: Lbs
12+
eventType:
13+
label: Unit
14+
options:
15+
- value: mass/kg
16+
label: Kg
17+
- value: mass/lb
18+
label: Lbs
1719
repeatable: any
1820
body-height:
1921
version: temporary
@@ -26,9 +28,11 @@ body-height:
2628
streamId: body-height
2729
type: number
2830
variations:
29-
eventType:
30-
length/m:
31-
label: m
32-
length/ft:
33-
label: Feet
31+
eventType:
32+
label: Unit
33+
options:
34+
- value: length/m
35+
label: m
36+
- value: length/ft
37+
label: Feet
3438
repeatable: any

docs/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ <h3>Items</h3>
4646
</tr>
4747
</thead>
4848
<tbody>
49-
<tr><td><span style="font-weight: bold;" id="body-height">body-height</span><br><u>Type:</u> number<br><u>When:</u> any</td><td>Body height<br>Measured body height</td><td><u>streamId:</u> body-height<br><u>eventType(s):</u> length/m, length/ft<br><u>version:</u> temporary</td></tr>
49+
<tr><td><span style="font-weight: bold;" id="body-height">body-height</span><br><u>Type:</u> number<br><u>When:</u> any</td><td>Body height<br>Measured body height</td><td><u>streamId:</u> body-height<br><u>eventType(s):</u> (Unit): length/m, length/ft<br><u>version:</u> temporary</td></tr>
5050
<tr><td><span style="font-weight: bold;" id="body-vulva-bleeding">body-vulva-bleeding</span><br><u>Type:</u> select<br><u>When:</u> any</td><td>Bleeding type<br>Bleeding type subjective<BR><SELECT style="width: 20em"><OPTION>0: None</OPTION><OPTION>1: Spotting</OPTION><OPTION>2: Light</OPTION><OPTION>3: Medium</OPTION><OPTION>4: Heavy</OPTION></SELECT></td><td><u>streamId:</u> body-vulva-bleeding<br><u>eventType(s):</u> ratio/generic<br><u>version:</u> v1</td></tr>
5151
<tr><td><span style="font-weight: bold;" id="body-vulva-bleeding-browndark">body-vulva-bleeding-browndark</span><br><u>Type:</u> checkbox<br><u>When:</u> daily</td><td>Brown coloration of bleeding<br>Brown coloration of bleeding</td><td><u>streamId:</u> body-vulva-bleeding-browndark<br><u>eventType(s):</u> activity/plain<br><u>version:</u> temporary</td></tr>
5252
<tr><td><span style="font-weight: bold;" id="body-vulva-mucus-inspect">body-vulva-mucus-inspect</span><br><u>Type:</u> select<br><u>When:</u> any</td><td>Cervical Fluid Inspect<br>Visual aspect of cervical fluid inspection<BR><SELECT style="width: 20em"><OPTION>clear: Clear</OPTION><OPTION>creamy: Creamy</OPTION><OPTION>dry-sticky: Dry & Sticky</OPTION><OPTION>egg-white: Egg White</OPTION></SELECT></td><td><u>streamId:</u> body-vulva-mucus-inspect<br><u>eventType(s):</u> vulva-mucus-inspect/v0<br><u>version:</u> v1</td></tr>
5353
<tr><td><span style="font-weight: bold;" id="body-vulva-mucus-stretch">body-vulva-mucus-stretch</span><br><u>Type:</u> select<br><u>When:</u> any</td><td>Cervical Fluid Stretch<br>Manual strech test of cervical fluid. Short can be streched less than 2 cm, long greater than 2cm.<BR><SELECT style="width: 20em"><OPTION>0: No Strech</OPTION><OPTION>1: Short</OPTION><OPTION>2: Long</OPTION></SELECT></td><td><u>streamId:</u> body-vulva-mucus-stretch<br><u>eventType(s):</u> ratio/generic<br><u>version:</u> v1</td></tr>
5454
<tr><td><span style="font-weight: bold;" id="body-vulva-wetness-feeling">body-vulva-wetness-feeling</span><br><u>Type:</u> select<br><u>When:</u> any</td><td>Vulva Wetness feeling<br>Vulva wetness feeling<BR><SELECT style="width: 20em"><OPTION>0: Dry</OPTION><OPTION>1: Wet</OPTION><OPTION>2: Very wet</OPTION></SELECT></td><td><u>streamId:</u> body-vulva-wetness-feeling<br><u>eventType(s):</u> ratio/generic<br><u>version:</u> v1</td></tr>
5555
<tr><td><span style="font-weight: bold;" id="body-vulva-wetness-wiping">body-vulva-wetness-wiping</span><br><u>Type:</u> select<br><u>When:</u> any</td><td>Vulva Wetness when wiping<br>Vulva wetness when wiping<BR><SELECT style="width: 20em"><OPTION>0: Dry</OPTION><OPTION>1: Wet</OPTION><OPTION>2: Very wet</OPTION></SELECT></td><td><u>streamId:</u> body-vulva-wetness-wiping<br><u>eventType(s):</u> ratio/generic<br><u>version:</u> v1</td></tr>
56-
<tr><td><span style="font-weight: bold;" id="body-weight">body-weight</span><br><u>Type:</u> number<br><u>When:</u> any</td><td>Body weight<br>Measured body weight</td><td><u>streamId:</u> body-weight<br><u>eventType(s):</u> mass/kg, mass/lb<br><u>version:</u> temporary</td></tr>
56+
<tr><td><span style="font-weight: bold;" id="body-weight">body-weight</span><br><u>Type:</u> number<br><u>When:</u> any</td><td>Body weight<br>Measured body weight</td><td><u>streamId:</u> body-weight<br><u>eventType(s):</u> (Unit): mass/kg, mass/lb<br><u>version:</u> temporary</td></tr>
5757
<tr><td><span style="font-weight: bold;" id="family-children-count">family-children-count</span><br><u>Type:</u> number<br><u>When:</u> none</td><td>Nb of children<br>Number of children at this date</td><td><u>streamId:</u> family-children<br><u>eventType(s):</u> count/generic<br><u>version:</u> temporary</td></tr>
5858
<tr><td><span style="font-weight: bold;" id="fertility-cycles-charted-count">fertility-cycles-charted-count</span><br><u>Type:</u> number<br><u>When:</u> none</td><td>Nb of charted cycles<br>Number of total charted cycles at this date</td><td><u>streamId:</u> fertility-cycles-charted-estimation<br><u>eventType(s):</u> count/generic<br><u>version:</u> temporary</td></tr>
5959
<tr><td><span style="font-weight: bold;" id="fertility-cycles-ovulation">fertility-cycles-ovulation</span><br><u>Type:</u> checkbox<br><u>When:</u> daily</td><td>Ovulation Day<br>Flag this day as an ovulation day</td><td><u>streamId:</u> fertility-cycles-ovulation<br><u>eventType(s):</u> activity/plain<br><u>version:</u> temporary</td></tr>

docs/items.json

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -209,16 +209,23 @@
209209
"type": "number",
210210
"variations": {
211211
"eventType": {
212-
"mass/kg": {
213-
"label": {
214-
"en": "Kg"
215-
}
212+
"label": {
213+
"en": "Unit"
216214
},
217-
"mass/lb": {
218-
"label": {
219-
"en": "Lbs"
215+
"options": [
216+
{
217+
"value": "mass/kg",
218+
"label": {
219+
"en": "Kg"
220+
}
221+
},
222+
{
223+
"value": "mass/lb",
224+
"label": {
225+
"en": "Lbs"
226+
}
220227
}
221-
}
228+
]
222229
}
223230
},
224231
"repeatable": "any"
@@ -237,16 +244,23 @@
237244
"type": "number",
238245
"variations": {
239246
"eventType": {
240-
"length/m": {
241-
"label": {
242-
"en": "m"
243-
}
247+
"label": {
248+
"en": "Unit"
244249
},
245-
"length/ft": {
246-
"label": {
247-
"en": "Feet"
250+
"options": [
251+
{
252+
"value": "length/m",
253+
"label": {
254+
"en": "m"
255+
}
256+
},
257+
{
258+
"value": "length/ft",
259+
"label": {
260+
"en": "Feet"
261+
}
248262
}
249-
}
263+
]
250264
}
251265
},
252266
"repeatable": "any"

docs/json-schemas/item.json

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,36 @@
6464
"type": "object",
6565
"nullable": false,
6666
"properties": {
67-
"eventTypes": {
68-
"type": "object"
67+
"eventType": {
68+
"type": "object",
69+
"properties": {
70+
"label": {
71+
"$ref": "defs.json#/definitions/localized"
72+
},
73+
"options": {
74+
"type": "array",
75+
"items": {
76+
"type": "object",
77+
"nullable": false,
78+
"properties": {
79+
"value": {
80+
"type": "string"
81+
},
82+
"label": {
83+
"$ref": "defs.json#/definitions/localized"
84+
}
85+
},
86+
"required": [
87+
"value",
88+
"label"
89+
],
90+
"additionalProperties": false
91+
}
92+
}
93+
}
6994
}
70-
}
95+
},
96+
"additionalProperties": false
7197
}
7298
},
7399
"allOf": [

docs/pack.json

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"publicationDate": "2025-10-08T12:48:11.640Z",
2+
"publicationDate": "2025-10-10T15:25:21.792Z",
33
"streams": [
44
{
55
"id": "body",
@@ -405,16 +405,23 @@
405405
"type": "number",
406406
"variations": {
407407
"eventType": {
408-
"mass/kg": {
409-
"label": {
410-
"en": "Kg"
411-
}
408+
"label": {
409+
"en": "Unit"
412410
},
413-
"mass/lb": {
414-
"label": {
415-
"en": "Lbs"
411+
"options": [
412+
{
413+
"value": "mass/kg",
414+
"label": {
415+
"en": "Kg"
416+
}
417+
},
418+
{
419+
"value": "mass/lb",
420+
"label": {
421+
"en": "Lbs"
422+
}
416423
}
417-
}
424+
]
418425
}
419426
},
420427
"repeatable": "any"
@@ -433,16 +440,23 @@
433440
"type": "number",
434441
"variations": {
435442
"eventType": {
436-
"length/m": {
437-
"label": {
438-
"en": "m"
439-
}
443+
"label": {
444+
"en": "Unit"
440445
},
441-
"length/ft": {
442-
"label": {
443-
"en": "Feet"
446+
"options": [
447+
{
448+
"value": "length/m",
449+
"label": {
450+
"en": "m"
451+
}
452+
},
453+
{
454+
"value": "length/ft",
455+
"label": {
456+
"en": "Feet"
457+
}
444458
}
445-
}
459+
]
446460
}
447461
},
448462
"repeatable": "any"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "hds-data-model",
2+
"name": "@hds/data-model",
33
"version": "1.0.0",
44
"description": "HDS data model",
55
"main": "src/index.js",

src/build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ for (const key of Object.keys(itemsById).sort()) {
6161
itemsByStreamId[i.streamId].push(key);
6262

6363
// continue
64-
const variation = (i.variations != null) ? Object.keys(i.variations.eventType).join(', ') : '';
64+
const variation = (i.variations?.eventType != null) ? `(${i.variations.eventType.label.en}): ` + i.variations.eventType.options.map(v => v.value).join(', ') : '';
6565
const type = (typeof i.eventType === 'string') ? i.eventType : variation;
6666
const select = (i.options == null) ? '' : '<BR><SELECT style="width: 20em">' + i.options.map((o) => (`<OPTION>${o.value}: ${o.label.en}</OPTION>`)).join('') + '</SELECT>';
6767
const infos = (i.devNotes == null) ? '' : `<BR><span style="font-style: italic; font-size: small">${i.devNotes.replaceAll('\n', '<br>')}</span>`;

src/items.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ function addItem (key, itemSrc) {
7474
// an item may have variation of eventTypes (e.g. body-weight)
7575
const itemEventTypes = [];
7676
if (item.variations?.eventType) {
77-
itemEventTypes.push(...Object.keys(item.variations?.eventType));
77+
const types = item.variations.eventType.options.map(o => o.value);
78+
itemEventTypes.push(...types);
7879
if (item.eventType) {
7980
throw new Error(`Item with ${key} mixes eventType and variation.eventTypes: ${JSON.stringify(item)}`);
8081
}

src/schemas/items.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,27 @@ const itemSchema = {
5757
type: 'object',
5858
nullable: false,
5959
properties: {
60-
eventTypes: {
61-
type: 'object'
60+
eventType: {
61+
type: 'object',
62+
properties: {
63+
label: { $ref: 'defs.json#/definitions/localized' },
64+
options: {
65+
type: 'array',
66+
items: {
67+
type: 'object',
68+
nullable: false,
69+
properties: {
70+
value: { type: 'string' },
71+
label: { $ref: 'defs.json#/definitions/localized' }
72+
},
73+
required: ['value', 'label'],
74+
additionalProperties: false
75+
}
76+
}
77+
}
6278
}
63-
}
79+
},
80+
additionalProperties: false
6481
}
6582
},
6683
allOf: [

0 commit comments

Comments
 (0)