@quesmed/types 2.6.271 → 2.6.273

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.
@@ -19,7 +19,8 @@ export interface IOsceMarksheetMark {
19
19
  id: Id;
20
20
  index: number;
21
21
  mark: number | null;
22
- comment?: string;
22
+ comment1?: string;
23
+ comment2?: string;
23
24
  suggestion?: string;
24
25
  selectedChoice: Nullable<EPaceMarkType>;
25
26
  osceMarksheetId: Id;
@@ -103,7 +103,8 @@ exports.OSCE_MARKSHEET_MARK_FIELDS = (0, client_1.gql) `
103
103
  score
104
104
  secondaryMark
105
105
  selectedChoice
106
- comment
106
+ comment1
107
+ comment2
107
108
  suggestion
108
109
  osceMarksheetId
109
110
  osceStationMarkId
@@ -260,7 +261,8 @@ exports.UPSERT_STATION_NOTE_FRAGMENT = (0, client_1.gql) `
260
261
  exports.AUTO_MARKED_OSCE_MARKSHEET_MARK_FIELDS = (0, client_1.gql) `
261
262
  fragment AutoMarkedOsceMarksheetMarkFields on OsceMarksheetMark {
262
263
  mark
263
- comment
264
+ comment1
265
+ comment2
264
266
  suggestion
265
267
  }
266
268
  `;
@@ -42,6 +42,10 @@ export interface IChangeOsceRoleVar {
42
42
  }
43
43
  export type IChangeOsceRoleData = RestrictedData<graphqlNormalize & IOsceMarksheet, 'changeOsceRole'>;
44
44
  export declare const MARK_OSCE_MARKSHEET_MARK: import("@apollo/client").DocumentNode;
45
+ export declare const getStationScore: (marks: IOsceMarksheetMark[]) => {
46
+ total: number;
47
+ userScore: number;
48
+ };
45
49
  export interface IMarkOsceMarksheetMarkVar {
46
50
  osceMarksheetMarkId: Id;
47
51
  mark: number | EPaceMarkType;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.END_VOICE_SESSION = exports.CREATE_VOICE_SESSION = exports.optimisticSetOsceMarksheetFeedback = exports.updateCacheOnSetOsceMarksheetFeedback = exports.SET_OSCE_MARKSHEET_FEEDBACK = exports.updateCacheOnAutoMarkOsceMarksheet = exports.AUTO_MARK_OSCE_MARKSHEET = exports.STREAM_OSCE_CHAT_MESSAGE = exports.LEAVE_OSCE_MARKSHEET = exports.optimisticEndOsceMarksheet = exports.updateCacheOnEndOsceMarksheet = exports.END_OSCE_MARKSHEET = exports.MODIFY_OSCE_MARKSHEET = exports.updateCacheOnSaveOsceMarksheet = exports.SAVE_OSCE_MARKSHEET = exports.PRESTART_OSCE_MARKSHEET = exports.START_OSCE_TIMER = exports.START_OSCE_MARKSHEET = exports.SELECT_OSCE_STATION = exports.updateCacheOnMarkOsceMarksheetMark = exports.optimisticMarkOsceMarksheetMark = exports.MARK_OSCE_MARKSHEET_MARK = exports.CHANGE_OSCE_ROLE = exports.BUILD_OSCE_MARKSHEET = exports.CREATE_OR_JOIN_OSCE_MARKSHEET = exports.CANCEL_OSCE_MATCHMAKING = exports.CHECK_OSCE_MATCHMAKING = exports.ACCEPT_OSCE_MATCHMAKING = exports.START_OSCE_MATCHMAKING = void 0;
3
+ exports.END_VOICE_SESSION = exports.CREATE_VOICE_SESSION = exports.optimisticSetOsceMarksheetFeedback = exports.updateCacheOnSetOsceMarksheetFeedback = exports.SET_OSCE_MARKSHEET_FEEDBACK = exports.updateCacheOnAutoMarkOsceMarksheet = exports.AUTO_MARK_OSCE_MARKSHEET = exports.STREAM_OSCE_CHAT_MESSAGE = exports.LEAVE_OSCE_MARKSHEET = exports.optimisticEndOsceMarksheet = exports.updateCacheOnEndOsceMarksheet = exports.END_OSCE_MARKSHEET = exports.MODIFY_OSCE_MARKSHEET = exports.updateCacheOnSaveOsceMarksheet = exports.SAVE_OSCE_MARKSHEET = exports.PRESTART_OSCE_MARKSHEET = exports.START_OSCE_TIMER = exports.START_OSCE_MARKSHEET = exports.SELECT_OSCE_STATION = exports.updateCacheOnMarkOsceMarksheetMark = exports.optimisticMarkOsceMarksheetMark = exports.getStationScore = exports.MARK_OSCE_MARKSHEET_MARK = exports.CHANGE_OSCE_ROLE = exports.BUILD_OSCE_MARKSHEET = exports.CREATE_OR_JOIN_OSCE_MARKSHEET = exports.CANCEL_OSCE_MATCHMAKING = exports.CHECK_OSCE_MATCHMAKING = exports.ACCEPT_OSCE_MATCHMAKING = exports.START_OSCE_MATCHMAKING = void 0;
4
4
  const client_1 = require("@apollo/client");
5
5
  const models_1 = require("../../../models");
6
6
  const fragments_1 = require("../../fragments");
@@ -101,6 +101,46 @@ exports.MARK_OSCE_MARKSHEET_MARK = (0, client_1.gql) `
101
101
  }
102
102
  }
103
103
  `;
104
+ const getStationScore = (marks) => {
105
+ const MarkMap = {
106
+ 1: 2,
107
+ 2: 1,
108
+ 3: 0,
109
+ };
110
+ if (!marks?.length) {
111
+ return {
112
+ total: 0,
113
+ userScore: 0,
114
+ };
115
+ }
116
+ const { total, userScore } = marks.reduce((acc, mark) => {
117
+ const choices = mark.osceStationMark?.choices;
118
+ const multiplier = mark.secondaryMark ? 2 : 1;
119
+ // Maximum possible score
120
+ acc.total += choices?.length
121
+ ? choices.reduce((sum, choice) => sum + multiplier * choice.score, 0)
122
+ : 1;
123
+ if (choices) {
124
+ // paces product
125
+ acc.userScore += MarkMap[mark.mark] ?? 0;
126
+ if (mark.secondaryMark) {
127
+ acc.userScore += MarkMap[mark.secondaryMark] ?? 0;
128
+ }
129
+ }
130
+ else {
131
+ acc.userScore += mark.mark ? 1 : 0;
132
+ }
133
+ return acc;
134
+ }, {
135
+ total: 0,
136
+ userScore: 0,
137
+ });
138
+ return {
139
+ total,
140
+ userScore,
141
+ };
142
+ };
143
+ exports.getStationScore = getStationScore;
104
144
  const optimisticMarkOsceMarksheetMark = (variables, productType) => {
105
145
  const data = {};
106
146
  if (productType === models_1.EProductType.PACES) {
@@ -169,6 +209,13 @@ const updateCacheOnMarkOsceMarksheetMark = (cache, result, options) => {
169
209
  mark
170
210
  score
171
211
  secondaryMark
212
+ selectedChoice
213
+ osceStationMark {
214
+ id
215
+ choices {
216
+ score
217
+ }
218
+ }
172
219
  }
173
220
  }
174
221
  `,
@@ -176,10 +223,7 @@ const updateCacheOnMarkOsceMarksheetMark = (cache, result, options) => {
176
223
  if (!marksheet?.marks?.length) {
177
224
  return;
178
225
  }
179
- const hasSecondaryMarks = marksheet.marks.some((m) => m.secondaryMark);
180
- const total = hasSecondaryMarks ? 2 * marksheet.marks.length : marksheet.marks.length;
181
- // const scored = marksheet.marks.filter(({ mark }) => Boolean(mark)).length;
182
- const userScore = marksheet.marks.reduce((sum, m) => sum + Number(m.score), 0);
226
+ const { total, userScore } = (0, exports.getStationScore)(marksheet.marks);
183
227
  cache.modify({
184
228
  id: cache.identify({ id: marksheetId, __typename: 'OsceMarksheet' }),
185
229
  fields: {
@@ -368,7 +412,8 @@ const updateCacheOnEndOsceMarksheet = (productType) => (cache, result, options)
368
412
  fields: {
369
413
  secondaryMark: () => mark.secondaryMark,
370
414
  mark: () => mark.mark,
371
- comment: () => mark.comment,
415
+ comment1: () => mark.comment1,
416
+ comment2: () => mark.comment2,
372
417
  suggestion: () => mark.suggestion,
373
418
  },
374
419
  });
@@ -462,7 +507,8 @@ const updateCacheOnAutoMarkOsceMarksheet = (cache, result, options) => {
462
507
  fields: {
463
508
  mark: () => mark.mark,
464
509
  secondaryMark: () => mark.secondaryMark,
465
- comment: () => mark.comment,
510
+ comment1: () => mark.comment1,
511
+ comment2: () => mark.comment2,
466
512
  suggestion: () => mark.suggestion,
467
513
  },
468
514
  });
@@ -19,7 +19,8 @@ export interface IOsceMarksheetMark {
19
19
  id: Id;
20
20
  index: number;
21
21
  mark: number | null;
22
- comment?: string;
22
+ comment1?: string;
23
+ comment2?: string;
23
24
  suggestion?: string;
24
25
  selectedChoice: Nullable<EPaceMarkType>;
25
26
  osceMarksheetId: Id;
@@ -100,7 +100,8 @@ export const OSCE_MARKSHEET_MARK_FIELDS = gql `
100
100
  score
101
101
  secondaryMark
102
102
  selectedChoice
103
- comment
103
+ comment1
104
+ comment2
104
105
  suggestion
105
106
  osceMarksheetId
106
107
  osceStationMarkId
@@ -257,7 +258,8 @@ export const UPSERT_STATION_NOTE_FRAGMENT = gql `
257
258
  export const AUTO_MARKED_OSCE_MARKSHEET_MARK_FIELDS = gql `
258
259
  fragment AutoMarkedOsceMarksheetMarkFields on OsceMarksheetMark {
259
260
  mark
260
- comment
261
+ comment1
262
+ comment2
261
263
  suggestion
262
264
  }
263
265
  `;
@@ -42,6 +42,10 @@ export interface IChangeOsceRoleVar {
42
42
  }
43
43
  export type IChangeOsceRoleData = RestrictedData<graphqlNormalize & IOsceMarksheet, 'changeOsceRole'>;
44
44
  export declare const MARK_OSCE_MARKSHEET_MARK: import("@apollo/client").DocumentNode;
45
+ export declare const getStationScore: (marks: IOsceMarksheetMark[]) => {
46
+ total: number;
47
+ userScore: number;
48
+ };
45
49
  export interface IMarkOsceMarksheetMarkVar {
46
50
  osceMarksheetMarkId: Id;
47
51
  mark: number | EPaceMarkType;
@@ -98,6 +98,45 @@ export const MARK_OSCE_MARKSHEET_MARK = gql `
98
98
  }
99
99
  }
100
100
  `;
101
+ export const getStationScore = (marks) => {
102
+ const MarkMap = {
103
+ 1: 2,
104
+ 2: 1,
105
+ 3: 0,
106
+ };
107
+ if (!marks?.length) {
108
+ return {
109
+ total: 0,
110
+ userScore: 0,
111
+ };
112
+ }
113
+ const { total, userScore } = marks.reduce((acc, mark) => {
114
+ const choices = mark.osceStationMark?.choices;
115
+ const multiplier = mark.secondaryMark ? 2 : 1;
116
+ // Maximum possible score
117
+ acc.total += choices?.length
118
+ ? choices.reduce((sum, choice) => sum + multiplier * choice.score, 0)
119
+ : 1;
120
+ if (choices) {
121
+ // paces product
122
+ acc.userScore += MarkMap[mark.mark] ?? 0;
123
+ if (mark.secondaryMark) {
124
+ acc.userScore += MarkMap[mark.secondaryMark] ?? 0;
125
+ }
126
+ }
127
+ else {
128
+ acc.userScore += mark.mark ? 1 : 0;
129
+ }
130
+ return acc;
131
+ }, {
132
+ total: 0,
133
+ userScore: 0,
134
+ });
135
+ return {
136
+ total,
137
+ userScore,
138
+ };
139
+ };
101
140
  export const optimisticMarkOsceMarksheetMark = (variables, productType) => {
102
141
  const data = {};
103
142
  if (productType === EProductType.PACES) {
@@ -165,6 +204,13 @@ export const updateCacheOnMarkOsceMarksheetMark = (cache, result, options) => {
165
204
  mark
166
205
  score
167
206
  secondaryMark
207
+ selectedChoice
208
+ osceStationMark {
209
+ id
210
+ choices {
211
+ score
212
+ }
213
+ }
168
214
  }
169
215
  }
170
216
  `,
@@ -172,10 +218,7 @@ export const updateCacheOnMarkOsceMarksheetMark = (cache, result, options) => {
172
218
  if (!marksheet?.marks?.length) {
173
219
  return;
174
220
  }
175
- const hasSecondaryMarks = marksheet.marks.some((m) => m.secondaryMark);
176
- const total = hasSecondaryMarks ? 2 * marksheet.marks.length : marksheet.marks.length;
177
- // const scored = marksheet.marks.filter(({ mark }) => Boolean(mark)).length;
178
- const userScore = marksheet.marks.reduce((sum, m) => sum + Number(m.score), 0);
221
+ const { total, userScore } = getStationScore(marksheet.marks);
179
222
  cache.modify({
180
223
  id: cache.identify({ id: marksheetId, __typename: 'OsceMarksheet' }),
181
224
  fields: {
@@ -362,7 +405,8 @@ export const updateCacheOnEndOsceMarksheet = (productType) => (cache, result, op
362
405
  fields: {
363
406
  secondaryMark: () => mark.secondaryMark,
364
407
  mark: () => mark.mark,
365
- comment: () => mark.comment,
408
+ comment1: () => mark.comment1,
409
+ comment2: () => mark.comment2,
366
410
  suggestion: () => mark.suggestion,
367
411
  },
368
412
  });
@@ -454,7 +498,8 @@ export const updateCacheOnAutoMarkOsceMarksheet = (cache, result, options) => {
454
498
  fields: {
455
499
  mark: () => mark.mark,
456
500
  secondaryMark: () => mark.secondaryMark,
457
- comment: () => mark.comment,
501
+ comment1: () => mark.comment1,
502
+ comment2: () => mark.comment2,
458
503
  suggestion: () => mark.suggestion,
459
504
  },
460
505
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types",
3
- "version": "2.6.271",
3
+ "version": "2.6.273",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",