@quesmed/types 1.0.24 → 1.0.25
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/Question.d.ts +4 -4
- package/package.json +1 -1
- package/utils/commonFunctions.js +11 -5
package/models/Question.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare enum EQuestionType {
|
|
|
20
20
|
export declare type IQuestionAnswer = string | [string] | [string[], string[]] | IPrescribeAnswer[];
|
|
21
21
|
export interface IQuestion {
|
|
22
22
|
id: Id;
|
|
23
|
-
typeId:
|
|
23
|
+
typeId: Id;
|
|
24
24
|
conceptId: Id;
|
|
25
25
|
public: boolean;
|
|
26
26
|
concept?: IConcept;
|
|
@@ -59,10 +59,10 @@ export interface IQuestionPrescribe extends IQuestion {
|
|
|
59
59
|
prescribeAnswer: IPrescribeAnswer[];
|
|
60
60
|
}
|
|
61
61
|
export interface IPrescribeAnswer {
|
|
62
|
-
dose: number;
|
|
63
62
|
drug: string;
|
|
64
|
-
|
|
63
|
+
dose: number;
|
|
65
64
|
units: string;
|
|
66
|
-
|
|
65
|
+
route: string;
|
|
67
66
|
frequency: string;
|
|
67
|
+
duration: string;
|
|
68
68
|
}
|
package/package.json
CHANGED
package/utils/commonFunctions.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
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;
|
|
5
6
|
function formatPrescribeAnswer(obj) {
|
|
6
7
|
obj.drug = obj.drug.toLowerCase().replace(/\s/g, '');
|
|
7
8
|
obj.route = obj.route.toLowerCase().replace(/\s/g, '');
|
|
@@ -23,6 +24,9 @@ function formatPrescribeAnswer(obj) {
|
|
|
23
24
|
else if (obj.route.includes('nebuli')) {
|
|
24
25
|
obj.route = 'neb';
|
|
25
26
|
}
|
|
27
|
+
else if (obj.route.includes('topical')) {
|
|
28
|
+
obj.route = 'top';
|
|
29
|
+
}
|
|
26
30
|
obj.units = obj.units.toLowerCase().replace(/\s/g, '');
|
|
27
31
|
if (obj.units === 'milligram' || obj.units === 'milligrams') {
|
|
28
32
|
obj.units = 'mg';
|
|
@@ -37,11 +41,10 @@ function formatPrescribeAnswer(obj) {
|
|
|
37
41
|
obj.units = 'units';
|
|
38
42
|
}
|
|
39
43
|
let m;
|
|
40
|
-
const regex = /\d/gm;
|
|
41
44
|
const durationMatches = [];
|
|
42
|
-
while ((m =
|
|
43
|
-
if (m.index ===
|
|
44
|
-
|
|
45
|
+
while ((m = floatRegex.exec(obj.duration)) !== null) {
|
|
46
|
+
if (m.index === floatRegex.lastIndex) {
|
|
47
|
+
floatRegex.lastIndex++;
|
|
45
48
|
}
|
|
46
49
|
m.forEach((match) => durationMatches.push(match));
|
|
47
50
|
}
|
|
@@ -51,7 +54,10 @@ function formatPrescribeAnswer(obj) {
|
|
|
51
54
|
obj.frequency = 'stat';
|
|
52
55
|
}
|
|
53
56
|
else if (obj.frequency.includes('once')) {
|
|
54
|
-
obj.frequency = '
|
|
57
|
+
obj.frequency = 'od';
|
|
58
|
+
}
|
|
59
|
+
else if (obj.frequency.includes('nightly')) {
|
|
60
|
+
obj.frequency = 'od';
|
|
55
61
|
}
|
|
56
62
|
else if (obj.frequency.includes('twice')) {
|
|
57
63
|
obj.frequency = 'bd';
|