@quesmed/types 1.3.14 → 1.3.18
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.cjs +2 -0
- package/gql_input_output_types/User.js +1 -2
- package/gql_input_output_types/index.cjs +2 -0
- package/gql_input_output_types/index.js +1 -2
- package/index.cjs +20 -0
- package/index.js +4 -7
- package/models/Author.cjs +2 -0
- package/models/Author.js +1 -2
- package/models/Book.cjs +2 -0
- package/models/Book.js +1 -2
- package/models/Card.cjs +2 -0
- package/models/Card.js +1 -2
- package/models/Chapter.cjs +2 -0
- package/models/Chapter.js +1 -2
- package/models/Concept.cjs +2 -0
- package/models/Concept.js +1 -2
- package/models/Difficulty.cjs +10 -0
- package/models/Difficulty.js +2 -5
- package/models/Feedback.cjs +2 -0
- package/models/Feedback.js +1 -2
- package/models/File.cjs +2 -0
- package/models/File.js +1 -2
- package/models/Marksheet.cjs +9 -0
- package/models/Marksheet.js +2 -5
- package/models/MockTest.cjs +2 -0
- package/models/MockTest.js +1 -2
- package/models/OsceMarksheet.cjs +23 -0
- package/models/OsceMarksheet.js +4 -7
- package/models/OsceStation.cjs +45 -0
- package/models/OsceStation.js +3 -6
- package/models/Picture.cjs +6 -0
- package/models/Picture.js +1 -2
- package/models/Promo.cjs +2 -0
- package/models/Promo.js +1 -2
- package/models/Question.cjs +37 -0
- package/models/Question.js +8 -15
- package/models/Subscription.cjs +9 -0
- package/models/Subscription.js +2 -5
- package/models/Todo.cjs +2 -0
- package/models/Todo.js +1 -2
- package/models/Token.cjs +2 -0
- package/models/Token.js +1 -2
- package/models/Topic.cjs +13 -0
- package/models/Topic.js +2 -5
- package/models/Type.cjs +2 -0
- package/models/Type.js +1 -2
- package/models/University.cjs +2 -0
- package/models/University.js +1 -2
- package/models/User.cjs +2 -0
- package/models/User.d.ts +1 -0
- package/models/User.js +1 -2
- package/models/Video.cjs +2 -0
- package/models/Video.js +1 -2
- package/models/index.cjs +35 -0
- package/models/index.js +23 -35
- package/package.json +17 -4
- package/resolvers/apollo.cjs +2 -0
- package/resolvers/apollo.d.ts +8 -0
- package/resolvers/apollo.js +1 -0
- package/resolvers/mutation/admin/algoliaSync.cjs +2 -0
- package/resolvers/mutation/admin/algoliaSync.js +1 -2
- package/resolvers/mutation/admin/index.cjs +14 -0
- package/resolvers/mutation/admin/index.js +2 -14
- package/resolvers/mutation/admin/token.cjs +2 -0
- package/resolvers/mutation/admin/token.js +1 -2
- package/resolvers/mutation/index.cjs +14 -0
- package/resolvers/mutation/index.js +2 -14
- package/resolvers/mutation/restricted/agora.cjs +2 -0
- package/resolvers/mutation/restricted/agora.js +1 -2
- package/resolvers/mutation/restricted/contactUs.cjs +2 -0
- package/resolvers/mutation/restricted/contactUs.js +1 -2
- package/resolvers/mutation/restricted/index.cjs +22 -0
- package/resolvers/mutation/restricted/index.js +10 -22
- package/resolvers/mutation/restricted/marksheet.cjs +2 -0
- package/resolvers/mutation/restricted/marksheet.js +1 -2
- package/resolvers/mutation/restricted/mockTest.cjs +2 -0
- package/resolvers/mutation/restricted/mockTest.js +1 -2
- package/resolvers/mutation/restricted/osce.cjs +2 -0
- package/resolvers/mutation/restricted/osce.js +1 -2
- package/resolvers/mutation/restricted/questionDiscussion.cjs +2 -0
- package/resolvers/mutation/restricted/questionDiscussion.js +1 -2
- package/resolvers/mutation/restricted/todo.cjs +29 -0
- package/resolvers/mutation/restricted/todo.d.ts +5 -0
- package/resolvers/mutation/restricted/todo.js +25 -2
- package/resolvers/mutation/restricted/token.cjs +2 -0
- package/resolvers/mutation/restricted/token.js +1 -2
- package/resolvers/mutation/restricted/users.cjs +2 -0
- package/resolvers/mutation/restricted/users.js +1 -2
- package/resolvers/mutation/restricted/video.cjs +2 -0
- package/resolvers/mutation/restricted/video.js +1 -2
- package/resolvers/mutation/stripe.cjs +2 -0
- package/resolvers/mutation/stripe.js +1 -2
- package/resolvers/mutation/users.cjs +2 -0
- package/resolvers/mutation/users.js +1 -2
- package/resolvers/mutation/validUserToken/index.cjs +13 -0
- package/resolvers/mutation/validUserToken/index.js +1 -13
- package/resolvers/mutation/validUserToken/user.cjs +2 -0
- package/resolvers/mutation/validUserToken/user.js +1 -2
- package/resolvers/query/admin/getUserToken.cjs +2 -0
- package/resolvers/query/admin/getUserToken.js +1 -2
- package/resolvers/query/admin/index.cjs +13 -0
- package/resolvers/query/admin/index.js +1 -13
- package/resolvers/query/author.cjs +2 -0
- package/resolvers/query/author.js +1 -2
- package/resolvers/query/book.cjs +2 -0
- package/resolvers/query/book.js +1 -2
- package/resolvers/query/feedback.cjs +2 -0
- package/resolvers/query/feedback.js +1 -2
- package/resolvers/query/index.cjs +21 -0
- package/resolvers/query/index.js +9 -21
- package/resolvers/query/restricted/anatomy.cjs +2 -0
- package/resolvers/query/restricted/anatomy.js +1 -2
- package/resolvers/query/restricted/index.cjs +22 -0
- package/resolvers/query/restricted/index.js +10 -22
- package/resolvers/query/restricted/marksheet.cjs +2 -0
- package/resolvers/query/restricted/marksheet.js +1 -2
- package/resolvers/query/restricted/mockTests.cjs +2 -0
- package/resolvers/query/restricted/mockTests.js +1 -2
- package/resolvers/query/restricted/osce.cjs +2 -0
- package/resolvers/query/restricted/osce.js +1 -2
- package/resolvers/query/restricted/quesBook.cjs +2 -0
- package/resolvers/query/restricted/quesBook.js +1 -2
- package/resolvers/query/restricted/todos.cjs +2 -0
- package/resolvers/query/restricted/todos.js +1 -2
- package/resolvers/query/restricted/topics.cjs +2 -0
- package/resolvers/query/restricted/topics.js +1 -2
- package/resolvers/query/restricted/university.cjs +2 -0
- package/resolvers/query/restricted/university.js +1 -2
- package/resolvers/query/restricted/user.cjs +2 -0
- package/resolvers/query/restricted/user.js +1 -2
- package/resolvers/query/restricted/video.cjs +2 -0
- package/resolvers/query/restricted/video.js +1 -2
- package/resolvers/query/sampleCards.cjs +2 -0
- package/resolvers/query/sampleCards.js +1 -2
- package/resolvers/query/sampleQuestions.cjs +2 -0
- package/resolvers/query/sampleQuestions.js +1 -2
- package/resolvers/query/subscription.cjs +2 -0
- package/resolvers/query/subscription.js +1 -2
- package/resolvers/query/university.cjs +2 -0
- package/resolvers/query/university.js +1 -2
- package/resolvers/query/user.cjs +2 -0
- package/resolvers/query/user.js +1 -2
- package/resolvers/query/video.cjs +2 -0
- package/resolvers/query/video.js +1 -2
- package/resolvers/subscription/index.cjs +13 -0
- package/resolvers/subscription/index.js +1 -13
- package/resolvers/subscription/osce.cjs +43 -0
- package/resolvers/subscription/osce.js +10 -14
- package/utils/commonFunctions.cjs +223 -0
- package/utils/commonFunctions.js +11 -17
- package/utils/index.cjs +17 -0
- package/utils/index.d.ts +5 -0
- package/utils/index.js +5 -0
- package/utils/lightgallery.cjs +91 -0
- package/utils/lightgallery.d.ts +4 -2
- package/utils/lightgallery.js +5 -6
- package/utils/offlineLink.cjs +237 -0
- package/utils/offlineLink.d.ts +64 -0
- package/utils/offlineLink.js +230 -0
- package/utils/uuid4.cjs +287 -0
- package/utils/uuid4.js +1 -3
- package/utils/wordsToNumber.cjs +48 -0
- package/utils/wordsToNumber.js +1 -5
|
@@ -0,0 +1,22 @@
|
|
|
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("./anatomy"), exports);
|
|
14
|
+
__exportStar(require("./marksheet"), exports);
|
|
15
|
+
__exportStar(require("./mockTests"), exports);
|
|
16
|
+
__exportStar(require("./osce"), exports);
|
|
17
|
+
__exportStar(require("./quesBook"), exports);
|
|
18
|
+
__exportStar(require("./todos"), exports);
|
|
19
|
+
__exportStar(require("./topics"), exports);
|
|
20
|
+
__exportStar(require("./university"), exports);
|
|
21
|
+
__exportStar(require("./user"), exports);
|
|
22
|
+
__exportStar(require("./video"), exports);
|
|
@@ -1,22 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./anatomy"), exports);
|
|
14
|
-
__exportStar(require("./marksheet"), exports);
|
|
15
|
-
__exportStar(require("./mockTests"), exports);
|
|
16
|
-
__exportStar(require("./osce"), exports);
|
|
17
|
-
__exportStar(require("./quesBook"), exports);
|
|
18
|
-
__exportStar(require("./todos"), exports);
|
|
19
|
-
__exportStar(require("./topics"), exports);
|
|
20
|
-
__exportStar(require("./university"), exports);
|
|
21
|
-
__exportStar(require("./user"), exports);
|
|
22
|
-
__exportStar(require("./video"), exports);
|
|
1
|
+
export * from './anatomy';
|
|
2
|
+
export * from './marksheet';
|
|
3
|
+
export * from './mockTests';
|
|
4
|
+
export * from './osce';
|
|
5
|
+
export * from './quesBook';
|
|
6
|
+
export * from './todos';
|
|
7
|
+
export * from './topics';
|
|
8
|
+
export * from './university';
|
|
9
|
+
export * from './user';
|
|
10
|
+
export * from './video';
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/resolvers/query/user.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/resolvers/query/video.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
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("./osce"), exports);
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
|
|
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("./osce"), exports);
|
|
1
|
+
export * from './osce';
|
|
@@ -0,0 +1,43 @@
|
|
|
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) => [
|
|
10
|
+
{
|
|
11
|
+
id: null,
|
|
12
|
+
createdAt: null,
|
|
13
|
+
osceMarksheetId,
|
|
14
|
+
userId: null,
|
|
15
|
+
user: null,
|
|
16
|
+
role: models_1.EOsceRoles.CANDIDATE,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: null,
|
|
20
|
+
createdAt: null,
|
|
21
|
+
osceMarksheetId,
|
|
22
|
+
userId: null,
|
|
23
|
+
user: null,
|
|
24
|
+
role: models_1.EOsceRoles.EXAMINER,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: null,
|
|
28
|
+
createdAt: null,
|
|
29
|
+
osceMarksheetId,
|
|
30
|
+
userId: null,
|
|
31
|
+
user: null,
|
|
32
|
+
role: models_1.EOsceRoles.ACTOR,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: null,
|
|
36
|
+
createdAt: null,
|
|
37
|
+
osceMarksheetId,
|
|
38
|
+
userId: null,
|
|
39
|
+
user: null,
|
|
40
|
+
role: models_1.EOsceRoles.OBSERVER,
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
exports.OsceGroupInit = OsceGroupInit;
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.OSCE_MATCHMAKING = 'OSCE_MATCHMAKING';
|
|
8
|
-
exports.OSCE_MATCHMAKING_USERS = 'OSCE_MATCHMAKING_USERS';
|
|
9
|
-
const OsceGroupInit = (osceMarksheetId) => [
|
|
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) => [
|
|
10
7
|
{
|
|
11
8
|
id: null,
|
|
12
9
|
createdAt: null,
|
|
13
10
|
osceMarksheetId,
|
|
14
11
|
userId: null,
|
|
15
12
|
user: null,
|
|
16
|
-
role:
|
|
13
|
+
role: EOsceRoles.CANDIDATE,
|
|
17
14
|
},
|
|
18
15
|
{
|
|
19
16
|
id: null,
|
|
@@ -21,7 +18,7 @@ const OsceGroupInit = (osceMarksheetId) => [
|
|
|
21
18
|
osceMarksheetId,
|
|
22
19
|
userId: null,
|
|
23
20
|
user: null,
|
|
24
|
-
role:
|
|
21
|
+
role: EOsceRoles.EXAMINER,
|
|
25
22
|
},
|
|
26
23
|
{
|
|
27
24
|
id: null,
|
|
@@ -29,7 +26,7 @@ const OsceGroupInit = (osceMarksheetId) => [
|
|
|
29
26
|
osceMarksheetId,
|
|
30
27
|
userId: null,
|
|
31
28
|
user: null,
|
|
32
|
-
role:
|
|
29
|
+
role: EOsceRoles.ACTOR,
|
|
33
30
|
},
|
|
34
31
|
{
|
|
35
32
|
id: null,
|
|
@@ -37,7 +34,6 @@ const OsceGroupInit = (osceMarksheetId) => [
|
|
|
37
34
|
osceMarksheetId,
|
|
38
35
|
userId: null,
|
|
39
36
|
user: null,
|
|
40
|
-
role:
|
|
37
|
+
role: EOsceRoles.OBSERVER,
|
|
41
38
|
},
|
|
42
39
|
];
|
|
43
|
-
exports.OsceGroupInit = OsceGroupInit;
|
|
@@ -0,0 +1,223 @@
|
|
|
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");
|
|
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(obj) {
|
|
38
|
+
obj.drug.value = obj.drug.value.toLowerCase().replace(/\s/g, '');
|
|
39
|
+
obj.route.value = obj.route.value.toLowerCase().replace(/\s/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' || obj.units.value === 'micrograms') {
|
|
66
|
+
obj.units.value = 'mcg';
|
|
67
|
+
}
|
|
68
|
+
else if (obj.units.value === 'gram' || obj.units.value === 'grams') {
|
|
69
|
+
obj.units.value = 'g';
|
|
70
|
+
}
|
|
71
|
+
else if (obj.units.value === 'unit') {
|
|
72
|
+
obj.units.value = 'units';
|
|
73
|
+
}
|
|
74
|
+
let m;
|
|
75
|
+
const durationMatches = new Set();
|
|
76
|
+
while ((m = floatRegex.exec(obj.duration.value)) !== null) {
|
|
77
|
+
if (m.index === floatRegex.lastIndex) {
|
|
78
|
+
floatRegex.lastIndex++;
|
|
79
|
+
}
|
|
80
|
+
m.forEach((match) => durationMatches.add(match));
|
|
81
|
+
}
|
|
82
|
+
const durationWords = (0, wordsToNumber_1.wordsToNumber)(obj.duration.value, false);
|
|
83
|
+
if (durationWords !== 0) {
|
|
84
|
+
durationMatches.add(durationWords.toString());
|
|
85
|
+
}
|
|
86
|
+
obj.duration.value = [...durationMatches].filter((x) => !!x).join(',');
|
|
87
|
+
const orgFrequencyValue = obj.frequency.value.toLowerCase();
|
|
88
|
+
obj.frequency.value = orgFrequencyValue.replace(/\s/g, '');
|
|
89
|
+
const frequencyIncHourly = obj.frequency.value.includes('hour');
|
|
90
|
+
const hourlyFreqInt = parseInt(obj.frequency.value);
|
|
91
|
+
if (obj.frequency.value === 'once-off') {
|
|
92
|
+
obj.frequency.value = 'stat';
|
|
93
|
+
}
|
|
94
|
+
else if (obj.frequency.value.includes('once') || (frequencyIncHourly && hourlyFreqInt === 24)) {
|
|
95
|
+
obj.frequency.value = 'od';
|
|
96
|
+
}
|
|
97
|
+
else if (obj.frequency.value.includes('nightly') || obj.frequency.value === 'on') {
|
|
98
|
+
obj.frequency.value = 'od';
|
|
99
|
+
}
|
|
100
|
+
else if (obj.frequency.value.includes('twice') ||
|
|
101
|
+
(frequencyIncHourly && hourlyFreqInt === 12)) {
|
|
102
|
+
obj.frequency.value = 'bd';
|
|
103
|
+
}
|
|
104
|
+
else if (obj.frequency.value.includes('trice') || (frequencyIncHourly && hourlyFreqInt === 8)) {
|
|
105
|
+
obj.frequency.value = 'tds';
|
|
106
|
+
}
|
|
107
|
+
else if (frequencyIncHourly && hourlyFreqInt === 6) {
|
|
108
|
+
obj.frequency.value = 'qds';
|
|
109
|
+
}
|
|
110
|
+
else if (!ACCEPTED_FREQ.includes(obj.frequency.value)) {
|
|
111
|
+
obj.frequency.value = (0, wordsToNumber_1.wordsToNumber)(orgFrequencyValue, true).toString();
|
|
112
|
+
}
|
|
113
|
+
return obj;
|
|
114
|
+
}
|
|
115
|
+
exports.formatPrescribeAnswer = formatPrescribeAnswer;
|
|
116
|
+
const answerRegex = /answer/gi;
|
|
117
|
+
function correctMark(mark) {
|
|
118
|
+
const data = {
|
|
119
|
+
correct: false,
|
|
120
|
+
incorrect: false,
|
|
121
|
+
correctIndex: -1,
|
|
122
|
+
};
|
|
123
|
+
if (!mark || !mark.mark) {
|
|
124
|
+
return data;
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
const qKeys = Object.keys(mark.question);
|
|
128
|
+
const answerKey = qKeys.find((k) => answerRegex.exec(k)) || 'answer';
|
|
129
|
+
const answer = mark.question[answerKey];
|
|
130
|
+
const flatAnswer = answer[0];
|
|
131
|
+
const flatAttempt = mark.mark[0];
|
|
132
|
+
if (models_1.EQuestionType.SINGLE_BEST_ANSWER === mark.question.typeId) {
|
|
133
|
+
const answer = flatAnswer;
|
|
134
|
+
const attempt = flatAttempt;
|
|
135
|
+
if (answer === attempt) {
|
|
136
|
+
data.correct = true;
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
data.incorrect = true;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
else if (models_1.EQuestionType.QUESTION_ANSWER === mark.question.typeId) {
|
|
143
|
+
const answer = flatAnswer.dose.toLowerCase().replace(/\s/g, '');
|
|
144
|
+
let attempt = '';
|
|
145
|
+
if (flatAttempt) {
|
|
146
|
+
attempt = flatAttempt.toLowerCase().replace(/\s/g, '');
|
|
147
|
+
}
|
|
148
|
+
if (answer === attempt) {
|
|
149
|
+
data.correct = true;
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
data.incorrect = true;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
else if (models_1.EQuestionType.MULTIPLE_ANSWERS === mark.question.typeId) {
|
|
156
|
+
const [answerA, answerB] = answer.map((x) => x.sort());
|
|
157
|
+
let [attemptA, attemptB] = [[], []];
|
|
158
|
+
if (Array.isArray(mark.mark) &&
|
|
159
|
+
mark.mark.length === 2 &&
|
|
160
|
+
Array.isArray(mark.mark[0]) &&
|
|
161
|
+
Array.isArray(mark.mark[1])) {
|
|
162
|
+
[attemptA, attemptB] = mark.mark.map((x) => x.sort());
|
|
163
|
+
}
|
|
164
|
+
if (answerA.length !== attemptA.length || answerB.length !== attemptB.length) {
|
|
165
|
+
data.incorrect = true;
|
|
166
|
+
}
|
|
167
|
+
else if (attemptA.every((x, i) => x === answerA[i]) &&
|
|
168
|
+
attemptB.every((x, i) => x === answerB[i])) {
|
|
169
|
+
data.correct = true;
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
data.incorrect = true;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
else if (models_1.EQuestionType.PRESCRIPTION_ANSWER === mark.question.typeId) {
|
|
176
|
+
const answers = answer.map(formatPrescribeAnswer);
|
|
177
|
+
let attempt = formatPrescribeAnswer(mapPrescribeMarkToAnswer({
|
|
178
|
+
drug: '',
|
|
179
|
+
dose: -1,
|
|
180
|
+
units: '',
|
|
181
|
+
route: '',
|
|
182
|
+
frequency: '',
|
|
183
|
+
duration: '',
|
|
184
|
+
}));
|
|
185
|
+
if (typeof flatAttempt === 'object' && Object.keys(flatAttempt).length === 6) {
|
|
186
|
+
attempt = formatPrescribeAnswer(mapPrescribeMarkToAnswer(flatAttempt));
|
|
187
|
+
}
|
|
188
|
+
let foundCorrect = false;
|
|
189
|
+
let index = 0;
|
|
190
|
+
for (const answer of answers) {
|
|
191
|
+
const doseCorrect = answer.dose.display || answer.dose.value === attempt.dose.value;
|
|
192
|
+
const drugCorrect = answer.drug.display || answer.drug.value === attempt.drug.value;
|
|
193
|
+
const durationCorrect = answer.duration.display ||
|
|
194
|
+
answer.duration.value.split(',').includes(attempt.duration.value);
|
|
195
|
+
const frequencyCorrect = answer.frequency.display || answer.frequency.value === attempt.frequency.value;
|
|
196
|
+
const routeCorrect = answer.route.display || answer.route.value === attempt.route.value;
|
|
197
|
+
const unitsCorrect = answer.units.display || answer.units.value === attempt.units.value;
|
|
198
|
+
if (doseCorrect &&
|
|
199
|
+
drugCorrect &&
|
|
200
|
+
durationCorrect &&
|
|
201
|
+
frequencyCorrect &&
|
|
202
|
+
routeCorrect &&
|
|
203
|
+
unitsCorrect) {
|
|
204
|
+
foundCorrect = true;
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
index++;
|
|
208
|
+
}
|
|
209
|
+
if (foundCorrect) {
|
|
210
|
+
data.correct = true;
|
|
211
|
+
data.correctIndex = index;
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
data.incorrect = true;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
catch (e) {
|
|
219
|
+
console.error(e);
|
|
220
|
+
}
|
|
221
|
+
return data;
|
|
222
|
+
}
|
|
223
|
+
exports.correctMark = correctMark;
|
package/utils/commonFunctions.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.correctMark = exports.formatPrescribeAnswer = exports.mapPrescribeMarkToAnswer = void 0;
|
|
4
|
-
const models_1 = require("../models");
|
|
5
|
-
const wordsToNumber_1 = require("./wordsToNumber");
|
|
1
|
+
import { EQuestionType, } from '../models';
|
|
2
|
+
import { wordsToNumber } from './wordsToNumber';
|
|
6
3
|
const floatRegex = /([0-9]*[.])?[0-9]+/gm;
|
|
7
4
|
const ACCEPTED_FREQ = ['stat', 'od', 'bd', 'tds', 'qds'];
|
|
8
|
-
function mapPrescribeMarkToAnswer(obj) {
|
|
5
|
+
export function mapPrescribeMarkToAnswer(obj) {
|
|
9
6
|
return {
|
|
10
7
|
drug: {
|
|
11
8
|
value: obj.drug,
|
|
@@ -33,8 +30,7 @@ function mapPrescribeMarkToAnswer(obj) {
|
|
|
33
30
|
},
|
|
34
31
|
};
|
|
35
32
|
}
|
|
36
|
-
|
|
37
|
-
function formatPrescribeAnswer(obj) {
|
|
33
|
+
export function formatPrescribeAnswer(obj) {
|
|
38
34
|
obj.drug.value = obj.drug.value.toLowerCase().replace(/\s/g, '');
|
|
39
35
|
obj.route.value = obj.route.value.toLowerCase().replace(/\s/g, '');
|
|
40
36
|
if (obj.route.value === 'oral') {
|
|
@@ -79,7 +75,7 @@ function formatPrescribeAnswer(obj) {
|
|
|
79
75
|
}
|
|
80
76
|
m.forEach((match) => durationMatches.add(match));
|
|
81
77
|
}
|
|
82
|
-
const durationWords =
|
|
78
|
+
const durationWords = wordsToNumber(obj.duration.value, false);
|
|
83
79
|
if (durationWords !== 0) {
|
|
84
80
|
durationMatches.add(durationWords.toString());
|
|
85
81
|
}
|
|
@@ -108,13 +104,12 @@ function formatPrescribeAnswer(obj) {
|
|
|
108
104
|
obj.frequency.value = 'qds';
|
|
109
105
|
}
|
|
110
106
|
else if (!ACCEPTED_FREQ.includes(obj.frequency.value)) {
|
|
111
|
-
obj.frequency.value =
|
|
107
|
+
obj.frequency.value = wordsToNumber(orgFrequencyValue, true).toString();
|
|
112
108
|
}
|
|
113
109
|
return obj;
|
|
114
110
|
}
|
|
115
|
-
exports.formatPrescribeAnswer = formatPrescribeAnswer;
|
|
116
111
|
const answerRegex = /answer/gi;
|
|
117
|
-
function correctMark(mark) {
|
|
112
|
+
export function correctMark(mark) {
|
|
118
113
|
const data = {
|
|
119
114
|
correct: false,
|
|
120
115
|
incorrect: false,
|
|
@@ -129,7 +124,7 @@ function correctMark(mark) {
|
|
|
129
124
|
const answer = mark.question[answerKey];
|
|
130
125
|
const flatAnswer = answer[0];
|
|
131
126
|
const flatAttempt = mark.mark[0];
|
|
132
|
-
if (
|
|
127
|
+
if (EQuestionType.SINGLE_BEST_ANSWER === mark.question.typeId) {
|
|
133
128
|
const answer = flatAnswer;
|
|
134
129
|
const attempt = flatAttempt;
|
|
135
130
|
if (answer === attempt) {
|
|
@@ -139,7 +134,7 @@ function correctMark(mark) {
|
|
|
139
134
|
data.incorrect = true;
|
|
140
135
|
}
|
|
141
136
|
}
|
|
142
|
-
else if (
|
|
137
|
+
else if (EQuestionType.QUESTION_ANSWER === mark.question.typeId) {
|
|
143
138
|
const answer = flatAnswer.dose.toLowerCase().replace(/\s/g, '');
|
|
144
139
|
let attempt = '';
|
|
145
140
|
if (flatAttempt) {
|
|
@@ -152,7 +147,7 @@ function correctMark(mark) {
|
|
|
152
147
|
data.incorrect = true;
|
|
153
148
|
}
|
|
154
149
|
}
|
|
155
|
-
else if (
|
|
150
|
+
else if (EQuestionType.MULTIPLE_ANSWERS === mark.question.typeId) {
|
|
156
151
|
const [answerA, answerB] = answer.map((x) => x.sort());
|
|
157
152
|
let [attemptA, attemptB] = [[], []];
|
|
158
153
|
if (Array.isArray(mark.mark) &&
|
|
@@ -172,7 +167,7 @@ function correctMark(mark) {
|
|
|
172
167
|
data.incorrect = true;
|
|
173
168
|
}
|
|
174
169
|
}
|
|
175
|
-
else if (
|
|
170
|
+
else if (EQuestionType.PRESCRIPTION_ANSWER === mark.question.typeId) {
|
|
176
171
|
const answers = answer.map(formatPrescribeAnswer);
|
|
177
172
|
let attempt = formatPrescribeAnswer(mapPrescribeMarkToAnswer({
|
|
178
173
|
drug: '',
|
|
@@ -220,4 +215,3 @@ function correctMark(mark) {
|
|
|
220
215
|
}
|
|
221
216
|
return data;
|
|
222
217
|
}
|
|
223
|
-
exports.correctMark = correctMark;
|