@quesmed/types 1.3.16 → 1.3.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/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 +6 -3
- 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 +19 -26
- 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.js +17 -11
- package/utils/commonFunctions.mjs +217 -0
- package/utils/index.d.ts +5 -0
- package/utils/index.js +17 -0
- package/utils/index.mjs +5 -0
- package/utils/lightgallery.js +9 -2
- package/utils/lightgallery.mjs +87 -0
- package/utils/offlineLink.d.ts +64 -0
- package/utils/offlineLink.js +237 -0
- package/utils/offlineLink.mjs +230 -0
- package/utils/uuid4.js +3 -1
- package/utils/uuid4.mjs +285 -0
- package/utils/wordsToNumber.js +5 -1
- package/utils/wordsToNumber.mjs +44 -0
|
@@ -40,7 +40,8 @@ export interface IOsceMatchmakingAction {
|
|
|
40
40
|
classYear: IClassYear;
|
|
41
41
|
lastSyncAt: number;
|
|
42
42
|
startedAt: number;
|
|
43
|
-
|
|
43
|
+
grouped: boolean;
|
|
44
|
+
completed: boolean;
|
|
44
45
|
}
|
|
45
46
|
export interface IOsceMatchmakingData extends IOsceMatchmakingAction {
|
|
46
47
|
}
|
|
@@ -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
|
+
];
|
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,7 +33,8 @@ export function mapPrescribeMarkToAnswer(obj) {
|
|
|
30
33
|
},
|
|
31
34
|
};
|
|
32
35
|
}
|
|
33
|
-
|
|
36
|
+
exports.mapPrescribeMarkToAnswer = mapPrescribeMarkToAnswer;
|
|
37
|
+
function formatPrescribeAnswer(obj) {
|
|
34
38
|
obj.drug.value = obj.drug.value.toLowerCase().replace(/\s/g, '');
|
|
35
39
|
obj.route.value = obj.route.value.toLowerCase().replace(/\s/g, '');
|
|
36
40
|
if (obj.route.value === 'oral') {
|
|
@@ -75,7 +79,7 @@ export function formatPrescribeAnswer(obj) {
|
|
|
75
79
|
}
|
|
76
80
|
m.forEach((match) => durationMatches.add(match));
|
|
77
81
|
}
|
|
78
|
-
const durationWords = wordsToNumber(obj.duration.value, false);
|
|
82
|
+
const durationWords = (0, wordsToNumber_1.wordsToNumber)(obj.duration.value, false);
|
|
79
83
|
if (durationWords !== 0) {
|
|
80
84
|
durationMatches.add(durationWords.toString());
|
|
81
85
|
}
|
|
@@ -104,12 +108,13 @@ export function formatPrescribeAnswer(obj) {
|
|
|
104
108
|
obj.frequency.value = 'qds';
|
|
105
109
|
}
|
|
106
110
|
else if (!ACCEPTED_FREQ.includes(obj.frequency.value)) {
|
|
107
|
-
obj.frequency.value = wordsToNumber(orgFrequencyValue, true).toString();
|
|
111
|
+
obj.frequency.value = (0, wordsToNumber_1.wordsToNumber)(orgFrequencyValue, true).toString();
|
|
108
112
|
}
|
|
109
113
|
return obj;
|
|
110
114
|
}
|
|
115
|
+
exports.formatPrescribeAnswer = formatPrescribeAnswer;
|
|
111
116
|
const answerRegex = /answer/gi;
|
|
112
|
-
|
|
117
|
+
function correctMark(mark) {
|
|
113
118
|
const data = {
|
|
114
119
|
correct: false,
|
|
115
120
|
incorrect: false,
|
|
@@ -124,7 +129,7 @@ export function correctMark(mark) {
|
|
|
124
129
|
const answer = mark.question[answerKey];
|
|
125
130
|
const flatAnswer = answer[0];
|
|
126
131
|
const flatAttempt = mark.mark[0];
|
|
127
|
-
if (EQuestionType.SINGLE_BEST_ANSWER === mark.question.typeId) {
|
|
132
|
+
if (models_1.EQuestionType.SINGLE_BEST_ANSWER === mark.question.typeId) {
|
|
128
133
|
const answer = flatAnswer;
|
|
129
134
|
const attempt = flatAttempt;
|
|
130
135
|
if (answer === attempt) {
|
|
@@ -134,7 +139,7 @@ export function correctMark(mark) {
|
|
|
134
139
|
data.incorrect = true;
|
|
135
140
|
}
|
|
136
141
|
}
|
|
137
|
-
else if (EQuestionType.QUESTION_ANSWER === mark.question.typeId) {
|
|
142
|
+
else if (models_1.EQuestionType.QUESTION_ANSWER === mark.question.typeId) {
|
|
138
143
|
const answer = flatAnswer.dose.toLowerCase().replace(/\s/g, '');
|
|
139
144
|
let attempt = '';
|
|
140
145
|
if (flatAttempt) {
|
|
@@ -147,7 +152,7 @@ export function correctMark(mark) {
|
|
|
147
152
|
data.incorrect = true;
|
|
148
153
|
}
|
|
149
154
|
}
|
|
150
|
-
else if (EQuestionType.MULTIPLE_ANSWERS === mark.question.typeId) {
|
|
155
|
+
else if (models_1.EQuestionType.MULTIPLE_ANSWERS === mark.question.typeId) {
|
|
151
156
|
const [answerA, answerB] = answer.map((x) => x.sort());
|
|
152
157
|
let [attemptA, attemptB] = [[], []];
|
|
153
158
|
if (Array.isArray(mark.mark) &&
|
|
@@ -167,7 +172,7 @@ export function correctMark(mark) {
|
|
|
167
172
|
data.incorrect = true;
|
|
168
173
|
}
|
|
169
174
|
}
|
|
170
|
-
else if (EQuestionType.PRESCRIPTION_ANSWER === mark.question.typeId) {
|
|
175
|
+
else if (models_1.EQuestionType.PRESCRIPTION_ANSWER === mark.question.typeId) {
|
|
171
176
|
const answers = answer.map(formatPrescribeAnswer);
|
|
172
177
|
let attempt = formatPrescribeAnswer(mapPrescribeMarkToAnswer({
|
|
173
178
|
drug: '',
|
|
@@ -215,3 +220,4 @@ export function correctMark(mark) {
|
|
|
215
220
|
}
|
|
216
221
|
return data;
|
|
217
222
|
}
|
|
223
|
+
exports.correctMark = correctMark;
|
|
@@ -0,0 +1,217 @@
|
|
|
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(obj) {
|
|
34
|
+
obj.drug.value = obj.drug.value.toLowerCase().replace(/\s/g, '');
|
|
35
|
+
obj.route.value = obj.route.value.toLowerCase().replace(/\s/g, '');
|
|
36
|
+
if (obj.route.value === 'oral') {
|
|
37
|
+
obj.route.value = 'po';
|
|
38
|
+
}
|
|
39
|
+
else if (obj.route.value.includes('intravenous')) {
|
|
40
|
+
obj.route.value = 'iv';
|
|
41
|
+
}
|
|
42
|
+
else if (obj.route.value.includes('intramuscular')) {
|
|
43
|
+
obj.route.value = 'im';
|
|
44
|
+
}
|
|
45
|
+
else if (obj.route.value.includes('subcutaneous')) {
|
|
46
|
+
obj.route.value = 'sc';
|
|
47
|
+
}
|
|
48
|
+
else if (obj.route.value.includes('inhale')) {
|
|
49
|
+
obj.route.value = 'inh';
|
|
50
|
+
}
|
|
51
|
+
else if (obj.route.value.includes('nebuli')) {
|
|
52
|
+
obj.route.value = 'neb';
|
|
53
|
+
}
|
|
54
|
+
else if (obj.route.value.includes('topical')) {
|
|
55
|
+
obj.route.value = 'top';
|
|
56
|
+
}
|
|
57
|
+
obj.units.value = obj.units.value.toLowerCase().replace(/\s/g, '');
|
|
58
|
+
if (obj.units.value === 'milligram' || obj.units.value === 'milligrams') {
|
|
59
|
+
obj.units.value = 'mg';
|
|
60
|
+
}
|
|
61
|
+
else if (obj.units.value === 'microgram' || obj.units.value === 'micrograms') {
|
|
62
|
+
obj.units.value = 'mcg';
|
|
63
|
+
}
|
|
64
|
+
else if (obj.units.value === 'gram' || obj.units.value === 'grams') {
|
|
65
|
+
obj.units.value = 'g';
|
|
66
|
+
}
|
|
67
|
+
else if (obj.units.value === 'unit') {
|
|
68
|
+
obj.units.value = 'units';
|
|
69
|
+
}
|
|
70
|
+
let m;
|
|
71
|
+
const durationMatches = new Set();
|
|
72
|
+
while ((m = floatRegex.exec(obj.duration.value)) !== null) {
|
|
73
|
+
if (m.index === floatRegex.lastIndex) {
|
|
74
|
+
floatRegex.lastIndex++;
|
|
75
|
+
}
|
|
76
|
+
m.forEach((match) => durationMatches.add(match));
|
|
77
|
+
}
|
|
78
|
+
const durationWords = wordsToNumber(obj.duration.value, false);
|
|
79
|
+
if (durationWords !== 0) {
|
|
80
|
+
durationMatches.add(durationWords.toString());
|
|
81
|
+
}
|
|
82
|
+
obj.duration.value = [...durationMatches].filter((x) => !!x).join(',');
|
|
83
|
+
const orgFrequencyValue = obj.frequency.value.toLowerCase();
|
|
84
|
+
obj.frequency.value = orgFrequencyValue.replace(/\s/g, '');
|
|
85
|
+
const frequencyIncHourly = obj.frequency.value.includes('hour');
|
|
86
|
+
const hourlyFreqInt = parseInt(obj.frequency.value);
|
|
87
|
+
if (obj.frequency.value === 'once-off') {
|
|
88
|
+
obj.frequency.value = 'stat';
|
|
89
|
+
}
|
|
90
|
+
else if (obj.frequency.value.includes('once') || (frequencyIncHourly && hourlyFreqInt === 24)) {
|
|
91
|
+
obj.frequency.value = 'od';
|
|
92
|
+
}
|
|
93
|
+
else if (obj.frequency.value.includes('nightly') || obj.frequency.value === 'on') {
|
|
94
|
+
obj.frequency.value = 'od';
|
|
95
|
+
}
|
|
96
|
+
else if (obj.frequency.value.includes('twice') ||
|
|
97
|
+
(frequencyIncHourly && hourlyFreqInt === 12)) {
|
|
98
|
+
obj.frequency.value = 'bd';
|
|
99
|
+
}
|
|
100
|
+
else if (obj.frequency.value.includes('trice') || (frequencyIncHourly && hourlyFreqInt === 8)) {
|
|
101
|
+
obj.frequency.value = 'tds';
|
|
102
|
+
}
|
|
103
|
+
else if (frequencyIncHourly && hourlyFreqInt === 6) {
|
|
104
|
+
obj.frequency.value = 'qds';
|
|
105
|
+
}
|
|
106
|
+
else if (!ACCEPTED_FREQ.includes(obj.frequency.value)) {
|
|
107
|
+
obj.frequency.value = wordsToNumber(orgFrequencyValue, true).toString();
|
|
108
|
+
}
|
|
109
|
+
return obj;
|
|
110
|
+
}
|
|
111
|
+
const answerRegex = /answer/gi;
|
|
112
|
+
export function correctMark(mark) {
|
|
113
|
+
const data = {
|
|
114
|
+
correct: false,
|
|
115
|
+
incorrect: false,
|
|
116
|
+
correctIndex: -1,
|
|
117
|
+
};
|
|
118
|
+
if (!mark || !mark.mark) {
|
|
119
|
+
return data;
|
|
120
|
+
}
|
|
121
|
+
try {
|
|
122
|
+
const qKeys = Object.keys(mark.question);
|
|
123
|
+
const answerKey = qKeys.find((k) => answerRegex.exec(k)) || 'answer';
|
|
124
|
+
const answer = mark.question[answerKey];
|
|
125
|
+
const flatAnswer = answer[0];
|
|
126
|
+
const flatAttempt = mark.mark[0];
|
|
127
|
+
if (EQuestionType.SINGLE_BEST_ANSWER === mark.question.typeId) {
|
|
128
|
+
const answer = flatAnswer;
|
|
129
|
+
const attempt = flatAttempt;
|
|
130
|
+
if (answer === attempt) {
|
|
131
|
+
data.correct = true;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
data.incorrect = true;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else if (EQuestionType.QUESTION_ANSWER === mark.question.typeId) {
|
|
138
|
+
const answer = flatAnswer.dose.toLowerCase().replace(/\s/g, '');
|
|
139
|
+
let attempt = '';
|
|
140
|
+
if (flatAttempt) {
|
|
141
|
+
attempt = flatAttempt.toLowerCase().replace(/\s/g, '');
|
|
142
|
+
}
|
|
143
|
+
if (answer === attempt) {
|
|
144
|
+
data.correct = true;
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
data.incorrect = true;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
else if (EQuestionType.MULTIPLE_ANSWERS === mark.question.typeId) {
|
|
151
|
+
const [answerA, answerB] = answer.map((x) => x.sort());
|
|
152
|
+
let [attemptA, attemptB] = [[], []];
|
|
153
|
+
if (Array.isArray(mark.mark) &&
|
|
154
|
+
mark.mark.length === 2 &&
|
|
155
|
+
Array.isArray(mark.mark[0]) &&
|
|
156
|
+
Array.isArray(mark.mark[1])) {
|
|
157
|
+
[attemptA, attemptB] = mark.mark.map((x) => x.sort());
|
|
158
|
+
}
|
|
159
|
+
if (answerA.length !== attemptA.length || answerB.length !== attemptB.length) {
|
|
160
|
+
data.incorrect = true;
|
|
161
|
+
}
|
|
162
|
+
else if (attemptA.every((x, i) => x === answerA[i]) &&
|
|
163
|
+
attemptB.every((x, i) => x === answerB[i])) {
|
|
164
|
+
data.correct = true;
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
data.incorrect = true;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
else if (EQuestionType.PRESCRIPTION_ANSWER === mark.question.typeId) {
|
|
171
|
+
const answers = answer.map(formatPrescribeAnswer);
|
|
172
|
+
let attempt = formatPrescribeAnswer(mapPrescribeMarkToAnswer({
|
|
173
|
+
drug: '',
|
|
174
|
+
dose: -1,
|
|
175
|
+
units: '',
|
|
176
|
+
route: '',
|
|
177
|
+
frequency: '',
|
|
178
|
+
duration: '',
|
|
179
|
+
}));
|
|
180
|
+
if (typeof flatAttempt === 'object' && Object.keys(flatAttempt).length === 6) {
|
|
181
|
+
attempt = formatPrescribeAnswer(mapPrescribeMarkToAnswer(flatAttempt));
|
|
182
|
+
}
|
|
183
|
+
let foundCorrect = false;
|
|
184
|
+
let index = 0;
|
|
185
|
+
for (const answer of answers) {
|
|
186
|
+
const doseCorrect = answer.dose.display || answer.dose.value === attempt.dose.value;
|
|
187
|
+
const drugCorrect = answer.drug.display || answer.drug.value === attempt.drug.value;
|
|
188
|
+
const durationCorrect = answer.duration.display ||
|
|
189
|
+
answer.duration.value.split(',').includes(attempt.duration.value);
|
|
190
|
+
const frequencyCorrect = answer.frequency.display || answer.frequency.value === attempt.frequency.value;
|
|
191
|
+
const routeCorrect = answer.route.display || answer.route.value === attempt.route.value;
|
|
192
|
+
const unitsCorrect = answer.units.display || answer.units.value === attempt.units.value;
|
|
193
|
+
if (doseCorrect &&
|
|
194
|
+
drugCorrect &&
|
|
195
|
+
durationCorrect &&
|
|
196
|
+
frequencyCorrect &&
|
|
197
|
+
routeCorrect &&
|
|
198
|
+
unitsCorrect) {
|
|
199
|
+
foundCorrect = true;
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
index++;
|
|
203
|
+
}
|
|
204
|
+
if (foundCorrect) {
|
|
205
|
+
data.correct = true;
|
|
206
|
+
data.correctIndex = index;
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
data.incorrect = true;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
catch (e) {
|
|
214
|
+
console.error(e);
|
|
215
|
+
}
|
|
216
|
+
return data;
|
|
217
|
+
}
|
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) {
|
|
@@ -63,7 +67,10 @@ const lightgalleryMutation = (text, pictures, cache) => __awaiter(void 0, void 0
|
|
|
63
67
|
try {
|
|
64
68
|
const localPath = yield cache.CacheManager.get(uri, {}).getPath();
|
|
65
69
|
if (localPath) {
|
|
66
|
-
file =
|
|
70
|
+
file =
|
|
71
|
+
cache.Platform.OS === 'ios'
|
|
72
|
+
? localPath.replace('file://', '')
|
|
73
|
+
: localPath;
|
|
67
74
|
}
|
|
68
75
|
}
|
|
69
76
|
catch (e) {
|
|
@@ -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
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ApolloClient, ApolloLink, MutationOptions, NextLink, Observable, Operation } from '@apollo/client';
|
|
3
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
4
|
+
import Localforage from 'localforage';
|
|
5
|
+
export interface IOfflineLinkParam {
|
|
6
|
+
storage: typeof Localforage | typeof AsyncStorage;
|
|
7
|
+
retryInterval?: number;
|
|
8
|
+
sequential?: boolean;
|
|
9
|
+
retryOnServerError?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare class OfflineLink extends ApolloLink {
|
|
12
|
+
storage: typeof Localforage | typeof AsyncStorage;
|
|
13
|
+
retryInterval: number;
|
|
14
|
+
sequential: boolean;
|
|
15
|
+
retryOnServerError: boolean;
|
|
16
|
+
queue: Map<string, MutationOptions>;
|
|
17
|
+
prefix: string;
|
|
18
|
+
client?: ApolloClient<any>;
|
|
19
|
+
timeoutId?: NodeJS.Timeout;
|
|
20
|
+
/**
|
|
21
|
+
* storage
|
|
22
|
+
* Provider that will persist the mutation queue. This can be any AsyncStorage compatible storage instance.
|
|
23
|
+
*
|
|
24
|
+
* retryInterval
|
|
25
|
+
* Milliseconds between attempts to retry failed mutations. Defaults to 0, which disables automatic retry.
|
|
26
|
+
*
|
|
27
|
+
* sequential
|
|
28
|
+
* Indicates if the attempts should be retried in order. Defaults to false which retries all failed mutations in parallel.
|
|
29
|
+
*
|
|
30
|
+
* retryOnServerError
|
|
31
|
+
* Indicates if mutations should be reattempted if there are server side errors, useful to retry mutations on session expiration. Defaults to false.
|
|
32
|
+
*/
|
|
33
|
+
constructor({ storage, retryInterval, sequential, retryOnServerError, }: IOfflineLinkParam);
|
|
34
|
+
request(operation: Operation, forward: NextLink): Observable<any>;
|
|
35
|
+
/**
|
|
36
|
+
* Obtains the queue of mutations that must be sent to the server.
|
|
37
|
+
* These are kept in a Map to preserve the order of the mutations in the queue.
|
|
38
|
+
*/
|
|
39
|
+
getQueue(): Promise<Map<any, any>>;
|
|
40
|
+
/**
|
|
41
|
+
* Persist the queue so mutations can be retried at a later point in time.
|
|
42
|
+
*/
|
|
43
|
+
private saveQueue;
|
|
44
|
+
/**
|
|
45
|
+
* Add a mutation attempt to the queue so that it can be retried at a later point in time.
|
|
46
|
+
*/
|
|
47
|
+
private add;
|
|
48
|
+
/**
|
|
49
|
+
* Remove a mutation attempt from the queue.
|
|
50
|
+
*/
|
|
51
|
+
private remove;
|
|
52
|
+
/**
|
|
53
|
+
* Takes the mutations in the queue and try to send them to the server again.
|
|
54
|
+
*/
|
|
55
|
+
sync(): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Runs sync() after the retryInterval
|
|
58
|
+
*/
|
|
59
|
+
private delayedSync;
|
|
60
|
+
/**
|
|
61
|
+
* Configure the link to use Apollo Client and immediately try to sync the queue (if there's anything there).
|
|
62
|
+
*/
|
|
63
|
+
setup(client: ApolloClient<any>): Promise<void>;
|
|
64
|
+
}
|