@quesmed/types 1.3.2 → 1.3.6

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.
@@ -68,4 +68,5 @@ export interface IDashboardOsce {
68
68
  export interface IOsceTypeDashboard extends IOsceType {
69
69
  completed: number;
70
70
  total: number;
71
+ avgScore: number;
71
72
  }
@@ -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.2",
3
+ "version": "1.3.6",
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: parseFloat(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
  }
@@ -1,6 +1,7 @@
1
- import { IOsceMarksheet } from '../models';
1
+ import { IOsceMarksheet, IOsceStation } from '../models';
2
2
  export interface ILightGalleryCache {
3
3
  CacheManager: any;
4
4
  Platform: any;
5
5
  }
6
- export declare const lightgalleryOsceResolve: (osceMarksheet: IOsceMarksheet, cache: ILightGalleryCache) => Promise<IOsceMarksheet>;
6
+ export declare function lightgalleryOsceResolve(data: IOsceStation, cache?: ILightGalleryCache): Promise<IOsceStation>;
7
+ export declare function lightgalleryOsceResolve(data: IOsceMarksheet, cache?: ILightGalleryCache): Promise<IOsceMarksheet>;
@@ -11,25 +11,47 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.lightgalleryOsceResolve = void 0;
13
13
  const lightgalleryRegex = /\[lightgallery\]/;
14
- const lightgalleryOsceResolve = (osceMarksheet, cache) => __awaiter(void 0, void 0, void 0, function* () {
15
- if (!osceMarksheet.osceStation) {
16
- throw new Error('OsceStation not found on OsceMarksheet');
17
- }
18
- const station = osceMarksheet.osceStation;
19
- if (station.candidatePictures && station.candidatePictures.length > 0) {
20
- osceMarksheet.osceStation.candidateBrief = yield lightgalleryMutation(osceMarksheet.osceStation.candidateBrief, station.candidatePictures, cache);
21
- }
22
- if (station.actorPictures && station.actorPictures.length > 0) {
23
- osceMarksheet.osceStation.actorBrief = yield lightgalleryMutation(osceMarksheet.osceStation.actorBrief, station.actorPictures, cache);
24
- }
25
- if (station.examinerPictures && station.examinerPictures.length > 0) {
26
- osceMarksheet.osceStation.examinerBrief = yield lightgalleryMutation(osceMarksheet.osceStation.examinerBrief, station.examinerPictures, cache);
27
- }
28
- if (station.walkthroughPictures && station.walkthroughPictures.length > 0) {
29
- osceMarksheet.osceStation.explanation = yield lightgalleryMutation(osceMarksheet.osceStation.explanation, station.walkthroughPictures, cache);
30
- }
31
- return osceMarksheet;
32
- });
14
+ function isOsceMarksheet(data) {
15
+ return 'osceStationId' in data;
16
+ }
17
+ function lightgalleryOsceResolve(data, cache) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ let station;
20
+ if (isOsceMarksheet(data)) {
21
+ if (!data.osceStation) {
22
+ throw new Error('OsceStation not found on OsceMarksheet');
23
+ }
24
+ station = data.osceStation;
25
+ }
26
+ else {
27
+ station = data;
28
+ }
29
+ const upOsceStation = {
30
+ candidateBrief: station.candidateBrief,
31
+ actorBrief: station.actorBrief,
32
+ examinerBrief: station.examinerBrief,
33
+ explanation: station.explanation,
34
+ };
35
+ if (station.candidatePictures && station.candidatePictures.length > 0) {
36
+ upOsceStation.candidateBrief = yield lightgalleryMutation(upOsceStation.candidateBrief, station.candidatePictures, cache);
37
+ }
38
+ if (station.actorPictures && station.actorPictures.length > 0) {
39
+ upOsceStation.actorBrief = yield lightgalleryMutation(upOsceStation.actorBrief, station.actorPictures, cache);
40
+ }
41
+ if (station.examinerPictures && station.examinerPictures.length > 0) {
42
+ upOsceStation.examinerBrief = yield lightgalleryMutation(upOsceStation.examinerBrief, station.examinerPictures, cache);
43
+ }
44
+ if (station.walkthroughPictures && station.walkthroughPictures.length > 0) {
45
+ upOsceStation.explanation = yield lightgalleryMutation(upOsceStation.explanation, station.walkthroughPictures, cache);
46
+ }
47
+ if (isOsceMarksheet(data)) {
48
+ return Object.assign(Object.assign({}, data), { osceStation: Object.assign(Object.assign({}, data.osceStation), upOsceStation) });
49
+ }
50
+ else {
51
+ return Object.assign(Object.assign({}, data), upOsceStation);
52
+ }
53
+ });
54
+ }
33
55
  exports.lightgalleryOsceResolve = lightgalleryOsceResolve;
34
56
  const lightgalleryMutation = (text, pictures, cache) => __awaiter(void 0, void 0, void 0, function* () {
35
57
  var _a;