@quesmed/types 1.4.8 → 1.4.9
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/package.json
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ApolloClient } from '@apollo/client';
|
|
2
1
|
import { EOsceMarksheetAction, EOsceRoles, Id, IOsceMarksheet, IOsceMarksheetMark } from '../../../models';
|
|
3
2
|
import { IOsceMatchmakingAction } from '../../subscription/osce';
|
|
4
3
|
import { graphqlNormalize, RestrictedData } from '../../types';
|
|
@@ -35,11 +34,11 @@ export interface IChangeOsceRoleVar {
|
|
|
35
34
|
export declare type IChangeOsceRoleData = RestrictedData<graphqlNormalize & IOsceMarksheet, 'changeOsceRole'>;
|
|
36
35
|
export declare const MARK_OSCE_MARKSHEET_MARK: import("@apollo/client").DocumentNode;
|
|
37
36
|
export interface IMarkOsceMarksheetMarkVar {
|
|
38
|
-
|
|
37
|
+
osceMarksheetMarkId: Id;
|
|
39
38
|
mark: boolean;
|
|
40
39
|
}
|
|
41
40
|
export declare type IMarkOsceMarksheetMarkData = RestrictedData<graphqlNormalize & Partial<IOsceMarksheetMark>, 'markOsceMarksheetMark'>;
|
|
42
|
-
export declare const optimisticMarkOsceMarksheetMark: (
|
|
41
|
+
export declare const optimisticMarkOsceMarksheetMark: (variables: IMarkOsceMarksheetMarkVar) => IMarkOsceMarksheetMarkData;
|
|
43
42
|
export declare const SELECT_OSCE_STATION: import("@apollo/client").DocumentNode;
|
|
44
43
|
export interface ISelectOsceMarksheetStationVar {
|
|
45
44
|
osceMarksheetId: Id;
|
|
@@ -63,28 +63,26 @@ exports.CHANGE_OSCE_ROLE = (0, client_1.gql) `
|
|
|
63
63
|
}
|
|
64
64
|
`;
|
|
65
65
|
exports.MARK_OSCE_MARKSHEET_MARK = (0, client_1.gql) `
|
|
66
|
-
${
|
|
67
|
-
mutation MarkOsceMarksheetMark($osceStationMarkId: Int!, $mark: Boolean!) {
|
|
66
|
+
mutation MarkOsceMarksheetMark($osceMarksheetMarkId: Int!, $mark: Boolean!) {
|
|
68
67
|
restricted {
|
|
69
68
|
markOsceMarksheetMark(
|
|
70
|
-
|
|
69
|
+
osceMarksheetMarkId: $osceMarksheetMarkId
|
|
71
70
|
mark: $mark
|
|
72
71
|
) {
|
|
73
|
-
|
|
72
|
+
id
|
|
73
|
+
mark
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
`;
|
|
78
|
-
const optimisticMarkOsceMarksheetMark = (
|
|
79
|
-
const __typename = 'OsceMarksheetMark';
|
|
80
|
-
const markOsceMarksheetMark = client.readFragment({
|
|
81
|
-
id: `${__typename}:${variables.osceStationMarkId}`,
|
|
82
|
-
fragment: osce_1.OSCE_MARKSHEET_MARK_FIELDS,
|
|
83
|
-
fragmentName: 'OsceMarksheetMarkFields',
|
|
84
|
-
});
|
|
78
|
+
const optimisticMarkOsceMarksheetMark = (variables) => {
|
|
85
79
|
return {
|
|
86
80
|
restricted: {
|
|
87
|
-
markOsceMarksheetMark:
|
|
81
|
+
markOsceMarksheetMark: {
|
|
82
|
+
id: variables.osceMarksheetMarkId,
|
|
83
|
+
mark: variables.mark,
|
|
84
|
+
__typename: 'OsceMarksheetMark',
|
|
85
|
+
},
|
|
88
86
|
},
|
|
89
87
|
};
|
|
90
88
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { gql } from '@apollo/client';
|
|
2
|
-
import { OSCE_MARKSHEET_FIELDS,
|
|
2
|
+
import { OSCE_MARKSHEET_FIELDS, OSCE_MATCHMAKING_ACTION_FIELDS, } from '../../fragments/osce';
|
|
3
3
|
export const START_OSCE_MATCHMAKING = gql `
|
|
4
4
|
mutation StartOsceMatchmaking($agoraId: String!) {
|
|
5
5
|
restricted {
|
|
@@ -60,28 +60,26 @@ export const CHANGE_OSCE_ROLE = gql `
|
|
|
60
60
|
}
|
|
61
61
|
`;
|
|
62
62
|
export const MARK_OSCE_MARKSHEET_MARK = gql `
|
|
63
|
-
${
|
|
64
|
-
mutation MarkOsceMarksheetMark($osceStationMarkId: Int!, $mark: Boolean!) {
|
|
63
|
+
mutation MarkOsceMarksheetMark($osceMarksheetMarkId: Int!, $mark: Boolean!) {
|
|
65
64
|
restricted {
|
|
66
65
|
markOsceMarksheetMark(
|
|
67
|
-
|
|
66
|
+
osceMarksheetMarkId: $osceMarksheetMarkId
|
|
68
67
|
mark: $mark
|
|
69
68
|
) {
|
|
70
|
-
|
|
69
|
+
id
|
|
70
|
+
mark
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
`;
|
|
75
|
-
export const optimisticMarkOsceMarksheetMark = (
|
|
76
|
-
const __typename = 'OsceMarksheetMark';
|
|
77
|
-
const markOsceMarksheetMark = client.readFragment({
|
|
78
|
-
id: `${__typename}:${variables.osceStationMarkId}`,
|
|
79
|
-
fragment: OSCE_MARKSHEET_MARK_FIELDS,
|
|
80
|
-
fragmentName: 'OsceMarksheetMarkFields',
|
|
81
|
-
});
|
|
75
|
+
export const optimisticMarkOsceMarksheetMark = (variables) => {
|
|
82
76
|
return {
|
|
83
77
|
restricted: {
|
|
84
|
-
markOsceMarksheetMark:
|
|
78
|
+
markOsceMarksheetMark: {
|
|
79
|
+
id: variables.osceMarksheetMarkId,
|
|
80
|
+
mark: variables.mark,
|
|
81
|
+
__typename: 'OsceMarksheetMark',
|
|
82
|
+
},
|
|
85
83
|
},
|
|
86
84
|
};
|
|
87
85
|
};
|
package/utils/commonFunctions.js
CHANGED
|
@@ -36,7 +36,10 @@ function mapPrescribeMarkToAnswer(obj) {
|
|
|
36
36
|
exports.mapPrescribeMarkToAnswer = mapPrescribeMarkToAnswer;
|
|
37
37
|
function formatPrescribeAnswer(obj) {
|
|
38
38
|
obj.drug.value = obj.drug.value.toLowerCase().replace(/\s/g, '');
|
|
39
|
-
obj.route.value = obj.route.value
|
|
39
|
+
obj.route.value = obj.route.value
|
|
40
|
+
.toLowerCase()
|
|
41
|
+
.replace(/\s/g, '')
|
|
42
|
+
.replace(/\//g, '');
|
|
40
43
|
if (obj.route.value === 'oral') {
|
|
41
44
|
obj.route.value = 'po';
|
|
42
45
|
}
|
|
@@ -62,7 +65,8 @@ function formatPrescribeAnswer(obj) {
|
|
|
62
65
|
if (obj.units.value === 'milligram' || obj.units.value === 'milligrams') {
|
|
63
66
|
obj.units.value = 'mg';
|
|
64
67
|
}
|
|
65
|
-
else if (obj.units.value === 'microgram' ||
|
|
68
|
+
else if (obj.units.value === 'microgram' ||
|
|
69
|
+
obj.units.value === 'micrograms') {
|
|
66
70
|
obj.units.value = 'mcg';
|
|
67
71
|
}
|
|
68
72
|
else if (obj.units.value === 'gram' || obj.units.value === 'grams') {
|
|
@@ -91,17 +95,20 @@ function formatPrescribeAnswer(obj) {
|
|
|
91
95
|
if (obj.frequency.value === 'once-off') {
|
|
92
96
|
obj.frequency.value = 'stat';
|
|
93
97
|
}
|
|
94
|
-
else if (obj.frequency.value.includes('once') ||
|
|
98
|
+
else if (obj.frequency.value.includes('once') ||
|
|
99
|
+
(frequencyIncHourly && hourlyFreqInt === 24)) {
|
|
95
100
|
obj.frequency.value = 'od';
|
|
96
101
|
}
|
|
97
|
-
else if (obj.frequency.value.includes('nightly') ||
|
|
102
|
+
else if (obj.frequency.value.includes('nightly') ||
|
|
103
|
+
obj.frequency.value === 'on') {
|
|
98
104
|
obj.frequency.value = 'od';
|
|
99
105
|
}
|
|
100
106
|
else if (obj.frequency.value.includes('twice') ||
|
|
101
107
|
(frequencyIncHourly && hourlyFreqInt === 12)) {
|
|
102
108
|
obj.frequency.value = 'bd';
|
|
103
109
|
}
|
|
104
|
-
else if (obj.frequency.value.includes('trice') ||
|
|
110
|
+
else if (obj.frequency.value.includes('trice') ||
|
|
111
|
+
(frequencyIncHourly && hourlyFreqInt === 8)) {
|
|
105
112
|
obj.frequency.value = 'tds';
|
|
106
113
|
}
|
|
107
114
|
else if (frequencyIncHourly && hourlyFreqInt === 6) {
|
|
@@ -140,7 +147,9 @@ function correctMark(mark) {
|
|
|
140
147
|
}
|
|
141
148
|
}
|
|
142
149
|
else if (models_1.EQuestionType.QUESTION_ANSWER === mark.question.typeId) {
|
|
143
|
-
const answer = flatAnswer.dose
|
|
150
|
+
const answer = flatAnswer.dose
|
|
151
|
+
.toLowerCase()
|
|
152
|
+
.replace(/\s/g, '');
|
|
144
153
|
let attempt = '';
|
|
145
154
|
if (flatAttempt) {
|
|
146
155
|
attempt = flatAttempt.toLowerCase().replace(/\s/g, '');
|
|
@@ -161,7 +170,8 @@ function correctMark(mark) {
|
|
|
161
170
|
Array.isArray(mark.mark[1])) {
|
|
162
171
|
[attemptA, attemptB] = mark.mark.map((x) => x.sort());
|
|
163
172
|
}
|
|
164
|
-
if (answerA.length !== attemptA.length ||
|
|
173
|
+
if (answerA.length !== attemptA.length ||
|
|
174
|
+
answerB.length !== attemptB.length) {
|
|
165
175
|
data.incorrect = true;
|
|
166
176
|
}
|
|
167
177
|
else if (attemptA.every((x, i) => x === answerA[i]) &&
|
|
@@ -182,7 +192,8 @@ function correctMark(mark) {
|
|
|
182
192
|
frequency: '',
|
|
183
193
|
duration: '',
|
|
184
194
|
}));
|
|
185
|
-
if (typeof flatAttempt === 'object' &&
|
|
195
|
+
if (typeof flatAttempt === 'object' &&
|
|
196
|
+
Object.keys(flatAttempt).length === 6) {
|
|
186
197
|
attempt = formatPrescribeAnswer(mapPrescribeMarkToAnswer(flatAttempt));
|
|
187
198
|
}
|
|
188
199
|
let foundCorrect = false;
|
|
@@ -192,7 +203,8 @@ function correctMark(mark) {
|
|
|
192
203
|
const drugCorrect = answer.drug.display || answer.drug.value === attempt.drug.value;
|
|
193
204
|
const durationCorrect = answer.duration.display ||
|
|
194
205
|
answer.duration.value.split(',').includes(attempt.duration.value);
|
|
195
|
-
const frequencyCorrect = answer.frequency.display ||
|
|
206
|
+
const frequencyCorrect = answer.frequency.display ||
|
|
207
|
+
answer.frequency.value === attempt.frequency.value;
|
|
196
208
|
const routeCorrect = answer.route.display || answer.route.value === attempt.route.value;
|
|
197
209
|
const unitsCorrect = answer.units.display || answer.units.value === attempt.units.value;
|
|
198
210
|
if (doseCorrect &&
|
|
@@ -32,7 +32,10 @@ export function mapPrescribeMarkToAnswer(obj) {
|
|
|
32
32
|
}
|
|
33
33
|
export function formatPrescribeAnswer(obj) {
|
|
34
34
|
obj.drug.value = obj.drug.value.toLowerCase().replace(/\s/g, '');
|
|
35
|
-
obj.route.value = obj.route.value
|
|
35
|
+
obj.route.value = obj.route.value
|
|
36
|
+
.toLowerCase()
|
|
37
|
+
.replace(/\s/g, '')
|
|
38
|
+
.replace(/\//g, '');
|
|
36
39
|
if (obj.route.value === 'oral') {
|
|
37
40
|
obj.route.value = 'po';
|
|
38
41
|
}
|
|
@@ -58,7 +61,8 @@ export function formatPrescribeAnswer(obj) {
|
|
|
58
61
|
if (obj.units.value === 'milligram' || obj.units.value === 'milligrams') {
|
|
59
62
|
obj.units.value = 'mg';
|
|
60
63
|
}
|
|
61
|
-
else if (obj.units.value === 'microgram' ||
|
|
64
|
+
else if (obj.units.value === 'microgram' ||
|
|
65
|
+
obj.units.value === 'micrograms') {
|
|
62
66
|
obj.units.value = 'mcg';
|
|
63
67
|
}
|
|
64
68
|
else if (obj.units.value === 'gram' || obj.units.value === 'grams') {
|
|
@@ -87,17 +91,20 @@ export function formatPrescribeAnswer(obj) {
|
|
|
87
91
|
if (obj.frequency.value === 'once-off') {
|
|
88
92
|
obj.frequency.value = 'stat';
|
|
89
93
|
}
|
|
90
|
-
else if (obj.frequency.value.includes('once') ||
|
|
94
|
+
else if (obj.frequency.value.includes('once') ||
|
|
95
|
+
(frequencyIncHourly && hourlyFreqInt === 24)) {
|
|
91
96
|
obj.frequency.value = 'od';
|
|
92
97
|
}
|
|
93
|
-
else if (obj.frequency.value.includes('nightly') ||
|
|
98
|
+
else if (obj.frequency.value.includes('nightly') ||
|
|
99
|
+
obj.frequency.value === 'on') {
|
|
94
100
|
obj.frequency.value = 'od';
|
|
95
101
|
}
|
|
96
102
|
else if (obj.frequency.value.includes('twice') ||
|
|
97
103
|
(frequencyIncHourly && hourlyFreqInt === 12)) {
|
|
98
104
|
obj.frequency.value = 'bd';
|
|
99
105
|
}
|
|
100
|
-
else if (obj.frequency.value.includes('trice') ||
|
|
106
|
+
else if (obj.frequency.value.includes('trice') ||
|
|
107
|
+
(frequencyIncHourly && hourlyFreqInt === 8)) {
|
|
101
108
|
obj.frequency.value = 'tds';
|
|
102
109
|
}
|
|
103
110
|
else if (frequencyIncHourly && hourlyFreqInt === 6) {
|
|
@@ -135,7 +142,9 @@ export function correctMark(mark) {
|
|
|
135
142
|
}
|
|
136
143
|
}
|
|
137
144
|
else if (EQuestionType.QUESTION_ANSWER === mark.question.typeId) {
|
|
138
|
-
const answer = flatAnswer.dose
|
|
145
|
+
const answer = flatAnswer.dose
|
|
146
|
+
.toLowerCase()
|
|
147
|
+
.replace(/\s/g, '');
|
|
139
148
|
let attempt = '';
|
|
140
149
|
if (flatAttempt) {
|
|
141
150
|
attempt = flatAttempt.toLowerCase().replace(/\s/g, '');
|
|
@@ -156,7 +165,8 @@ export function correctMark(mark) {
|
|
|
156
165
|
Array.isArray(mark.mark[1])) {
|
|
157
166
|
[attemptA, attemptB] = mark.mark.map((x) => x.sort());
|
|
158
167
|
}
|
|
159
|
-
if (answerA.length !== attemptA.length ||
|
|
168
|
+
if (answerA.length !== attemptA.length ||
|
|
169
|
+
answerB.length !== attemptB.length) {
|
|
160
170
|
data.incorrect = true;
|
|
161
171
|
}
|
|
162
172
|
else if (attemptA.every((x, i) => x === answerA[i]) &&
|
|
@@ -177,7 +187,8 @@ export function correctMark(mark) {
|
|
|
177
187
|
frequency: '',
|
|
178
188
|
duration: '',
|
|
179
189
|
}));
|
|
180
|
-
if (typeof flatAttempt === 'object' &&
|
|
190
|
+
if (typeof flatAttempt === 'object' &&
|
|
191
|
+
Object.keys(flatAttempt).length === 6) {
|
|
181
192
|
attempt = formatPrescribeAnswer(mapPrescribeMarkToAnswer(flatAttempt));
|
|
182
193
|
}
|
|
183
194
|
let foundCorrect = false;
|
|
@@ -187,7 +198,8 @@ export function correctMark(mark) {
|
|
|
187
198
|
const drugCorrect = answer.drug.display || answer.drug.value === attempt.drug.value;
|
|
188
199
|
const durationCorrect = answer.duration.display ||
|
|
189
200
|
answer.duration.value.split(',').includes(attempt.duration.value);
|
|
190
|
-
const frequencyCorrect = answer.frequency.display ||
|
|
201
|
+
const frequencyCorrect = answer.frequency.display ||
|
|
202
|
+
answer.frequency.value === attempt.frequency.value;
|
|
191
203
|
const routeCorrect = answer.route.display || answer.route.value === attempt.route.value;
|
|
192
204
|
const unitsCorrect = answer.units.display || answer.units.value === attempt.units.value;
|
|
193
205
|
if (doseCorrect &&
|