@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.
- package/models/OsceMarksheet.d.ts +1 -0
- package/models/Question.d.ts +1 -1
- package/package.json +1 -1
- package/utils/commonFunctions.d.ts +3 -1
- package/utils/commonFunctions.js +27 -12
- package/utils/lightgallery.d.ts +3 -2
- package/utils/lightgallery.js +41 -19
package/models/Question.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -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;
|
package/utils/commonFunctions.js
CHANGED
|
@@ -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
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
answer.
|
|
177
|
-
|
|
178
|
-
|
|
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
|
}
|
package/utils/lightgallery.d.ts
CHANGED
|
@@ -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
|
|
6
|
+
export declare function lightgalleryOsceResolve(data: IOsceStation, cache?: ILightGalleryCache): Promise<IOsceStation>;
|
|
7
|
+
export declare function lightgalleryOsceResolve(data: IOsceMarksheet, cache?: ILightGalleryCache): Promise<IOsceMarksheet>;
|
package/utils/lightgallery.js
CHANGED
|
@@ -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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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;
|