@quesmed/types 1.3.4 → 1.3.5

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.
@@ -82,7 +82,7 @@ export interface IPrescribeAnswer {
82
82
  }
83
83
  export interface IPrescribeMark {
84
84
  drug: string;
85
- dose: number;
85
+ dose: number | string;
86
86
  units: string;
87
87
  route: string;
88
88
  frequency: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "main": "index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,4 +1,6 @@
1
- import { IMarksheetMark } from '../models';
1
+ import { IMarksheetMark, IPrescribeAnswer, IPrescribeMark } from '../models';
2
+ export declare function mapPrescribeMarkToAnswer(obj: IPrescribeMark): IPrescribeAnswer;
3
+ export declare function formatPrescribeAnswer(obj: IPrescribeAnswer): IPrescribeAnswer;
2
4
  export interface ICorrectMarkData {
3
5
  correct: boolean;
4
6
  incorrect: boolean;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.correctMark = void 0;
3
+ exports.correctMark = exports.formatPrescribeAnswer = exports.mapPrescribeMarkToAnswer = void 0;
4
4
  const models_1 = require("../models");
5
5
  const floatRegex = /([0-9]*[.])?[0-9]+/gm;
6
6
  function mapPrescribeMarkToAnswer(obj) {
@@ -10,7 +10,7 @@ function mapPrescribeMarkToAnswer(obj) {
10
10
  display: false,
11
11
  },
12
12
  dose: {
13
- value: obj.dose,
13
+ value: parseInt(obj.dose),
14
14
  display: false,
15
15
  },
16
16
  units: {
@@ -31,6 +31,7 @@ function mapPrescribeMarkToAnswer(obj) {
31
31
  },
32
32
  };
33
33
  }
34
+ exports.mapPrescribeMarkToAnswer = mapPrescribeMarkToAnswer;
34
35
  function formatPrescribeAnswer(obj) {
35
36
  obj.drug.value = obj.drug.value.toLowerCase().replace(/\s/g, '');
36
37
  obj.route.value = obj.route.value.toLowerCase().replace(/\s/g, '');
@@ -76,25 +77,32 @@ function formatPrescribeAnswer(obj) {
76
77
  }
77
78
  m.forEach((match) => durationMatches.push(match));
78
79
  }
79
- obj.duration.value = durationMatches.join(',');
80
+ obj.duration.value = durationMatches.filter((x) => !!x).join(',');
80
81
  obj.frequency.value = obj.frequency.value.toLowerCase().replace(/\s/g, '');
82
+ const frequencyIncHourly = obj.frequency.value.includes('hour');
83
+ const hourlyFreqInt = parseInt(obj.frequency.value);
81
84
  if (obj.frequency.value === 'once-off') {
82
85
  obj.frequency.value = 'stat';
83
86
  }
84
- else if (obj.frequency.value.includes('once')) {
87
+ else if (obj.frequency.value.includes('once') || (frequencyIncHourly && hourlyFreqInt === 24)) {
85
88
  obj.frequency.value = 'od';
86
89
  }
87
90
  else if (obj.frequency.value.includes('nightly')) {
88
91
  obj.frequency.value = 'od';
89
92
  }
90
- else if (obj.frequency.value.includes('twice')) {
93
+ else if (obj.frequency.value.includes('twice') ||
94
+ (frequencyIncHourly && hourlyFreqInt === 12)) {
91
95
  obj.frequency.value = 'bd';
92
96
  }
93
- else if (obj.frequency.value.includes('trice')) {
97
+ else if (obj.frequency.value.includes('trice') || (frequencyIncHourly && hourlyFreqInt === 8)) {
94
98
  obj.frequency.value = 'tds';
95
99
  }
100
+ else if (frequencyIncHourly && hourlyFreqInt === 6) {
101
+ obj.frequency.value = 'qds';
102
+ }
96
103
  return obj;
97
104
  }
105
+ exports.formatPrescribeAnswer = formatPrescribeAnswer;
98
106
  const answerRegex = /answer/gi;
99
107
  function correctMark(mark) {
100
108
  const data = {
@@ -170,12 +178,19 @@ function correctMark(mark) {
170
178
  let foundCorrect = false;
171
179
  let index = 0;
172
180
  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) {
181
+ const doseCorrect = answer.dose.display || answer.dose.value === attempt.dose.value;
182
+ const drugCorrect = answer.drug.display || answer.drug.value === attempt.drug.value;
183
+ const durationCorrect = answer.duration.display ||
184
+ answer.duration.value.split(',').includes(attempt.duration.value);
185
+ const frequencyCorrect = answer.frequency.display || answer.frequency.value === attempt.frequency.value;
186
+ const routeCorrect = answer.route.display || answer.route.value === attempt.route.value;
187
+ const unitsCorrect = answer.units.display || answer.units.value === attempt.units.value;
188
+ if (doseCorrect &&
189
+ drugCorrect &&
190
+ durationCorrect &&
191
+ frequencyCorrect &&
192
+ routeCorrect &&
193
+ unitsCorrect) {
179
194
  foundCorrect = true;
180
195
  break;
181
196
  }