@quesmed/types 1.0.26 → 1.1.1

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.
@@ -0,0 +1,14 @@
1
+ import { Id } from './Type';
2
+ export interface IAuthor {
3
+ id: Id;
4
+ createdAt: string | Date;
5
+ updatedAt: string | Date;
6
+ name: string;
7
+ qualifications: string | null;
8
+ title: string;
9
+ description: string;
10
+ avatar: string;
11
+ linkedIn: string;
12
+ twitter: string;
13
+ facebook: string;
14
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,22 @@
1
+ import { IAuthor } from './Author';
2
+ import { Id } from './Type';
3
+ export interface IBook {
4
+ id: Id;
5
+ createdAt: string | Date;
6
+ updatedAt: string | Date;
7
+ name: string;
8
+ publisher: string;
9
+ publishDate: string | Date;
10
+ pages: number;
11
+ format: string;
12
+ language: string;
13
+ type: string;
14
+ ISBN: number;
15
+ price: number;
16
+ avatar: string;
17
+ heroImg: string;
18
+ description: string;
19
+ chapters: string | string[];
20
+ stripePriceId: string;
21
+ authors: IAuthor[];
22
+ }
package/models/Book.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -5,7 +5,7 @@ export interface IChapter {
5
5
  id: Id;
6
6
  createdAt: string | Date;
7
7
  updatedAt: string | Date;
8
- explanation: string;
8
+ explanation: string | null;
9
9
  clinical: boolean;
10
10
  pictures: IChapterPicture[];
11
11
  files: IFile[];
@@ -1,4 +1,4 @@
1
- import { IPrescribeAnswer, IQuestion, IQuestionQAAnswer } from './Question';
1
+ import { IPrescribeMark, IQuestion, IQuestionQAAnswer } from './Question';
2
2
  import { Id } from './Type';
3
3
  export interface IMarksheet {
4
4
  id: Id;
@@ -9,11 +9,11 @@ export interface IMarksheet {
9
9
  mockTestId: number | null;
10
10
  }
11
11
  export declare enum EQuestionLike {
12
- LIKE = 0,
13
- DISLIKE = 1,
14
- REMOVE = 2
12
+ NONE = 0,
13
+ LIKE = 1,
14
+ DISLIKE = 2
15
15
  }
16
- export declare type IMarksheetMarkJSONB = string | [string] | [IQuestionQAAnswer] | [string[], string[]] | [IPrescribeAnswer] | null;
16
+ export declare type IMarksheetMarkJSONB = string | [string] | [IQuestionQAAnswer] | [string[], string[]] | [IPrescribeMark] | null;
17
17
  export interface IMarksheetMark {
18
18
  id: Id;
19
19
  index: number;
@@ -26,7 +26,7 @@ export interface IMarksheetMark {
26
26
  mark: IMarksheetMarkJSONB;
27
27
  like: number;
28
28
  dislike: number;
29
- isLikeByMe: string;
29
+ isLikeByMe: EQuestionLike;
30
30
  discussion: IDiscussion[];
31
31
  }
32
32
  export interface IDiscussion {
@@ -36,7 +36,7 @@ export interface IDiscussion {
36
36
  comment: string;
37
37
  like: number;
38
38
  dislike: number;
39
- isLikeByMe: string;
39
+ isLikeByMe: EQuestionLike;
40
40
  commentId: number;
41
41
  questionId: number;
42
42
  reply: IDiscussion[];
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EQuestionLike = void 0;
4
4
  var EQuestionLike;
5
5
  (function (EQuestionLike) {
6
- EQuestionLike[EQuestionLike["LIKE"] = 0] = "LIKE";
7
- EQuestionLike[EQuestionLike["DISLIKE"] = 1] = "DISLIKE";
8
- EQuestionLike[EQuestionLike["REMOVE"] = 2] = "REMOVE";
6
+ EQuestionLike[EQuestionLike["NONE"] = 0] = "NONE";
7
+ EQuestionLike[EQuestionLike["LIKE"] = 1] = "LIKE";
8
+ EQuestionLike[EQuestionLike["DISLIKE"] = 2] = "DISLIKE";
9
9
  })(EQuestionLike = exports.EQuestionLike || (exports.EQuestionLike = {}));
@@ -38,7 +38,7 @@ export interface IQuestion {
38
38
  export interface IQuestionChoice {
39
39
  id: Id;
40
40
  name: string;
41
- explanation: string;
41
+ explanation: string | null;
42
42
  label: string;
43
43
  answer: boolean;
44
44
  votes: number;
@@ -67,7 +67,19 @@ export interface IQuestionPrescribe extends IQuestion {
67
67
  answer: IPrescribeAnswer[];
68
68
  prescribeAnswer: IPrescribeAnswer[];
69
69
  }
70
+ export declare type IPrescribeAnswerData<T> = {
71
+ value: T;
72
+ display: boolean;
73
+ };
70
74
  export interface IPrescribeAnswer {
75
+ drug: IPrescribeAnswerData<string>;
76
+ dose: IPrescribeAnswerData<number>;
77
+ units: IPrescribeAnswerData<string>;
78
+ route: IPrescribeAnswerData<string>;
79
+ frequency: IPrescribeAnswerData<string>;
80
+ duration: IPrescribeAnswerData<string>;
81
+ }
82
+ export interface IPrescribeMark {
71
83
  drug: string;
72
84
  dose: number;
73
85
  units: string;
package/models/Topic.d.ts CHANGED
@@ -1,8 +1,17 @@
1
1
  import { IConcept } from './Concept';
2
2
  import { Id } from './Type';
3
+ export declare enum ETopicType {
4
+ ALL = 0,
5
+ BASIC_SCIENCE = 1,
6
+ CLINICAL = 2,
7
+ ANATOMY = 3,
8
+ DATA_INTERPRETATION = 4,
9
+ PSA = 5
10
+ }
3
11
  export interface ITopic {
4
12
  id: Id;
5
13
  name: string;
6
14
  clinical: boolean;
7
15
  concepts?: IConcept[];
16
+ typeId: ETopicType | null;
8
17
  }
package/models/Topic.js CHANGED
@@ -1,2 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ETopicType = void 0;
4
+ var ETopicType;
5
+ (function (ETopicType) {
6
+ ETopicType[ETopicType["ALL"] = 0] = "ALL";
7
+ ETopicType[ETopicType["BASIC_SCIENCE"] = 1] = "BASIC_SCIENCE";
8
+ ETopicType[ETopicType["CLINICAL"] = 2] = "CLINICAL";
9
+ ETopicType[ETopicType["ANATOMY"] = 3] = "ANATOMY";
10
+ ETopicType[ETopicType["DATA_INTERPRETATION"] = 4] = "DATA_INTERPRETATION";
11
+ ETopicType[ETopicType["PSA"] = 5] = "PSA";
12
+ })(ETopicType = exports.ETopicType || (exports.ETopicType = {}));
package/models/Type.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export declare type Id = number;
2
2
  export declare type Count = {
3
- count: number;
4
- }[];
3
+ count: string;
4
+ };
5
5
  export declare type Sum = {
6
- sum: number;
7
- }[];
6
+ sum: string;
7
+ };
package/models/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export * from './Author';
2
+ export * from './Book';
1
3
  export * from './Card';
2
4
  export * from './Chapter';
3
5
  export * from './Concept';
package/models/index.js CHANGED
@@ -10,6 +10,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./Author"), exports);
14
+ __exportStar(require("./Book"), exports);
13
15
  __exportStar(require("./Card"), exports);
14
16
  __exportStar(require("./Chapter"), exports);
15
17
  __exportStar(require("./Concept"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types",
3
- "version": "1.0.26",
3
+ "version": "1.1.1",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "main": "index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,3 @@
1
+ import { IAuthor } from '../../models';
2
+ export interface IAuthorData extends IAuthor {
3
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ import { IBook } from '../../models';
2
+ export interface IBookData extends IBook {
3
+ }
4
+ export interface IBookVar {
5
+ id: number;
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,5 @@
1
+ export * from './author';
2
+ export * from './book';
1
3
  export * from './feedback';
2
4
  export * from './sampleCards';
3
5
  export * from './sampleQuestions';
@@ -10,6 +10,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./author"), exports);
14
+ __exportStar(require("./book"), exports);
13
15
  __exportStar(require("./feedback"), exports);
14
16
  __exportStar(require("./sampleCards"), exports);
15
17
  __exportStar(require("./sampleQuestions"), exports);
@@ -1,10 +1,10 @@
1
- import { Id, ITopic } from '../../../models';
1
+ import { ETopicType, Id, ITopic } from '../../../models';
2
2
  export interface ITopicVar {
3
3
  id: Id;
4
4
  }
5
5
  export declare type ITopicData = ITopic;
6
6
  export interface ITopicsVar {
7
- filter: 'clinical' | 'pre-clinical' | 'interpretation';
7
+ filter: ETopicType;
8
8
  }
9
9
  export interface ITopicInfo {
10
10
  id: number;
@@ -3,67 +3,95 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.correctMark = void 0;
4
4
  const models_1 = require("../models");
5
5
  const floatRegex = /([0-9]*[.])?[0-9]+/gm;
6
+ function mapPrescribeMarkToAnswer(obj) {
7
+ return {
8
+ drug: {
9
+ value: obj.drug,
10
+ display: false,
11
+ },
12
+ dose: {
13
+ value: obj.dose,
14
+ display: false,
15
+ },
16
+ units: {
17
+ value: obj.units,
18
+ display: false,
19
+ },
20
+ route: {
21
+ value: obj.route,
22
+ display: false,
23
+ },
24
+ frequency: {
25
+ value: obj.frequency,
26
+ display: false,
27
+ },
28
+ duration: {
29
+ value: obj.duration,
30
+ display: false,
31
+ },
32
+ };
33
+ }
6
34
  function formatPrescribeAnswer(obj) {
7
- obj.drug = obj.drug.toLowerCase().replace(/\s/g, '');
8
- obj.route = obj.route.toLowerCase().replace(/\s/g, '');
9
- if (obj.route === 'oral') {
10
- obj.route = 'po';
35
+ obj.drug.value = obj.drug.value.toLowerCase().replace(/\s/g, '');
36
+ obj.route.value = obj.route.value.toLowerCase().replace(/\s/g, '');
37
+ if (obj.route.value === 'oral') {
38
+ obj.route.value = 'po';
11
39
  }
12
- else if (obj.route.includes('intravenous')) {
13
- obj.route = 'iv';
40
+ else if (obj.route.value.includes('intravenous')) {
41
+ obj.route.value = 'iv';
14
42
  }
15
- else if (obj.route.includes('intramuscular')) {
16
- obj.route = 'im';
43
+ else if (obj.route.value.includes('intramuscular')) {
44
+ obj.route.value = 'im';
17
45
  }
18
- else if (obj.route.includes('subcutaneous')) {
19
- obj.route = 'sc';
46
+ else if (obj.route.value.includes('subcutaneous')) {
47
+ obj.route.value = 'sc';
20
48
  }
21
- else if (obj.route.includes('inhale')) {
22
- obj.route = 'inh';
49
+ else if (obj.route.value.includes('inhale')) {
50
+ obj.route.value = 'inh';
23
51
  }
24
- else if (obj.route.includes('nebuli')) {
25
- obj.route = 'neb';
52
+ else if (obj.route.value.includes('nebuli')) {
53
+ obj.route.value = 'neb';
26
54
  }
27
- else if (obj.route.includes('topical')) {
28
- obj.route = 'top';
55
+ else if (obj.route.value.includes('topical')) {
56
+ obj.route.value = 'top';
29
57
  }
30
- obj.units = obj.units.toLowerCase().replace(/\s/g, '');
31
- if (obj.units === 'milligram' || obj.units === 'milligrams') {
32
- obj.units = 'mg';
58
+ obj.units.value = obj.units.value.toLowerCase().replace(/\s/g, '');
59
+ if (obj.units.value === 'milligram' || obj.units.value === 'milligrams') {
60
+ obj.units.value = 'mg';
33
61
  }
34
- else if (obj.units === 'microgram' || obj.units === 'micrograms') {
35
- obj.units = 'mcg';
62
+ else if (obj.units.value === 'microgram' || obj.units.value === 'micrograms') {
63
+ obj.units.value = 'mcg';
36
64
  }
37
- else if (obj.units === 'gram' || obj.units === 'grams') {
38
- obj.units = 'g';
65
+ else if (obj.units.value === 'gram' || obj.units.value === 'grams') {
66
+ obj.units.value = 'g';
39
67
  }
40
- else if (obj.units === 'unit') {
41
- obj.units = 'units';
68
+ else if (obj.units.value === 'unit') {
69
+ obj.units.value = 'units';
42
70
  }
43
71
  let m;
44
72
  const durationMatches = [];
45
- while ((m = floatRegex.exec(obj.duration)) !== null) {
73
+ while ((m = floatRegex.exec(obj.duration.value)) !== null) {
46
74
  if (m.index === floatRegex.lastIndex) {
47
75
  floatRegex.lastIndex++;
48
76
  }
49
77
  m.forEach((match) => durationMatches.push(match));
50
78
  }
51
- obj.duration = durationMatches.join(',');
52
- obj.frequency = obj.frequency.toLowerCase().replace(/\s/g, '');
53
- if (obj.frequency === 'once-off') {
54
- obj.frequency = 'stat';
79
+ obj.duration.value = durationMatches.join(',');
80
+ obj.frequency.value = obj.frequency.value.toLowerCase().replace(/\s/g, '');
81
+ if (obj.frequency.value === 'once-off') {
82
+ obj.frequency.value = 'stat';
55
83
  }
56
- else if (obj.frequency.includes('once')) {
57
- obj.frequency = 'od';
84
+ else if (obj.frequency.value.includes('once')) {
85
+ obj.frequency.value = 'od';
58
86
  }
59
- else if (obj.frequency.includes('nightly')) {
60
- obj.frequency = 'od';
87
+ else if (obj.frequency.value.includes('nightly')) {
88
+ obj.frequency.value = 'od';
61
89
  }
62
- else if (obj.frequency.includes('twice')) {
63
- obj.frequency = 'bd';
90
+ else if (obj.frequency.value.includes('twice')) {
91
+ obj.frequency.value = 'bd';
64
92
  }
65
- else if (obj.frequency.includes('trice')) {
66
- obj.frequency = 'tds';
93
+ else if (obj.frequency.value.includes('trice')) {
94
+ obj.frequency.value = 'tds';
67
95
  }
68
96
  return obj;
69
97
  }
@@ -77,69 +105,94 @@ function correctMark(mark) {
77
105
  if (!mark || !mark.mark) {
78
106
  return data;
79
107
  }
80
- const qKeys = Object.keys(mark.question);
81
- const answerKey = qKeys.find((k) => answerRegex.exec(k)) || 'answer';
82
- const answer = mark.question[answerKey];
83
- const flatAnswer = answer[0];
84
- const flatAttempt = mark.mark[0];
85
- if (models_1.EQuestionType.SINGLE_BEST_ANSWER === mark.question.typeId) {
86
- const answer = flatAnswer;
87
- const attempt = flatAttempt;
88
- if (answer === attempt) {
89
- data.correct = true;
90
- }
91
- else {
92
- data.incorrect = true;
93
- }
94
- }
95
- else if (models_1.EQuestionType.QUESTION_ANSWER === mark.question.typeId) {
96
- const answer = flatAnswer.dose.toLowerCase().replace(/\s/g, '');
97
- const attempt = flatAttempt.toLowerCase().replace(/\s/g, '');
98
- if (answer === attempt) {
99
- data.correct = true;
100
- }
101
- else {
102
- data.incorrect = true;
103
- }
104
- }
105
- else if (models_1.EQuestionType.MULTIPLE_ANSWERS === mark.question.typeId) {
106
- const [answerA, answerB] = answer.map((x) => x.sort());
107
- const [attemptA, attemptB] = mark.mark.map((x) => x.sort());
108
- if (answerA.length !== attemptA.length || answerB.length !== attemptB.length) {
109
- data.incorrect = true;
110
- }
111
- else if (attemptA.every((x, i) => x === answerA[i]) && attemptB.every((x, i) => answerB[i])) {
112
- data.correct = true;
113
- }
114
- else {
115
- data.incorrect = true;
108
+ try {
109
+ const qKeys = Object.keys(mark.question);
110
+ const answerKey = qKeys.find((k) => answerRegex.exec(k)) || 'answer';
111
+ const answer = mark.question[answerKey];
112
+ const flatAnswer = answer[0];
113
+ const flatAttempt = mark.mark[0];
114
+ if (models_1.EQuestionType.SINGLE_BEST_ANSWER === mark.question.typeId) {
115
+ const answer = flatAnswer;
116
+ const attempt = flatAttempt;
117
+ if (answer === attempt) {
118
+ data.correct = true;
119
+ }
120
+ else {
121
+ data.incorrect = true;
122
+ }
116
123
  }
117
- }
118
- else if (models_1.EQuestionType.PRESCRIPTION_ANSWER === mark.question.typeId) {
119
- const answers = answer.map(formatPrescribeAnswer);
120
- const attempt = formatPrescribeAnswer(flatAttempt);
121
- let foundCorrect = false;
122
- let index = 0;
123
- for (const answer of answers) {
124
- if (answer.dose === attempt.dose &&
125
- answer.drug === attempt.drug &&
126
- answer.duration.split(',').includes(attempt.duration) &&
127
- answer.frequency === attempt.frequency &&
128
- answer.route === attempt.route &&
129
- answer.units === attempt.units) {
130
- foundCorrect = true;
131
- break;
124
+ else if (models_1.EQuestionType.QUESTION_ANSWER === mark.question.typeId) {
125
+ const answer = flatAnswer.dose.toLowerCase().replace(/\s/g, '');
126
+ let attempt = '';
127
+ if (flatAttempt) {
128
+ attempt = flatAttempt.toLowerCase().replace(/\s/g, '');
129
+ }
130
+ if (answer === attempt) {
131
+ data.correct = true;
132
+ }
133
+ else {
134
+ data.incorrect = true;
132
135
  }
133
- index++;
134
136
  }
135
- if (foundCorrect) {
136
- data.correct = true;
137
- data.correctIndex = index;
137
+ else if (models_1.EQuestionType.MULTIPLE_ANSWERS === mark.question.typeId) {
138
+ const [answerA, answerB] = answer.map((x) => x.sort());
139
+ let [attemptA, attemptB] = [[], []];
140
+ if (Array.isArray(mark.mark) &&
141
+ mark.mark.length === 2 &&
142
+ Array.isArray(mark.mark[0]) &&
143
+ Array.isArray(mark.mark[1])) {
144
+ [attemptA, attemptB] = mark.mark.map((x) => x.sort());
145
+ }
146
+ if (answerA.length !== attemptA.length || answerB.length !== attemptB.length) {
147
+ data.incorrect = true;
148
+ }
149
+ else if (attemptA.every((x, i) => x === answerA[i]) &&
150
+ attemptB.every((_, i) => answerB[i])) {
151
+ data.correct = true;
152
+ }
153
+ else {
154
+ data.incorrect = true;
155
+ }
138
156
  }
139
- else {
140
- data.incorrect = true;
157
+ else if (models_1.EQuestionType.PRESCRIPTION_ANSWER === mark.question.typeId) {
158
+ const answers = answer.map(formatPrescribeAnswer);
159
+ let attempt = formatPrescribeAnswer(mapPrescribeMarkToAnswer({
160
+ drug: '',
161
+ dose: -1,
162
+ units: '',
163
+ route: '',
164
+ frequency: '',
165
+ duration: '',
166
+ }));
167
+ if (typeof flatAttempt === 'object' && Object.keys(flatAttempt).length === 6) {
168
+ attempt = formatPrescribeAnswer(mapPrescribeMarkToAnswer(flatAttempt));
169
+ }
170
+ let foundCorrect = false;
171
+ let index = 0;
172
+ for (const answer of answers) {
173
+ if (answer.dose.value === attempt.dose.value &&
174
+ answer.drug.value === attempt.drug.value &&
175
+ answer.duration.value.split(',').includes(attempt.duration.value) &&
176
+ answer.frequency.value === attempt.frequency.value &&
177
+ answer.route.value === attempt.route.value &&
178
+ answer.units.value === attempt.units.value) {
179
+ foundCorrect = true;
180
+ break;
181
+ }
182
+ index++;
183
+ }
184
+ if (foundCorrect) {
185
+ data.correct = true;
186
+ data.correctIndex = index;
187
+ }
188
+ else {
189
+ data.incorrect = true;
190
+ }
141
191
  }
142
192
  }
193
+ catch (e) {
194
+ console.error(e);
195
+ }
143
196
  return data;
144
197
  }
145
198
  exports.correctMark = correctMark;