@quesmed/types 1.3.17 → 1.3.22
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/gql_input_output_types/User.js +2 -1
- package/gql_input_output_types/User.mjs +1 -0
- package/gql_input_output_types/index.d.ts +1 -0
- package/gql_input_output_types/index.js +2 -1
- package/gql_input_output_types/index.mjs +1 -0
- package/index.js +7 -4
- package/index.mjs +17 -0
- package/models/Author.js +2 -1
- package/models/Author.mjs +1 -0
- package/models/Book.js +2 -1
- package/models/Book.mjs +1 -0
- package/models/Card.js +2 -1
- package/models/Card.mjs +1 -0
- package/models/Chapter.js +2 -1
- package/models/Chapter.mjs +1 -0
- package/models/Concept.js +2 -1
- package/models/Concept.mjs +1 -0
- package/models/Difficulty.js +5 -2
- package/models/Difficulty.mjs +7 -0
- package/models/Feedback.js +2 -1
- package/models/Feedback.mjs +1 -0
- package/models/File.js +2 -1
- package/models/File.mjs +1 -0
- package/models/Marksheet.js +5 -2
- package/models/Marksheet.mjs +6 -0
- package/models/MockTest.js +2 -1
- package/models/MockTest.mjs +1 -0
- package/models/OsceMarksheet.js +7 -4
- package/models/OsceMarksheet.mjs +20 -0
- package/models/OsceStation.js +6 -3
- package/models/OsceStation.mjs +42 -0
- package/models/Picture.js +2 -1
- package/models/Picture.mjs +5 -0
- package/models/Promo.js +2 -1
- package/models/Promo.mjs +1 -0
- package/models/Question.js +15 -8
- package/models/Question.mjs +30 -0
- package/models/Subscription.js +5 -2
- package/models/Subscription.mjs +6 -0
- package/models/Todo.js +2 -1
- package/models/Todo.mjs +1 -0
- package/models/Token.js +2 -1
- package/models/Token.mjs +1 -0
- package/models/Topic.js +5 -2
- package/models/Topic.mjs +10 -0
- package/models/Type.js +2 -1
- package/models/Type.mjs +1 -0
- package/models/University.js +2 -1
- package/models/University.mjs +1 -0
- package/models/User.js +2 -1
- package/models/User.mjs +1 -0
- package/models/Video.js +2 -1
- package/models/Video.mjs +1 -0
- package/models/index.js +35 -23
- package/models/index.mjs +23 -0
- package/package.json +2 -1
- package/resolvers/apollo.js +2 -1
- package/resolvers/apollo.mjs +1 -0
- package/resolvers/mutation/admin/algoliaSync.js +2 -1
- package/resolvers/mutation/admin/algoliaSync.mjs +1 -0
- package/resolvers/mutation/admin/index.js +14 -2
- package/resolvers/mutation/admin/index.mjs +2 -0
- package/resolvers/mutation/admin/token.js +2 -1
- package/resolvers/mutation/admin/token.mjs +1 -0
- package/resolvers/mutation/index.js +14 -2
- package/resolvers/mutation/index.mjs +2 -0
- package/resolvers/mutation/restricted/agora.js +2 -1
- package/resolvers/mutation/restricted/agora.mjs +1 -0
- package/resolvers/mutation/restricted/contactUs.js +2 -1
- package/resolvers/mutation/restricted/contactUs.mjs +1 -0
- package/resolvers/mutation/restricted/index.js +22 -10
- package/resolvers/mutation/restricted/index.mjs +10 -0
- package/resolvers/mutation/restricted/marksheet.js +2 -1
- package/resolvers/mutation/restricted/marksheet.mjs +1 -0
- package/resolvers/mutation/restricted/mockTest.js +2 -1
- package/resolvers/mutation/restricted/mockTest.mjs +1 -0
- package/resolvers/mutation/restricted/osce.js +2 -1
- package/resolvers/mutation/restricted/osce.mjs +1 -0
- package/resolvers/mutation/restricted/questionDiscussion.js +2 -1
- package/resolvers/mutation/restricted/questionDiscussion.mjs +1 -0
- package/resolvers/mutation/restricted/todo.js +7 -3
- package/resolvers/mutation/restricted/todo.mjs +25 -0
- package/resolvers/mutation/restricted/token.js +2 -1
- package/resolvers/mutation/restricted/token.mjs +1 -0
- package/resolvers/mutation/restricted/users.js +2 -1
- package/resolvers/mutation/restricted/users.mjs +1 -0
- package/resolvers/mutation/restricted/video.js +2 -1
- package/resolvers/mutation/restricted/video.mjs +1 -0
- package/resolvers/mutation/stripe.js +2 -1
- package/resolvers/mutation/stripe.mjs +1 -0
- package/resolvers/mutation/users.js +2 -1
- package/resolvers/mutation/users.mjs +1 -0
- package/resolvers/mutation/validUserToken/index.js +13 -1
- package/resolvers/mutation/validUserToken/index.mjs +1 -0
- package/resolvers/mutation/validUserToken/user.js +2 -1
- package/resolvers/mutation/validUserToken/user.mjs +1 -0
- package/resolvers/query/admin/getUserToken.js +2 -1
- package/resolvers/query/admin/getUserToken.mjs +1 -0
- package/resolvers/query/admin/index.js +13 -1
- package/resolvers/query/admin/index.mjs +1 -0
- package/resolvers/query/author.js +2 -1
- package/resolvers/query/author.mjs +1 -0
- package/resolvers/query/book.js +2 -1
- package/resolvers/query/book.mjs +1 -0
- package/resolvers/query/feedback.js +2 -1
- package/resolvers/query/feedback.mjs +1 -0
- package/resolvers/query/index.js +21 -9
- package/resolvers/query/index.mjs +9 -0
- package/resolvers/query/restricted/anatomy.js +2 -1
- package/resolvers/query/restricted/anatomy.mjs +1 -0
- package/resolvers/query/restricted/index.js +22 -10
- package/resolvers/query/restricted/index.mjs +10 -0
- package/resolvers/query/restricted/marksheet.js +2 -1
- package/resolvers/query/restricted/marksheet.mjs +1 -0
- package/resolvers/query/restricted/mockTests.js +2 -1
- package/resolvers/query/restricted/mockTests.mjs +1 -0
- package/resolvers/query/restricted/osce.js +2 -1
- package/resolvers/query/restricted/osce.mjs +1 -0
- package/resolvers/query/restricted/quesBook.js +2 -1
- package/resolvers/query/restricted/quesBook.mjs +1 -0
- package/resolvers/query/restricted/todos.js +2 -1
- package/resolvers/query/restricted/todos.mjs +1 -0
- package/resolvers/query/restricted/topics.js +2 -1
- package/resolvers/query/restricted/topics.mjs +1 -0
- package/resolvers/query/restricted/university.js +2 -1
- package/resolvers/query/restricted/university.mjs +1 -0
- package/resolvers/query/restricted/user.js +2 -1
- package/resolvers/query/restricted/user.mjs +1 -0
- package/resolvers/query/restricted/video.js +2 -1
- package/resolvers/query/restricted/video.mjs +1 -0
- package/resolvers/query/sampleCards.js +2 -1
- package/resolvers/query/sampleCards.mjs +1 -0
- package/resolvers/query/sampleQuestions.js +2 -1
- package/resolvers/query/sampleQuestions.mjs +1 -0
- package/resolvers/query/subscription.js +2 -1
- package/resolvers/query/subscription.mjs +1 -0
- package/resolvers/query/university.js +2 -1
- package/resolvers/query/university.mjs +1 -0
- package/resolvers/query/user.js +2 -1
- package/resolvers/query/user.mjs +1 -0
- package/resolvers/query/video.js +2 -1
- package/resolvers/query/video.mjs +1 -0
- package/resolvers/subscription/index.js +13 -1
- package/resolvers/subscription/index.mjs +1 -0
- package/resolvers/subscription/osce.d.ts +2 -1
- package/resolvers/subscription/osce.js +14 -10
- package/resolvers/subscription/osce.mjs +39 -0
- package/utils/commonFunctions.d.ts +1 -1
- package/utils/commonFunctions.js +39 -20
- package/utils/commonFunctions.mjs +230 -0
- package/utils/index.d.ts +5 -0
- package/utils/index.js +17 -0
- package/utils/index.mjs +5 -0
- package/utils/lightgallery.js +5 -1
- package/utils/lightgallery.mjs +87 -0
- package/{resolvers → utils}/offlineLink.d.ts +0 -0
- package/utils/offlineLink.js +237 -0
- package/{resolvers/offlineLink.js → utils/offlineLink.mjs} +4 -4
- package/utils/uuid4.js +3 -1
- package/utils/uuid4.mjs +285 -0
- package/utils/wordsToNumber.js +5 -1
- package/utils/wordsToNumber.mjs +44 -0
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OsceGroupInit = exports.OSCE_MATCHMAKING_USERS = exports.OSCE_MATCHMAKING = exports.OSCE_MARKSHEET_ACTION = exports.ROLE_CHANGED = void 0;
|
|
4
|
+
const models_1 = require("../../models");
|
|
5
|
+
exports.ROLE_CHANGED = 'ROLE_CHANGED';
|
|
6
|
+
exports.OSCE_MARKSHEET_ACTION = 'OSCE_MARKSHEET_ACTION';
|
|
7
|
+
exports.OSCE_MATCHMAKING = 'OSCE_MATCHMAKING';
|
|
8
|
+
exports.OSCE_MATCHMAKING_USERS = 'OSCE_MATCHMAKING_USERS';
|
|
9
|
+
const OsceGroupInit = (osceMarksheetId) => [
|
|
7
10
|
{
|
|
8
11
|
id: null,
|
|
9
12
|
createdAt: null,
|
|
10
13
|
osceMarksheetId,
|
|
11
14
|
userId: null,
|
|
12
15
|
user: null,
|
|
13
|
-
role: EOsceRoles.CANDIDATE,
|
|
16
|
+
role: models_1.EOsceRoles.CANDIDATE,
|
|
14
17
|
},
|
|
15
18
|
{
|
|
16
19
|
id: null,
|
|
@@ -18,7 +21,7 @@ export const OsceGroupInit = (osceMarksheetId) => [
|
|
|
18
21
|
osceMarksheetId,
|
|
19
22
|
userId: null,
|
|
20
23
|
user: null,
|
|
21
|
-
role: EOsceRoles.EXAMINER,
|
|
24
|
+
role: models_1.EOsceRoles.EXAMINER,
|
|
22
25
|
},
|
|
23
26
|
{
|
|
24
27
|
id: null,
|
|
@@ -26,7 +29,7 @@ export const OsceGroupInit = (osceMarksheetId) => [
|
|
|
26
29
|
osceMarksheetId,
|
|
27
30
|
userId: null,
|
|
28
31
|
user: null,
|
|
29
|
-
role: EOsceRoles.ACTOR,
|
|
32
|
+
role: models_1.EOsceRoles.ACTOR,
|
|
30
33
|
},
|
|
31
34
|
{
|
|
32
35
|
id: null,
|
|
@@ -34,6 +37,7 @@ export const OsceGroupInit = (osceMarksheetId) => [
|
|
|
34
37
|
osceMarksheetId,
|
|
35
38
|
userId: null,
|
|
36
39
|
user: null,
|
|
37
|
-
role: EOsceRoles.OBSERVER,
|
|
40
|
+
role: models_1.EOsceRoles.OBSERVER,
|
|
38
41
|
},
|
|
39
42
|
];
|
|
43
|
+
exports.OsceGroupInit = OsceGroupInit;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { EOsceRoles, } from '../../models';
|
|
2
|
+
export const ROLE_CHANGED = 'ROLE_CHANGED';
|
|
3
|
+
export const OSCE_MARKSHEET_ACTION = 'OSCE_MARKSHEET_ACTION';
|
|
4
|
+
export const OSCE_MATCHMAKING = 'OSCE_MATCHMAKING';
|
|
5
|
+
export const OSCE_MATCHMAKING_USERS = 'OSCE_MATCHMAKING_USERS';
|
|
6
|
+
export const OsceGroupInit = (osceMarksheetId) => [
|
|
7
|
+
{
|
|
8
|
+
id: null,
|
|
9
|
+
createdAt: null,
|
|
10
|
+
osceMarksheetId,
|
|
11
|
+
userId: null,
|
|
12
|
+
user: null,
|
|
13
|
+
role: EOsceRoles.CANDIDATE,
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
id: null,
|
|
17
|
+
createdAt: null,
|
|
18
|
+
osceMarksheetId,
|
|
19
|
+
userId: null,
|
|
20
|
+
user: null,
|
|
21
|
+
role: EOsceRoles.EXAMINER,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: null,
|
|
25
|
+
createdAt: null,
|
|
26
|
+
osceMarksheetId,
|
|
27
|
+
userId: null,
|
|
28
|
+
user: null,
|
|
29
|
+
role: EOsceRoles.ACTOR,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: null,
|
|
33
|
+
createdAt: null,
|
|
34
|
+
osceMarksheetId,
|
|
35
|
+
userId: null,
|
|
36
|
+
user: null,
|
|
37
|
+
role: EOsceRoles.OBSERVER,
|
|
38
|
+
},
|
|
39
|
+
];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IMarksheetMark, IPrescribeAnswer, IPrescribeMark } from '../models';
|
|
2
2
|
export declare function mapPrescribeMarkToAnswer(obj: IPrescribeMark): IPrescribeAnswer;
|
|
3
|
-
export declare function formatPrescribeAnswer(
|
|
3
|
+
export declare function formatPrescribeAnswer(baseAnswer: IPrescribeAnswer): IPrescribeAnswer;
|
|
4
4
|
export interface ICorrectMarkData {
|
|
5
5
|
correct: boolean;
|
|
6
6
|
incorrect: boolean;
|
package/utils/commonFunctions.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.correctMark = exports.formatPrescribeAnswer = exports.mapPrescribeMarkToAnswer = void 0;
|
|
4
|
+
const models_1 = require("../models");
|
|
5
|
+
const wordsToNumber_1 = require("./wordsToNumber");
|
|
3
6
|
const floatRegex = /([0-9]*[.])?[0-9]+/gm;
|
|
4
7
|
const ACCEPTED_FREQ = ['stat', 'od', 'bd', 'tds', 'qds'];
|
|
5
|
-
|
|
8
|
+
function mapPrescribeMarkToAnswer(obj) {
|
|
6
9
|
return {
|
|
7
10
|
drug: {
|
|
8
11
|
value: obj.drug,
|
|
@@ -30,9 +33,14 @@ export function mapPrescribeMarkToAnswer(obj) {
|
|
|
30
33
|
},
|
|
31
34
|
};
|
|
32
35
|
}
|
|
33
|
-
|
|
36
|
+
exports.mapPrescribeMarkToAnswer = mapPrescribeMarkToAnswer;
|
|
37
|
+
function formatPrescribeAnswer(baseAnswer) {
|
|
38
|
+
const obj = Object.assign(Object.assign({}, baseAnswer), { drug: Object.assign({}, baseAnswer.drug), dose: Object.assign({}, baseAnswer.dose), units: Object.assign({}, baseAnswer.units), route: Object.assign({}, baseAnswer.route), frequency: Object.assign({}, baseAnswer.frequency), duration: Object.assign({}, baseAnswer.duration) });
|
|
34
39
|
obj.drug.value = obj.drug.value.toLowerCase().replace(/\s/g, '');
|
|
35
|
-
obj.route.value = obj.route.value
|
|
40
|
+
obj.route.value = obj.route.value
|
|
41
|
+
.toLowerCase()
|
|
42
|
+
.replace(/\s/g, '')
|
|
43
|
+
.replace(/\//g, '');
|
|
36
44
|
if (obj.route.value === 'oral') {
|
|
37
45
|
obj.route.value = 'po';
|
|
38
46
|
}
|
|
@@ -58,7 +66,8 @@ export function formatPrescribeAnswer(obj) {
|
|
|
58
66
|
if (obj.units.value === 'milligram' || obj.units.value === 'milligrams') {
|
|
59
67
|
obj.units.value = 'mg';
|
|
60
68
|
}
|
|
61
|
-
else if (obj.units.value === 'microgram' ||
|
|
69
|
+
else if (obj.units.value === 'microgram' ||
|
|
70
|
+
obj.units.value === 'micrograms') {
|
|
62
71
|
obj.units.value = 'mcg';
|
|
63
72
|
}
|
|
64
73
|
else if (obj.units.value === 'gram' || obj.units.value === 'grams') {
|
|
@@ -75,7 +84,7 @@ export function formatPrescribeAnswer(obj) {
|
|
|
75
84
|
}
|
|
76
85
|
m.forEach((match) => durationMatches.add(match));
|
|
77
86
|
}
|
|
78
|
-
const durationWords = wordsToNumber(obj.duration.value, false);
|
|
87
|
+
const durationWords = (0, wordsToNumber_1.wordsToNumber)(obj.duration.value, false);
|
|
79
88
|
if (durationWords !== 0) {
|
|
80
89
|
durationMatches.add(durationWords.toString());
|
|
81
90
|
}
|
|
@@ -87,29 +96,33 @@ export function formatPrescribeAnswer(obj) {
|
|
|
87
96
|
if (obj.frequency.value === 'once-off') {
|
|
88
97
|
obj.frequency.value = 'stat';
|
|
89
98
|
}
|
|
90
|
-
else if (obj.frequency.value.includes('once') ||
|
|
99
|
+
else if (obj.frequency.value.includes('once') ||
|
|
100
|
+
(frequencyIncHourly && hourlyFreqInt === 24)) {
|
|
91
101
|
obj.frequency.value = 'od';
|
|
92
102
|
}
|
|
93
|
-
else if (obj.frequency.value.includes('nightly') ||
|
|
103
|
+
else if (obj.frequency.value.includes('nightly') ||
|
|
104
|
+
obj.frequency.value === 'on') {
|
|
94
105
|
obj.frequency.value = 'od';
|
|
95
106
|
}
|
|
96
107
|
else if (obj.frequency.value.includes('twice') ||
|
|
97
108
|
(frequencyIncHourly && hourlyFreqInt === 12)) {
|
|
98
109
|
obj.frequency.value = 'bd';
|
|
99
110
|
}
|
|
100
|
-
else if (obj.frequency.value.includes('trice') ||
|
|
111
|
+
else if (obj.frequency.value.includes('trice') ||
|
|
112
|
+
(frequencyIncHourly && hourlyFreqInt === 8)) {
|
|
101
113
|
obj.frequency.value = 'tds';
|
|
102
114
|
}
|
|
103
115
|
else if (frequencyIncHourly && hourlyFreqInt === 6) {
|
|
104
116
|
obj.frequency.value = 'qds';
|
|
105
117
|
}
|
|
106
118
|
else if (!ACCEPTED_FREQ.includes(obj.frequency.value)) {
|
|
107
|
-
obj.frequency.value = wordsToNumber(orgFrequencyValue, true).toString();
|
|
119
|
+
obj.frequency.value = (0, wordsToNumber_1.wordsToNumber)(orgFrequencyValue, true).toString();
|
|
108
120
|
}
|
|
109
121
|
return obj;
|
|
110
122
|
}
|
|
123
|
+
exports.formatPrescribeAnswer = formatPrescribeAnswer;
|
|
111
124
|
const answerRegex = /answer/gi;
|
|
112
|
-
|
|
125
|
+
function correctMark(mark) {
|
|
113
126
|
const data = {
|
|
114
127
|
correct: false,
|
|
115
128
|
incorrect: false,
|
|
@@ -124,7 +137,7 @@ export function correctMark(mark) {
|
|
|
124
137
|
const answer = mark.question[answerKey];
|
|
125
138
|
const flatAnswer = answer[0];
|
|
126
139
|
const flatAttempt = mark.mark[0];
|
|
127
|
-
if (EQuestionType.SINGLE_BEST_ANSWER === mark.question.typeId) {
|
|
140
|
+
if (models_1.EQuestionType.SINGLE_BEST_ANSWER === mark.question.typeId) {
|
|
128
141
|
const answer = flatAnswer;
|
|
129
142
|
const attempt = flatAttempt;
|
|
130
143
|
if (answer === attempt) {
|
|
@@ -134,8 +147,10 @@ export function correctMark(mark) {
|
|
|
134
147
|
data.incorrect = true;
|
|
135
148
|
}
|
|
136
149
|
}
|
|
137
|
-
else if (EQuestionType.QUESTION_ANSWER === mark.question.typeId) {
|
|
138
|
-
const answer = flatAnswer.dose
|
|
150
|
+
else if (models_1.EQuestionType.QUESTION_ANSWER === mark.question.typeId) {
|
|
151
|
+
const answer = flatAnswer.dose
|
|
152
|
+
.toLowerCase()
|
|
153
|
+
.replace(/\s/g, '');
|
|
139
154
|
let attempt = '';
|
|
140
155
|
if (flatAttempt) {
|
|
141
156
|
attempt = flatAttempt.toLowerCase().replace(/\s/g, '');
|
|
@@ -147,7 +162,7 @@ export function correctMark(mark) {
|
|
|
147
162
|
data.incorrect = true;
|
|
148
163
|
}
|
|
149
164
|
}
|
|
150
|
-
else if (EQuestionType.MULTIPLE_ANSWERS === mark.question.typeId) {
|
|
165
|
+
else if (models_1.EQuestionType.MULTIPLE_ANSWERS === mark.question.typeId) {
|
|
151
166
|
const [answerA, answerB] = answer.map((x) => x.sort());
|
|
152
167
|
let [attemptA, attemptB] = [[], []];
|
|
153
168
|
if (Array.isArray(mark.mark) &&
|
|
@@ -156,7 +171,8 @@ export function correctMark(mark) {
|
|
|
156
171
|
Array.isArray(mark.mark[1])) {
|
|
157
172
|
[attemptA, attemptB] = mark.mark.map((x) => x.sort());
|
|
158
173
|
}
|
|
159
|
-
if (answerA.length !== attemptA.length ||
|
|
174
|
+
if (answerA.length !== attemptA.length ||
|
|
175
|
+
answerB.length !== attemptB.length) {
|
|
160
176
|
data.incorrect = true;
|
|
161
177
|
}
|
|
162
178
|
else if (attemptA.every((x, i) => x === answerA[i]) &&
|
|
@@ -167,7 +183,7 @@ export function correctMark(mark) {
|
|
|
167
183
|
data.incorrect = true;
|
|
168
184
|
}
|
|
169
185
|
}
|
|
170
|
-
else if (EQuestionType.PRESCRIPTION_ANSWER === mark.question.typeId) {
|
|
186
|
+
else if (models_1.EQuestionType.PRESCRIPTION_ANSWER === mark.question.typeId) {
|
|
171
187
|
const answers = answer.map(formatPrescribeAnswer);
|
|
172
188
|
let attempt = formatPrescribeAnswer(mapPrescribeMarkToAnswer({
|
|
173
189
|
drug: '',
|
|
@@ -177,7 +193,8 @@ export function correctMark(mark) {
|
|
|
177
193
|
frequency: '',
|
|
178
194
|
duration: '',
|
|
179
195
|
}));
|
|
180
|
-
if (typeof flatAttempt === 'object' &&
|
|
196
|
+
if (typeof flatAttempt === 'object' &&
|
|
197
|
+
Object.keys(flatAttempt).length === 6) {
|
|
181
198
|
attempt = formatPrescribeAnswer(mapPrescribeMarkToAnswer(flatAttempt));
|
|
182
199
|
}
|
|
183
200
|
let foundCorrect = false;
|
|
@@ -187,7 +204,8 @@ export function correctMark(mark) {
|
|
|
187
204
|
const drugCorrect = answer.drug.display || answer.drug.value === attempt.drug.value;
|
|
188
205
|
const durationCorrect = answer.duration.display ||
|
|
189
206
|
answer.duration.value.split(',').includes(attempt.duration.value);
|
|
190
|
-
const frequencyCorrect = answer.frequency.display ||
|
|
207
|
+
const frequencyCorrect = answer.frequency.display ||
|
|
208
|
+
answer.frequency.value === attempt.frequency.value;
|
|
191
209
|
const routeCorrect = answer.route.display || answer.route.value === attempt.route.value;
|
|
192
210
|
const unitsCorrect = answer.units.display || answer.units.value === attempt.units.value;
|
|
193
211
|
if (doseCorrect &&
|
|
@@ -215,3 +233,4 @@ export function correctMark(mark) {
|
|
|
215
233
|
}
|
|
216
234
|
return data;
|
|
217
235
|
}
|
|
236
|
+
exports.correctMark = correctMark;
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { EQuestionType, } from '../models';
|
|
2
|
+
import { wordsToNumber } from './wordsToNumber';
|
|
3
|
+
const floatRegex = /([0-9]*[.])?[0-9]+/gm;
|
|
4
|
+
const ACCEPTED_FREQ = ['stat', 'od', 'bd', 'tds', 'qds'];
|
|
5
|
+
export function mapPrescribeMarkToAnswer(obj) {
|
|
6
|
+
return {
|
|
7
|
+
drug: {
|
|
8
|
+
value: obj.drug,
|
|
9
|
+
display: false,
|
|
10
|
+
},
|
|
11
|
+
dose: {
|
|
12
|
+
value: parseFloat(obj.dose),
|
|
13
|
+
display: false,
|
|
14
|
+
},
|
|
15
|
+
units: {
|
|
16
|
+
value: obj.units,
|
|
17
|
+
display: false,
|
|
18
|
+
},
|
|
19
|
+
route: {
|
|
20
|
+
value: obj.route,
|
|
21
|
+
display: false,
|
|
22
|
+
},
|
|
23
|
+
frequency: {
|
|
24
|
+
value: obj.frequency,
|
|
25
|
+
display: false,
|
|
26
|
+
},
|
|
27
|
+
duration: {
|
|
28
|
+
value: obj.duration,
|
|
29
|
+
display: false,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export function formatPrescribeAnswer(baseAnswer) {
|
|
34
|
+
const obj = Object.assign(Object.assign({}, baseAnswer), { drug: Object.assign({}, baseAnswer.drug), dose: Object.assign({}, baseAnswer.dose), units: Object.assign({}, baseAnswer.units), route: Object.assign({}, baseAnswer.route), frequency: Object.assign({}, baseAnswer.frequency), duration: Object.assign({}, baseAnswer.duration) });
|
|
35
|
+
obj.drug.value = obj.drug.value.toLowerCase().replace(/\s/g, '');
|
|
36
|
+
obj.route.value = obj.route.value
|
|
37
|
+
.toLowerCase()
|
|
38
|
+
.replace(/\s/g, '')
|
|
39
|
+
.replace(/\//g, '');
|
|
40
|
+
if (obj.route.value === 'oral') {
|
|
41
|
+
obj.route.value = 'po';
|
|
42
|
+
}
|
|
43
|
+
else if (obj.route.value.includes('intravenous')) {
|
|
44
|
+
obj.route.value = 'iv';
|
|
45
|
+
}
|
|
46
|
+
else if (obj.route.value.includes('intramuscular')) {
|
|
47
|
+
obj.route.value = 'im';
|
|
48
|
+
}
|
|
49
|
+
else if (obj.route.value.includes('subcutaneous')) {
|
|
50
|
+
obj.route.value = 'sc';
|
|
51
|
+
}
|
|
52
|
+
else if (obj.route.value.includes('inhale')) {
|
|
53
|
+
obj.route.value = 'inh';
|
|
54
|
+
}
|
|
55
|
+
else if (obj.route.value.includes('nebuli')) {
|
|
56
|
+
obj.route.value = 'neb';
|
|
57
|
+
}
|
|
58
|
+
else if (obj.route.value.includes('topical')) {
|
|
59
|
+
obj.route.value = 'top';
|
|
60
|
+
}
|
|
61
|
+
obj.units.value = obj.units.value.toLowerCase().replace(/\s/g, '');
|
|
62
|
+
if (obj.units.value === 'milligram' || obj.units.value === 'milligrams') {
|
|
63
|
+
obj.units.value = 'mg';
|
|
64
|
+
}
|
|
65
|
+
else if (obj.units.value === 'microgram' ||
|
|
66
|
+
obj.units.value === 'micrograms') {
|
|
67
|
+
obj.units.value = 'mcg';
|
|
68
|
+
}
|
|
69
|
+
else if (obj.units.value === 'gram' || obj.units.value === 'grams') {
|
|
70
|
+
obj.units.value = 'g';
|
|
71
|
+
}
|
|
72
|
+
else if (obj.units.value === 'unit') {
|
|
73
|
+
obj.units.value = 'units';
|
|
74
|
+
}
|
|
75
|
+
let m;
|
|
76
|
+
const durationMatches = new Set();
|
|
77
|
+
while ((m = floatRegex.exec(obj.duration.value)) !== null) {
|
|
78
|
+
if (m.index === floatRegex.lastIndex) {
|
|
79
|
+
floatRegex.lastIndex++;
|
|
80
|
+
}
|
|
81
|
+
m.forEach((match) => durationMatches.add(match));
|
|
82
|
+
}
|
|
83
|
+
const durationWords = wordsToNumber(obj.duration.value, false);
|
|
84
|
+
if (durationWords !== 0) {
|
|
85
|
+
durationMatches.add(durationWords.toString());
|
|
86
|
+
}
|
|
87
|
+
obj.duration.value = [...durationMatches].filter((x) => !!x).join(',');
|
|
88
|
+
const orgFrequencyValue = obj.frequency.value.toLowerCase();
|
|
89
|
+
obj.frequency.value = orgFrequencyValue.replace(/\s/g, '');
|
|
90
|
+
const frequencyIncHourly = obj.frequency.value.includes('hour');
|
|
91
|
+
const hourlyFreqInt = parseInt(obj.frequency.value);
|
|
92
|
+
if (obj.frequency.value === 'once-off') {
|
|
93
|
+
obj.frequency.value = 'stat';
|
|
94
|
+
}
|
|
95
|
+
else if (obj.frequency.value.includes('once') ||
|
|
96
|
+
(frequencyIncHourly && hourlyFreqInt === 24)) {
|
|
97
|
+
obj.frequency.value = 'od';
|
|
98
|
+
}
|
|
99
|
+
else if (obj.frequency.value.includes('nightly') ||
|
|
100
|
+
obj.frequency.value === 'on') {
|
|
101
|
+
obj.frequency.value = 'od';
|
|
102
|
+
}
|
|
103
|
+
else if (obj.frequency.value.includes('twice') ||
|
|
104
|
+
(frequencyIncHourly && hourlyFreqInt === 12)) {
|
|
105
|
+
obj.frequency.value = 'bd';
|
|
106
|
+
}
|
|
107
|
+
else if (obj.frequency.value.includes('trice') ||
|
|
108
|
+
(frequencyIncHourly && hourlyFreqInt === 8)) {
|
|
109
|
+
obj.frequency.value = 'tds';
|
|
110
|
+
}
|
|
111
|
+
else if (frequencyIncHourly && hourlyFreqInt === 6) {
|
|
112
|
+
obj.frequency.value = 'qds';
|
|
113
|
+
}
|
|
114
|
+
else if (!ACCEPTED_FREQ.includes(obj.frequency.value)) {
|
|
115
|
+
obj.frequency.value = wordsToNumber(orgFrequencyValue, true).toString();
|
|
116
|
+
}
|
|
117
|
+
return obj;
|
|
118
|
+
}
|
|
119
|
+
const answerRegex = /answer/gi;
|
|
120
|
+
export function correctMark(mark) {
|
|
121
|
+
const data = {
|
|
122
|
+
correct: false,
|
|
123
|
+
incorrect: false,
|
|
124
|
+
correctIndex: -1,
|
|
125
|
+
};
|
|
126
|
+
if (!mark || !mark.mark) {
|
|
127
|
+
return data;
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
130
|
+
const qKeys = Object.keys(mark.question);
|
|
131
|
+
const answerKey = qKeys.find((k) => answerRegex.exec(k)) || 'answer';
|
|
132
|
+
const answer = mark.question[answerKey];
|
|
133
|
+
const flatAnswer = answer[0];
|
|
134
|
+
const flatAttempt = mark.mark[0];
|
|
135
|
+
if (EQuestionType.SINGLE_BEST_ANSWER === mark.question.typeId) {
|
|
136
|
+
const answer = flatAnswer;
|
|
137
|
+
const attempt = flatAttempt;
|
|
138
|
+
if (answer === attempt) {
|
|
139
|
+
data.correct = true;
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
data.incorrect = true;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
else if (EQuestionType.QUESTION_ANSWER === mark.question.typeId) {
|
|
146
|
+
const answer = flatAnswer.dose
|
|
147
|
+
.toLowerCase()
|
|
148
|
+
.replace(/\s/g, '');
|
|
149
|
+
let attempt = '';
|
|
150
|
+
if (flatAttempt) {
|
|
151
|
+
attempt = flatAttempt.toLowerCase().replace(/\s/g, '');
|
|
152
|
+
}
|
|
153
|
+
if (answer === attempt) {
|
|
154
|
+
data.correct = true;
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
data.incorrect = true;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
else if (EQuestionType.MULTIPLE_ANSWERS === mark.question.typeId) {
|
|
161
|
+
const [answerA, answerB] = answer.map((x) => x.sort());
|
|
162
|
+
let [attemptA, attemptB] = [[], []];
|
|
163
|
+
if (Array.isArray(mark.mark) &&
|
|
164
|
+
mark.mark.length === 2 &&
|
|
165
|
+
Array.isArray(mark.mark[0]) &&
|
|
166
|
+
Array.isArray(mark.mark[1])) {
|
|
167
|
+
[attemptA, attemptB] = mark.mark.map((x) => x.sort());
|
|
168
|
+
}
|
|
169
|
+
if (answerA.length !== attemptA.length ||
|
|
170
|
+
answerB.length !== attemptB.length) {
|
|
171
|
+
data.incorrect = true;
|
|
172
|
+
}
|
|
173
|
+
else if (attemptA.every((x, i) => x === answerA[i]) &&
|
|
174
|
+
attemptB.every((x, i) => x === answerB[i])) {
|
|
175
|
+
data.correct = true;
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
data.incorrect = true;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
else if (EQuestionType.PRESCRIPTION_ANSWER === mark.question.typeId) {
|
|
182
|
+
const answers = answer.map(formatPrescribeAnswer);
|
|
183
|
+
let attempt = formatPrescribeAnswer(mapPrescribeMarkToAnswer({
|
|
184
|
+
drug: '',
|
|
185
|
+
dose: -1,
|
|
186
|
+
units: '',
|
|
187
|
+
route: '',
|
|
188
|
+
frequency: '',
|
|
189
|
+
duration: '',
|
|
190
|
+
}));
|
|
191
|
+
if (typeof flatAttempt === 'object' &&
|
|
192
|
+
Object.keys(flatAttempt).length === 6) {
|
|
193
|
+
attempt = formatPrescribeAnswer(mapPrescribeMarkToAnswer(flatAttempt));
|
|
194
|
+
}
|
|
195
|
+
let foundCorrect = false;
|
|
196
|
+
let index = 0;
|
|
197
|
+
for (const answer of answers) {
|
|
198
|
+
const doseCorrect = answer.dose.display || answer.dose.value === attempt.dose.value;
|
|
199
|
+
const drugCorrect = answer.drug.display || answer.drug.value === attempt.drug.value;
|
|
200
|
+
const durationCorrect = answer.duration.display ||
|
|
201
|
+
answer.duration.value.split(',').includes(attempt.duration.value);
|
|
202
|
+
const frequencyCorrect = answer.frequency.display ||
|
|
203
|
+
answer.frequency.value === attempt.frequency.value;
|
|
204
|
+
const routeCorrect = answer.route.display || answer.route.value === attempt.route.value;
|
|
205
|
+
const unitsCorrect = answer.units.display || answer.units.value === attempt.units.value;
|
|
206
|
+
if (doseCorrect &&
|
|
207
|
+
drugCorrect &&
|
|
208
|
+
durationCorrect &&
|
|
209
|
+
frequencyCorrect &&
|
|
210
|
+
routeCorrect &&
|
|
211
|
+
unitsCorrect) {
|
|
212
|
+
foundCorrect = true;
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
index++;
|
|
216
|
+
}
|
|
217
|
+
if (foundCorrect) {
|
|
218
|
+
data.correct = true;
|
|
219
|
+
data.correctIndex = index;
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
data.incorrect = true;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
catch (e) {
|
|
227
|
+
console.error(e);
|
|
228
|
+
}
|
|
229
|
+
return data;
|
|
230
|
+
}
|
package/utils/index.d.ts
ADDED
package/utils/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./commonFunctions"), exports);
|
|
14
|
+
__exportStar(require("./lightgallery"), exports);
|
|
15
|
+
__exportStar(require("./offlineLink"), exports);
|
|
16
|
+
__exportStar(require("./uuid4"), exports);
|
|
17
|
+
__exportStar(require("./wordsToNumber"), exports);
|
package/utils/index.mjs
ADDED
package/utils/lightgallery.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -7,11 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
9
|
});
|
|
9
10
|
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.lightgalleryOsceResolve = void 0;
|
|
10
13
|
const lightgalleryRegex = /\[lightgallery\]/;
|
|
11
14
|
function isOsceMarksheet(data) {
|
|
12
15
|
return 'osceStationId' in data;
|
|
13
16
|
}
|
|
14
|
-
|
|
17
|
+
function lightgalleryOsceResolve(data, cache) {
|
|
15
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
19
|
let station;
|
|
17
20
|
if (isOsceMarksheet(data)) {
|
|
@@ -49,6 +52,7 @@ export function lightgalleryOsceResolve(data, cache) {
|
|
|
49
52
|
}
|
|
50
53
|
});
|
|
51
54
|
}
|
|
55
|
+
exports.lightgalleryOsceResolve = lightgalleryOsceResolve;
|
|
52
56
|
const lightgalleryMutation = (text, pictures, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
57
|
var _a;
|
|
54
58
|
if (pictures.length === 0) {
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
const lightgalleryRegex = /\[lightgallery\]/;
|
|
11
|
+
function isOsceMarksheet(data) {
|
|
12
|
+
return 'osceStationId' in data;
|
|
13
|
+
}
|
|
14
|
+
export function lightgalleryOsceResolve(data, cache) {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
let station;
|
|
17
|
+
if (isOsceMarksheet(data)) {
|
|
18
|
+
if (!data.osceStation) {
|
|
19
|
+
throw new Error('OsceStation not found on OsceMarksheet');
|
|
20
|
+
}
|
|
21
|
+
station = data.osceStation;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
station = data;
|
|
25
|
+
}
|
|
26
|
+
const upOsceStation = {
|
|
27
|
+
candidateBrief: station.candidateBrief,
|
|
28
|
+
actorBrief: station.actorBrief,
|
|
29
|
+
examinerBrief: station.examinerBrief,
|
|
30
|
+
explanation: station.explanation,
|
|
31
|
+
};
|
|
32
|
+
if (station.candidatePictures && station.candidatePictures.length > 0) {
|
|
33
|
+
upOsceStation.candidateBrief = yield lightgalleryMutation(upOsceStation.candidateBrief, station.candidatePictures, cache);
|
|
34
|
+
}
|
|
35
|
+
if (station.actorPictures && station.actorPictures.length > 0) {
|
|
36
|
+
upOsceStation.actorBrief = yield lightgalleryMutation(upOsceStation.actorBrief, station.actorPictures, cache);
|
|
37
|
+
}
|
|
38
|
+
if (station.examinerPictures && station.examinerPictures.length > 0) {
|
|
39
|
+
upOsceStation.examinerBrief = yield lightgalleryMutation(upOsceStation.examinerBrief, station.examinerPictures, cache);
|
|
40
|
+
}
|
|
41
|
+
if (station.walkthroughPictures && station.walkthroughPictures.length > 0) {
|
|
42
|
+
upOsceStation.explanation = yield lightgalleryMutation(upOsceStation.explanation, station.walkthroughPictures, cache);
|
|
43
|
+
}
|
|
44
|
+
if (isOsceMarksheet(data)) {
|
|
45
|
+
return Object.assign(Object.assign({}, data), { osceStation: Object.assign(Object.assign({}, data.osceStation), upOsceStation) });
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
return Object.assign(Object.assign({}, data), upOsceStation);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
const lightgalleryMutation = (text, pictures, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
+
var _a;
|
|
54
|
+
if (pictures.length === 0) {
|
|
55
|
+
return text;
|
|
56
|
+
}
|
|
57
|
+
const picturesHTML = [];
|
|
58
|
+
for (const { picture } of pictures) {
|
|
59
|
+
const pic = picture.path;
|
|
60
|
+
const uri = `https://app.quesmed.com/${pic}`;
|
|
61
|
+
let file = '';
|
|
62
|
+
if (cache) {
|
|
63
|
+
try {
|
|
64
|
+
const localPath = yield cache.CacheManager.get(uri, {}).getPath();
|
|
65
|
+
if (localPath) {
|
|
66
|
+
file =
|
|
67
|
+
cache.Platform.OS === 'ios'
|
|
68
|
+
? localPath.replace('file://', '')
|
|
69
|
+
: localPath;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
console.error(e);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (((_a = picture.caption) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
77
|
+
picturesHTML.push(``);
|
|
78
|
+
}
|
|
79
|
+
picturesHTML.push(``);
|
|
80
|
+
}
|
|
81
|
+
if (lightgalleryRegex.test(text)) {
|
|
82
|
+
return text.replace(lightgalleryRegex, picturesHTML[0]);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
return text + '\n\n' + picturesHTML[0] + '\n';
|
|
86
|
+
}
|
|
87
|
+
});
|
|
File without changes
|