case-editor-tools 1.0.0-beta.26 → 1.0.0-beta.27

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.
@@ -15,7 +15,8 @@ export declare const NativeStudyEngineExpressions: {
15
15
  getSurveyKeyAssignedFrom: (surveyKey: string) => Expression;
16
16
  getSurveyKeyAssignedUntil: (surveyKey: string) => Expression;
17
17
  hasStudyStatus: (status: string) => Expression;
18
- hasParticipantFlag: (key: string, value: string) => Expression;
18
+ hasParticipantFlagKeyAndValue: (key: string, value: string) => Expression;
19
+ hasParticipantFlagKey: (key: string) => Expression;
19
20
  lastSubmissionDateOlderThan: (reference: number | Expression, surveyKey?: string | undefined) => Expression;
20
21
  hasMessageTypeAssigned: (messageType: string) => Expression;
21
22
  getMessageNextTime: (messageType: string) => Expression;
@@ -36,7 +37,7 @@ export declare const StudyEngineActions: {
36
37
  ifThen: (condition: Expression, ...args: Expression[]) => Expression;
37
38
  participantActions: {
38
39
  updateStudyStatus: (status: string) => Expression;
39
- updateFlag: (key: string, newValue: string) => Expression;
40
+ updateFlag: (key: string, newValue: string | number | Expression) => Expression;
40
41
  removeFlag: (key: string) => Expression;
41
42
  assignedSurveys: {
42
43
  add: (surveyKey: string, category: 'immediate' | 'prio' | 'normal' | 'optional', activeFrom?: number | Expression | undefined, activeUntil?: number | Expression | undefined) => Expression;
@@ -87,7 +88,7 @@ export declare const StudyEngine: {
87
88
  ifThen: (condition: Expression, ...args: Expression[]) => Expression;
88
89
  participantActions: {
89
90
  updateStudyStatus: (status: string) => Expression;
90
- updateFlag: (key: string, newValue: string) => Expression;
91
+ updateFlag: (key: string, newValue: string | number | Expression) => Expression;
91
92
  removeFlag: (key: string) => Expression;
92
93
  assignedSurveys: {
93
94
  add: (surveyKey: string, category: 'immediate' | 'prio' | 'normal' | 'optional', activeFrom?: number | Expression | undefined, activeUntil?: number | Expression | undefined) => Expression;
@@ -121,7 +122,8 @@ export declare const StudyEngine: {
121
122
  getSurveyKeyAssignedFrom: (surveyKey: string) => Expression;
122
123
  getSurveyKeyAssignedUntil: (surveyKey: string) => Expression;
123
124
  hasStudyStatus: (status: string) => Expression;
124
- hasParticipantFlag: (key: string, value: string) => Expression;
125
+ hasParticipantFlagKeyAndValue: (key: string, value: string) => Expression;
126
+ hasParticipantFlagKey: (key: string) => Expression;
125
127
  lastSubmissionDateOlderThan: (reference: number | Expression, surveyKey?: string | undefined) => Expression;
126
128
  hasMessageTypeAssigned: (messageType: string) => Expression;
127
129
  getMessageNextTime: (messageType: string) => Expression;
@@ -86,12 +86,18 @@ const getSurveyKeyAssignedUntil = (surveyKey) => expressionUtils_expressionGen.g
86
86
  */
87
87
  const hasStudyStatus = (status) => expressionUtils_expressionGen.generateExpression('getSurveyKeyAssignedUntil', undefined, status);
88
88
  /**
89
- * Check if a participant flag is present
89
+ * Check if a participant flag with specific value is present
90
90
  * @param key look up this flag
91
91
  * @param value and for this value
92
92
  * @returns return true if key - value pair (with case sensitive matching for both key and value) is present. If any of the two is different, or participant flags is empty, it returns false.
93
93
  */
94
- const hasParticipantFlag = (key, value) => expressionUtils_expressionGen.generateExpression('hasParticipantFlag', undefined, key, value);
94
+ const hasParticipantFlagKeyAndValue = (key, value) => expressionUtils_expressionGen.generateExpression('hasParticipantFlag', undefined, key, value);
95
+ /**
96
+ * Check if a participant flag is present
97
+ * @param key look up this flag
98
+ * @returns return true if key is present. If any of the two is different, or participant flags is empty, it returns false.
99
+ */
100
+ const hasParticipantFlagKey = (key) => expressionUtils_expressionGen.generateExpression('hasParticipantFlagKey', undefined, key);
95
101
  /**
96
102
  * Checks if the participant has a message type assigned (at least one)
97
103
  * @param messageType
@@ -153,7 +159,7 @@ const UPDATE_STUDY_STATUS = (status) => expressionUtils_expressionGen.generateEx
153
159
  /**
154
160
  * Add or update a participant flag
155
161
  * @param key
156
- * @param newValue
162
+ * @param newValue: string, number or expression where result should be written in the flag's value
157
163
  * @returns
158
164
  */
159
165
  const UPDATE_FLAG = (key, newValue) => expressionUtils_expressionGen.generateExpression('UPDATE_FLAG', undefined, key, newValue);
@@ -272,7 +278,8 @@ const NativeStudyEngineExpressions = {
272
278
  getSurveyKeyAssignedFrom,
273
279
  getSurveyKeyAssignedUntil,
274
280
  hasStudyStatus,
275
- hasParticipantFlag,
281
+ hasParticipantFlagKeyAndValue,
282
+ hasParticipantFlagKey,
276
283
  lastSubmissionDateOlderThan,
277
284
  hasMessageTypeAssigned,
278
285
  getMessageNextTime,
@@ -1 +1 @@
1
- {"version":3,"file":"studyEngineExpressions.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"studyEngineExpressions.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "case-editor-tools",
3
3
  "description": "Javascript tools to simplify survey and study coding for CASE.",
4
- "version": "1.0.0-beta.26",
4
+ "version": "1.0.0-beta.27",
5
5
  "main": "index.js",
6
6
  "license": "Apache-2.0",
7
7
  "repository": "github:case-framework/case-editor-tools",
8
8
  "devDependencies": {
9
9
  "@rollup/plugin-commonjs": "^21.0.1",
10
- "@rollup/plugin-node-resolve": "^13.1.1",
10
+ "@rollup/plugin-node-resolve": "^13.1.3",
11
11
  "rollup": "^2.61.1",
12
12
  "rollup-plugin-copy": "^3.4.0",
13
13
  "rollup-plugin-delete": "^2.0.0",
@@ -20,6 +20,6 @@
20
20
  "build": "rollup -c"
21
21
  },
22
22
  "dependencies": {
23
- "survey-engine": "^1.0.2"
23
+ "survey-engine": "^1.0.3"
24
24
  }
25
25
  }
@@ -22,6 +22,7 @@ export declare const NativeSurveyEngineExpressions: {
22
22
  isDefined: (arg: Expression) => Expression;
23
23
  hasResponse: (itemKey: string, responseKey: string) => Expression;
24
24
  getResponseItem: (itemKey: string, responseKey: string) => Expression;
25
+ parseValueAsNum: (valueRef: Expression) => Expression;
25
26
  getResponseValueAsNum: (itemKey: string, responseKey: string) => Expression;
26
27
  getResponseValueAsStr: (itemKey: string, responseKey: string) => Expression;
27
28
  checkResponseValueWithRegex: (itemKey: string, responseKey: string, regexPattern: string) => Expression;
@@ -72,7 +73,11 @@ export declare const SurveyEngine: {
72
73
  datePicker: {
73
74
  get: (itemKey: string) => Expression;
74
75
  };
75
- hasParticipantFlag: (key: string, value: string) => Expression;
76
+ participantFlags: {
77
+ hasKey: (key: string, value: string) => Expression;
78
+ hasKeyAndValue: (key: string, value: string) => Expression;
79
+ getAsNum: (key: string) => Expression;
80
+ };
76
81
  getters: {
77
82
  getContext: () => Expression;
78
83
  getResponses: () => Expression;
@@ -94,6 +99,7 @@ export declare const SurveyEngine: {
94
99
  isDefined: (arg: Expression) => Expression;
95
100
  hasResponse: (itemKey: string, responseKey: string) => Expression;
96
101
  getResponseItem: (itemKey: string, responseKey: string) => Expression;
102
+ parseValueAsNum: (valueRef: Expression) => Expression;
97
103
  getResponseValueAsNum: (itemKey: string, responseKey: string) => Expression;
98
104
  getResponseValueAsStr: (itemKey: string, responseKey: string) => Expression;
99
105
  checkResponseValueWithRegex: (itemKey: string, responseKey: string, regexPattern: string) => Expression;
@@ -61,6 +61,14 @@ const gte = (val1, val2) => expressionUtils_expressionGen.generateExpression('gt
61
61
  * @returns
62
62
  */
63
63
  const timestampWithOffset = (delta, reference) => expressionUtils_expressionGen.generateExpression('timestampWithOffset', undefined, types_duration.durationObjectToSeconds(delta), reference ? reference : undefined);
64
+ /**
65
+ * Parse the result of an expression as a number
66
+ * @param valueRef expression that returns a string with the value that should be parsed
67
+ * @returns expression that returns the value or undefined
68
+ */
69
+ const parseValueAsNum = (valueRef) => {
70
+ return expressionUtils_expressionGen.generateExpression('parseValueAsNum', 'float', valueRef);
71
+ };
64
72
  /**
65
73
  * Extract value from a response if exits parsed as a number
66
74
  * @param itemKey full key of the survey item (e.g. SURVEY.GROUP.QUESTIONKEY)
@@ -286,13 +294,29 @@ const getSurveyItemValidation = (itemKey, validationKey) => {
286
294
  const dateResponseDiffFromNow = (itemKey, responseKey, unit, ignoreSign) => {
287
295
  return expressionUtils_expressionGen.generateExpression('dateResponseDiffFromNow', undefined, itemKey, responseKey, unit, ignoreSign ? 1 : undefined);
288
296
  };
297
+ /**
298
+ * Check participant flags object if contains the specified key value pair
299
+ * @param key retrieve participant flag's value for this key
300
+ * @returns
301
+ */
302
+ const parseParticipantFlagAsNum = (key) => {
303
+ return parseValueAsNum(getAttribute(getAttribute(getContext(), 'participantFlags'), key));
304
+ };
305
+ /**
306
+ * Check participant flags object if contains the specified key value pair
307
+ * @param key retrieve participant flag's value for this key
308
+ * @returns
309
+ */
310
+ const hasParticipantFlagKey = (key, value) => {
311
+ return isDefined(getAttribute(getAttribute(getContext(), 'participantFlags'), key));
312
+ };
289
313
  /**
290
314
  * Check participant flags object if contains the specified key value pair
291
315
  * @param key retrieve participant flag's value for this key
292
316
  * @param value string value to be checked for a match
293
317
  * @returns
294
318
  */
295
- const hasParticipantFlag = (key, value) => {
319
+ const hasParticipantFlagKeyAndValue = (key, value) => {
296
320
  return eq(getAttribute(getAttribute(getContext(), 'participantFlags'), key), value);
297
321
  };
298
322
  /**
@@ -355,6 +379,7 @@ const NativeSurveyEngineExpressions = {
355
379
  isDefined,
356
380
  hasResponse,
357
381
  getResponseItem,
382
+ parseValueAsNum,
358
383
  getResponseValueAsNum,
359
384
  getResponseValueAsStr,
360
385
  checkResponseValueWithRegex,
@@ -400,7 +425,11 @@ const SurveyEngine = Object.assign(Object.assign({}, NativeSurveyEngineExpressio
400
425
  regexCheck: multilineTextInputRegexCheck,
401
426
  }, datePicker: {
402
427
  get: getDatePickerResponseValue,
403
- }, hasParticipantFlag });
428
+ }, participantFlags: {
429
+ hasKey: hasParticipantFlagKey,
430
+ hasKeyAndValue: hasParticipantFlagKeyAndValue,
431
+ getAsNum: parseParticipantFlagAsNum,
432
+ } });
404
433
 
405
434
  exports.NativeSurveyEngineExpressions = NativeSurveyEngineExpressions;
406
435
  exports.SurveyEngine = SurveyEngine;
@@ -1 +1 @@
1
- {"version":3,"file":"survey-engine-expressions.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"survey-engine-expressions.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}