@d4l/collect-lib 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +8 -0
- package/README.md +319 -0
- package/dist/index.d.mts +1129 -0
- package/dist/index.d.ts +1129 -0
- package/dist/index.js +5249 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +5249 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +44 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1129 @@
|
|
|
1
|
+
import { Duration } from 'luxon';
|
|
2
|
+
import * as fhir_r5 from 'fhir/r5';
|
|
3
|
+
|
|
4
|
+
type ConsentTimes = {
|
|
5
|
+
[key: string]: Date | null;
|
|
6
|
+
};
|
|
7
|
+
type Consent = {
|
|
8
|
+
name: string;
|
|
9
|
+
programName: string;
|
|
10
|
+
version: number;
|
|
11
|
+
text: TranslatedString;
|
|
12
|
+
title: TranslatedString;
|
|
13
|
+
published?: string;
|
|
14
|
+
};
|
|
15
|
+
type ConsentPath = RecursiveKeyOf<Consent>;
|
|
16
|
+
|
|
17
|
+
type Answer = string | string[];
|
|
18
|
+
type Answers = {
|
|
19
|
+
[key: string]: Answer;
|
|
20
|
+
};
|
|
21
|
+
type MultiAnswers = {
|
|
22
|
+
[key: string]: {
|
|
23
|
+
date: Date | null;
|
|
24
|
+
answers: Answers;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
type Survey = {
|
|
28
|
+
name: string;
|
|
29
|
+
programName: string;
|
|
30
|
+
frequency: TaskFrequency;
|
|
31
|
+
scoring?: SurveyScoring;
|
|
32
|
+
content: SurveyContent;
|
|
33
|
+
};
|
|
34
|
+
type TaskFrequency = {
|
|
35
|
+
type: FrequencyType;
|
|
36
|
+
start: string;
|
|
37
|
+
end?: string;
|
|
38
|
+
location?: string;
|
|
39
|
+
factor?: number;
|
|
40
|
+
editDuration?: string;
|
|
41
|
+
skipFirst?: boolean;
|
|
42
|
+
retainCTAs?: number;
|
|
43
|
+
allowAddOnDemand?: boolean;
|
|
44
|
+
};
|
|
45
|
+
type SurveyScoring = {
|
|
46
|
+
scores: {
|
|
47
|
+
valueset?: {
|
|
48
|
+
[valuesetURL: string]: {
|
|
49
|
+
[answerCode: string]: number;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
number?: {
|
|
53
|
+
[questionLinkId: string]: ScoreThreshold[];
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
type ScoreThreshold = {
|
|
58
|
+
operator: string;
|
|
59
|
+
threshold: number;
|
|
60
|
+
score: number;
|
|
61
|
+
};
|
|
62
|
+
type FrequencyType = 'single' | 'daily' | 'weekly' | 'monthly' | 'onDemand';
|
|
63
|
+
type SurveyContent = {
|
|
64
|
+
default: {
|
|
65
|
+
title: TranslatedString;
|
|
66
|
+
description?: TranslatedString;
|
|
67
|
+
image?: string;
|
|
68
|
+
icon?: string;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
type SurveyContentPath = RecursiveKeyOf<SurveyContent>;
|
|
72
|
+
|
|
73
|
+
type Display = {
|
|
74
|
+
name: string;
|
|
75
|
+
programName: string;
|
|
76
|
+
displayType: DisplayType;
|
|
77
|
+
frequency: TaskFrequency;
|
|
78
|
+
content: DisplayContent;
|
|
79
|
+
};
|
|
80
|
+
type DisplayType = 'report' | 'recommendation' | 'end-of-participation';
|
|
81
|
+
type DisplayContent = {
|
|
82
|
+
default: {
|
|
83
|
+
title: TranslatedString;
|
|
84
|
+
message: TranslatedString;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
type DisplayContentPath = RecursiveKeyOf<DisplayContent>;
|
|
88
|
+
interface SeenDisplay {
|
|
89
|
+
/**
|
|
90
|
+
* The name of the triggering display step
|
|
91
|
+
*/
|
|
92
|
+
name: string;
|
|
93
|
+
/**
|
|
94
|
+
* Date at which the display was seen by the user
|
|
95
|
+
*/
|
|
96
|
+
seenAt: string;
|
|
97
|
+
/**
|
|
98
|
+
* The app language at the point at which the user has seen the display
|
|
99
|
+
*/
|
|
100
|
+
lng: string;
|
|
101
|
+
/**
|
|
102
|
+
* The type of display
|
|
103
|
+
*/
|
|
104
|
+
displayType: DisplayType;
|
|
105
|
+
/**
|
|
106
|
+
* If applicable, the content of the display
|
|
107
|
+
*/
|
|
108
|
+
content?: DisplayContent;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
interface EligibilityScore {
|
|
112
|
+
/**
|
|
113
|
+
* The actual survey name
|
|
114
|
+
*/
|
|
115
|
+
surveyName: string;
|
|
116
|
+
/**
|
|
117
|
+
* The actual eligibility score
|
|
118
|
+
*/
|
|
119
|
+
value: number;
|
|
120
|
+
/**
|
|
121
|
+
* The maximum eligibility score
|
|
122
|
+
*/
|
|
123
|
+
max: number;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
type SkippedStep = {
|
|
127
|
+
programName: string;
|
|
128
|
+
stepType: ProgramStepType;
|
|
129
|
+
stepInfo: string;
|
|
130
|
+
createdAt: string;
|
|
131
|
+
updatedAt: string;
|
|
132
|
+
};
|
|
133
|
+
type Program = {
|
|
134
|
+
name: string;
|
|
135
|
+
tenantID: string;
|
|
136
|
+
languages: string[];
|
|
137
|
+
type: ProgramType;
|
|
138
|
+
phases: ProgramStep[][];
|
|
139
|
+
donation: ProgramDonation;
|
|
140
|
+
content: ProgramContent;
|
|
141
|
+
endDate?: string;
|
|
142
|
+
tags?: ProgramTag[];
|
|
143
|
+
publishedAt?: string;
|
|
144
|
+
};
|
|
145
|
+
type ProgramType = 'study' | 'sensor';
|
|
146
|
+
type ProgramStepBase = {
|
|
147
|
+
type: ProgramStepType;
|
|
148
|
+
required: boolean;
|
|
149
|
+
start?: StepCondition;
|
|
150
|
+
end?: StepCondition;
|
|
151
|
+
requiredCondition?: StepCondition;
|
|
152
|
+
};
|
|
153
|
+
type ProgramStepType = 'consent' | 'token' | 'survey' | 'routine' | 'display' | 'eligibility' | 'sensor';
|
|
154
|
+
type ProgramStep = ProgramConsentStep | ProgramTokenStep | ProgramSurveyStep | ProgramDisplayStep | ProgramEligibilityStep | ProgramSensorStep | ProgramRoutineStep;
|
|
155
|
+
type ProgramConsentStep = ProgramStepBase & {
|
|
156
|
+
type: 'consent';
|
|
157
|
+
consentKey: string;
|
|
158
|
+
minVersion?: number;
|
|
159
|
+
};
|
|
160
|
+
type ProgramTokenStep = ProgramStepBase & {
|
|
161
|
+
type: 'token';
|
|
162
|
+
tokenLength: number;
|
|
163
|
+
};
|
|
164
|
+
type ProgramSurveyStep = ProgramStepBase & {
|
|
165
|
+
type: 'survey';
|
|
166
|
+
surveyName: string;
|
|
167
|
+
standalone?: boolean;
|
|
168
|
+
};
|
|
169
|
+
type ProgramRoutineStep = ProgramStepBase & {
|
|
170
|
+
type: 'routine';
|
|
171
|
+
routineName: string;
|
|
172
|
+
};
|
|
173
|
+
type ProgramDisplayStep = ProgramStepBase & {
|
|
174
|
+
type: 'display';
|
|
175
|
+
displayName: string;
|
|
176
|
+
isCompleted?: boolean;
|
|
177
|
+
};
|
|
178
|
+
type ProgramEligibilityStep = ProgramStepBase & {
|
|
179
|
+
type: 'eligibility';
|
|
180
|
+
surveyName: string;
|
|
181
|
+
threshold: Threshold;
|
|
182
|
+
standalone?: boolean;
|
|
183
|
+
};
|
|
184
|
+
type Threshold = {
|
|
185
|
+
operator: ComparisonOperator;
|
|
186
|
+
value: number;
|
|
187
|
+
};
|
|
188
|
+
type ComparisonOperator = 'exists' | 'eq' | 'neq' | 'gt' | 'lt' | 'gteq' | 'lteq';
|
|
189
|
+
type ProgramSensorStep = ProgramStepBase & {
|
|
190
|
+
type: 'sensor';
|
|
191
|
+
devices: ProgramDevice[];
|
|
192
|
+
};
|
|
193
|
+
type StepCondition = {
|
|
194
|
+
type: ConditionType;
|
|
195
|
+
surveyName?: string;
|
|
196
|
+
routineName?: string;
|
|
197
|
+
linkID?: string;
|
|
198
|
+
questionType?: ConditionQuestionType;
|
|
199
|
+
operand?: string;
|
|
200
|
+
operator?: ConditionOperatorType;
|
|
201
|
+
offset?: string;
|
|
202
|
+
item?: StepCondition;
|
|
203
|
+
items?: StepCondition[];
|
|
204
|
+
sorting?: ConditionSorting;
|
|
205
|
+
consentKey?: string;
|
|
206
|
+
};
|
|
207
|
+
type ConditionType = 'question' | 'survey' | 'routine' | 'and' | 'or' | 'offset' | 'consent';
|
|
208
|
+
type ConditionQuestionType = 'coding' | 'date';
|
|
209
|
+
type ConditionOperatorType = fhir5.QuestionnaireItemEnableWhen['operator'];
|
|
210
|
+
type ConditionSorting = 'earliest' | 'latest';
|
|
211
|
+
type ProgramDonation = {
|
|
212
|
+
consentKey?: string;
|
|
213
|
+
delay: number;
|
|
214
|
+
revocation: 'delete' | 'anonymize';
|
|
215
|
+
anonymization?: ProgramAnonymization;
|
|
216
|
+
target: string;
|
|
217
|
+
};
|
|
218
|
+
type ProgramAnonymization = {
|
|
219
|
+
blur?: {
|
|
220
|
+
location: string;
|
|
221
|
+
authored?: DateBlurringFunction;
|
|
222
|
+
researchSubject?: DateBlurringFunction;
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
type DateBlurringFunction = 'startOfDay' | 'endOfDay' | 'startOfWeek' | 'endOfWeek' | 'startOfMonth' | 'endOfMonth';
|
|
226
|
+
type ProgramContent = {
|
|
227
|
+
title: TranslatedString;
|
|
228
|
+
description: TranslatedString;
|
|
229
|
+
contact: TranslatedString;
|
|
230
|
+
image?: string;
|
|
231
|
+
privacyPolicy?: {
|
|
232
|
+
text: TranslatedString;
|
|
233
|
+
};
|
|
234
|
+
participationInformation?: {
|
|
235
|
+
text: TranslatedString;
|
|
236
|
+
};
|
|
237
|
+
eligibility?: {
|
|
238
|
+
title: TranslatedString;
|
|
239
|
+
description: TranslatedString;
|
|
240
|
+
include: TranslatedString;
|
|
241
|
+
exclude: TranslatedString;
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
type ProgramContentPath = RecursiveKeyOf<ProgramContent>;
|
|
245
|
+
type ProgramTag = {
|
|
246
|
+
code: string;
|
|
247
|
+
labels: TranslatedString;
|
|
248
|
+
effectiveType: TagEffectiveType;
|
|
249
|
+
};
|
|
250
|
+
type TagEffectiveType = 'dateTime' | 'period' | 'unknown';
|
|
251
|
+
|
|
252
|
+
interface QuestionnaireResponse {
|
|
253
|
+
status: fhir5.QuestionnaireResponse['status'];
|
|
254
|
+
language: string;
|
|
255
|
+
answers: {
|
|
256
|
+
id: string;
|
|
257
|
+
type: QuestionInputType;
|
|
258
|
+
response: ReponseValue | ReponseValue[];
|
|
259
|
+
text: string;
|
|
260
|
+
}[];
|
|
261
|
+
questionnaire: {
|
|
262
|
+
name: string;
|
|
263
|
+
url: string;
|
|
264
|
+
version: string;
|
|
265
|
+
};
|
|
266
|
+
createdAt: string;
|
|
267
|
+
programName: string;
|
|
268
|
+
/**
|
|
269
|
+
* Date for which this response was expected
|
|
270
|
+
*/
|
|
271
|
+
effectiveDate?: string;
|
|
272
|
+
isSkipped?: boolean;
|
|
273
|
+
}
|
|
274
|
+
type ReponseValue = {
|
|
275
|
+
value: string;
|
|
276
|
+
system?: string;
|
|
277
|
+
display?: string;
|
|
278
|
+
};
|
|
279
|
+
type QuestionInputType = 'decimal' | 'date' | 'year' | 'single-select' | 'multi-select' | 'scale-ordinal' | 'scale-numeric' | 'string' | 'text';
|
|
280
|
+
|
|
281
|
+
type DEVICE_ANNOTATION_DATA_TYPE = 'header' | 'flag' | 'any' | 'timestamp' | 'heartRate' | 'eulerAngles' | 'acceleration' | 'freeAcceleration' | 'angularSpeed' | 'angularVelocity' | 'magneticField' | 'distance' | 'remoteDistance' | 'rssi' | 'beaconId' | 'caloriesTotal' | 'distanceTotal' | 'speed' | 'motionCadence' | 'floorsTotal' | 'absoluteElevation' | 'positiveElevationTotal' | 'negativeElevationTotal' | 'minSpeed' | 'maxSpeed' | 'averageSpeed' | 'minMotionCadence' | 'maxMotionCadence' | 'averageMotionCadence' | 'vo2max' | 'stepsTotal' | 'runningStepsTotal' | 'dailySteps' | 'dailyDistance' | 'dailyCalories' | 'dailyFloors' | 'dailyElevationGain' | 'activityDetection' | 'egvs' | 'ecg' | 'spo2' | 'samsungSdkHeartRate' | 'interbeatInterval' | 'ppgGreen' | 'ppgRed' | 'ppgInfrared' | 'skinTemperature' | 'sleepLevel' | 'duration' | 'respiratoryRate' | 'hrv' | 'calories' | 'steps' | 'normalWalkingEnergyExpenditure' | 'normalWalkingEnergyExpenditurePerHour' | 'intensityEnergyExpenditure' | 'intensityEnergyExpenditurePerHour' | 'totalEnergyExpenditurePerHour' | 'fatBurned' | 'fatBurnedPerHour' | 'metabolicEquivalent' | 'minimumMetabolicEquivalent' | 'maximumMetabolicEquivalent' | 'averageMetabolicEquivalent' | 'durationOfNormalWalkingEpisodes' | 'durationOfIntensityWalkingEpisodes';
|
|
282
|
+
type DEVICE_ANNOTATION_DATA_FORMAT = 'bitmask' | 'boolean' | 'unsignedInt' | 'signedInt' | 'signedBigInt' | 'float32' | 'float64' | 'byte';
|
|
283
|
+
type DEVICE_ANNOTATION = DEVICE_ANNOTATION_ITEM[];
|
|
284
|
+
interface DEVICE_ANNOTATION_ITEM {
|
|
285
|
+
type: DEVICE_ANNOTATION_DATA_TYPE;
|
|
286
|
+
size: number;
|
|
287
|
+
format: DEVICE_ANNOTATION_DATA_FORMAT;
|
|
288
|
+
channels?: number;
|
|
289
|
+
channelLabels?: string[];
|
|
290
|
+
littleEndian?: boolean;
|
|
291
|
+
unit?: string;
|
|
292
|
+
note?: string;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
declare const RECORDING_MODEL_CURRENT_VERSION = "0.0.6";
|
|
296
|
+
interface Recording {
|
|
297
|
+
version: string;
|
|
298
|
+
effectiveFrom?: string;
|
|
299
|
+
effectiveTo?: string;
|
|
300
|
+
duration?: number;
|
|
301
|
+
tags: RecordingTag[];
|
|
302
|
+
deviceKeys: DEVICE_KEY[];
|
|
303
|
+
dataTypes: DEVICE_ANNOTATION_DATA_TYPE[];
|
|
304
|
+
note?: string;
|
|
305
|
+
routine?: string;
|
|
306
|
+
isPassive?: boolean;
|
|
307
|
+
isSkipped?: boolean;
|
|
308
|
+
}
|
|
309
|
+
type RecordingTag = {
|
|
310
|
+
id: string;
|
|
311
|
+
start: string;
|
|
312
|
+
end?: string;
|
|
313
|
+
code: string;
|
|
314
|
+
labels: {
|
|
315
|
+
[key: string]: string;
|
|
316
|
+
};
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
type DeviceConfig = BLEDeviceConfig | InternalDeviceConfig | APIDeviceConfig;
|
|
320
|
+
interface BaseDeviceConfig {
|
|
321
|
+
device: DEVICE_KEY;
|
|
322
|
+
}
|
|
323
|
+
interface BLEDeviceConfig extends BaseDeviceConfig {
|
|
324
|
+
type: 'ble';
|
|
325
|
+
device: DEVICE_KEY_BLE;
|
|
326
|
+
dataTypes: DEVICE_ANNOTATION_DATA_TYPE[];
|
|
327
|
+
labels?: BleDeviceMetaLabel[];
|
|
328
|
+
outputRate?: number;
|
|
329
|
+
sensorDelay?: number;
|
|
330
|
+
streamingMode?: DEVICE_MOVELLA_PAYLOAD_MODES;
|
|
331
|
+
}
|
|
332
|
+
interface InternalDeviceConfig extends BaseDeviceConfig {
|
|
333
|
+
type: 'internal';
|
|
334
|
+
device: DEVICE_KEY_INTERNAL;
|
|
335
|
+
dataTypes: DEVICE_ANNOTATION_DATA_TYPE[];
|
|
336
|
+
}
|
|
337
|
+
interface APIDeviceConfig extends BaseDeviceConfig {
|
|
338
|
+
type: 'api';
|
|
339
|
+
device: DEVICE_KEY_API;
|
|
340
|
+
dataTypes: DEVICE_SIGNAL_TYPE[];
|
|
341
|
+
}
|
|
342
|
+
interface BleDeviceMetaLabel {
|
|
343
|
+
device: string;
|
|
344
|
+
name: string;
|
|
345
|
+
de?: string;
|
|
346
|
+
en?: string;
|
|
347
|
+
}
|
|
348
|
+
type DEVICE_KEY = DEVICE_KEY_BLE | DEVICE_KEY_API | DEVICE_KEY_INTERNAL;
|
|
349
|
+
type DEVICE_KEY_BLE = 'DOT' | 'OH1' | 'H10' | 'EstimoteUWB' | 'TicWatchE2' | 'PixelWatch1' | 'GalaxyWatch6';
|
|
350
|
+
type DEVICE_KEY_API = 'FITBIT' | 'DEXCOM' | 'dexcom_g4' | 'dexcom_g5' | 'dexcom_g6' | 'dexcom_g6+' | 'dexcom_g7';
|
|
351
|
+
type DEVICE_KEY_INTERNAL = 'INTERNAL' | 'internal_accelerometer' | 'internal_gyroscope' | 'internal_magnetometer' | 'internal_beacon_sensing';
|
|
352
|
+
type DEVICE_MOVELLA_PAYLOAD_MODES = 'completeEuler' | 'customMode1' | 'rateQuantities';
|
|
353
|
+
type DEVICE_SIGNAL_TYPE = 'heartRate' | 'imu' | 'beacon' | 'beaconUWB' | 'beaconRemoteUWB' | 'rssiScan' | 'physicalActivityMonitoring' | 'customPassiveMonitoring' | 'activeSamsungSDKMonitoring' | 'passiveSamsungSDKMonitoring' | 'accelerometer' | 'gyroscope' | 'magnetometer' | 'egvs' | 'heartRateVariability' | 'respiratoryRate' | 'steps' | 'calories' | 'sleep' | 'skinTemperature' | 'spo2';
|
|
354
|
+
|
|
355
|
+
declare const RECORDING_SIGNAL_MODEL_CURRENT_VERSION = "0.0.8";
|
|
356
|
+
interface RecordingSignalItem {
|
|
357
|
+
date: Date;
|
|
358
|
+
value: Uint8Array;
|
|
359
|
+
}
|
|
360
|
+
interface RecordingSignalPreview {
|
|
361
|
+
dataType: string;
|
|
362
|
+
items: PreviewTimeSeriesItem[];
|
|
363
|
+
}
|
|
364
|
+
interface PreviewTimeSeriesItem {
|
|
365
|
+
date: Date;
|
|
366
|
+
values: number[];
|
|
367
|
+
}
|
|
368
|
+
interface RecordingSignal {
|
|
369
|
+
version: string;
|
|
370
|
+
peripheralId: string;
|
|
371
|
+
recordingId: string;
|
|
372
|
+
deviceKey: DEVICE_KEY;
|
|
373
|
+
annotation: DEVICE_ANNOTATION;
|
|
374
|
+
effectiveFrom?: string;
|
|
375
|
+
effectiveTo?: string;
|
|
376
|
+
duration?: number;
|
|
377
|
+
vendorId?: string;
|
|
378
|
+
manufacturerName?: string;
|
|
379
|
+
deviceShortName?: string;
|
|
380
|
+
deviceFullName?: string;
|
|
381
|
+
deviceLabel?: BleDeviceMetaLabel;
|
|
382
|
+
outputRate?: number;
|
|
383
|
+
sensorDelay?: number;
|
|
384
|
+
type?: DEVICE_SIGNAL_TYPE;
|
|
385
|
+
items?: RecordingSignalItem[];
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* See: https://build.fhir.org/valueset-research-subject-state.html
|
|
390
|
+
*/
|
|
391
|
+
type ResearchSubjectProgressState = 'candidate' | 'eligible' | 'follow-up' | 'ineligible' | 'not-registered' | 'off-study' | 'on-study' | 'on-study-intervention' | 'on-study-observation' | 'pending-on-study' | 'potential-candidate' | 'screening' | 'withdrawn';
|
|
392
|
+
type ResearchSubjectProgress = {
|
|
393
|
+
state: ResearchSubjectProgressState;
|
|
394
|
+
date?: string;
|
|
395
|
+
};
|
|
396
|
+
interface ResearchSubject {
|
|
397
|
+
/**
|
|
398
|
+
* See: https://build.fhir.org/researchsubject.html#statemachine
|
|
399
|
+
* Flow:
|
|
400
|
+
* 1. "candidate" Registered with donation service but not consented
|
|
401
|
+
* With eligibility test
|
|
402
|
+
* 2. "screening" Consented but eligibility test not completed
|
|
403
|
+
* 3. "eligible" If eligible after eligibility test
|
|
404
|
+
* 3.1 "on-study" After passing eligibility test
|
|
405
|
+
* 4. "ineligible" If ineligible after eligibility test
|
|
406
|
+
* 4.1 "off-study" After failing eligibility test and leaving the study while revoking consent
|
|
407
|
+
*
|
|
408
|
+
* Without eligibility test
|
|
409
|
+
* 2. "on-study" Consented
|
|
410
|
+
* 3. "off-study" When leaving the study an revoking consent
|
|
411
|
+
*/
|
|
412
|
+
progress: ResearchSubjectProgress[];
|
|
413
|
+
/**
|
|
414
|
+
* The name of the program to which this ResearchSubject belongs
|
|
415
|
+
*/
|
|
416
|
+
programName: string;
|
|
417
|
+
/**
|
|
418
|
+
* Information about the user, i.e anonymous or the token
|
|
419
|
+
*/
|
|
420
|
+
subject: string;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
type RoutineTimes = {
|
|
424
|
+
[key: string]: Date | null;
|
|
425
|
+
};
|
|
426
|
+
type Routine = {
|
|
427
|
+
name: string;
|
|
428
|
+
programName: string;
|
|
429
|
+
frequency: TaskFrequency;
|
|
430
|
+
content: RoutineContent;
|
|
431
|
+
devices: ProgramDevice[];
|
|
432
|
+
duration?: string;
|
|
433
|
+
};
|
|
434
|
+
type ProgramDevice = {
|
|
435
|
+
type: ProgramDeviceType;
|
|
436
|
+
dataTypes: ProgramDevicesDataType[];
|
|
437
|
+
labels?: ProgramDevicesLabel[];
|
|
438
|
+
outputRate?: number;
|
|
439
|
+
sensorDelay?: number;
|
|
440
|
+
streamingMode?: DEVICE_MOVELLA_PAYLOAD_MODES;
|
|
441
|
+
clientID?: string;
|
|
442
|
+
};
|
|
443
|
+
type ProgramDeviceType = 'EstimoteUWB' | 'DEXCOM' | 'DOT' | 'H10' | 'OH1' | 'INTERNAL' | 'FITBIT' | 'GalaxyWatch6' | 'PixelWatch1';
|
|
444
|
+
type ProgramDevicesDataType = 'distance' | 'rssi' | 'eulerAngles' | 'freeAcceleration' | 'angularVelocity' | 'heartRate' | 'hrv' | 'internal_gyroscope' | 'internal_accelerometer' | 'internal_magnetometer' | 'internal_beacon_sensing' | 'acceleration' | 'angularSpeed' | 'magneticField' | 'stepsTotal' | 'caloriesTotal' | 'distanceTotal' | 'floorsTotal' | 'absoluteElevation' | 'positiveElevationTotal' | 'negativeElevationTotal' | 'minSpeed' | 'maxSpeed' | 'averageSpeed' | 'speed' | 'vo2max' | 'motionCadence' | 'minMotionCadence' | 'maxMotionCadence' | 'averageMotionCadence' | 'dailySteps' | 'dailyDistance' | 'dailyCalories' | 'dailyFloors' | 'activityDetection' | 'egvs' | 'samsungSdkHeartRate' | 'interbeatInterval' | 'skinTemperature' | 'ppgGreen' | 'ppgRed' | 'ppgInfrared' | 'ecg' | 'spo2' | 'steps' | 'calories' | 'sleep' | 'respiratoryRate';
|
|
445
|
+
type ProgramDevicesLabel = {
|
|
446
|
+
name: string;
|
|
447
|
+
} & TranslatedString;
|
|
448
|
+
type RoutineContent = {
|
|
449
|
+
default: {
|
|
450
|
+
title: TranslatedString;
|
|
451
|
+
};
|
|
452
|
+
steps?: RoutineContentStep[];
|
|
453
|
+
};
|
|
454
|
+
type RoutineContentStep = {
|
|
455
|
+
title: TranslatedString;
|
|
456
|
+
blocks: {
|
|
457
|
+
image?: string;
|
|
458
|
+
instructions: TranslatedString;
|
|
459
|
+
}[];
|
|
460
|
+
};
|
|
461
|
+
type RoutineContentPath = RecursiveKeyOf<RoutineContent>;
|
|
462
|
+
|
|
463
|
+
interface Tag {
|
|
464
|
+
code: string;
|
|
465
|
+
labels: {
|
|
466
|
+
[key: string]: string;
|
|
467
|
+
};
|
|
468
|
+
date: string;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
type TranslatedString = {
|
|
472
|
+
[key: string]: string;
|
|
473
|
+
};
|
|
474
|
+
/**
|
|
475
|
+
* Extract all nested keys of a type
|
|
476
|
+
*/
|
|
477
|
+
type RecursiveKeyOf<TObj extends object> = {
|
|
478
|
+
[TKey in keyof TObj & (string | number)]: RecursiveKeyOfHandleValue<TObj[TKey], `${TKey}`>;
|
|
479
|
+
}[keyof TObj & (string | number)];
|
|
480
|
+
type RecursiveKeyOfInner<TObj extends object> = {
|
|
481
|
+
[TKey in keyof TObj & (string | number)]: RecursiveKeyOfHandleValue<TObj[TKey], `.${TKey}`>;
|
|
482
|
+
}[keyof TObj & (string | number)];
|
|
483
|
+
type RecursiveKeyOfHandleValue<TValue, Text extends string> = TValue extends any[] ? Text : TValue extends object ? Text | `${Text}${RecursiveKeyOfInner<TValue>}` : Text;
|
|
484
|
+
|
|
485
|
+
declare function toDeviceConfig(devices: ProgramDevice[]): DeviceConfig[];
|
|
486
|
+
|
|
487
|
+
declare const DEVICE_ANNOTATION_TIMESTAMP_SIZE = 6;
|
|
488
|
+
declare const DEVICE_ANNOTATION_TIMESTAMP_UNIT = "ms";
|
|
489
|
+
declare const DEVICE_ANNOTATION_TIMESTAMP_NOTE = "UNIX epoch";
|
|
490
|
+
declare const DEVICE_ANNOTATION_ITEM_UNIX_TIMESTAMP: DEVICE_ANNOTATION_ITEM;
|
|
491
|
+
declare const DEVICE_ANNOTATION_ITEM_ACCELERATION: DEVICE_ANNOTATION_ITEM;
|
|
492
|
+
declare const DEVICE_ANNOTATION_ITEM_ANGULAR_SPEED: DEVICE_ANNOTATION_ITEM;
|
|
493
|
+
declare const DEVICE_ANNOTATION_ITEM_MAGNETIC_FIELD: DEVICE_ANNOTATION_ITEM;
|
|
494
|
+
declare const DEVICE_ANNOTATION_ITEM_RSSI: DEVICE_ANNOTATION_ITEM;
|
|
495
|
+
declare const DEVICE_ANNOTATION_ITEM_BEACON_ID: DEVICE_ANNOTATION_ITEM;
|
|
496
|
+
declare const DEVICE_ANNOTATION_ITEM_DISTANCE: DEVICE_ANNOTATION_ITEM;
|
|
497
|
+
declare const DEVICE_ANNOTATION_ITEM_REMOTE_DISTANCE: DEVICE_ANNOTATION_ITEM;
|
|
498
|
+
declare const DEVICE_ANNOTATION_ITEM_EGVS: DEVICE_ANNOTATION_ITEM;
|
|
499
|
+
declare const DEVICE_ANNOTATION_ITEM_HEARTRATE: DEVICE_ANNOTATION_ITEM;
|
|
500
|
+
declare const DEVICE_ANNOTATION_HEARTRATE: DEVICE_ANNOTATION;
|
|
501
|
+
|
|
502
|
+
declare const FITBIT_ANNOTATION_ITEM_CALORIES: DEVICE_ANNOTATION_ITEM;
|
|
503
|
+
declare const FITBIT_CALORIES_ANNOTATION: DEVICE_ANNOTATION;
|
|
504
|
+
declare const FITBIT_ANNOTATION_ITEM_STEPS: DEVICE_ANNOTATION_ITEM;
|
|
505
|
+
declare const FITBIT_STEPS_ANNOTATION: DEVICE_ANNOTATION;
|
|
506
|
+
declare const FITBIT_ANNOTATION_ITEM_HEART_RATE: DEVICE_ANNOTATION_ITEM;
|
|
507
|
+
declare const FITBIT_HEART_RATE_ANNOTATION: DEVICE_ANNOTATION;
|
|
508
|
+
declare const FITBIT_ANNOTATION_ITEM_HEART_RATE_VARIABILITY: DEVICE_ANNOTATION_ITEM;
|
|
509
|
+
declare const FITBIT_HEART_RATE_VARIABILITY_ANNOTATION: DEVICE_ANNOTATION;
|
|
510
|
+
declare const FITBIT_ANNOTATION_ITEM_BREATHING_RATE: DEVICE_ANNOTATION_ITEM;
|
|
511
|
+
declare const FITBIT_BREATHING_RATE_ANNOTATION: DEVICE_ANNOTATION;
|
|
512
|
+
declare const FITBIT_ANNOTATION_ITEM_SKIN_TEMPERATURE: DEVICE_ANNOTATION_ITEM;
|
|
513
|
+
declare const FITBIT_SKIN_TEMPERATURE_ANNOTATION: DEVICE_ANNOTATION;
|
|
514
|
+
/**
|
|
515
|
+
* Encodes the Fitbit api sleep level types to unsigned integers for buffer encoding
|
|
516
|
+
*/
|
|
517
|
+
type FitbitSleepLevelTypes = 'restless' | 'asleep' | 'awake' | 'deep' | 'light' | 'rem' | 'wake';
|
|
518
|
+
declare const FITBIT_SLEEP_LEVEL_MAP: {
|
|
519
|
+
[key in FitbitSleepLevelTypes]: number;
|
|
520
|
+
};
|
|
521
|
+
declare const FITBIT_ANNOTATION_ITEM_SLEEP_LEVEL: DEVICE_ANNOTATION_ITEM;
|
|
522
|
+
declare const FITBIT_ANNOTATION_ITEM_SLEEP_LEVEL_DURATION: DEVICE_ANNOTATION_ITEM;
|
|
523
|
+
declare const FITBIT_SLEEP_ANNOTATION: DEVICE_ANNOTATION;
|
|
524
|
+
declare const FITBIT_ANNOTATION_ITEM_SPO2: DEVICE_ANNOTATION_ITEM;
|
|
525
|
+
declare const FITBIT_SPO2_ANNOTATION: DEVICE_ANNOTATION;
|
|
526
|
+
declare const FITBIT_SIGNAL_TYPE_ANNOTATIONS: {
|
|
527
|
+
[key in DEVICE_SIGNAL_TYPE]?: DEVICE_ANNOTATION;
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
declare const InternalSensorAnnotationTypes: {
|
|
531
|
+
[key in DEVICE_KEY_INTERNAL]?: DEVICE_ANNOTATION_DATA_TYPE;
|
|
532
|
+
};
|
|
533
|
+
|
|
534
|
+
declare function getMovellaAnnotation(config: BLEDeviceConfig): DEVICE_ANNOTATION;
|
|
535
|
+
|
|
536
|
+
declare const DEVICE_D4L_COMPANION_ANNOTATION_ITEM_DATA_TYPES_FLAG: DEVICE_ANNOTATION_ITEM;
|
|
537
|
+
declare const DEVICE_D4L_COMPANION_ANNOTATION_ITEM_TIMESTAMP: DEVICE_ANNOTATION_ITEM;
|
|
538
|
+
declare const BLE_PAMS_ANNOTATION_ITEM_HEADER: DEVICE_ANNOTATION_ITEM;
|
|
539
|
+
declare const BLE_PAMS_ANNOTATION_ITEM_FLAGS_8: DEVICE_ANNOTATION_ITEM;
|
|
540
|
+
declare const BLE_PAMS_ANNOTATION_ITEM_FLAGS_16: DEVICE_ANNOTATION_ITEM;
|
|
541
|
+
declare const BLE_PAMS_ANNOTATION_ITEM_FLAGS_24: DEVICE_ANNOTATION_ITEM;
|
|
542
|
+
declare const BLE_PAMS_ANNOTATION_ITEM_FLAGS_32: DEVICE_ANNOTATION_ITEM;
|
|
543
|
+
declare const BLE_PAMS_ANNOTATION_ITEM_BYTE: DEVICE_ANNOTATION_ITEM;
|
|
544
|
+
declare const BLE_PAMS_ANNOTATION_ITEM_TWO_BYTES: DEVICE_ANNOTATION_ITEM;
|
|
545
|
+
declare const BLE_PAMS_ANNOTATION_ITEM_THREE_BYTES: DEVICE_ANNOTATION_ITEM;
|
|
546
|
+
declare const BLE_PAMS_ANNOTATION_ITEM_FOUR_BYTES: DEVICE_ANNOTATION_ITEM;
|
|
547
|
+
declare const BLE_PAMS_ANNOTATION_ITEM_SPEED: DEVICE_ANNOTATION_ITEM;
|
|
548
|
+
declare const BLE_PAMS_ANNOTATION_ITEM_MOTION_CADENCE: DEVICE_ANNOTATION_ITEM;
|
|
549
|
+
declare const BLE_PAMS_ANNOTATION_ITEM_ABSOLUTE_ELEVATION: DEVICE_ANNOTATION_ITEM;
|
|
550
|
+
declare const BLE_PAMS_ANNOTATION_ITEM_CALORIES_TOTAL: DEVICE_ANNOTATION_ITEM;
|
|
551
|
+
declare const BLE_PAMS_ANNOTATION_ITEM_DISTANCE_TOTAL: DEVICE_ANNOTATION_ITEM;
|
|
552
|
+
declare const BLE_PAMS_ANNOTATION_ITEM_FLOORS_TOTAL: DEVICE_ANNOTATION_ITEM;
|
|
553
|
+
declare const BLE_PAMS_ANNOTATION_ITEM_POSITIVE_ELEVATION_GAIN: DEVICE_ANNOTATION_ITEM;
|
|
554
|
+
declare const BLE_PAMS_ANNOTATION_ITEM_NEGATIVE_ELEVATION_GAIN: DEVICE_ANNOTATION_ITEM;
|
|
555
|
+
declare const BLE_PAMS_ANNOTATION_ITEM_MINIMUM_SPEED: DEVICE_ANNOTATION_ITEM;
|
|
556
|
+
declare const BLE_PAMS_ANNOTATION_ITEM_MAXIMUM_SPEED: DEVICE_ANNOTATION_ITEM;
|
|
557
|
+
declare const BLE_PAMS_ANNOTATION_ITEM_AVERAGE_SPEED: DEVICE_ANNOTATION_ITEM;
|
|
558
|
+
declare const BLE_PAMS_ANNOTATION_ITEM_MINIMUM_MOTION_CADENCE: DEVICE_ANNOTATION_ITEM;
|
|
559
|
+
declare const BLE_PAMS_ANNOTATION_ITEM_MAXIMUM_MOTION_CADENCE: DEVICE_ANNOTATION_ITEM;
|
|
560
|
+
declare const BLE_PAMS_ANNOTATION_ITEM_AVERAGE_MOTION_CADENCE: DEVICE_ANNOTATION_ITEM;
|
|
561
|
+
declare const BLE_PAMS_ANNOTATION_ITEM_HEART_RATE: DEVICE_ANNOTATION_ITEM;
|
|
562
|
+
declare const BLE_PAMS_ANNOTATION_ITEM_VO2_MAX: DEVICE_ANNOTATION_ITEM;
|
|
563
|
+
declare const BLE_PAMS_ANNOTATION_ITEM_STEPS_TOTAL: DEVICE_ANNOTATION_ITEM;
|
|
564
|
+
declare const BLE_PAMS_ANNOTATION_ITEM_RUNNING_STEPS_TOTAL: DEVICE_ANNOTATION_ITEM;
|
|
565
|
+
declare const BLE_CPMS_ANNOTATION_ITEM_DAILY_STEPS: DEVICE_ANNOTATION_ITEM;
|
|
566
|
+
declare const BLE_CPMS_ANNOTATION_ITEM_DAILY_DISTANCE: DEVICE_ANNOTATION_ITEM;
|
|
567
|
+
declare const BLE_CPMS_ANNOTATION_ITEM_DAILY_CALORIES: DEVICE_ANNOTATION_ITEM;
|
|
568
|
+
declare const BLE_CPMS_ANNOTATION_ITEM_DAILY_FLOORS: DEVICE_ANNOTATION_ITEM;
|
|
569
|
+
declare const BLE_CPMS_ANNOTATION_ITEM_DAILY_ELEVATION_GAIN: DEVICE_ANNOTATION_ITEM;
|
|
570
|
+
declare const BLE_CPMS_ANNOTATION_ITEM_ACTIVITY_TYPE: DEVICE_ANNOTATION_ITEM;
|
|
571
|
+
declare const BLE_ASMS_ANNOTATION_ITEM_ECG: DEVICE_ANNOTATION_ITEM;
|
|
572
|
+
declare const BLE_ASMS_ANNOTATION_ITEM_SPO2: DEVICE_ANNOTATION_ITEM;
|
|
573
|
+
declare const BLE_PSMS_ANNOTATION_ITEM_HEART_RATE: DEVICE_ANNOTATION_ITEM;
|
|
574
|
+
declare const BLE_PSMS_ANNOTATION_ITEM_IBI: DEVICE_ANNOTATION_ITEM;
|
|
575
|
+
declare const BLE_PSMS_ANNOTATION_ITEM_PPG_GREEN: DEVICE_ANNOTATION_ITEM;
|
|
576
|
+
declare const BLE_PSMS_ANNOTATION_ITEM_PPG_RED: DEVICE_ANNOTATION_ITEM;
|
|
577
|
+
declare const BLE_PSMS_ANNOTATION_ITEM_PPG_IR: DEVICE_ANNOTATION_ITEM;
|
|
578
|
+
declare const BLE_PSMS_ANNOTATION_ITEM_SKIN_TEMPERATURE: DEVICE_ANNOTATION_ITEM;
|
|
579
|
+
declare const IMUAnnotation: DEVICE_ANNOTATION;
|
|
580
|
+
declare const PAMSGeneralActivityInstantaneousAnnotation: DEVICE_ANNOTATION;
|
|
581
|
+
declare const PAMSGeneralActivitySummaryAnnotation: DEVICE_ANNOTATION;
|
|
582
|
+
declare const PAMSCardioVascularActivityAnnotation: DEVICE_ANNOTATION;
|
|
583
|
+
declare const PAMSStepCounterActivitySummaryAnnotation: DEVICE_ANNOTATION;
|
|
584
|
+
declare const CPMSHealthServicesPassiveDataAnnotation: DEVICE_ANNOTATION;
|
|
585
|
+
declare const CPMSHealthServicesActivityDetectionAnnotation: DEVICE_ANNOTATION;
|
|
586
|
+
declare const ASMSECGMeasurementAnnotation: DEVICE_ANNOTATION;
|
|
587
|
+
declare const ASMSSpO2MeasurementAnnotation: DEVICE_ANNOTATION;
|
|
588
|
+
declare const PSMSHeartRateAnnotation: DEVICE_ANNOTATION;
|
|
589
|
+
declare const PSMSSkinTemperatureAnnotation: DEVICE_ANNOTATION;
|
|
590
|
+
declare const PSMSPPGGreenAnnotation: DEVICE_ANNOTATION;
|
|
591
|
+
declare const PSMSPPGRedAnnotation: DEVICE_ANNOTATION;
|
|
592
|
+
declare const PSMSPPGIRAnnotation: DEVICE_ANNOTATION;
|
|
593
|
+
declare const WearOS3AnnotationMap: {
|
|
594
|
+
[key in DEVICE_SIGNAL_TYPE]?: DEVICE_ANNOTATION[];
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
interface CryptoModule {
|
|
598
|
+
deriveEncryptionKey(recoveryKey: Uint8Array, salt: string): Promise<Uint8Array>;
|
|
599
|
+
generateKey(size: number): Uint8Array;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* Converter inferface with functions that require some platform specific functions to implement
|
|
604
|
+
* Generally functions requiring either Buffer or Base64 methods provided by polyfills/replacement libs
|
|
605
|
+
*/
|
|
606
|
+
interface Converter {
|
|
607
|
+
arrayBufferToBase64: (buffer: ArrayBuffer) => string;
|
|
608
|
+
base64ToArrayBuffer: (string: string) => ArrayBuffer;
|
|
609
|
+
uint8ArrayToBase64: (array: Uint8Array) => string;
|
|
610
|
+
base64ToUint8Array: (string: string) => Uint8Array;
|
|
611
|
+
uint8ArrayToUTF8: (uint: Uint8Array) => string;
|
|
612
|
+
base64ToHex: (base64String: string) => string;
|
|
613
|
+
hexToBase64: (hex: string) => string;
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Convert a binary string (as returned by forge) to Uint8Array
|
|
617
|
+
* @param binaryString String returned by forge methods
|
|
618
|
+
* @returns The Uint8Array of the input
|
|
619
|
+
*/
|
|
620
|
+
declare const binaryStringToUint8Array: (binaryString: string) => Uint8Array;
|
|
621
|
+
/**
|
|
622
|
+
* Convert a binary string (as returned by forge) to Uint8Array
|
|
623
|
+
* @param array Uint8Array
|
|
624
|
+
* @returns The binary string representation of the input (as used by forge)
|
|
625
|
+
*/
|
|
626
|
+
declare const uint8ArrayToBinaryString: (array: Uint8Array) => string;
|
|
627
|
+
/**
|
|
628
|
+
* Convert an UTF-8 string into encoded Uint8Array.
|
|
629
|
+
* @param string The string that needs to be converted
|
|
630
|
+
* @returns The UTF-8 encoded Uint8Array of the input
|
|
631
|
+
*/
|
|
632
|
+
declare const utf8ToUint8Array: (string: string) => Uint8Array;
|
|
633
|
+
/**
|
|
634
|
+
* Browser implementation of the Converter interface
|
|
635
|
+
*/
|
|
636
|
+
declare class WebConverter implements Converter {
|
|
637
|
+
arrayBufferToBase64: (buffer: ArrayBuffer) => string;
|
|
638
|
+
base64ToArrayBuffer: (string: string) => ArrayBuffer;
|
|
639
|
+
uint8ArrayToBase64: (array: Uint8Array) => string;
|
|
640
|
+
/**
|
|
641
|
+
* Convert a base64 encoded string into Uint8Array
|
|
642
|
+
* @param string The string that needs to be converted into an Uint8Array
|
|
643
|
+
* @returns A Uint8Array
|
|
644
|
+
*/
|
|
645
|
+
base64ToUint8Array: (string: string) => Uint8Array;
|
|
646
|
+
/**
|
|
647
|
+
* Convert a base64 encoded Uint8Array into a UTF-8 encoded string
|
|
648
|
+
* @param uint The base64 encoded Uint8Array
|
|
649
|
+
* @returns The UTF-8 encoded string
|
|
650
|
+
*/
|
|
651
|
+
uint8ArrayToUTF8: (uint: Uint8Array) => string;
|
|
652
|
+
base64ToHex: (base64String: string) => string;
|
|
653
|
+
hexToBase64: (hexString: string) => string;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
declare class KeyHandler {
|
|
657
|
+
private converter;
|
|
658
|
+
private crypto;
|
|
659
|
+
constructor(converter: Converter, crypto: CryptoModule);
|
|
660
|
+
generateRecoveryKey(): Uint8Array;
|
|
661
|
+
validateRecoveryKey: (recoveryKey: Uint8Array) => boolean;
|
|
662
|
+
mnemonicToEntropy: (mnemonic: string, lng: string) => Uint8Array;
|
|
663
|
+
entropyToMnemonic: (entropy: Uint8Array | null, lng: string) => string;
|
|
664
|
+
/**
|
|
665
|
+
* Derive all necessary program keys from the recovery phrase and the program name
|
|
666
|
+
* @param recoveryKey The 16byte long recovery key (from the recovery phrase)
|
|
667
|
+
* @param programName The name of the program for which the keys should be generated
|
|
668
|
+
* @returns All necessary program keys
|
|
669
|
+
*/
|
|
670
|
+
deriveProgramKeys(recoveryKey: Uint8Array, programName: string): Promise<{
|
|
671
|
+
public: string;
|
|
672
|
+
private: string;
|
|
673
|
+
recovery: string;
|
|
674
|
+
}>;
|
|
675
|
+
extendPublicKey: (publicKey: Uint8Array) => string;
|
|
676
|
+
/**
|
|
677
|
+
* Hash a message with SHA-256
|
|
678
|
+
* @param message The message to hash
|
|
679
|
+
* @returns The hashed message
|
|
680
|
+
*/
|
|
681
|
+
hash: (message: string) => string;
|
|
682
|
+
/**
|
|
683
|
+
* Sign a message
|
|
684
|
+
* @param message The message to sign
|
|
685
|
+
* @param priv The private key used to sign the message
|
|
686
|
+
* @returns The signed message
|
|
687
|
+
*/
|
|
688
|
+
sign: (message: string, priv: string) => Promise<Uint8Array>;
|
|
689
|
+
/**
|
|
690
|
+
* Fetch the encoded signed buffer and verify it against the signature
|
|
691
|
+
* @param message The signed message
|
|
692
|
+
* @param signature The signature of the message
|
|
693
|
+
* @param pub The public key used to verify the signature
|
|
694
|
+
* @returns True, if the signature is valid. Otherwise, false.
|
|
695
|
+
*/
|
|
696
|
+
verify: (message: string, signature: Uint8Array, pub: string) => Promise<boolean>;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
type DonorIdentity = {
|
|
700
|
+
t: 'data-donation';
|
|
701
|
+
keys: {
|
|
702
|
+
priv: string;
|
|
703
|
+
pub: string;
|
|
704
|
+
rec: string;
|
|
705
|
+
};
|
|
706
|
+
v: number;
|
|
707
|
+
scope: string;
|
|
708
|
+
};
|
|
709
|
+
type DonationRecord = {
|
|
710
|
+
id: string;
|
|
711
|
+
document: fhir5.Resource;
|
|
712
|
+
status: RecordState;
|
|
713
|
+
};
|
|
714
|
+
type RecordState = 'Active' | 'Deleted';
|
|
715
|
+
interface SDKInterface {
|
|
716
|
+
/**
|
|
717
|
+
* Checks readiness state of donation service
|
|
718
|
+
* @returns true if service is available
|
|
719
|
+
*/
|
|
720
|
+
donationServiceAvailable: () => Promise<boolean>;
|
|
721
|
+
/**
|
|
722
|
+
* Create a donor identity for a program
|
|
723
|
+
* @param recoveryKey The 16byte long recovery key (from the recovery phrase)
|
|
724
|
+
* @param programName The name of the program
|
|
725
|
+
* @returns A donor identity consisting of a private-public key pair and a recovery key
|
|
726
|
+
*/
|
|
727
|
+
createDonorIdentity: (recoveryKey: Uint8Array, programName: string) => Promise<DonorIdentity>;
|
|
728
|
+
/**
|
|
729
|
+
* Register a donor identity for a program
|
|
730
|
+
* @param recoveryKey The 16byte long recovery key (from the recovery phrase)
|
|
731
|
+
* @param programName The name of the program for which the registration should be done
|
|
732
|
+
* @param participationCode The optional participation code
|
|
733
|
+
* @returns The newly created donor identity
|
|
734
|
+
*/
|
|
735
|
+
register: (recoveryKey: Uint8Array, program: Program, participationCode?: string) => Promise<{
|
|
736
|
+
donorIdentity: DonorIdentity;
|
|
737
|
+
subjectId: string;
|
|
738
|
+
}>;
|
|
739
|
+
/**
|
|
740
|
+
* Donate resources for a study
|
|
741
|
+
* @param donorIdentity The donor identity for the study
|
|
742
|
+
* @param programName The program for which the resources should be donated
|
|
743
|
+
* @param records The list of resources that should be donated
|
|
744
|
+
* @returns True, if the donation was successful. Otherwise, false.
|
|
745
|
+
*/
|
|
746
|
+
donate: (donorIdentity: DonorIdentity, program: Program, records: {
|
|
747
|
+
id: string;
|
|
748
|
+
document: fhir5.Resource;
|
|
749
|
+
status: RecordState;
|
|
750
|
+
}[]) => Promise<boolean>;
|
|
751
|
+
/**
|
|
752
|
+
* Restore donations based on already made donations
|
|
753
|
+
* @param donorIdentity The donor identity for the study
|
|
754
|
+
* @param programName The name of the program for which the resources should be restored
|
|
755
|
+
* @returns The list of resources that were donated by the given donor identity
|
|
756
|
+
*/
|
|
757
|
+
restore: (donorIdentity: DonorIdentity, programName: string) => Promise<{
|
|
758
|
+
document: fhir5.Resource;
|
|
759
|
+
id: string;
|
|
760
|
+
}[]>;
|
|
761
|
+
/**
|
|
762
|
+
* Revoke all previous donations and do a final donation
|
|
763
|
+
* @param donorIdentity The donor identity to revoke consent for
|
|
764
|
+
* @param programName The name of the program for which the resources should be revoked
|
|
765
|
+
* @param records The final donation. Must include ResearchSubject
|
|
766
|
+
* @returns True, if the revocation was successful. Otherwise, false.
|
|
767
|
+
*/
|
|
768
|
+
revoke: (donorIdentity: DonorIdentity, program: Program, records: DonationRecord[]) => Promise<boolean>;
|
|
769
|
+
}
|
|
770
|
+
declare enum ERROR_CODES {
|
|
771
|
+
COULD_NOT_SIGN = "could_not_sign",
|
|
772
|
+
PROGRAM_NOT_FOUND = "program_not_found",
|
|
773
|
+
NO_TARGET_KEY = "no_target_key",
|
|
774
|
+
COULD_NOT_GET_SERVICE_TOKEN = "could_not_get_service_token",
|
|
775
|
+
NOT_ONLINE = "not_online",
|
|
776
|
+
PROGRAM_NO_STUDY_ID = "program_no_study_id",
|
|
777
|
+
PROGRAM_NO_DONATION = "program_no_donation",
|
|
778
|
+
MISSING_PARTICIPATION_CODE = "missing_participation_code",
|
|
779
|
+
DONOR_ALREADY_REGISTERED = "donor_already_registered",
|
|
780
|
+
DONOR_REGISTRATION_FAILED = "donor_registration_failed",
|
|
781
|
+
INTERNAL_SERVER_ERROR = "internal_server_error",
|
|
782
|
+
STUDY_ID_DOES_NOT_MATCH_DONOR_IDENTITY = "study_id_does_not_match_donor",
|
|
783
|
+
MISSING_RESEARCH_SUBJECT = "missing_research_subject",
|
|
784
|
+
MISSING_CONSENT = "missing_consent",
|
|
785
|
+
RESTORE_DECRYPTION_FAILED = "restore_decryption_failed",
|
|
786
|
+
UPLOAD_PREFERENCES_NOT_MET = "upload_preferences_not_met",
|
|
787
|
+
UPLOAD_FAILED = "upload_failed"
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
declare class DonationSDK implements SDKInterface {
|
|
791
|
+
/**
|
|
792
|
+
* Flag indicating if the SDK has been initialized
|
|
793
|
+
*/
|
|
794
|
+
private selfSignSecret;
|
|
795
|
+
/**
|
|
796
|
+
* Requester targeting the Donation API
|
|
797
|
+
*/
|
|
798
|
+
private donationAPI;
|
|
799
|
+
private keyHandler;
|
|
800
|
+
private converter;
|
|
801
|
+
private hybridEncrypter;
|
|
802
|
+
constructor(selfSignSecret: string, donationAPIurl: string, converter: Converter, crypto: CryptoModule);
|
|
803
|
+
/**
|
|
804
|
+
* Get the public key for the specified target
|
|
805
|
+
* @param target The target to get the public key for
|
|
806
|
+
* @returns The public key of the donation target
|
|
807
|
+
*/
|
|
808
|
+
private getKeyFor;
|
|
809
|
+
/**
|
|
810
|
+
* Get an authenticated requester for the donation API
|
|
811
|
+
* @param donorIdentity The donor identity
|
|
812
|
+
* @returns An authenticated requester for the donation API
|
|
813
|
+
*/
|
|
814
|
+
private getAuthenticatedDonationAPI;
|
|
815
|
+
/**
|
|
816
|
+
* Create an authentication token which can be used to authenticate with the Donation API
|
|
817
|
+
* @param pub A public base64 encoded key - the donorId
|
|
818
|
+
* @param priv The corresponding base64 encoded private key
|
|
819
|
+
* @param token A unique token issued by the Donation API
|
|
820
|
+
* @param secret SELF_SIGN_SECRET configured for both UA and Donation Service
|
|
821
|
+
* @returns The authentication token that can be used to authenticate with the Donation API
|
|
822
|
+
*/
|
|
823
|
+
private createAuthToken;
|
|
824
|
+
/**
|
|
825
|
+
* Validate an authentication token which can be used to authenticated with the Donation API
|
|
826
|
+
* @param authToken The authentication token that can be used to authenticate with the Donation API
|
|
827
|
+
* @param token A unique token issued by the Donation API
|
|
828
|
+
* @param pub A public base64 encoded key - the donorId
|
|
829
|
+
* @returns True if the authentication token is valid. Otherwise, false.
|
|
830
|
+
*/
|
|
831
|
+
private validateAuthToken;
|
|
832
|
+
donationServiceAvailable(): Promise<boolean>;
|
|
833
|
+
createDonorIdentity(recoveryKey: Uint8Array, programName: string): Promise<DonorIdentity>;
|
|
834
|
+
register(recoveryKey: Uint8Array, program: Program, participationCode?: string): Promise<{
|
|
835
|
+
donorIdentity: DonorIdentity;
|
|
836
|
+
subjectId: string;
|
|
837
|
+
}>;
|
|
838
|
+
donate(donorIdentity: DonorIdentity, program: Program, records: DonationRecord[]): Promise<boolean>;
|
|
839
|
+
/**
|
|
840
|
+
* Encrypt donations to be donated to a specific target
|
|
841
|
+
* @param donatableRecords The donations to encrypt
|
|
842
|
+
* @param donorIdentity The identity of the donor to use
|
|
843
|
+
* @param target The donation target
|
|
844
|
+
* @returns The list of encrypted donations
|
|
845
|
+
*/
|
|
846
|
+
private encryptDonations;
|
|
847
|
+
restore(donorIdentity: DonorIdentity, programName: string): Promise<{
|
|
848
|
+
document: fhir5.Resource;
|
|
849
|
+
id: string;
|
|
850
|
+
status: RecordState;
|
|
851
|
+
}[]>;
|
|
852
|
+
revoke(donorIdentity: DonorIdentity, program: Program, records: DonationRecord[]): Promise<boolean>;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* Transform a string to a Date
|
|
857
|
+
* @param dateString A date string (YYYY-MM-DD)
|
|
858
|
+
* @returns The Date
|
|
859
|
+
*/
|
|
860
|
+
declare const stringToDate: (dateString: string) => Date | undefined;
|
|
861
|
+
/**
|
|
862
|
+
* Transform a string to a year
|
|
863
|
+
* @param yearString The year string (YYYY)
|
|
864
|
+
* @returns The year as a number
|
|
865
|
+
*/
|
|
866
|
+
declare const stringToYear: (yearString: string) => number | undefined;
|
|
867
|
+
declare const isYearString: (year: string) => boolean;
|
|
868
|
+
|
|
869
|
+
declare const isScoreEligible: (step: ProgramEligibilityStep, score?: number) => boolean;
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* Checks if a given condition is fulfilled by evaluating the answers of a questionnaire response.
|
|
873
|
+
*/
|
|
874
|
+
interface Guard {
|
|
875
|
+
/**
|
|
876
|
+
* Evaluates if the guard is fulfilled with the given answers
|
|
877
|
+
* @param answers Dictionary of question id -> answers value
|
|
878
|
+
*/
|
|
879
|
+
evaluate(answers: Answers): boolean;
|
|
880
|
+
/**
|
|
881
|
+
* Evaluates if the guard is fulfilled and returns since when it counts as fulfilled.
|
|
882
|
+
* Returns null if it is not fulfilled
|
|
883
|
+
* Requires surveyName to be defined to use the correct answers for evaluation.
|
|
884
|
+
* @param multiAnswers Dictionary of surveyName -> Answers, date of the response
|
|
885
|
+
* @param consentTimes Dictionary of consentKey -> date of the given consent (or null)
|
|
886
|
+
* @param routineTimes Dictionary of routine names -> date when the last recording for the routine was done (or null)
|
|
887
|
+
*/
|
|
888
|
+
getFulfillmentDate(multiAnswers: MultiAnswers, consentTimes?: ConsentTimes, routineTimes?: RoutineTimes): Date | null;
|
|
889
|
+
}
|
|
890
|
+
/**
|
|
891
|
+
* Assumption: Date answers in the questionnaire are formatted like this: YYYY-MM-DD
|
|
892
|
+
* For questionnaires returns the evaluation of <answer> <operator> <operand>.
|
|
893
|
+
* For steps returns the <answer>+<offset> of the answer
|
|
894
|
+
*/
|
|
895
|
+
declare class DateCondition implements Guard {
|
|
896
|
+
surveyName?: string;
|
|
897
|
+
questionID: string;
|
|
898
|
+
operand?: Date;
|
|
899
|
+
operator: ConditionOperatorType;
|
|
900
|
+
offset: Duration;
|
|
901
|
+
constructor(questionID: string, operand: string, operator: ConditionOperatorType, surveyName?: string, offset?: string);
|
|
902
|
+
evaluate(answers: Answers): boolean;
|
|
903
|
+
getFulfillmentDate(multiAnswers: MultiAnswers): Date | null;
|
|
904
|
+
}
|
|
905
|
+
/**
|
|
906
|
+
* Wrapper around the constructor for the creation of the stepcondition version
|
|
907
|
+
* Does not need operator and operand as it just returns a given date answer
|
|
908
|
+
*/
|
|
909
|
+
declare const newStepDateCondtion: (questionID: string, surveyName: string, offset?: string) => DateCondition;
|
|
910
|
+
/**
|
|
911
|
+
* Assumption: Year answers in the questionnaire are formatted like this: YYYY
|
|
912
|
+
*/
|
|
913
|
+
declare class YearCondition implements Guard {
|
|
914
|
+
questionID: string;
|
|
915
|
+
operand?: number;
|
|
916
|
+
operator: ConditionOperatorType;
|
|
917
|
+
constructor(questionID: string, operand: string, operator: ConditionOperatorType);
|
|
918
|
+
evaluate(answers: Answers): boolean;
|
|
919
|
+
getFulfillmentDate(_multiAnswers: MultiAnswers): Date | null;
|
|
920
|
+
}
|
|
921
|
+
declare class AnswerCodeCondition implements Guard {
|
|
922
|
+
surveyName?: string;
|
|
923
|
+
questionID: string;
|
|
924
|
+
operand?: string;
|
|
925
|
+
operator: ConditionOperatorType;
|
|
926
|
+
offset: Duration;
|
|
927
|
+
constructor(questionID: string, operand: string, operator: ConditionOperatorType, surveyName?: string, offset?: string);
|
|
928
|
+
evaluate(answers: Answers): boolean;
|
|
929
|
+
getFulfillmentDate(multiAnswers: MultiAnswers): Date | null;
|
|
930
|
+
}
|
|
931
|
+
declare class DecimalCondition implements Guard {
|
|
932
|
+
questionID: string;
|
|
933
|
+
operand?: number;
|
|
934
|
+
operator: ConditionOperatorType;
|
|
935
|
+
constructor(questionID: string, operand: fhir5.QuestionnaireItemEnableWhen['answerDecimal'], operator: ConditionOperatorType);
|
|
936
|
+
evaluate(answers: Answers): boolean;
|
|
937
|
+
getFulfillmentDate(_multiAnswers: MultiAnswers): Date | null;
|
|
938
|
+
}
|
|
939
|
+
declare class ExistsCondition implements Guard {
|
|
940
|
+
questionID: string;
|
|
941
|
+
constructor(questionID: string);
|
|
942
|
+
evaluate(answers: Answers): boolean;
|
|
943
|
+
getFulfillmentDate(_multiAnswers: MultiAnswers): Date | null;
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* Checks if a condition is true or false
|
|
947
|
+
*/
|
|
948
|
+
declare class BoolCondition implements Guard {
|
|
949
|
+
condition: boolean;
|
|
950
|
+
constructor(condition: boolean);
|
|
951
|
+
evaluate(_answers: Answers): boolean;
|
|
952
|
+
getFulfillmentDate(_multiAnswers: MultiAnswers): Date | null;
|
|
953
|
+
}
|
|
954
|
+
/**
|
|
955
|
+
* Combines a set of Guards with AND
|
|
956
|
+
*/
|
|
957
|
+
declare class Conjunction implements Guard {
|
|
958
|
+
conditions: Guard[];
|
|
959
|
+
sorting: ConditionSorting;
|
|
960
|
+
constructor(conditions: Guard[], sorting?: ConditionSorting);
|
|
961
|
+
evaluate(answers: Answers): boolean;
|
|
962
|
+
getFulfillmentDate(multiAnswers: MultiAnswers, consentTimes?: ConsentTimes): Date | null;
|
|
963
|
+
}
|
|
964
|
+
/**
|
|
965
|
+
* Combines a set of Guards with OR
|
|
966
|
+
*/
|
|
967
|
+
declare class Disjunction implements Guard {
|
|
968
|
+
conditions: Guard[];
|
|
969
|
+
sorting: ConditionSorting;
|
|
970
|
+
constructor(conditions: Guard[], sorting?: ConditionSorting);
|
|
971
|
+
evaluate(answers: Answers): boolean;
|
|
972
|
+
getFulfillmentDate(multiAnswers: MultiAnswers, consentTimes?: ConsentTimes): Date | null;
|
|
973
|
+
}
|
|
974
|
+
/**
|
|
975
|
+
* Adds an offset to getFulfillmentDate of the encapsuled item.
|
|
976
|
+
* No effect on evaluate.
|
|
977
|
+
*/
|
|
978
|
+
declare class Offset implements Guard {
|
|
979
|
+
condition: Guard;
|
|
980
|
+
offset: Duration;
|
|
981
|
+
constructor(condition: Guard, offset?: string);
|
|
982
|
+
evaluate(answers: Answers): boolean;
|
|
983
|
+
getFulfillmentDate(multiAnswers: MultiAnswers, consentTimes?: ConsentTimes): Date | null;
|
|
984
|
+
}
|
|
985
|
+
declare class ConsentCondition implements Guard {
|
|
986
|
+
consentKey: string;
|
|
987
|
+
offset: Duration;
|
|
988
|
+
constructor(consentKey: string, offset?: string);
|
|
989
|
+
evaluate(_answers: Answers): boolean;
|
|
990
|
+
getFulfillmentDate(_multiAnswers: MultiAnswers, consentTimes: ConsentTimes): Date | null;
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* Checks if the survey was answered
|
|
994
|
+
*/
|
|
995
|
+
declare class SurveyCondition implements Guard {
|
|
996
|
+
surveyName: string;
|
|
997
|
+
offset: Duration;
|
|
998
|
+
constructor(surveyName: string, offset?: string);
|
|
999
|
+
evaluate(_answers: Answers): boolean;
|
|
1000
|
+
getFulfillmentDate(multiAnswers: MultiAnswers): Date | null;
|
|
1001
|
+
}
|
|
1002
|
+
/**
|
|
1003
|
+
* Checks if a routine was recorded
|
|
1004
|
+
*/
|
|
1005
|
+
declare class RoutineCondition implements Guard {
|
|
1006
|
+
routineName: string;
|
|
1007
|
+
offset: Duration;
|
|
1008
|
+
constructor(routineName: string, offset?: string);
|
|
1009
|
+
evaluate(_answers: Answers): boolean;
|
|
1010
|
+
getFulfillmentDate(_multiAnswers: MultiAnswers, _consentTimes: ConsentTimes, routineTimes: RoutineTimes): Date | null;
|
|
1011
|
+
}
|
|
1012
|
+
declare const generateQuestionGuard: (enableWhen: fhir5.QuestionnaireItemEnableWhen[] | undefined, enableBehavior: fhir5.QuestionnaireItem["enableBehavior"]) => Guard | undefined;
|
|
1013
|
+
declare const generateStepGuard: (cond: StepCondition) => {
|
|
1014
|
+
guard: Guard;
|
|
1015
|
+
surveyNames: string[];
|
|
1016
|
+
routineNames: string[];
|
|
1017
|
+
consentKeys: string[];
|
|
1018
|
+
};
|
|
1019
|
+
|
|
1020
|
+
declare const ULID_REGEX: RegExp;
|
|
1021
|
+
declare const UUID_REGEX: RegExp;
|
|
1022
|
+
type NullOnInvalidInput = {
|
|
1023
|
+
nullOnInvalidInput: true;
|
|
1024
|
+
};
|
|
1025
|
+
type ThrowOnInvalidInput = {
|
|
1026
|
+
nullOnInvalidInput: false;
|
|
1027
|
+
};
|
|
1028
|
+
declare function UUIDtoULID(ulid: string, opts?: ThrowOnInvalidInput): string;
|
|
1029
|
+
declare function UUIDtoULID(ulid: string, opts: NullOnInvalidInput): string | null;
|
|
1030
|
+
declare function ULIDtoUUID(ulid: string, opts?: ThrowOnInvalidInput): string;
|
|
1031
|
+
declare function ULIDtoUUID(ulid: string, opts: NullOnInvalidInput): string | null;
|
|
1032
|
+
|
|
1033
|
+
type WordListLanguage = 'de' | 'en';
|
|
1034
|
+
declare const WORDLIST_LANGUAGES: WordListLanguage[];
|
|
1035
|
+
declare const getLanguageOfPassPhrase: (words: string[]) => WordListLanguage | undefined;
|
|
1036
|
+
declare const extractWordsFromRecoveryPhrase: (phrase: string) => string[];
|
|
1037
|
+
declare const wordlists: {
|
|
1038
|
+
en: string[];
|
|
1039
|
+
de: string[];
|
|
1040
|
+
};
|
|
1041
|
+
|
|
1042
|
+
declare function generateFHIRConsent(id: string, consent: Consent, decision: fhir5.Consent['decision'], start: string, end?: string): fhir5.Consent;
|
|
1043
|
+
|
|
1044
|
+
declare const SliderMinLabelExtension = "http://fhir.data4life.care/StructureDefinition/slider-label-min";
|
|
1045
|
+
declare const SliderMaxLabelExtension = "http://fhir.data4life.care/StructureDefinition/slider-label-max";
|
|
1046
|
+
declare const SliderStepSizeExtension = "http://fhir.data4life.care/StructureDefinition/slider-step-size";
|
|
1047
|
+
declare const RelativeMinValueExtension = "http://fhir.data4life.care/StructureDefinition/relative-min-value";
|
|
1048
|
+
declare const RelativeMaxValueExtension = "http://fhir.data4life.care/StructureDefinition/relative-max-value";
|
|
1049
|
+
declare const CustomExtensionStudyName = "http://fhir.data4life.care/StructureDefinition/study-name";
|
|
1050
|
+
declare const CustomExtensionDate = "http://fhir.data4life.care/StructureDefinition/effective-date";
|
|
1051
|
+
declare const MaxValueExtension = "http://hl7.org/fhir/StructureDefinition/maxValue";
|
|
1052
|
+
declare const MinValueExtension = "http://hl7.org/fhir/StructureDefinition/minValue";
|
|
1053
|
+
declare const MinLengthExtension = "http://hl7.org/fhir/StructureDefinition/minLength";
|
|
1054
|
+
declare const QItemControlDefinition = "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl";
|
|
1055
|
+
declare const RoutineIsPassiveExtension = "http://fhir.data4life.care/StructureDefinition/is-passive-recording";
|
|
1056
|
+
declare const SignalIDSystem = "http://fhir.data4life.care/r5/NamingSystem/app-signal-ids";
|
|
1057
|
+
declare const AppIDNamingSystem = "http://fhir.data4life.care/r5/NamingSystem/app-db-ids";
|
|
1058
|
+
declare const SensorTypeSystem = "http://fhir.data4life.care/r5/NamingSystem/sensor-device-type";
|
|
1059
|
+
declare const SensorIdentifierSystem = "http://fhir.data4life.care/r5/NamingSystem/sensor-peripheral-id";
|
|
1060
|
+
declare const TokenNamingSystem = "http://fhir.data4life.care/r5/NamingSystem/participation-token";
|
|
1061
|
+
declare const ConsentNameSystem = "http://fhir.data4life.care/r5/NamingSystem/consent-name";
|
|
1062
|
+
declare const ConsentVersionSystem = "http://fhir.data4life.care/r5/NamingSystem/consent-version";
|
|
1063
|
+
declare const ObservationTypeSystem = "http://fhir.data4life.care/r5/CodeSystem/observation-types";
|
|
1064
|
+
declare const MeasurementTypeSystem = "http://fhir.data4life.care/r5/CodeSystem/sensor-measurement-types";
|
|
1065
|
+
declare const StudyNameSystem = "http://fhir.data4life.care/r5/CodeSystem/study-name";
|
|
1066
|
+
declare const SensorSettingsSystem = "http://fhir.data4life.care/r5/CodeSystem/sensor-settings";
|
|
1067
|
+
declare const CustomQuestionSystem = "http://fhir.data4life.care/r5/CodeSystem/custom-question-class";
|
|
1068
|
+
declare const CommunicationTypeSystem = "http://fhir.data4life.care/r5/CodeSystem/communication-types";
|
|
1069
|
+
declare const DEVICE_LABEL_CODING: {
|
|
1070
|
+
system: string;
|
|
1071
|
+
code: string;
|
|
1072
|
+
display: string;
|
|
1073
|
+
};
|
|
1074
|
+
declare const DEVICE_OUTPUT_RATE_CODING: {
|
|
1075
|
+
system: string;
|
|
1076
|
+
code: string;
|
|
1077
|
+
display: string;
|
|
1078
|
+
};
|
|
1079
|
+
declare const DEVICE_SENSOR_DELAY_CODING: {
|
|
1080
|
+
system: string;
|
|
1081
|
+
code: string;
|
|
1082
|
+
display: string;
|
|
1083
|
+
};
|
|
1084
|
+
declare const SIGNAL_DURATION_CODING: {
|
|
1085
|
+
system: string;
|
|
1086
|
+
code: string;
|
|
1087
|
+
display: string;
|
|
1088
|
+
};
|
|
1089
|
+
declare const ANDROID_SENSORS_CONSTANT_NAMES: string[];
|
|
1090
|
+
|
|
1091
|
+
/**
|
|
1092
|
+
* Replaces {{program-name}} and {{fhir-base-host}} templates in the given string
|
|
1093
|
+
*/
|
|
1094
|
+
type StringTemplater = (template: string) => string;
|
|
1095
|
+
declare function generateUrn(): string;
|
|
1096
|
+
declare function capitalizeFirstLetter(string: string): string;
|
|
1097
|
+
declare function getText<K>(content: any, path: K, lng: string): string;
|
|
1098
|
+
/**
|
|
1099
|
+
* Get a value at a certain path from an object
|
|
1100
|
+
* @param obj The object to get from
|
|
1101
|
+
* @param path The path to get e.g 'path.to.property'
|
|
1102
|
+
* @returns The value at the path or undefined
|
|
1103
|
+
*/
|
|
1104
|
+
declare function get(obj: Record<string, any>, path: string): string | undefined;
|
|
1105
|
+
|
|
1106
|
+
declare function generateFHIREligibility(surveyName: string, createdAt: string, value: number, max: number, stringTemplater: StringTemplater): fhir5.Observation;
|
|
1107
|
+
|
|
1108
|
+
declare function generateFHIRResponse(id: string, { programName, effectiveDate, language, questionnaire, createdAt, status, answers, }: QuestionnaireResponse): fhir5.QuestionnaireResponse;
|
|
1109
|
+
declare const toQuestionnaireResponseItem: (answer: {
|
|
1110
|
+
id: string;
|
|
1111
|
+
type: QuestionInputType;
|
|
1112
|
+
response: ReponseValue | ReponseValue[];
|
|
1113
|
+
text: string;
|
|
1114
|
+
}) => fhir5.QuestionnaireResponseItem;
|
|
1115
|
+
|
|
1116
|
+
type RecordingSignalWithId = RecordingSignal & {
|
|
1117
|
+
id: string;
|
|
1118
|
+
};
|
|
1119
|
+
declare function generateFHIRRecordingBundle(id: string, recording: Recording, signals: RecordingSignalWithId[], stringTemplater: StringTemplater): fhir5.Bundle;
|
|
1120
|
+
|
|
1121
|
+
declare const generateFHIRResearchSubject: (id: string, { programName, subject, progress }: ResearchSubject) => fhir_r5.ResearchSubject;
|
|
1122
|
+
|
|
1123
|
+
declare function generateFHIRSeenDisplay(id: string, seenDisplay: SeenDisplay): fhir5.Communication;
|
|
1124
|
+
|
|
1125
|
+
declare function generateFHIRTag(code: string, date: string, labels: {
|
|
1126
|
+
[key: string]: string;
|
|
1127
|
+
}, stringTemplater: StringTemplater): fhir5.Observation;
|
|
1128
|
+
|
|
1129
|
+
export { ANDROID_SENSORS_CONSTANT_NAMES, type APIDeviceConfig, ASMSECGMeasurementAnnotation, ASMSSpO2MeasurementAnnotation, type Answer, AnswerCodeCondition, type Answers, AppIDNamingSystem, type BLEDeviceConfig, BLE_ASMS_ANNOTATION_ITEM_ECG, BLE_ASMS_ANNOTATION_ITEM_SPO2, BLE_CPMS_ANNOTATION_ITEM_ACTIVITY_TYPE, BLE_CPMS_ANNOTATION_ITEM_DAILY_CALORIES, BLE_CPMS_ANNOTATION_ITEM_DAILY_DISTANCE, BLE_CPMS_ANNOTATION_ITEM_DAILY_ELEVATION_GAIN, BLE_CPMS_ANNOTATION_ITEM_DAILY_FLOORS, BLE_CPMS_ANNOTATION_ITEM_DAILY_STEPS, BLE_PAMS_ANNOTATION_ITEM_ABSOLUTE_ELEVATION, BLE_PAMS_ANNOTATION_ITEM_AVERAGE_MOTION_CADENCE, BLE_PAMS_ANNOTATION_ITEM_AVERAGE_SPEED, BLE_PAMS_ANNOTATION_ITEM_BYTE, BLE_PAMS_ANNOTATION_ITEM_CALORIES_TOTAL, BLE_PAMS_ANNOTATION_ITEM_DISTANCE_TOTAL, BLE_PAMS_ANNOTATION_ITEM_FLAGS_16, BLE_PAMS_ANNOTATION_ITEM_FLAGS_24, BLE_PAMS_ANNOTATION_ITEM_FLAGS_32, BLE_PAMS_ANNOTATION_ITEM_FLAGS_8, BLE_PAMS_ANNOTATION_ITEM_FLOORS_TOTAL, BLE_PAMS_ANNOTATION_ITEM_FOUR_BYTES, BLE_PAMS_ANNOTATION_ITEM_HEADER, BLE_PAMS_ANNOTATION_ITEM_HEART_RATE, BLE_PAMS_ANNOTATION_ITEM_MAXIMUM_MOTION_CADENCE, BLE_PAMS_ANNOTATION_ITEM_MAXIMUM_SPEED, BLE_PAMS_ANNOTATION_ITEM_MINIMUM_MOTION_CADENCE, BLE_PAMS_ANNOTATION_ITEM_MINIMUM_SPEED, BLE_PAMS_ANNOTATION_ITEM_MOTION_CADENCE, BLE_PAMS_ANNOTATION_ITEM_NEGATIVE_ELEVATION_GAIN, BLE_PAMS_ANNOTATION_ITEM_POSITIVE_ELEVATION_GAIN, BLE_PAMS_ANNOTATION_ITEM_RUNNING_STEPS_TOTAL, BLE_PAMS_ANNOTATION_ITEM_SPEED, BLE_PAMS_ANNOTATION_ITEM_STEPS_TOTAL, BLE_PAMS_ANNOTATION_ITEM_THREE_BYTES, BLE_PAMS_ANNOTATION_ITEM_TWO_BYTES, BLE_PAMS_ANNOTATION_ITEM_VO2_MAX, BLE_PSMS_ANNOTATION_ITEM_HEART_RATE, BLE_PSMS_ANNOTATION_ITEM_IBI, BLE_PSMS_ANNOTATION_ITEM_PPG_GREEN, BLE_PSMS_ANNOTATION_ITEM_PPG_IR, BLE_PSMS_ANNOTATION_ITEM_PPG_RED, BLE_PSMS_ANNOTATION_ITEM_SKIN_TEMPERATURE, type BaseDeviceConfig, type BleDeviceMetaLabel, BoolCondition, CPMSHealthServicesActivityDetectionAnnotation, CPMSHealthServicesPassiveDataAnnotation, CommunicationTypeSystem, type ComparisonOperator, type ConditionOperatorType, type ConditionQuestionType, type ConditionSorting, type ConditionType, Conjunction, type Consent, ConsentCondition, ConsentNameSystem, type ConsentPath, type ConsentTimes, ConsentVersionSystem, type Converter, type CryptoModule, CustomExtensionDate, CustomExtensionStudyName, CustomQuestionSystem, type DEVICE_ANNOTATION, type DEVICE_ANNOTATION_DATA_FORMAT, type DEVICE_ANNOTATION_DATA_TYPE, DEVICE_ANNOTATION_HEARTRATE, type DEVICE_ANNOTATION_ITEM, DEVICE_ANNOTATION_ITEM_ACCELERATION, DEVICE_ANNOTATION_ITEM_ANGULAR_SPEED, DEVICE_ANNOTATION_ITEM_BEACON_ID, DEVICE_ANNOTATION_ITEM_DISTANCE, DEVICE_ANNOTATION_ITEM_EGVS, DEVICE_ANNOTATION_ITEM_HEARTRATE, DEVICE_ANNOTATION_ITEM_MAGNETIC_FIELD, DEVICE_ANNOTATION_ITEM_REMOTE_DISTANCE, DEVICE_ANNOTATION_ITEM_RSSI, DEVICE_ANNOTATION_ITEM_UNIX_TIMESTAMP, DEVICE_ANNOTATION_TIMESTAMP_NOTE, DEVICE_ANNOTATION_TIMESTAMP_SIZE, DEVICE_ANNOTATION_TIMESTAMP_UNIT, DEVICE_D4L_COMPANION_ANNOTATION_ITEM_DATA_TYPES_FLAG, DEVICE_D4L_COMPANION_ANNOTATION_ITEM_TIMESTAMP, type DEVICE_KEY, type DEVICE_KEY_API, type DEVICE_KEY_BLE, type DEVICE_KEY_INTERNAL, DEVICE_LABEL_CODING, type DEVICE_MOVELLA_PAYLOAD_MODES, DEVICE_OUTPUT_RATE_CODING, DEVICE_SENSOR_DELAY_CODING, type DEVICE_SIGNAL_TYPE, type DateBlurringFunction, DateCondition, DecimalCondition, type DeviceConfig, Disjunction, type Display, type DisplayContent, type DisplayContentPath, type DisplayType, type DonationRecord, DonationSDK, type DonorIdentity, ERROR_CODES, type EligibilityScore, ExistsCondition, FITBIT_ANNOTATION_ITEM_BREATHING_RATE, FITBIT_ANNOTATION_ITEM_CALORIES, FITBIT_ANNOTATION_ITEM_HEART_RATE, FITBIT_ANNOTATION_ITEM_HEART_RATE_VARIABILITY, FITBIT_ANNOTATION_ITEM_SKIN_TEMPERATURE, FITBIT_ANNOTATION_ITEM_SLEEP_LEVEL, FITBIT_ANNOTATION_ITEM_SLEEP_LEVEL_DURATION, FITBIT_ANNOTATION_ITEM_SPO2, FITBIT_ANNOTATION_ITEM_STEPS, FITBIT_BREATHING_RATE_ANNOTATION, FITBIT_CALORIES_ANNOTATION, FITBIT_HEART_RATE_ANNOTATION, FITBIT_HEART_RATE_VARIABILITY_ANNOTATION, FITBIT_SIGNAL_TYPE_ANNOTATIONS, FITBIT_SKIN_TEMPERATURE_ANNOTATION, FITBIT_SLEEP_ANNOTATION, FITBIT_SLEEP_LEVEL_MAP, FITBIT_SPO2_ANNOTATION, FITBIT_STEPS_ANNOTATION, type FitbitSleepLevelTypes, type FrequencyType, type Guard, IMUAnnotation, type InternalDeviceConfig, InternalSensorAnnotationTypes, KeyHandler, MaxValueExtension, MeasurementTypeSystem, MinLengthExtension, MinValueExtension, type MultiAnswers, ObservationTypeSystem, Offset, PAMSCardioVascularActivityAnnotation, PAMSGeneralActivityInstantaneousAnnotation, PAMSGeneralActivitySummaryAnnotation, PAMSStepCounterActivitySummaryAnnotation, PSMSHeartRateAnnotation, PSMSPPGGreenAnnotation, PSMSPPGIRAnnotation, PSMSPPGRedAnnotation, PSMSSkinTemperatureAnnotation, type PreviewTimeSeriesItem, type Program, type ProgramAnonymization, type ProgramConsentStep, type ProgramContent, type ProgramContentPath, type ProgramDevice, type ProgramDeviceType, type ProgramDevicesDataType, type ProgramDevicesLabel, type ProgramDisplayStep, type ProgramDonation, type ProgramEligibilityStep, type ProgramRoutineStep, type ProgramSensorStep, type ProgramStep, type ProgramStepBase, type ProgramStepType, type ProgramSurveyStep, type ProgramTag, type ProgramTokenStep, type ProgramType, QItemControlDefinition, type QuestionInputType, type QuestionnaireResponse, RECORDING_MODEL_CURRENT_VERSION, RECORDING_SIGNAL_MODEL_CURRENT_VERSION, type RecordState, type Recording, type RecordingSignal, type RecordingSignalItem, type RecordingSignalPreview, type RecordingSignalWithId, type RecordingTag, type RecursiveKeyOf, RelativeMaxValueExtension, RelativeMinValueExtension, type ReponseValue, type ResearchSubject, type ResearchSubjectProgress, type ResearchSubjectProgressState, type Routine, RoutineCondition, type RoutineContent, type RoutineContentPath, type RoutineContentStep, RoutineIsPassiveExtension, type RoutineTimes, type SDKInterface, SIGNAL_DURATION_CODING, type ScoreThreshold, type SeenDisplay, SensorIdentifierSystem, SensorSettingsSystem, SensorTypeSystem, SignalIDSystem, type SkippedStep, SliderMaxLabelExtension, SliderMinLabelExtension, SliderStepSizeExtension, type StepCondition, type StringTemplater, StudyNameSystem, type Survey, SurveyCondition, type SurveyContent, type SurveyContentPath, type SurveyScoring, type Tag, type TagEffectiveType, type TaskFrequency, type Threshold, TokenNamingSystem, type TranslatedString, ULID_REGEX, ULIDtoUUID, UUID_REGEX, UUIDtoULID, WORDLIST_LANGUAGES, WearOS3AnnotationMap, WebConverter, type WordListLanguage, YearCondition, binaryStringToUint8Array, capitalizeFirstLetter, extractWordsFromRecoveryPhrase, generateFHIRConsent, generateFHIREligibility, generateFHIRRecordingBundle, generateFHIRResearchSubject, generateFHIRResponse, generateFHIRSeenDisplay, generateFHIRTag, generateQuestionGuard, generateStepGuard, generateUrn, get, getLanguageOfPassPhrase, getMovellaAnnotation, getText, isScoreEligible, isYearString, newStepDateCondtion, stringToDate, stringToYear, toDeviceConfig, toQuestionnaireResponseItem, uint8ArrayToBinaryString, utf8ToUint8Array, wordlists };
|