@quesmed/types-rn 2.6.19 → 2.6.21
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/models/Marksheet.d.ts +2 -2
- package/models/Psa.d.ts +0 -6
- package/models/Question.d.ts +10 -12
- package/models/Question.js +0 -2
- package/models/User.d.ts +2 -3
- package/package.json +1 -1
- package/resolvers/mutation/restricted/questionDiscussion.js +0 -6
- package/resolvers/query/restricted/marksheet.js +3 -1066
- package/utils/commonFunctions.d.ts +2 -3
- package/utils/commonFunctions.js +23 -191
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/object.d.ts +1 -0
- package/utils/object.js +20 -0
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { IMarksheetMark,
|
|
2
|
-
export declare function mapPrescribeMarkToAnswer(obj: IPrescribeMark): IPrescribeAnswer;
|
|
3
|
-
export declare function formatPrescribeAnswer(baseAnswer: IPrescribeAnswer): IPrescribeAnswer;
|
|
1
|
+
import { IMarksheetMark, IPrescribeMark, IQuestionPrescription } from '../models';
|
|
4
2
|
export interface ICorrectMarkData {
|
|
5
3
|
correct: boolean;
|
|
6
4
|
incorrect: boolean;
|
|
7
5
|
correctIndex: number;
|
|
8
6
|
}
|
|
7
|
+
export declare function mapPrescribeMarkToAnswer(obj: IQuestionPrescription | IPrescribeMark): IPrescribeMark;
|
|
9
8
|
export declare function correctMark(mark: IMarksheetMark): ICorrectMarkData;
|
package/utils/commonFunctions.js
CHANGED
|
@@ -1,165 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.correctMark = exports.
|
|
3
|
+
exports.correctMark = exports.mapPrescribeMarkToAnswer = void 0;
|
|
4
4
|
const models_1 = require("../models");
|
|
5
|
-
const
|
|
6
|
-
const floatRegex = /([0-9]*[.])?[0-9]+/gm;
|
|
7
|
-
const ACCEPTED_FREQ = ['stat', 'od', 'bd', 'tds', 'qds'];
|
|
8
|
-
function mapPrescribeMarkToAnswer(obj) {
|
|
9
|
-
return {
|
|
10
|
-
drug: {
|
|
11
|
-
value: obj.drug,
|
|
12
|
-
display: false,
|
|
13
|
-
},
|
|
14
|
-
dose: {
|
|
15
|
-
value: parseFloat(obj.dose),
|
|
16
|
-
display: false,
|
|
17
|
-
},
|
|
18
|
-
units: {
|
|
19
|
-
value: obj.units,
|
|
20
|
-
display: false,
|
|
21
|
-
},
|
|
22
|
-
route: {
|
|
23
|
-
value: obj.route,
|
|
24
|
-
display: false,
|
|
25
|
-
},
|
|
26
|
-
frequency: {
|
|
27
|
-
value: obj.frequency,
|
|
28
|
-
display: false,
|
|
29
|
-
},
|
|
30
|
-
duration: {
|
|
31
|
-
value: obj.duration,
|
|
32
|
-
display: false,
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
exports.mapPrescribeMarkToAnswer = mapPrescribeMarkToAnswer;
|
|
37
|
-
function formatPrescribeAnswer(baseAnswer) {
|
|
38
|
-
const obj = Object.assign({}, baseAnswer, {
|
|
39
|
-
drug: Object.assign({}, baseAnswer.drug, {
|
|
40
|
-
value: baseAnswer.drug?.value ?? '',
|
|
41
|
-
}),
|
|
42
|
-
dose: Object.assign({}, baseAnswer.dose, {
|
|
43
|
-
value: baseAnswer.dose?.value ?? 0,
|
|
44
|
-
}),
|
|
45
|
-
units: Object.assign({}, baseAnswer.units, {
|
|
46
|
-
value: baseAnswer.units?.value ?? '',
|
|
47
|
-
}),
|
|
48
|
-
route: Object.assign({}, baseAnswer.route, {
|
|
49
|
-
value: baseAnswer.route?.value ?? '',
|
|
50
|
-
}),
|
|
51
|
-
frequency: Object.assign({}, baseAnswer.frequency, {
|
|
52
|
-
value: baseAnswer.frequency?.value ?? '',
|
|
53
|
-
}),
|
|
54
|
-
duration: Object.assign({}, baseAnswer.duration, {
|
|
55
|
-
value: baseAnswer.duration?.value ?? '',
|
|
56
|
-
}),
|
|
57
|
-
});
|
|
58
|
-
// DRUG
|
|
59
|
-
obj.drug.value = obj.drug.value.toLowerCase().replace(/\s/g, '');
|
|
60
|
-
// ROUTE
|
|
61
|
-
obj.route.value = obj.route.value
|
|
62
|
-
.toLowerCase()
|
|
63
|
-
.replace(/\s/g, '')
|
|
64
|
-
.replace(/\//g, '');
|
|
65
|
-
if (obj.route.value.includes('oral')) {
|
|
66
|
-
obj.route.value = 'po';
|
|
67
|
-
}
|
|
68
|
-
else if (obj.route.value.includes('intravenous')) {
|
|
69
|
-
obj.route.value = 'iv';
|
|
70
|
-
}
|
|
71
|
-
else if (obj.route.value.includes('intramuscular')) {
|
|
72
|
-
obj.route.value = 'im';
|
|
73
|
-
}
|
|
74
|
-
else if (obj.route.value.includes('subcutaneous')) {
|
|
75
|
-
obj.route.value = 'sc';
|
|
76
|
-
}
|
|
77
|
-
else if (obj.route.value.includes('inhale')) {
|
|
78
|
-
obj.route.value = 'inh';
|
|
79
|
-
}
|
|
80
|
-
else if (obj.route.value.includes('nebuli')) {
|
|
81
|
-
obj.route.value = 'neb';
|
|
82
|
-
}
|
|
83
|
-
else if (obj.route.value.includes('topical')) {
|
|
84
|
-
obj.route.value = 'top';
|
|
85
|
-
}
|
|
86
|
-
else if (obj.route.value.includes('rectal')) {
|
|
87
|
-
obj.route.value = 'pr';
|
|
88
|
-
}
|
|
89
|
-
// UNITS
|
|
90
|
-
obj.units.value = obj.units.value.toLowerCase().replace(/\s/g, '');
|
|
91
|
-
switch (obj.units.value) {
|
|
92
|
-
case 'milligram':
|
|
93
|
-
case 'milligrams':
|
|
94
|
-
obj.units.value = 'mg';
|
|
95
|
-
break;
|
|
96
|
-
case 'microgram':
|
|
97
|
-
case 'micrograms':
|
|
98
|
-
obj.units.value = 'mcg';
|
|
99
|
-
break;
|
|
100
|
-
case 'gram':
|
|
101
|
-
case 'grams':
|
|
102
|
-
obj.units.value = 'g';
|
|
103
|
-
break;
|
|
104
|
-
case 'unit':
|
|
105
|
-
obj.units.value = 'units';
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
// DURATION
|
|
109
|
-
let m;
|
|
110
|
-
const durationMatches = new Set();
|
|
111
|
-
while ((m = floatRegex.exec(obj.duration.value)) !== null) {
|
|
112
|
-
if (m.index === floatRegex.lastIndex) {
|
|
113
|
-
floatRegex.lastIndex++;
|
|
114
|
-
}
|
|
115
|
-
m.forEach((match) => durationMatches.add(match));
|
|
116
|
-
}
|
|
117
|
-
const durationWords = (0, wordsToNumber_1.wordsToNumber)(obj.duration.value, false);
|
|
118
|
-
if (durationWords !== 0) {
|
|
119
|
-
durationMatches.add(durationWords.toString());
|
|
120
|
-
}
|
|
121
|
-
obj.duration.value = [...durationMatches].filter((x) => !!x).join(',');
|
|
122
|
-
// FREQUENCY
|
|
123
|
-
const orgFrequencyValue = obj.frequency.value.toLowerCase();
|
|
124
|
-
const timesPerDay = obj.frequency.value.includes('times per day') ||
|
|
125
|
-
obj.frequency.value.includes('times a day');
|
|
126
|
-
// remove whitespace for processing
|
|
127
|
-
obj.frequency.value = orgFrequencyValue.replace(/\s/g, '');
|
|
128
|
-
const freqWordsToInt = (0, wordsToNumber_1.wordsToNumber)(orgFrequencyValue, true);
|
|
129
|
-
const frequencyIncHourly = obj.frequency.value.includes('hour');
|
|
130
|
-
const textToInt = parseInt(obj.frequency.value);
|
|
131
|
-
if (obj.frequency.value === 'once-off') {
|
|
132
|
-
obj.frequency.value = 'stat';
|
|
133
|
-
}
|
|
134
|
-
else if (obj.frequency.value.includes('once') ||
|
|
135
|
-
(frequencyIncHourly && textToInt === 24) ||
|
|
136
|
-
(timesPerDay && freqWordsToInt === 1)) {
|
|
137
|
-
obj.frequency.value = 'od';
|
|
138
|
-
}
|
|
139
|
-
else if (obj.frequency.value.includes('nightly') ||
|
|
140
|
-
obj.frequency.value === 'on') {
|
|
141
|
-
obj.frequency.value = 'od';
|
|
142
|
-
}
|
|
143
|
-
else if (obj.frequency.value.includes('twice') ||
|
|
144
|
-
(frequencyIncHourly && textToInt === 12) ||
|
|
145
|
-
(timesPerDay && freqWordsToInt === 2)) {
|
|
146
|
-
obj.frequency.value = 'bd';
|
|
147
|
-
}
|
|
148
|
-
else if (obj.frequency.value.includes('trice') ||
|
|
149
|
-
(frequencyIncHourly && textToInt === 8) ||
|
|
150
|
-
(timesPerDay && freqWordsToInt === 3)) {
|
|
151
|
-
obj.frequency.value = 'tds';
|
|
152
|
-
}
|
|
153
|
-
else if ((frequencyIncHourly && textToInt === 6) ||
|
|
154
|
-
(timesPerDay && freqWordsToInt === 4)) {
|
|
155
|
-
obj.frequency.value = 'qds';
|
|
156
|
-
}
|
|
157
|
-
else if (!ACCEPTED_FREQ.includes(obj.frequency.value)) {
|
|
158
|
-
obj.frequency.value = (0, wordsToNumber_1.wordsToNumber)(orgFrequencyValue, true).toString();
|
|
159
|
-
}
|
|
160
|
-
return obj;
|
|
161
|
-
}
|
|
162
|
-
exports.formatPrescribeAnswer = formatPrescribeAnswer;
|
|
5
|
+
const object_1 = require("./object");
|
|
163
6
|
function createHashMap(arr) {
|
|
164
7
|
const map = new Map();
|
|
165
8
|
for (const innerArr of arr) {
|
|
@@ -169,6 +12,17 @@ function createHashMap(arr) {
|
|
|
169
12
|
}
|
|
170
13
|
return map;
|
|
171
14
|
}
|
|
15
|
+
function mapPrescribeMarkToAnswer(obj) {
|
|
16
|
+
return {
|
|
17
|
+
drugId: obj.drugId,
|
|
18
|
+
doseId: obj.doseId,
|
|
19
|
+
durationId: obj.durationId,
|
|
20
|
+
frequencyId: obj.frequencyId,
|
|
21
|
+
unitId: obj.unitId,
|
|
22
|
+
routeId: obj.routeId,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
exports.mapPrescribeMarkToAnswer = mapPrescribeMarkToAnswer;
|
|
172
26
|
function correctMark(mark) {
|
|
173
27
|
const data = {
|
|
174
28
|
correct: false,
|
|
@@ -232,41 +86,19 @@ function correctMark(mark) {
|
|
|
232
86
|
}
|
|
233
87
|
}
|
|
234
88
|
else if (models_1.EQuestionType.PRESCRIPTION_ANSWER === mark.question.typeId) {
|
|
235
|
-
const answers = answer.map(formatPrescribeAnswer);
|
|
236
|
-
let attempt = formatPrescribeAnswer(mapPrescribeMarkToAnswer({
|
|
237
|
-
drug: '',
|
|
238
|
-
dose: -1,
|
|
239
|
-
units: '',
|
|
240
|
-
route: '',
|
|
241
|
-
frequency: '',
|
|
242
|
-
duration: '',
|
|
243
|
-
}));
|
|
244
|
-
if (typeof flatAttempt === 'object' &&
|
|
245
|
-
Object.keys(flatAttempt).length === 6) {
|
|
246
|
-
attempt = formatPrescribeAnswer(mapPrescribeMarkToAnswer(flatAttempt));
|
|
247
|
-
}
|
|
248
89
|
let foundCorrect = false;
|
|
249
90
|
let index = 0;
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
const
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
answer
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
if (doseCorrect &&
|
|
261
|
-
drugCorrect &&
|
|
262
|
-
durationCorrect &&
|
|
263
|
-
frequencyCorrect &&
|
|
264
|
-
routeCorrect &&
|
|
265
|
-
unitsCorrect) {
|
|
266
|
-
foundCorrect = true;
|
|
267
|
-
break;
|
|
91
|
+
if (typeof flatAttempt === 'object' &&
|
|
92
|
+
Object.keys(flatAttempt).length > 0) {
|
|
93
|
+
const answers = answer.map(mapPrescribeMarkToAnswer);
|
|
94
|
+
const attempt = mapPrescribeMarkToAnswer(flatAttempt);
|
|
95
|
+
for (const answer of answers) {
|
|
96
|
+
if ((0, object_1.compareObjects)(answer, attempt)) {
|
|
97
|
+
foundCorrect = true;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
index++;
|
|
268
101
|
}
|
|
269
|
-
index++;
|
|
270
102
|
}
|
|
271
103
|
if (foundCorrect) {
|
|
272
104
|
data.correct = true;
|
package/utils/index.d.ts
CHANGED
package/utils/index.js
CHANGED
|
@@ -20,6 +20,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
20
20
|
exports.printDuration = exports.Uuid4 = void 0;
|
|
21
21
|
__exportStar(require("./commonFunctions"), exports);
|
|
22
22
|
__exportStar(require("./lightgallery"), exports);
|
|
23
|
+
__exportStar(require("./object"), exports);
|
|
23
24
|
__exportStar(require("./offlineLink"), exports);
|
|
24
25
|
__exportStar(require("./random"), exports);
|
|
25
26
|
__exportStar(require("./supermemo"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function compareObjects<T = Record<string, unknown>, V = Record<string, unknown>>(obj1: T, obj2: V): boolean;
|
package/utils/object.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compareObjects = void 0;
|
|
4
|
+
function compareObjects(obj1, obj2) {
|
|
5
|
+
const ob1 = obj1;
|
|
6
|
+
const ob2 = obj2;
|
|
7
|
+
const keys1 = Object.keys(ob1);
|
|
8
|
+
const keys2 = Object.keys(ob2);
|
|
9
|
+
if (keys1.length !== keys2.length) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
for (let i = 0; i < keys1.length; i++) {
|
|
13
|
+
const key = keys1[i];
|
|
14
|
+
if (ob1[key] !== ob2[key]) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
exports.compareObjects = compareObjects;
|