@quesmed/types 1.0.22 → 1.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/models/Marksheet.d.ts +2 -2
- package/models/MockTest.d.ts +1 -0
- package/models/Question.d.ts +28 -6
- package/models/Question.js +28 -1
- package/package.json +1 -1
- package/utils/commonFunctions.js +12 -6
package/models/Marksheet.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IPrescribeAnswer, IQuestion } from './Question';
|
|
1
|
+
import { IPrescribeAnswer, IQuestion, IQuestionQAAnswer } from './Question';
|
|
2
2
|
import { Id } from './Type';
|
|
3
3
|
export interface IMarksheet {
|
|
4
4
|
id: Id;
|
|
@@ -13,7 +13,7 @@ export declare enum EQuestionLike {
|
|
|
13
13
|
DISLIKE = 1,
|
|
14
14
|
REMOVE = 2
|
|
15
15
|
}
|
|
16
|
-
export declare type IMarksheetMarkJSONB = string | [string] | [string[], string[]] | [IPrescribeAnswer] | null;
|
|
16
|
+
export declare type IMarksheetMarkJSONB = string | [string] | [IQuestionQAAnswer] | [string[], string[]] | [IPrescribeAnswer] | null;
|
|
17
17
|
export interface IMarksheetMark {
|
|
18
18
|
id: Id;
|
|
19
19
|
index: number;
|
package/models/MockTest.d.ts
CHANGED
package/models/Question.d.ts
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import { IConcept } from './Concept';
|
|
2
2
|
import { IQuestionPicture } from './Picture';
|
|
3
3
|
import { Id } from './Type';
|
|
4
|
+
export declare enum EPsaSectionType {
|
|
5
|
+
PRESCRIBING = 1,
|
|
6
|
+
PRESCRIPTION_REVIEW = 2,
|
|
7
|
+
PLANNING_MANAGEMENT = 3,
|
|
8
|
+
PROVIDING_INFORMATION = 4,
|
|
9
|
+
CALCULATION_SKILLS = 5,
|
|
10
|
+
ADVERSE_DRUG_REACTION = 6,
|
|
11
|
+
DRUG_MONITORING = 7,
|
|
12
|
+
DATA_INTERPRETATION = 8
|
|
13
|
+
}
|
|
4
14
|
export declare enum EQuestionType {
|
|
5
15
|
SINGLE_BEST_ANSWER = 1,
|
|
6
16
|
QUESTION_ANSWER = 2,
|
|
7
17
|
MULTIPLE_ANSWERS = 3,
|
|
8
18
|
PRESCRIPTION_ANSWER = 4
|
|
9
19
|
}
|
|
10
|
-
export declare type IQuestionAnswer = string | [string] | [string[], string[]] | IPrescribeAnswer[];
|
|
20
|
+
export declare type IQuestionAnswer = string | [string] | [IQuestionQAAnswer] | [string[], string[]] | IPrescribeAnswer[];
|
|
21
|
+
export declare type IQuestionAll = IQuestion | IQuestionSBA | IQuestionQA | IQuestionMultiQ | IQuestionPrescribe;
|
|
11
22
|
export interface IQuestion {
|
|
12
23
|
id: Id;
|
|
13
24
|
typeId: Id;
|
|
@@ -20,6 +31,9 @@ export interface IQuestion {
|
|
|
20
31
|
totalVotes: number;
|
|
21
32
|
choices: IQuestionChoice[];
|
|
22
33
|
pictures: IQuestionPicture[];
|
|
34
|
+
difficulty: number;
|
|
35
|
+
elo: number;
|
|
36
|
+
psaSectionId: EPsaSectionType;
|
|
23
37
|
}
|
|
24
38
|
export interface IQuestionChoice {
|
|
25
39
|
id: Id;
|
|
@@ -29,27 +43,35 @@ export interface IQuestionChoice {
|
|
|
29
43
|
answer: boolean;
|
|
30
44
|
votes: number;
|
|
31
45
|
}
|
|
46
|
+
export declare function isQuestionSBA(data: IQuestionAll): data is IQuestionSBA;
|
|
32
47
|
export interface IQuestionSBA extends IQuestion {
|
|
33
48
|
answer: [string];
|
|
34
49
|
sbaAnswer: [string];
|
|
35
50
|
}
|
|
51
|
+
export interface IQuestionQAAnswer {
|
|
52
|
+
dose: string;
|
|
53
|
+
units: string;
|
|
54
|
+
}
|
|
55
|
+
export declare function isQuestionQA(data: IQuestionAll): data is IQuestionQA;
|
|
36
56
|
export interface IQuestionQA extends IQuestion {
|
|
37
|
-
answer: [
|
|
38
|
-
qaAnswer: [
|
|
57
|
+
answer: [IQuestionQAAnswer];
|
|
58
|
+
qaAnswer: [IQuestionQAAnswer];
|
|
39
59
|
}
|
|
60
|
+
export declare function isQuestionMultiQ(data: IQuestionAll): data is IQuestionMultiQ;
|
|
40
61
|
export interface IQuestionMultiQ extends IQuestion {
|
|
41
62
|
answer: [string[], string[]];
|
|
42
63
|
multiAnswer: [string[], string[]];
|
|
43
64
|
}
|
|
65
|
+
export declare function isQuestionPrescribe(data: IQuestionAll): data is IQuestionPrescribe;
|
|
44
66
|
export interface IQuestionPrescribe extends IQuestion {
|
|
45
67
|
answer: IPrescribeAnswer[];
|
|
46
68
|
prescribeAnswer: IPrescribeAnswer[];
|
|
47
69
|
}
|
|
48
70
|
export interface IPrescribeAnswer {
|
|
49
|
-
dose: number;
|
|
50
71
|
drug: string;
|
|
51
|
-
|
|
72
|
+
dose: number;
|
|
52
73
|
units: string;
|
|
53
|
-
|
|
74
|
+
route: string;
|
|
54
75
|
frequency: string;
|
|
76
|
+
duration: string;
|
|
55
77
|
}
|
package/models/Question.js
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EQuestionType = void 0;
|
|
3
|
+
exports.isQuestionPrescribe = exports.isQuestionMultiQ = exports.isQuestionQA = exports.isQuestionSBA = exports.EQuestionType = exports.EPsaSectionType = void 0;
|
|
4
|
+
var EPsaSectionType;
|
|
5
|
+
(function (EPsaSectionType) {
|
|
6
|
+
EPsaSectionType[EPsaSectionType["PRESCRIBING"] = 1] = "PRESCRIBING";
|
|
7
|
+
EPsaSectionType[EPsaSectionType["PRESCRIPTION_REVIEW"] = 2] = "PRESCRIPTION_REVIEW";
|
|
8
|
+
EPsaSectionType[EPsaSectionType["PLANNING_MANAGEMENT"] = 3] = "PLANNING_MANAGEMENT";
|
|
9
|
+
EPsaSectionType[EPsaSectionType["PROVIDING_INFORMATION"] = 4] = "PROVIDING_INFORMATION";
|
|
10
|
+
EPsaSectionType[EPsaSectionType["CALCULATION_SKILLS"] = 5] = "CALCULATION_SKILLS";
|
|
11
|
+
EPsaSectionType[EPsaSectionType["ADVERSE_DRUG_REACTION"] = 6] = "ADVERSE_DRUG_REACTION";
|
|
12
|
+
EPsaSectionType[EPsaSectionType["DRUG_MONITORING"] = 7] = "DRUG_MONITORING";
|
|
13
|
+
EPsaSectionType[EPsaSectionType["DATA_INTERPRETATION"] = 8] = "DATA_INTERPRETATION";
|
|
14
|
+
})(EPsaSectionType = exports.EPsaSectionType || (exports.EPsaSectionType = {}));
|
|
4
15
|
var EQuestionType;
|
|
5
16
|
(function (EQuestionType) {
|
|
6
17
|
EQuestionType[EQuestionType["SINGLE_BEST_ANSWER"] = 1] = "SINGLE_BEST_ANSWER";
|
|
@@ -8,3 +19,19 @@ var EQuestionType;
|
|
|
8
19
|
EQuestionType[EQuestionType["MULTIPLE_ANSWERS"] = 3] = "MULTIPLE_ANSWERS";
|
|
9
20
|
EQuestionType[EQuestionType["PRESCRIPTION_ANSWER"] = 4] = "PRESCRIPTION_ANSWER";
|
|
10
21
|
})(EQuestionType = exports.EQuestionType || (exports.EQuestionType = {}));
|
|
22
|
+
function isQuestionSBA(data) {
|
|
23
|
+
return data.typeId === EQuestionType.SINGLE_BEST_ANSWER;
|
|
24
|
+
}
|
|
25
|
+
exports.isQuestionSBA = isQuestionSBA;
|
|
26
|
+
function isQuestionQA(data) {
|
|
27
|
+
return data.typeId === EQuestionType.QUESTION_ANSWER;
|
|
28
|
+
}
|
|
29
|
+
exports.isQuestionQA = isQuestionQA;
|
|
30
|
+
function isQuestionMultiQ(data) {
|
|
31
|
+
return data.typeId === EQuestionType.MULTIPLE_ANSWERS;
|
|
32
|
+
}
|
|
33
|
+
exports.isQuestionMultiQ = isQuestionMultiQ;
|
|
34
|
+
function isQuestionPrescribe(data) {
|
|
35
|
+
return data.typeId === EQuestionType.PRESCRIPTION_ANSWER;
|
|
36
|
+
}
|
|
37
|
+
exports.isQuestionPrescribe = isQuestionPrescribe;
|
package/package.json
CHANGED
package/utils/commonFunctions.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.correctMark = void 0;
|
|
4
4
|
const models_1 = require("../models");
|
|
5
|
+
const floatRegex = /([0-9]*[.])?[0-9]+/gm;
|
|
5
6
|
function formatPrescribeAnswer(obj) {
|
|
6
7
|
obj.drug = obj.drug.toLowerCase().replace(/\s/g, '');
|
|
7
8
|
obj.route = obj.route.toLowerCase().replace(/\s/g, '');
|
|
@@ -23,6 +24,9 @@ function formatPrescribeAnswer(obj) {
|
|
|
23
24
|
else if (obj.route.includes('nebuli')) {
|
|
24
25
|
obj.route = 'neb';
|
|
25
26
|
}
|
|
27
|
+
else if (obj.route.includes('topical')) {
|
|
28
|
+
obj.route = 'top';
|
|
29
|
+
}
|
|
26
30
|
obj.units = obj.units.toLowerCase().replace(/\s/g, '');
|
|
27
31
|
if (obj.units === 'milligram' || obj.units === 'milligrams') {
|
|
28
32
|
obj.units = 'mg';
|
|
@@ -37,11 +41,10 @@ function formatPrescribeAnswer(obj) {
|
|
|
37
41
|
obj.units = 'units';
|
|
38
42
|
}
|
|
39
43
|
let m;
|
|
40
|
-
const regex = /\d/gm;
|
|
41
44
|
const durationMatches = [];
|
|
42
|
-
while ((m =
|
|
43
|
-
if (m.index ===
|
|
44
|
-
|
|
45
|
+
while ((m = floatRegex.exec(obj.duration)) !== null) {
|
|
46
|
+
if (m.index === floatRegex.lastIndex) {
|
|
47
|
+
floatRegex.lastIndex++;
|
|
45
48
|
}
|
|
46
49
|
m.forEach((match) => durationMatches.push(match));
|
|
47
50
|
}
|
|
@@ -51,7 +54,10 @@ function formatPrescribeAnswer(obj) {
|
|
|
51
54
|
obj.frequency = 'stat';
|
|
52
55
|
}
|
|
53
56
|
else if (obj.frequency.includes('once')) {
|
|
54
|
-
obj.frequency = '
|
|
57
|
+
obj.frequency = 'od';
|
|
58
|
+
}
|
|
59
|
+
else if (obj.frequency.includes('nightly')) {
|
|
60
|
+
obj.frequency = 'od';
|
|
55
61
|
}
|
|
56
62
|
else if (obj.frequency.includes('twice')) {
|
|
57
63
|
obj.frequency = 'bd';
|
|
@@ -87,7 +93,7 @@ function correctMark(mark) {
|
|
|
87
93
|
}
|
|
88
94
|
}
|
|
89
95
|
else if (models_1.EQuestionType.QUESTION_ANSWER === mark.question.typeId) {
|
|
90
|
-
const answer = flatAnswer.toLowerCase().replace(/\s/g, '');
|
|
96
|
+
const answer = flatAnswer.dose.toLowerCase().replace(/\s/g, '');
|
|
91
97
|
const attempt = flatAttempt.toLowerCase().replace(/\s/g, '');
|
|
92
98
|
if (answer === attempt) {
|
|
93
99
|
data.correct = true;
|