@quesmed/types 1.0.23 → 1.0.27

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.
@@ -1,4 +1,4 @@
1
- import { IPrescribeAnswer, IQuestion } from './Question';
1
+ import { IPrescribeMark, 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[]] | [IPrescribeMark] | null;
17
17
  export interface IMarksheetMark {
18
18
  id: Id;
19
19
  index: number;
@@ -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,47 @@ 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: [string];
38
- qaAnswer: [string];
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
  }
70
+ export declare type IPrescribeAnswerData<T> = {
71
+ value: T;
72
+ display: boolean;
73
+ };
48
74
  export interface IPrescribeAnswer {
49
- dose: number;
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 {
50
83
  drug: string;
51
- route: string;
84
+ dose: number;
52
85
  units: string;
53
- duration: string;
86
+ route: string;
54
87
  frequency: string;
88
+ duration: string;
55
89
  }
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types",
3
- "version": "1.0.23",
3
+ "version": "1.0.27",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "main": "index.js",
6
6
  "types": "dist/index.d.ts",
@@ -2,62 +2,96 @@
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;
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
+ }
5
34
  function formatPrescribeAnswer(obj) {
6
- obj.drug = obj.drug.toLowerCase().replace(/\s/g, '');
7
- obj.route = obj.route.toLowerCase().replace(/\s/g, '');
8
- if (obj.route === 'oral') {
9
- 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';
10
39
  }
11
- else if (obj.route.includes('intravenous')) {
12
- obj.route = 'iv';
40
+ else if (obj.route.value.includes('intravenous')) {
41
+ obj.route.value = 'iv';
13
42
  }
14
- else if (obj.route.includes('intramuscular')) {
15
- obj.route = 'im';
43
+ else if (obj.route.value.includes('intramuscular')) {
44
+ obj.route.value = 'im';
16
45
  }
17
- else if (obj.route.includes('subcutaneous')) {
18
- obj.route = 'sc';
46
+ else if (obj.route.value.includes('subcutaneous')) {
47
+ obj.route.value = 'sc';
19
48
  }
20
- else if (obj.route.includes('inhale')) {
21
- obj.route = 'inh';
49
+ else if (obj.route.value.includes('inhale')) {
50
+ obj.route.value = 'inh';
22
51
  }
23
- else if (obj.route.includes('nebuli')) {
24
- obj.route = 'neb';
52
+ else if (obj.route.value.includes('nebuli')) {
53
+ obj.route.value = 'neb';
25
54
  }
26
- obj.units = obj.units.toLowerCase().replace(/\s/g, '');
27
- if (obj.units === 'milligram' || obj.units === 'milligrams') {
28
- obj.units = 'mg';
55
+ else if (obj.route.value.includes('topical')) {
56
+ obj.route.value = 'top';
29
57
  }
30
- else if (obj.units === 'microgram' || obj.units === 'micrograms') {
31
- obj.units = 'mcg';
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';
32
61
  }
33
- else if (obj.units === 'gram' || obj.units === 'grams') {
34
- obj.units = 'g';
62
+ else if (obj.units.value === 'microgram' || obj.units.value === 'micrograms') {
63
+ obj.units.value = 'mcg';
35
64
  }
36
- else if (obj.units === 'unit') {
37
- obj.units = 'units';
65
+ else if (obj.units.value === 'gram' || obj.units.value === 'grams') {
66
+ obj.units.value = 'g';
67
+ }
68
+ else if (obj.units.value === 'unit') {
69
+ obj.units.value = 'units';
38
70
  }
39
71
  let m;
40
- const regex = /\d/gm;
41
72
  const durationMatches = [];
42
- while ((m = regex.exec(obj.duration)) !== null) {
43
- if (m.index === regex.lastIndex) {
44
- regex.lastIndex++;
73
+ while ((m = floatRegex.exec(obj.duration.value)) !== null) {
74
+ if (m.index === floatRegex.lastIndex) {
75
+ floatRegex.lastIndex++;
45
76
  }
46
77
  m.forEach((match) => durationMatches.push(match));
47
78
  }
48
- obj.duration = durationMatches.join(',');
49
- obj.frequency = obj.frequency.toLowerCase().replace(/\s/g, '');
50
- if (obj.frequency === 'once-off') {
51
- 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';
83
+ }
84
+ else if (obj.frequency.value.includes('once')) {
85
+ obj.frequency.value = 'od';
52
86
  }
53
- else if (obj.frequency.includes('once')) {
54
- obj.frequency = 'po';
87
+ else if (obj.frequency.value.includes('nightly')) {
88
+ obj.frequency.value = 'od';
55
89
  }
56
- else if (obj.frequency.includes('twice')) {
57
- obj.frequency = 'bd';
90
+ else if (obj.frequency.value.includes('twice')) {
91
+ obj.frequency.value = 'bd';
58
92
  }
59
- else if (obj.frequency.includes('trice')) {
60
- obj.frequency = 'tds';
93
+ else if (obj.frequency.value.includes('trice')) {
94
+ obj.frequency.value = 'tds';
61
95
  }
62
96
  return obj;
63
97
  }
@@ -87,7 +121,7 @@ function correctMark(mark) {
87
121
  }
88
122
  }
89
123
  else if (models_1.EQuestionType.QUESTION_ANSWER === mark.question.typeId) {
90
- const answer = flatAnswer.toLowerCase().replace(/\s/g, '');
124
+ const answer = flatAnswer.dose.toLowerCase().replace(/\s/g, '');
91
125
  const attempt = flatAttempt.toLowerCase().replace(/\s/g, '');
92
126
  if (answer === attempt) {
93
127
  data.correct = true;
@@ -111,16 +145,16 @@ function correctMark(mark) {
111
145
  }
112
146
  else if (models_1.EQuestionType.PRESCRIPTION_ANSWER === mark.question.typeId) {
113
147
  const answers = answer.map(formatPrescribeAnswer);
114
- const attempt = formatPrescribeAnswer(flatAttempt);
148
+ const attempt = formatPrescribeAnswer(mapPrescribeMarkToAnswer(flatAttempt));
115
149
  let foundCorrect = false;
116
150
  let index = 0;
117
151
  for (const answer of answers) {
118
- if (answer.dose === attempt.dose &&
119
- answer.drug === attempt.drug &&
120
- answer.duration.split(',').includes(attempt.duration) &&
121
- answer.frequency === attempt.frequency &&
122
- answer.route === attempt.route &&
123
- answer.units === attempt.units) {
152
+ if (answer.dose.value === attempt.dose.value &&
153
+ answer.drug.value === attempt.drug.value &&
154
+ answer.duration.value.split(',').includes(attempt.duration.value) &&
155
+ answer.frequency.value === attempt.frequency.value &&
156
+ answer.route.value === attempt.route.value &&
157
+ answer.units.value === attempt.units.value) {
124
158
  foundCorrect = true;
125
159
  break;
126
160
  }