@quesmed/types-rn 2.6.20 → 2.6.22
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/Marksheet.d.ts +2 -2
- package/models/Psa.d.ts +0 -6
- package/models/Question.d.ts +10 -12
- package/models/Question.js +0 -2
- package/package.json +1 -1
- package/resolvers/mutation/restricted/marksheet.js +24 -96
- package/resolvers/mutation/restricted/questionDiscussion.js +0 -6
- package/resolvers/query/restricted/marksheet.js +12 -48
- package/resolvers/query/restricted/question.js +6 -24
- package/utils/commonFunctions.d.ts +2 -3
- package/utils/commonFunctions.js +23 -191
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/object.d.ts +1 -0
- package/utils/object.js +20 -0
package/models/Marksheet.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IBuildConfigData, IPreBuildMarksheet } from '../resolvers/mutation/restricted/marksheet';
|
|
2
2
|
import { EProductType } from './Product';
|
|
3
|
-
import {
|
|
3
|
+
import { IPrescribeMark, IQuestion, IQuestionChoice, IQuestionQAAnswer } from './Question';
|
|
4
4
|
import { ETopicType } from './Topic';
|
|
5
5
|
import { Id } from './Type';
|
|
6
6
|
import { IUser } from './User';
|
|
@@ -92,7 +92,7 @@ export interface IMarksheet {
|
|
|
92
92
|
builderConfig?: IBuildConfigData;
|
|
93
93
|
productId: EProductType;
|
|
94
94
|
}
|
|
95
|
-
export type IMarksheetMarkJSONB = string | [string] | [IQuestionQAAnswer] | [string[], string[]] | [IPrescribeMark] |
|
|
95
|
+
export type IMarksheetMarkJSONB = string | [string] | [IQuestionQAAnswer] | [string[], string[]] | [IPrescribeMark] | null;
|
|
96
96
|
export interface IMarksheetMark {
|
|
97
97
|
id: Id;
|
|
98
98
|
createdAt: number | Date;
|
package/models/Psa.d.ts
CHANGED
|
@@ -16,21 +16,15 @@ export interface IQuestionPrescription {
|
|
|
16
16
|
id: Id;
|
|
17
17
|
questionId: Id;
|
|
18
18
|
doseId: Id;
|
|
19
|
-
doseDisplay: string;
|
|
20
19
|
doseVisible: boolean;
|
|
21
20
|
drugId: Id;
|
|
22
|
-
drugDisplay: string;
|
|
23
21
|
drugVisible: boolean;
|
|
24
22
|
routeId: Id;
|
|
25
|
-
routeDisplay: string;
|
|
26
23
|
routeVisible: boolean;
|
|
27
24
|
frequencyId: Id;
|
|
28
|
-
frequencyDisplay: string;
|
|
29
25
|
frequencyVisible: boolean;
|
|
30
26
|
durationId: Id;
|
|
31
|
-
durationDisplay: string;
|
|
32
27
|
durationVisible: boolean;
|
|
33
28
|
unitId: Id;
|
|
34
|
-
unitDisplay: string;
|
|
35
29
|
unitVisible: boolean;
|
|
36
30
|
}
|
package/models/Question.d.ts
CHANGED
|
@@ -25,9 +25,7 @@ export declare enum EQuestionType {
|
|
|
25
25
|
PRESCRIPTION_ANSWER = 4,
|
|
26
26
|
EXTENDED_MATCHING_ANSWER = 5,
|
|
27
27
|
SELECT_THREE_ANSWER = 6,
|
|
28
|
-
RANKING_ANSWER = 7
|
|
29
|
-
MRCP_PART_1 = 8,
|
|
30
|
-
MRCP_PART_2 = 9
|
|
28
|
+
RANKING_ANSWER = 7
|
|
31
29
|
}
|
|
32
30
|
export declare enum EQuestionLike {
|
|
33
31
|
NONE = 0,
|
|
@@ -62,7 +60,7 @@ export interface IQuestionCommentLike {
|
|
|
62
60
|
comment: IQuestionComment;
|
|
63
61
|
likeTrueDislikeFalse: boolean;
|
|
64
62
|
}
|
|
65
|
-
export type IQuestionAnswer = string | [string] | [IQuestionQAAnswer] | [string[], string[]] |
|
|
63
|
+
export type IQuestionAnswer = string | [string] | [IQuestionQAAnswer] | [string[], string[]] | IPrescribeMark[] | [string, string][] | [string, string, string] | string[];
|
|
66
64
|
export type IQuestionAll = IQuestion | IQuestionSBA | IQuestionQA | IQuestionMultiQ | IQuestionPrescribe | IQuestionEMQ | IQuestionSelect3 | IQuestionRanking;
|
|
67
65
|
export interface IQuestion {
|
|
68
66
|
id: Id;
|
|
@@ -197,8 +195,8 @@ export interface IQuestionRanking extends IQuestion {
|
|
|
197
195
|
}
|
|
198
196
|
export declare function isQuestionPrescribe(data: IQuestionAll): data is IQuestionPrescribe;
|
|
199
197
|
export interface IQuestionPrescribe extends IQuestion {
|
|
200
|
-
answer:
|
|
201
|
-
prescribeAnswer:
|
|
198
|
+
answer: IPrescribeMark[];
|
|
199
|
+
prescribeAnswer: IQuestionPrescription[];
|
|
202
200
|
}
|
|
203
201
|
export type IPrescribeAnswerData<T> = {
|
|
204
202
|
value: T;
|
|
@@ -213,10 +211,10 @@ export interface IPrescribeAnswer {
|
|
|
213
211
|
duration: IPrescribeAnswerData<string>;
|
|
214
212
|
}
|
|
215
213
|
export interface IPrescribeMark {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
214
|
+
drugId: number;
|
|
215
|
+
doseId: number;
|
|
216
|
+
unitId: number;
|
|
217
|
+
routeId: number;
|
|
218
|
+
frequencyId: number;
|
|
219
|
+
durationId: number;
|
|
222
220
|
}
|
package/models/Question.js
CHANGED
|
@@ -21,8 +21,6 @@ var EQuestionType;
|
|
|
21
21
|
EQuestionType[EQuestionType["EXTENDED_MATCHING_ANSWER"] = 5] = "EXTENDED_MATCHING_ANSWER";
|
|
22
22
|
EQuestionType[EQuestionType["SELECT_THREE_ANSWER"] = 6] = "SELECT_THREE_ANSWER";
|
|
23
23
|
EQuestionType[EQuestionType["RANKING_ANSWER"] = 7] = "RANKING_ANSWER";
|
|
24
|
-
EQuestionType[EQuestionType["MRCP_PART_1"] = 8] = "MRCP_PART_1";
|
|
25
|
-
EQuestionType[EQuestionType["MRCP_PART_2"] = 9] = "MRCP_PART_2";
|
|
26
24
|
})(EQuestionType = exports.EQuestionType || (exports.EQuestionType = {}));
|
|
27
25
|
var EQuestionLike;
|
|
28
26
|
(function (EQuestionLike) {
|
package/package.json
CHANGED
|
@@ -582,30 +582,12 @@ exports.BUILD_QUESTION_MARKSHEET = (0, client_1.gql) `
|
|
|
582
582
|
dislikes
|
|
583
583
|
isLikedByMe
|
|
584
584
|
prescribeAnswer: answer {
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
display
|
|
592
|
-
}
|
|
593
|
-
route {
|
|
594
|
-
value
|
|
595
|
-
display
|
|
596
|
-
}
|
|
597
|
-
frequency {
|
|
598
|
-
display
|
|
599
|
-
value
|
|
600
|
-
}
|
|
601
|
-
duration {
|
|
602
|
-
display
|
|
603
|
-
value
|
|
604
|
-
}
|
|
605
|
-
units {
|
|
606
|
-
display
|
|
607
|
-
value
|
|
608
|
-
}
|
|
585
|
+
doseId
|
|
586
|
+
durationId
|
|
587
|
+
drugId
|
|
588
|
+
routeId
|
|
589
|
+
unitId
|
|
590
|
+
frequencyId
|
|
609
591
|
}
|
|
610
592
|
}
|
|
611
593
|
... on QuestionEMQ {
|
|
@@ -1600,30 +1582,12 @@ exports.BUILD_MARKSHEET = (0, client_1.gql) `
|
|
|
1600
1582
|
dislikes
|
|
1601
1583
|
isLikedByMe
|
|
1602
1584
|
prescribeAnswer: answer {
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
display
|
|
1610
|
-
}
|
|
1611
|
-
route {
|
|
1612
|
-
value
|
|
1613
|
-
display
|
|
1614
|
-
}
|
|
1615
|
-
frequency {
|
|
1616
|
-
display
|
|
1617
|
-
value
|
|
1618
|
-
}
|
|
1619
|
-
duration {
|
|
1620
|
-
display
|
|
1621
|
-
value
|
|
1622
|
-
}
|
|
1623
|
-
units {
|
|
1624
|
-
display
|
|
1625
|
-
value
|
|
1626
|
-
}
|
|
1585
|
+
doseId
|
|
1586
|
+
durationId
|
|
1587
|
+
drugId
|
|
1588
|
+
routeId
|
|
1589
|
+
unitId
|
|
1590
|
+
frequencyId
|
|
1627
1591
|
}
|
|
1628
1592
|
}
|
|
1629
1593
|
... on QuestionEMQ {
|
|
@@ -2623,30 +2587,12 @@ exports.RE_BUILD_MARKSHEET = (0, client_1.gql) `
|
|
|
2623
2587
|
dislikes
|
|
2624
2588
|
isLikedByMe
|
|
2625
2589
|
prescribeAnswer: answer {
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
display
|
|
2633
|
-
}
|
|
2634
|
-
route {
|
|
2635
|
-
value
|
|
2636
|
-
display
|
|
2637
|
-
}
|
|
2638
|
-
frequency {
|
|
2639
|
-
display
|
|
2640
|
-
value
|
|
2641
|
-
}
|
|
2642
|
-
duration {
|
|
2643
|
-
display
|
|
2644
|
-
value
|
|
2645
|
-
}
|
|
2646
|
-
units {
|
|
2647
|
-
display
|
|
2648
|
-
value
|
|
2649
|
-
}
|
|
2590
|
+
doseId
|
|
2591
|
+
durationId
|
|
2592
|
+
drugId
|
|
2593
|
+
routeId
|
|
2594
|
+
unitId
|
|
2595
|
+
frequencyId
|
|
2650
2596
|
}
|
|
2651
2597
|
}
|
|
2652
2598
|
... on QuestionEMQ {
|
|
@@ -3624,30 +3570,12 @@ exports.QUICK_BUILD_MARKSHEET = (0, client_1.gql) `
|
|
|
3624
3570
|
dislikes
|
|
3625
3571
|
isLikedByMe
|
|
3626
3572
|
prescribeAnswer: answer {
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
display
|
|
3634
|
-
}
|
|
3635
|
-
route {
|
|
3636
|
-
value
|
|
3637
|
-
display
|
|
3638
|
-
}
|
|
3639
|
-
frequency {
|
|
3640
|
-
display
|
|
3641
|
-
value
|
|
3642
|
-
}
|
|
3643
|
-
duration {
|
|
3644
|
-
display
|
|
3645
|
-
value
|
|
3646
|
-
}
|
|
3647
|
-
units {
|
|
3648
|
-
display
|
|
3649
|
-
value
|
|
3650
|
-
}
|
|
3573
|
+
doseId
|
|
3574
|
+
durationId
|
|
3575
|
+
drugId
|
|
3576
|
+
routeId
|
|
3577
|
+
unitId
|
|
3578
|
+
frequencyId
|
|
3651
3579
|
}
|
|
3652
3580
|
}
|
|
3653
3581
|
... on QuestionEMQ {
|
|
@@ -436,8 +436,6 @@ const getQuestionHighlightsFragment = (typeId) => {
|
|
|
436
436
|
case models_1.EQuestionType.RANKING_ANSWER:
|
|
437
437
|
return exports.QUESTION_RANKING_HIGHLIGHT_FIELDS;
|
|
438
438
|
case models_1.EQuestionType.SINGLE_BEST_ANSWER:
|
|
439
|
-
case models_1.EQuestionType.MRCP_PART_1:
|
|
440
|
-
case models_1.EQuestionType.MRCP_PART_2:
|
|
441
439
|
default:
|
|
442
440
|
return exports.QUESTION_SBA_HIGHLIGHT_FIELDS;
|
|
443
441
|
}
|
|
@@ -458,8 +456,6 @@ const getQuestionTypeName = (typeId) => {
|
|
|
458
456
|
case models_1.EQuestionType.RANKING_ANSWER:
|
|
459
457
|
return 'QuestionRanking';
|
|
460
458
|
case models_1.EQuestionType.SINGLE_BEST_ANSWER:
|
|
461
|
-
case models_1.EQuestionType.MRCP_PART_1:
|
|
462
|
-
case models_1.EQuestionType.MRCP_PART_2:
|
|
463
459
|
default:
|
|
464
460
|
return 'QuestionSBA';
|
|
465
461
|
}
|
|
@@ -480,8 +476,6 @@ const getQuestionFragment = (typeId) => {
|
|
|
480
476
|
case models_1.EQuestionType.RANKING_ANSWER:
|
|
481
477
|
return exports.QUESTION_RANKING_COMMENT_FIELDS;
|
|
482
478
|
case models_1.EQuestionType.SINGLE_BEST_ANSWER:
|
|
483
|
-
case models_1.EQuestionType.MRCP_PART_1:
|
|
484
|
-
case models_1.EQuestionType.MRCP_PART_2:
|
|
485
479
|
default:
|
|
486
480
|
return exports.QUESTION_SBA_COMMENT_FIELDS;
|
|
487
481
|
}
|
|
@@ -584,30 +584,12 @@ exports.MARKSHEET = (0, client_1.gql) `
|
|
|
584
584
|
dislikes
|
|
585
585
|
isLikedByMe
|
|
586
586
|
prescribeAnswer: answer {
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
display
|
|
594
|
-
}
|
|
595
|
-
route {
|
|
596
|
-
value
|
|
597
|
-
display
|
|
598
|
-
}
|
|
599
|
-
frequency {
|
|
600
|
-
display
|
|
601
|
-
value
|
|
602
|
-
}
|
|
603
|
-
duration {
|
|
604
|
-
display
|
|
605
|
-
value
|
|
606
|
-
}
|
|
607
|
-
units {
|
|
608
|
-
display
|
|
609
|
-
value
|
|
610
|
-
}
|
|
587
|
+
doseId
|
|
588
|
+
durationId
|
|
589
|
+
drugId
|
|
590
|
+
routeId
|
|
591
|
+
unitId
|
|
592
|
+
frequencyId
|
|
611
593
|
}
|
|
612
594
|
}
|
|
613
595
|
... on QuestionEMQ {
|
|
@@ -1703,30 +1685,12 @@ exports.FLAGGED_QUESTIONS_MARKSHEET = (0, client_1.gql) `
|
|
|
1703
1685
|
dislikes
|
|
1704
1686
|
isLikedByMe
|
|
1705
1687
|
prescribeAnswer: answer {
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
display
|
|
1713
|
-
}
|
|
1714
|
-
route {
|
|
1715
|
-
value
|
|
1716
|
-
display
|
|
1717
|
-
}
|
|
1718
|
-
frequency {
|
|
1719
|
-
display
|
|
1720
|
-
value
|
|
1721
|
-
}
|
|
1722
|
-
duration {
|
|
1723
|
-
display
|
|
1724
|
-
value
|
|
1725
|
-
}
|
|
1726
|
-
units {
|
|
1727
|
-
display
|
|
1728
|
-
value
|
|
1729
|
-
}
|
|
1688
|
+
doseId
|
|
1689
|
+
durationId
|
|
1690
|
+
drugId
|
|
1691
|
+
routeId
|
|
1692
|
+
unitId
|
|
1693
|
+
frequencyId
|
|
1730
1694
|
}
|
|
1731
1695
|
}
|
|
1732
1696
|
... on QuestionEMQ {
|
|
@@ -512,30 +512,12 @@ exports.QUESTION = (0, client_1.gql) `
|
|
|
512
512
|
dislikes
|
|
513
513
|
isLikedByMe
|
|
514
514
|
prescribeAnswer: answer {
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
display
|
|
522
|
-
}
|
|
523
|
-
route {
|
|
524
|
-
value
|
|
525
|
-
display
|
|
526
|
-
}
|
|
527
|
-
frequency {
|
|
528
|
-
display
|
|
529
|
-
value
|
|
530
|
-
}
|
|
531
|
-
duration {
|
|
532
|
-
display
|
|
533
|
-
value
|
|
534
|
-
}
|
|
535
|
-
units {
|
|
536
|
-
display
|
|
537
|
-
value
|
|
538
|
-
}
|
|
515
|
+
doseId
|
|
516
|
+
durationId
|
|
517
|
+
drugId
|
|
518
|
+
routeId
|
|
519
|
+
unitId
|
|
520
|
+
frequencyId
|
|
539
521
|
}
|
|
540
522
|
}
|
|
541
523
|
... on QuestionEMQ {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { IMarksheetMark,
|
|
2
|
-
export declare function mapPrescribeMarkToAnswer(obj: IPrescribeMark): IPrescribeAnswer;
|
|
3
|
-
export declare function formatPrescribeAnswer(baseAnswer: IPrescribeAnswer): IPrescribeAnswer;
|
|
1
|
+
import { IMarksheetMark, IPrescribeMark, IQuestionPrescription } from '../models';
|
|
4
2
|
export interface ICorrectMarkData {
|
|
5
3
|
correct: boolean;
|
|
6
4
|
incorrect: boolean;
|
|
7
5
|
correctIndex: number;
|
|
8
6
|
}
|
|
7
|
+
export declare function mapPrescribeMarkToAnswer(obj: IQuestionPrescription | IPrescribeMark): IPrescribeMark;
|
|
9
8
|
export declare function correctMark(mark: IMarksheetMark): ICorrectMarkData;
|
package/utils/commonFunctions.js
CHANGED
|
@@ -1,165 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.correctMark = exports.
|
|
3
|
+
exports.correctMark = exports.mapPrescribeMarkToAnswer = void 0;
|
|
4
4
|
const models_1 = require("../models");
|
|
5
|
-
const
|
|
6
|
-
const floatRegex = /([0-9]*[.])?[0-9]+/gm;
|
|
7
|
-
const ACCEPTED_FREQ = ['stat', 'od', 'bd', 'tds', 'qds'];
|
|
8
|
-
function mapPrescribeMarkToAnswer(obj) {
|
|
9
|
-
return {
|
|
10
|
-
drug: {
|
|
11
|
-
value: obj.drug,
|
|
12
|
-
display: false,
|
|
13
|
-
},
|
|
14
|
-
dose: {
|
|
15
|
-
value: parseFloat(obj.dose),
|
|
16
|
-
display: false,
|
|
17
|
-
},
|
|
18
|
-
units: {
|
|
19
|
-
value: obj.units,
|
|
20
|
-
display: false,
|
|
21
|
-
},
|
|
22
|
-
route: {
|
|
23
|
-
value: obj.route,
|
|
24
|
-
display: false,
|
|
25
|
-
},
|
|
26
|
-
frequency: {
|
|
27
|
-
value: obj.frequency,
|
|
28
|
-
display: false,
|
|
29
|
-
},
|
|
30
|
-
duration: {
|
|
31
|
-
value: obj.duration,
|
|
32
|
-
display: false,
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
exports.mapPrescribeMarkToAnswer = mapPrescribeMarkToAnswer;
|
|
37
|
-
function formatPrescribeAnswer(baseAnswer) {
|
|
38
|
-
const obj = Object.assign({}, baseAnswer, {
|
|
39
|
-
drug: Object.assign({}, baseAnswer.drug, {
|
|
40
|
-
value: baseAnswer.drug?.value ?? '',
|
|
41
|
-
}),
|
|
42
|
-
dose: Object.assign({}, baseAnswer.dose, {
|
|
43
|
-
value: baseAnswer.dose?.value ?? 0,
|
|
44
|
-
}),
|
|
45
|
-
units: Object.assign({}, baseAnswer.units, {
|
|
46
|
-
value: baseAnswer.units?.value ?? '',
|
|
47
|
-
}),
|
|
48
|
-
route: Object.assign({}, baseAnswer.route, {
|
|
49
|
-
value: baseAnswer.route?.value ?? '',
|
|
50
|
-
}),
|
|
51
|
-
frequency: Object.assign({}, baseAnswer.frequency, {
|
|
52
|
-
value: baseAnswer.frequency?.value ?? '',
|
|
53
|
-
}),
|
|
54
|
-
duration: Object.assign({}, baseAnswer.duration, {
|
|
55
|
-
value: baseAnswer.duration?.value ?? '',
|
|
56
|
-
}),
|
|
57
|
-
});
|
|
58
|
-
// DRUG
|
|
59
|
-
obj.drug.value = obj.drug.value.toLowerCase().replace(/\s/g, '');
|
|
60
|
-
// ROUTE
|
|
61
|
-
obj.route.value = obj.route.value
|
|
62
|
-
.toLowerCase()
|
|
63
|
-
.replace(/\s/g, '')
|
|
64
|
-
.replace(/\//g, '');
|
|
65
|
-
if (obj.route.value.includes('oral')) {
|
|
66
|
-
obj.route.value = 'po';
|
|
67
|
-
}
|
|
68
|
-
else if (obj.route.value.includes('intravenous')) {
|
|
69
|
-
obj.route.value = 'iv';
|
|
70
|
-
}
|
|
71
|
-
else if (obj.route.value.includes('intramuscular')) {
|
|
72
|
-
obj.route.value = 'im';
|
|
73
|
-
}
|
|
74
|
-
else if (obj.route.value.includes('subcutaneous')) {
|
|
75
|
-
obj.route.value = 'sc';
|
|
76
|
-
}
|
|
77
|
-
else if (obj.route.value.includes('inhale')) {
|
|
78
|
-
obj.route.value = 'inh';
|
|
79
|
-
}
|
|
80
|
-
else if (obj.route.value.includes('nebuli')) {
|
|
81
|
-
obj.route.value = 'neb';
|
|
82
|
-
}
|
|
83
|
-
else if (obj.route.value.includes('topical')) {
|
|
84
|
-
obj.route.value = 'top';
|
|
85
|
-
}
|
|
86
|
-
else if (obj.route.value.includes('rectal')) {
|
|
87
|
-
obj.route.value = 'pr';
|
|
88
|
-
}
|
|
89
|
-
// UNITS
|
|
90
|
-
obj.units.value = obj.units.value.toLowerCase().replace(/\s/g, '');
|
|
91
|
-
switch (obj.units.value) {
|
|
92
|
-
case 'milligram':
|
|
93
|
-
case 'milligrams':
|
|
94
|
-
obj.units.value = 'mg';
|
|
95
|
-
break;
|
|
96
|
-
case 'microgram':
|
|
97
|
-
case 'micrograms':
|
|
98
|
-
obj.units.value = 'mcg';
|
|
99
|
-
break;
|
|
100
|
-
case 'gram':
|
|
101
|
-
case 'grams':
|
|
102
|
-
obj.units.value = 'g';
|
|
103
|
-
break;
|
|
104
|
-
case 'unit':
|
|
105
|
-
obj.units.value = 'units';
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
// DURATION
|
|
109
|
-
let m;
|
|
110
|
-
const durationMatches = new Set();
|
|
111
|
-
while ((m = floatRegex.exec(obj.duration.value)) !== null) {
|
|
112
|
-
if (m.index === floatRegex.lastIndex) {
|
|
113
|
-
floatRegex.lastIndex++;
|
|
114
|
-
}
|
|
115
|
-
m.forEach((match) => durationMatches.add(match));
|
|
116
|
-
}
|
|
117
|
-
const durationWords = (0, wordsToNumber_1.wordsToNumber)(obj.duration.value, false);
|
|
118
|
-
if (durationWords !== 0) {
|
|
119
|
-
durationMatches.add(durationWords.toString());
|
|
120
|
-
}
|
|
121
|
-
obj.duration.value = [...durationMatches].filter((x) => !!x).join(',');
|
|
122
|
-
// FREQUENCY
|
|
123
|
-
const orgFrequencyValue = obj.frequency.value.toLowerCase();
|
|
124
|
-
const timesPerDay = obj.frequency.value.includes('times per day') ||
|
|
125
|
-
obj.frequency.value.includes('times a day');
|
|
126
|
-
// remove whitespace for processing
|
|
127
|
-
obj.frequency.value = orgFrequencyValue.replace(/\s/g, '');
|
|
128
|
-
const freqWordsToInt = (0, wordsToNumber_1.wordsToNumber)(orgFrequencyValue, true);
|
|
129
|
-
const frequencyIncHourly = obj.frequency.value.includes('hour');
|
|
130
|
-
const textToInt = parseInt(obj.frequency.value);
|
|
131
|
-
if (obj.frequency.value === 'once-off') {
|
|
132
|
-
obj.frequency.value = 'stat';
|
|
133
|
-
}
|
|
134
|
-
else if (obj.frequency.value.includes('once') ||
|
|
135
|
-
(frequencyIncHourly && textToInt === 24) ||
|
|
136
|
-
(timesPerDay && freqWordsToInt === 1)) {
|
|
137
|
-
obj.frequency.value = 'od';
|
|
138
|
-
}
|
|
139
|
-
else if (obj.frequency.value.includes('nightly') ||
|
|
140
|
-
obj.frequency.value === 'on') {
|
|
141
|
-
obj.frequency.value = 'od';
|
|
142
|
-
}
|
|
143
|
-
else if (obj.frequency.value.includes('twice') ||
|
|
144
|
-
(frequencyIncHourly && textToInt === 12) ||
|
|
145
|
-
(timesPerDay && freqWordsToInt === 2)) {
|
|
146
|
-
obj.frequency.value = 'bd';
|
|
147
|
-
}
|
|
148
|
-
else if (obj.frequency.value.includes('trice') ||
|
|
149
|
-
(frequencyIncHourly && textToInt === 8) ||
|
|
150
|
-
(timesPerDay && freqWordsToInt === 3)) {
|
|
151
|
-
obj.frequency.value = 'tds';
|
|
152
|
-
}
|
|
153
|
-
else if ((frequencyIncHourly && textToInt === 6) ||
|
|
154
|
-
(timesPerDay && freqWordsToInt === 4)) {
|
|
155
|
-
obj.frequency.value = 'qds';
|
|
156
|
-
}
|
|
157
|
-
else if (!ACCEPTED_FREQ.includes(obj.frequency.value)) {
|
|
158
|
-
obj.frequency.value = (0, wordsToNumber_1.wordsToNumber)(orgFrequencyValue, true).toString();
|
|
159
|
-
}
|
|
160
|
-
return obj;
|
|
161
|
-
}
|
|
162
|
-
exports.formatPrescribeAnswer = formatPrescribeAnswer;
|
|
5
|
+
const object_1 = require("./object");
|
|
163
6
|
function createHashMap(arr) {
|
|
164
7
|
const map = new Map();
|
|
165
8
|
for (const innerArr of arr) {
|
|
@@ -169,6 +12,17 @@ function createHashMap(arr) {
|
|
|
169
12
|
}
|
|
170
13
|
return map;
|
|
171
14
|
}
|
|
15
|
+
function mapPrescribeMarkToAnswer(obj) {
|
|
16
|
+
return {
|
|
17
|
+
drugId: obj.drugId,
|
|
18
|
+
doseId: obj.doseId,
|
|
19
|
+
durationId: obj.durationId,
|
|
20
|
+
frequencyId: obj.frequencyId,
|
|
21
|
+
unitId: obj.unitId,
|
|
22
|
+
routeId: obj.routeId,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
exports.mapPrescribeMarkToAnswer = mapPrescribeMarkToAnswer;
|
|
172
26
|
function correctMark(mark) {
|
|
173
27
|
const data = {
|
|
174
28
|
correct: false,
|
|
@@ -232,41 +86,19 @@ function correctMark(mark) {
|
|
|
232
86
|
}
|
|
233
87
|
}
|
|
234
88
|
else if (models_1.EQuestionType.PRESCRIPTION_ANSWER === mark.question.typeId) {
|
|
235
|
-
const answers = answer.map(formatPrescribeAnswer);
|
|
236
|
-
let attempt = formatPrescribeAnswer(mapPrescribeMarkToAnswer({
|
|
237
|
-
drug: '',
|
|
238
|
-
dose: -1,
|
|
239
|
-
units: '',
|
|
240
|
-
route: '',
|
|
241
|
-
frequency: '',
|
|
242
|
-
duration: '',
|
|
243
|
-
}));
|
|
244
|
-
if (typeof flatAttempt === 'object' &&
|
|
245
|
-
Object.keys(flatAttempt).length === 6) {
|
|
246
|
-
attempt = formatPrescribeAnswer(mapPrescribeMarkToAnswer(flatAttempt));
|
|
247
|
-
}
|
|
248
89
|
let foundCorrect = false;
|
|
249
90
|
let index = 0;
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
const
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
answer
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
if (doseCorrect &&
|
|
261
|
-
drugCorrect &&
|
|
262
|
-
durationCorrect &&
|
|
263
|
-
frequencyCorrect &&
|
|
264
|
-
routeCorrect &&
|
|
265
|
-
unitsCorrect) {
|
|
266
|
-
foundCorrect = true;
|
|
267
|
-
break;
|
|
91
|
+
if (typeof flatAttempt === 'object' &&
|
|
92
|
+
Object.keys(flatAttempt).length > 0) {
|
|
93
|
+
const answers = answer.map(mapPrescribeMarkToAnswer);
|
|
94
|
+
const attempt = mapPrescribeMarkToAnswer(flatAttempt);
|
|
95
|
+
for (const answer of answers) {
|
|
96
|
+
if ((0, object_1.compareObjects)(answer, attempt)) {
|
|
97
|
+
foundCorrect = true;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
index++;
|
|
268
101
|
}
|
|
269
|
-
index++;
|
|
270
102
|
}
|
|
271
103
|
if (foundCorrect) {
|
|
272
104
|
data.correct = true;
|
package/utils/index.d.ts
CHANGED
package/utils/index.js
CHANGED
|
@@ -20,6 +20,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
20
20
|
exports.printDuration = exports.Uuid4 = void 0;
|
|
21
21
|
__exportStar(require("./commonFunctions"), exports);
|
|
22
22
|
__exportStar(require("./lightgallery"), exports);
|
|
23
|
+
__exportStar(require("./object"), exports);
|
|
23
24
|
__exportStar(require("./offlineLink"), exports);
|
|
24
25
|
__exportStar(require("./random"), exports);
|
|
25
26
|
__exportStar(require("./supermemo"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function compareObjects<T = Record<string, unknown>, V = Record<string, unknown>>(obj1: T, obj2: V): boolean;
|
package/utils/object.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compareObjects = void 0;
|
|
4
|
+
function compareObjects(obj1, obj2) {
|
|
5
|
+
const ob1 = obj1;
|
|
6
|
+
const ob2 = obj2;
|
|
7
|
+
const keys1 = Object.keys(ob1);
|
|
8
|
+
const keys2 = Object.keys(ob2);
|
|
9
|
+
if (keys1.length !== keys2.length) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
for (let i = 0; i < keys1.length; i++) {
|
|
13
|
+
const key = keys1[i];
|
|
14
|
+
if (ob1[key] !== ob2[key]) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
exports.compareObjects = compareObjects;
|