@quesmed/types 1.3.16 → 1.3.21

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.
Files changed (161) hide show
  1. package/gql_input_output_types/User.js +2 -1
  2. package/gql_input_output_types/User.mjs +1 -0
  3. package/gql_input_output_types/index.d.ts +1 -0
  4. package/gql_input_output_types/index.js +2 -1
  5. package/gql_input_output_types/index.mjs +1 -0
  6. package/index.js +7 -4
  7. package/index.mjs +17 -0
  8. package/models/Author.js +2 -1
  9. package/models/Author.mjs +1 -0
  10. package/models/Book.js +2 -1
  11. package/models/Book.mjs +1 -0
  12. package/models/Card.js +2 -1
  13. package/models/Card.mjs +1 -0
  14. package/models/Chapter.js +2 -1
  15. package/models/Chapter.mjs +1 -0
  16. package/models/Concept.js +2 -1
  17. package/models/Concept.mjs +1 -0
  18. package/models/Difficulty.js +5 -2
  19. package/models/Difficulty.mjs +7 -0
  20. package/models/Feedback.js +2 -1
  21. package/models/Feedback.mjs +1 -0
  22. package/models/File.js +2 -1
  23. package/models/File.mjs +1 -0
  24. package/models/Marksheet.js +5 -2
  25. package/models/Marksheet.mjs +6 -0
  26. package/models/MockTest.js +2 -1
  27. package/models/MockTest.mjs +1 -0
  28. package/models/OsceMarksheet.js +7 -4
  29. package/models/OsceMarksheet.mjs +20 -0
  30. package/models/OsceStation.js +6 -3
  31. package/models/OsceStation.mjs +42 -0
  32. package/models/Picture.js +2 -1
  33. package/models/Picture.mjs +5 -0
  34. package/models/Promo.js +2 -1
  35. package/models/Promo.mjs +1 -0
  36. package/models/Question.js +15 -8
  37. package/models/Question.mjs +30 -0
  38. package/models/Subscription.js +5 -2
  39. package/models/Subscription.mjs +6 -0
  40. package/models/Todo.js +2 -1
  41. package/models/Todo.mjs +1 -0
  42. package/models/Token.js +2 -1
  43. package/models/Token.mjs +1 -0
  44. package/models/Topic.js +5 -2
  45. package/models/Topic.mjs +10 -0
  46. package/models/Type.js +2 -1
  47. package/models/Type.mjs +1 -0
  48. package/models/University.js +2 -1
  49. package/models/University.mjs +1 -0
  50. package/models/User.js +2 -1
  51. package/models/User.mjs +1 -0
  52. package/models/Video.js +2 -1
  53. package/models/Video.mjs +1 -0
  54. package/models/index.js +35 -23
  55. package/models/index.mjs +23 -0
  56. package/package.json +6 -3
  57. package/resolvers/apollo.js +2 -1
  58. package/resolvers/apollo.mjs +1 -0
  59. package/resolvers/mutation/admin/algoliaSync.js +2 -1
  60. package/resolvers/mutation/admin/algoliaSync.mjs +1 -0
  61. package/resolvers/mutation/admin/index.js +14 -2
  62. package/resolvers/mutation/admin/index.mjs +2 -0
  63. package/resolvers/mutation/admin/token.js +2 -1
  64. package/resolvers/mutation/admin/token.mjs +1 -0
  65. package/resolvers/mutation/index.js +14 -2
  66. package/resolvers/mutation/index.mjs +2 -0
  67. package/resolvers/mutation/restricted/agora.js +2 -1
  68. package/resolvers/mutation/restricted/agora.mjs +1 -0
  69. package/resolvers/mutation/restricted/contactUs.js +2 -1
  70. package/resolvers/mutation/restricted/contactUs.mjs +1 -0
  71. package/resolvers/mutation/restricted/index.js +22 -10
  72. package/resolvers/mutation/restricted/index.mjs +10 -0
  73. package/resolvers/mutation/restricted/marksheet.js +2 -1
  74. package/resolvers/mutation/restricted/marksheet.mjs +1 -0
  75. package/resolvers/mutation/restricted/mockTest.js +2 -1
  76. package/resolvers/mutation/restricted/mockTest.mjs +1 -0
  77. package/resolvers/mutation/restricted/osce.js +2 -1
  78. package/resolvers/mutation/restricted/osce.mjs +1 -0
  79. package/resolvers/mutation/restricted/questionDiscussion.js +2 -1
  80. package/resolvers/mutation/restricted/questionDiscussion.mjs +1 -0
  81. package/resolvers/mutation/restricted/todo.js +19 -26
  82. package/resolvers/mutation/restricted/todo.mjs +25 -0
  83. package/resolvers/mutation/restricted/token.js +2 -1
  84. package/resolvers/mutation/restricted/token.mjs +1 -0
  85. package/resolvers/mutation/restricted/users.js +2 -1
  86. package/resolvers/mutation/restricted/users.mjs +1 -0
  87. package/resolvers/mutation/restricted/video.js +2 -1
  88. package/resolvers/mutation/restricted/video.mjs +1 -0
  89. package/resolvers/mutation/stripe.js +2 -1
  90. package/resolvers/mutation/stripe.mjs +1 -0
  91. package/resolvers/mutation/users.js +2 -1
  92. package/resolvers/mutation/users.mjs +1 -0
  93. package/resolvers/mutation/validUserToken/index.js +13 -1
  94. package/resolvers/mutation/validUserToken/index.mjs +1 -0
  95. package/resolvers/mutation/validUserToken/user.js +2 -1
  96. package/resolvers/mutation/validUserToken/user.mjs +1 -0
  97. package/resolvers/query/admin/getUserToken.js +2 -1
  98. package/resolvers/query/admin/getUserToken.mjs +1 -0
  99. package/resolvers/query/admin/index.js +13 -1
  100. package/resolvers/query/admin/index.mjs +1 -0
  101. package/resolvers/query/author.js +2 -1
  102. package/resolvers/query/author.mjs +1 -0
  103. package/resolvers/query/book.js +2 -1
  104. package/resolvers/query/book.mjs +1 -0
  105. package/resolvers/query/feedback.js +2 -1
  106. package/resolvers/query/feedback.mjs +1 -0
  107. package/resolvers/query/index.js +21 -9
  108. package/resolvers/query/index.mjs +9 -0
  109. package/resolvers/query/restricted/anatomy.js +2 -1
  110. package/resolvers/query/restricted/anatomy.mjs +1 -0
  111. package/resolvers/query/restricted/index.js +22 -10
  112. package/resolvers/query/restricted/index.mjs +10 -0
  113. package/resolvers/query/restricted/marksheet.js +2 -1
  114. package/resolvers/query/restricted/marksheet.mjs +1 -0
  115. package/resolvers/query/restricted/mockTests.js +2 -1
  116. package/resolvers/query/restricted/mockTests.mjs +1 -0
  117. package/resolvers/query/restricted/osce.js +2 -1
  118. package/resolvers/query/restricted/osce.mjs +1 -0
  119. package/resolvers/query/restricted/quesBook.js +2 -1
  120. package/resolvers/query/restricted/quesBook.mjs +1 -0
  121. package/resolvers/query/restricted/todos.js +2 -1
  122. package/resolvers/query/restricted/todos.mjs +1 -0
  123. package/resolvers/query/restricted/topics.js +2 -1
  124. package/resolvers/query/restricted/topics.mjs +1 -0
  125. package/resolvers/query/restricted/university.js +2 -1
  126. package/resolvers/query/restricted/university.mjs +1 -0
  127. package/resolvers/query/restricted/user.js +2 -1
  128. package/resolvers/query/restricted/user.mjs +1 -0
  129. package/resolvers/query/restricted/video.js +2 -1
  130. package/resolvers/query/restricted/video.mjs +1 -0
  131. package/resolvers/query/sampleCards.js +2 -1
  132. package/resolvers/query/sampleCards.mjs +1 -0
  133. package/resolvers/query/sampleQuestions.js +2 -1
  134. package/resolvers/query/sampleQuestions.mjs +1 -0
  135. package/resolvers/query/subscription.js +2 -1
  136. package/resolvers/query/subscription.mjs +1 -0
  137. package/resolvers/query/university.js +2 -1
  138. package/resolvers/query/university.mjs +1 -0
  139. package/resolvers/query/user.js +2 -1
  140. package/resolvers/query/user.mjs +1 -0
  141. package/resolvers/query/video.js +2 -1
  142. package/resolvers/query/video.mjs +1 -0
  143. package/resolvers/subscription/index.js +13 -1
  144. package/resolvers/subscription/index.mjs +1 -0
  145. package/resolvers/subscription/osce.d.ts +2 -1
  146. package/resolvers/subscription/osce.js +14 -10
  147. package/resolvers/subscription/osce.mjs +39 -0
  148. package/utils/commonFunctions.js +17 -11
  149. package/utils/commonFunctions.mjs +217 -0
  150. package/utils/index.d.ts +5 -0
  151. package/utils/index.js +17 -0
  152. package/utils/index.mjs +5 -0
  153. package/utils/lightgallery.js +9 -2
  154. package/utils/lightgallery.mjs +87 -0
  155. package/utils/offlineLink.d.ts +64 -0
  156. package/utils/offlineLink.js +237 -0
  157. package/utils/offlineLink.mjs +230 -0
  158. package/utils/uuid4.js +3 -1
  159. package/utils/uuid4.mjs +285 -0
  160. package/utils/wordsToNumber.js +5 -1
  161. package/utils/wordsToNumber.mjs +44 -0
@@ -40,7 +40,8 @@ export interface IOsceMatchmakingAction {
40
40
  classYear: IClassYear;
41
41
  lastSyncAt: number;
42
42
  startedAt: number;
43
- complete: boolean;
43
+ grouped: boolean;
44
+ completed: boolean;
44
45
  }
45
46
  export interface IOsceMatchmakingData extends IOsceMatchmakingAction {
46
47
  }
@@ -1,16 +1,19 @@
1
- import { EOsceRoles, } from '../../models';
2
- export const ROLE_CHANGED = 'ROLE_CHANGED';
3
- export const OSCE_MARKSHEET_ACTION = 'OSCE_MARKSHEET_ACTION';
4
- export const OSCE_MATCHMAKING = 'OSCE_MATCHMAKING';
5
- export const OSCE_MATCHMAKING_USERS = 'OSCE_MATCHMAKING_USERS';
6
- export const OsceGroupInit = (osceMarksheetId) => [
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OsceGroupInit = exports.OSCE_MATCHMAKING_USERS = exports.OSCE_MATCHMAKING = exports.OSCE_MARKSHEET_ACTION = exports.ROLE_CHANGED = void 0;
4
+ const models_1 = require("../../models");
5
+ exports.ROLE_CHANGED = 'ROLE_CHANGED';
6
+ exports.OSCE_MARKSHEET_ACTION = 'OSCE_MARKSHEET_ACTION';
7
+ exports.OSCE_MATCHMAKING = 'OSCE_MATCHMAKING';
8
+ exports.OSCE_MATCHMAKING_USERS = 'OSCE_MATCHMAKING_USERS';
9
+ const OsceGroupInit = (osceMarksheetId) => [
7
10
  {
8
11
  id: null,
9
12
  createdAt: null,
10
13
  osceMarksheetId,
11
14
  userId: null,
12
15
  user: null,
13
- role: EOsceRoles.CANDIDATE,
16
+ role: models_1.EOsceRoles.CANDIDATE,
14
17
  },
15
18
  {
16
19
  id: null,
@@ -18,7 +21,7 @@ export const OsceGroupInit = (osceMarksheetId) => [
18
21
  osceMarksheetId,
19
22
  userId: null,
20
23
  user: null,
21
- role: EOsceRoles.EXAMINER,
24
+ role: models_1.EOsceRoles.EXAMINER,
22
25
  },
23
26
  {
24
27
  id: null,
@@ -26,7 +29,7 @@ export const OsceGroupInit = (osceMarksheetId) => [
26
29
  osceMarksheetId,
27
30
  userId: null,
28
31
  user: null,
29
- role: EOsceRoles.ACTOR,
32
+ role: models_1.EOsceRoles.ACTOR,
30
33
  },
31
34
  {
32
35
  id: null,
@@ -34,6 +37,7 @@ export const OsceGroupInit = (osceMarksheetId) => [
34
37
  osceMarksheetId,
35
38
  userId: null,
36
39
  user: null,
37
- role: EOsceRoles.OBSERVER,
40
+ role: models_1.EOsceRoles.OBSERVER,
38
41
  },
39
42
  ];
43
+ exports.OsceGroupInit = OsceGroupInit;
@@ -0,0 +1,39 @@
1
+ import { EOsceRoles, } from '../../models';
2
+ export const ROLE_CHANGED = 'ROLE_CHANGED';
3
+ export const OSCE_MARKSHEET_ACTION = 'OSCE_MARKSHEET_ACTION';
4
+ export const OSCE_MATCHMAKING = 'OSCE_MATCHMAKING';
5
+ export const OSCE_MATCHMAKING_USERS = 'OSCE_MATCHMAKING_USERS';
6
+ export const OsceGroupInit = (osceMarksheetId) => [
7
+ {
8
+ id: null,
9
+ createdAt: null,
10
+ osceMarksheetId,
11
+ userId: null,
12
+ user: null,
13
+ role: EOsceRoles.CANDIDATE,
14
+ },
15
+ {
16
+ id: null,
17
+ createdAt: null,
18
+ osceMarksheetId,
19
+ userId: null,
20
+ user: null,
21
+ role: EOsceRoles.EXAMINER,
22
+ },
23
+ {
24
+ id: null,
25
+ createdAt: null,
26
+ osceMarksheetId,
27
+ userId: null,
28
+ user: null,
29
+ role: EOsceRoles.ACTOR,
30
+ },
31
+ {
32
+ id: null,
33
+ createdAt: null,
34
+ osceMarksheetId,
35
+ userId: null,
36
+ user: null,
37
+ role: EOsceRoles.OBSERVER,
38
+ },
39
+ ];
@@ -1,8 +1,11 @@
1
- import { EQuestionType, } from '../models';
2
- import { wordsToNumber } from './wordsToNumber';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.correctMark = exports.formatPrescribeAnswer = exports.mapPrescribeMarkToAnswer = void 0;
4
+ const models_1 = require("../models");
5
+ const wordsToNumber_1 = require("./wordsToNumber");
3
6
  const floatRegex = /([0-9]*[.])?[0-9]+/gm;
4
7
  const ACCEPTED_FREQ = ['stat', 'od', 'bd', 'tds', 'qds'];
5
- export function mapPrescribeMarkToAnswer(obj) {
8
+ function mapPrescribeMarkToAnswer(obj) {
6
9
  return {
7
10
  drug: {
8
11
  value: obj.drug,
@@ -30,7 +33,8 @@ export function mapPrescribeMarkToAnswer(obj) {
30
33
  },
31
34
  };
32
35
  }
33
- export function formatPrescribeAnswer(obj) {
36
+ exports.mapPrescribeMarkToAnswer = mapPrescribeMarkToAnswer;
37
+ function formatPrescribeAnswer(obj) {
34
38
  obj.drug.value = obj.drug.value.toLowerCase().replace(/\s/g, '');
35
39
  obj.route.value = obj.route.value.toLowerCase().replace(/\s/g, '');
36
40
  if (obj.route.value === 'oral') {
@@ -75,7 +79,7 @@ export function formatPrescribeAnswer(obj) {
75
79
  }
76
80
  m.forEach((match) => durationMatches.add(match));
77
81
  }
78
- const durationWords = wordsToNumber(obj.duration.value, false);
82
+ const durationWords = (0, wordsToNumber_1.wordsToNumber)(obj.duration.value, false);
79
83
  if (durationWords !== 0) {
80
84
  durationMatches.add(durationWords.toString());
81
85
  }
@@ -104,12 +108,13 @@ export function formatPrescribeAnswer(obj) {
104
108
  obj.frequency.value = 'qds';
105
109
  }
106
110
  else if (!ACCEPTED_FREQ.includes(obj.frequency.value)) {
107
- obj.frequency.value = wordsToNumber(orgFrequencyValue, true).toString();
111
+ obj.frequency.value = (0, wordsToNumber_1.wordsToNumber)(orgFrequencyValue, true).toString();
108
112
  }
109
113
  return obj;
110
114
  }
115
+ exports.formatPrescribeAnswer = formatPrescribeAnswer;
111
116
  const answerRegex = /answer/gi;
112
- export function correctMark(mark) {
117
+ function correctMark(mark) {
113
118
  const data = {
114
119
  correct: false,
115
120
  incorrect: false,
@@ -124,7 +129,7 @@ export function correctMark(mark) {
124
129
  const answer = mark.question[answerKey];
125
130
  const flatAnswer = answer[0];
126
131
  const flatAttempt = mark.mark[0];
127
- if (EQuestionType.SINGLE_BEST_ANSWER === mark.question.typeId) {
132
+ if (models_1.EQuestionType.SINGLE_BEST_ANSWER === mark.question.typeId) {
128
133
  const answer = flatAnswer;
129
134
  const attempt = flatAttempt;
130
135
  if (answer === attempt) {
@@ -134,7 +139,7 @@ export function correctMark(mark) {
134
139
  data.incorrect = true;
135
140
  }
136
141
  }
137
- else if (EQuestionType.QUESTION_ANSWER === mark.question.typeId) {
142
+ else if (models_1.EQuestionType.QUESTION_ANSWER === mark.question.typeId) {
138
143
  const answer = flatAnswer.dose.toLowerCase().replace(/\s/g, '');
139
144
  let attempt = '';
140
145
  if (flatAttempt) {
@@ -147,7 +152,7 @@ export function correctMark(mark) {
147
152
  data.incorrect = true;
148
153
  }
149
154
  }
150
- else if (EQuestionType.MULTIPLE_ANSWERS === mark.question.typeId) {
155
+ else if (models_1.EQuestionType.MULTIPLE_ANSWERS === mark.question.typeId) {
151
156
  const [answerA, answerB] = answer.map((x) => x.sort());
152
157
  let [attemptA, attemptB] = [[], []];
153
158
  if (Array.isArray(mark.mark) &&
@@ -167,7 +172,7 @@ export function correctMark(mark) {
167
172
  data.incorrect = true;
168
173
  }
169
174
  }
170
- else if (EQuestionType.PRESCRIPTION_ANSWER === mark.question.typeId) {
175
+ else if (models_1.EQuestionType.PRESCRIPTION_ANSWER === mark.question.typeId) {
171
176
  const answers = answer.map(formatPrescribeAnswer);
172
177
  let attempt = formatPrescribeAnswer(mapPrescribeMarkToAnswer({
173
178
  drug: '',
@@ -215,3 +220,4 @@ export function correctMark(mark) {
215
220
  }
216
221
  return data;
217
222
  }
223
+ exports.correctMark = correctMark;
@@ -0,0 +1,217 @@
1
+ import { EQuestionType, } from '../models';
2
+ import { wordsToNumber } from './wordsToNumber';
3
+ const floatRegex = /([0-9]*[.])?[0-9]+/gm;
4
+ const ACCEPTED_FREQ = ['stat', 'od', 'bd', 'tds', 'qds'];
5
+ export function mapPrescribeMarkToAnswer(obj) {
6
+ return {
7
+ drug: {
8
+ value: obj.drug,
9
+ display: false,
10
+ },
11
+ dose: {
12
+ value: parseFloat(obj.dose),
13
+ display: false,
14
+ },
15
+ units: {
16
+ value: obj.units,
17
+ display: false,
18
+ },
19
+ route: {
20
+ value: obj.route,
21
+ display: false,
22
+ },
23
+ frequency: {
24
+ value: obj.frequency,
25
+ display: false,
26
+ },
27
+ duration: {
28
+ value: obj.duration,
29
+ display: false,
30
+ },
31
+ };
32
+ }
33
+ export function formatPrescribeAnswer(obj) {
34
+ obj.drug.value = obj.drug.value.toLowerCase().replace(/\s/g, '');
35
+ obj.route.value = obj.route.value.toLowerCase().replace(/\s/g, '');
36
+ if (obj.route.value === 'oral') {
37
+ obj.route.value = 'po';
38
+ }
39
+ else if (obj.route.value.includes('intravenous')) {
40
+ obj.route.value = 'iv';
41
+ }
42
+ else if (obj.route.value.includes('intramuscular')) {
43
+ obj.route.value = 'im';
44
+ }
45
+ else if (obj.route.value.includes('subcutaneous')) {
46
+ obj.route.value = 'sc';
47
+ }
48
+ else if (obj.route.value.includes('inhale')) {
49
+ obj.route.value = 'inh';
50
+ }
51
+ else if (obj.route.value.includes('nebuli')) {
52
+ obj.route.value = 'neb';
53
+ }
54
+ else if (obj.route.value.includes('topical')) {
55
+ obj.route.value = 'top';
56
+ }
57
+ obj.units.value = obj.units.value.toLowerCase().replace(/\s/g, '');
58
+ if (obj.units.value === 'milligram' || obj.units.value === 'milligrams') {
59
+ obj.units.value = 'mg';
60
+ }
61
+ else if (obj.units.value === 'microgram' || obj.units.value === 'micrograms') {
62
+ obj.units.value = 'mcg';
63
+ }
64
+ else if (obj.units.value === 'gram' || obj.units.value === 'grams') {
65
+ obj.units.value = 'g';
66
+ }
67
+ else if (obj.units.value === 'unit') {
68
+ obj.units.value = 'units';
69
+ }
70
+ let m;
71
+ const durationMatches = new Set();
72
+ while ((m = floatRegex.exec(obj.duration.value)) !== null) {
73
+ if (m.index === floatRegex.lastIndex) {
74
+ floatRegex.lastIndex++;
75
+ }
76
+ m.forEach((match) => durationMatches.add(match));
77
+ }
78
+ const durationWords = wordsToNumber(obj.duration.value, false);
79
+ if (durationWords !== 0) {
80
+ durationMatches.add(durationWords.toString());
81
+ }
82
+ obj.duration.value = [...durationMatches].filter((x) => !!x).join(',');
83
+ const orgFrequencyValue = obj.frequency.value.toLowerCase();
84
+ obj.frequency.value = orgFrequencyValue.replace(/\s/g, '');
85
+ const frequencyIncHourly = obj.frequency.value.includes('hour');
86
+ const hourlyFreqInt = parseInt(obj.frequency.value);
87
+ if (obj.frequency.value === 'once-off') {
88
+ obj.frequency.value = 'stat';
89
+ }
90
+ else if (obj.frequency.value.includes('once') || (frequencyIncHourly && hourlyFreqInt === 24)) {
91
+ obj.frequency.value = 'od';
92
+ }
93
+ else if (obj.frequency.value.includes('nightly') || obj.frequency.value === 'on') {
94
+ obj.frequency.value = 'od';
95
+ }
96
+ else if (obj.frequency.value.includes('twice') ||
97
+ (frequencyIncHourly && hourlyFreqInt === 12)) {
98
+ obj.frequency.value = 'bd';
99
+ }
100
+ else if (obj.frequency.value.includes('trice') || (frequencyIncHourly && hourlyFreqInt === 8)) {
101
+ obj.frequency.value = 'tds';
102
+ }
103
+ else if (frequencyIncHourly && hourlyFreqInt === 6) {
104
+ obj.frequency.value = 'qds';
105
+ }
106
+ else if (!ACCEPTED_FREQ.includes(obj.frequency.value)) {
107
+ obj.frequency.value = wordsToNumber(orgFrequencyValue, true).toString();
108
+ }
109
+ return obj;
110
+ }
111
+ const answerRegex = /answer/gi;
112
+ export function correctMark(mark) {
113
+ const data = {
114
+ correct: false,
115
+ incorrect: false,
116
+ correctIndex: -1,
117
+ };
118
+ if (!mark || !mark.mark) {
119
+ return data;
120
+ }
121
+ try {
122
+ const qKeys = Object.keys(mark.question);
123
+ const answerKey = qKeys.find((k) => answerRegex.exec(k)) || 'answer';
124
+ const answer = mark.question[answerKey];
125
+ const flatAnswer = answer[0];
126
+ const flatAttempt = mark.mark[0];
127
+ if (EQuestionType.SINGLE_BEST_ANSWER === mark.question.typeId) {
128
+ const answer = flatAnswer;
129
+ const attempt = flatAttempt;
130
+ if (answer === attempt) {
131
+ data.correct = true;
132
+ }
133
+ else {
134
+ data.incorrect = true;
135
+ }
136
+ }
137
+ else if (EQuestionType.QUESTION_ANSWER === mark.question.typeId) {
138
+ const answer = flatAnswer.dose.toLowerCase().replace(/\s/g, '');
139
+ let attempt = '';
140
+ if (flatAttempt) {
141
+ attempt = flatAttempt.toLowerCase().replace(/\s/g, '');
142
+ }
143
+ if (answer === attempt) {
144
+ data.correct = true;
145
+ }
146
+ else {
147
+ data.incorrect = true;
148
+ }
149
+ }
150
+ else if (EQuestionType.MULTIPLE_ANSWERS === mark.question.typeId) {
151
+ const [answerA, answerB] = answer.map((x) => x.sort());
152
+ let [attemptA, attemptB] = [[], []];
153
+ if (Array.isArray(mark.mark) &&
154
+ mark.mark.length === 2 &&
155
+ Array.isArray(mark.mark[0]) &&
156
+ Array.isArray(mark.mark[1])) {
157
+ [attemptA, attemptB] = mark.mark.map((x) => x.sort());
158
+ }
159
+ if (answerA.length !== attemptA.length || answerB.length !== attemptB.length) {
160
+ data.incorrect = true;
161
+ }
162
+ else if (attemptA.every((x, i) => x === answerA[i]) &&
163
+ attemptB.every((x, i) => x === answerB[i])) {
164
+ data.correct = true;
165
+ }
166
+ else {
167
+ data.incorrect = true;
168
+ }
169
+ }
170
+ else if (EQuestionType.PRESCRIPTION_ANSWER === mark.question.typeId) {
171
+ const answers = answer.map(formatPrescribeAnswer);
172
+ let attempt = formatPrescribeAnswer(mapPrescribeMarkToAnswer({
173
+ drug: '',
174
+ dose: -1,
175
+ units: '',
176
+ route: '',
177
+ frequency: '',
178
+ duration: '',
179
+ }));
180
+ if (typeof flatAttempt === 'object' && Object.keys(flatAttempt).length === 6) {
181
+ attempt = formatPrescribeAnswer(mapPrescribeMarkToAnswer(flatAttempt));
182
+ }
183
+ let foundCorrect = false;
184
+ let index = 0;
185
+ for (const answer of answers) {
186
+ const doseCorrect = answer.dose.display || answer.dose.value === attempt.dose.value;
187
+ const drugCorrect = answer.drug.display || answer.drug.value === attempt.drug.value;
188
+ const durationCorrect = answer.duration.display ||
189
+ answer.duration.value.split(',').includes(attempt.duration.value);
190
+ const frequencyCorrect = answer.frequency.display || answer.frequency.value === attempt.frequency.value;
191
+ const routeCorrect = answer.route.display || answer.route.value === attempt.route.value;
192
+ const unitsCorrect = answer.units.display || answer.units.value === attempt.units.value;
193
+ if (doseCorrect &&
194
+ drugCorrect &&
195
+ durationCorrect &&
196
+ frequencyCorrect &&
197
+ routeCorrect &&
198
+ unitsCorrect) {
199
+ foundCorrect = true;
200
+ break;
201
+ }
202
+ index++;
203
+ }
204
+ if (foundCorrect) {
205
+ data.correct = true;
206
+ data.correctIndex = index;
207
+ }
208
+ else {
209
+ data.incorrect = true;
210
+ }
211
+ }
212
+ }
213
+ catch (e) {
214
+ console.error(e);
215
+ }
216
+ return data;
217
+ }
@@ -0,0 +1,5 @@
1
+ export * from './commonFunctions';
2
+ export * from './lightgallery';
3
+ export * from './offlineLink';
4
+ export * from './uuid4';
5
+ export * from './wordsToNumber';
package/utils/index.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./commonFunctions"), exports);
14
+ __exportStar(require("./lightgallery"), exports);
15
+ __exportStar(require("./offlineLink"), exports);
16
+ __exportStar(require("./uuid4"), exports);
17
+ __exportStar(require("./wordsToNumber"), exports);
@@ -0,0 +1,5 @@
1
+ export * from './commonFunctions';
2
+ export * from './lightgallery';
3
+ export * from './offlineLink';
4
+ export * from './uuid4';
5
+ export * from './wordsToNumber';
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -7,11 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
9
  });
9
10
  };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.lightgalleryOsceResolve = void 0;
10
13
  const lightgalleryRegex = /\[lightgallery\]/;
11
14
  function isOsceMarksheet(data) {
12
15
  return 'osceStationId' in data;
13
16
  }
14
- export function lightgalleryOsceResolve(data, cache) {
17
+ function lightgalleryOsceResolve(data, cache) {
15
18
  return __awaiter(this, void 0, void 0, function* () {
16
19
  let station;
17
20
  if (isOsceMarksheet(data)) {
@@ -49,6 +52,7 @@ export function lightgalleryOsceResolve(data, cache) {
49
52
  }
50
53
  });
51
54
  }
55
+ exports.lightgalleryOsceResolve = lightgalleryOsceResolve;
52
56
  const lightgalleryMutation = (text, pictures, cache) => __awaiter(void 0, void 0, void 0, function* () {
53
57
  var _a;
54
58
  if (pictures.length === 0) {
@@ -63,7 +67,10 @@ const lightgalleryMutation = (text, pictures, cache) => __awaiter(void 0, void 0
63
67
  try {
64
68
  const localPath = yield cache.CacheManager.get(uri, {}).getPath();
65
69
  if (localPath) {
66
- file = cache.Platform.OS === 'ios' ? localPath.replace('file://', '') : localPath;
70
+ file =
71
+ cache.Platform.OS === 'ios'
72
+ ? localPath.replace('file://', '')
73
+ : localPath;
67
74
  }
68
75
  }
69
76
  catch (e) {
@@ -0,0 +1,87 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ const lightgalleryRegex = /\[lightgallery\]/;
11
+ function isOsceMarksheet(data) {
12
+ return 'osceStationId' in data;
13
+ }
14
+ export function lightgalleryOsceResolve(data, cache) {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ let station;
17
+ if (isOsceMarksheet(data)) {
18
+ if (!data.osceStation) {
19
+ throw new Error('OsceStation not found on OsceMarksheet');
20
+ }
21
+ station = data.osceStation;
22
+ }
23
+ else {
24
+ station = data;
25
+ }
26
+ const upOsceStation = {
27
+ candidateBrief: station.candidateBrief,
28
+ actorBrief: station.actorBrief,
29
+ examinerBrief: station.examinerBrief,
30
+ explanation: station.explanation,
31
+ };
32
+ if (station.candidatePictures && station.candidatePictures.length > 0) {
33
+ upOsceStation.candidateBrief = yield lightgalleryMutation(upOsceStation.candidateBrief, station.candidatePictures, cache);
34
+ }
35
+ if (station.actorPictures && station.actorPictures.length > 0) {
36
+ upOsceStation.actorBrief = yield lightgalleryMutation(upOsceStation.actorBrief, station.actorPictures, cache);
37
+ }
38
+ if (station.examinerPictures && station.examinerPictures.length > 0) {
39
+ upOsceStation.examinerBrief = yield lightgalleryMutation(upOsceStation.examinerBrief, station.examinerPictures, cache);
40
+ }
41
+ if (station.walkthroughPictures && station.walkthroughPictures.length > 0) {
42
+ upOsceStation.explanation = yield lightgalleryMutation(upOsceStation.explanation, station.walkthroughPictures, cache);
43
+ }
44
+ if (isOsceMarksheet(data)) {
45
+ return Object.assign(Object.assign({}, data), { osceStation: Object.assign(Object.assign({}, data.osceStation), upOsceStation) });
46
+ }
47
+ else {
48
+ return Object.assign(Object.assign({}, data), upOsceStation);
49
+ }
50
+ });
51
+ }
52
+ const lightgalleryMutation = (text, pictures, cache) => __awaiter(void 0, void 0, void 0, function* () {
53
+ var _a;
54
+ if (pictures.length === 0) {
55
+ return text;
56
+ }
57
+ const picturesHTML = [];
58
+ for (const { picture } of pictures) {
59
+ const pic = picture.path;
60
+ const uri = `https://app.quesmed.com/${pic}`;
61
+ let file = '';
62
+ if (cache) {
63
+ try {
64
+ const localPath = yield cache.CacheManager.get(uri, {}).getPath();
65
+ if (localPath) {
66
+ file =
67
+ cache.Platform.OS === 'ios'
68
+ ? localPath.replace('file://', '')
69
+ : localPath;
70
+ }
71
+ }
72
+ catch (e) {
73
+ console.error(e);
74
+ }
75
+ }
76
+ if (((_a = picture.caption) === null || _a === void 0 ? void 0 : _a.length) > 0) {
77
+ picturesHTML.push(`![${file}](${uri} "${picture.caption}")`);
78
+ }
79
+ picturesHTML.push(`![${file}](${uri})`);
80
+ }
81
+ if (lightgalleryRegex.test(text)) {
82
+ return text.replace(lightgalleryRegex, picturesHTML[0]);
83
+ }
84
+ else {
85
+ return text + '\n\n' + picturesHTML[0] + '\n';
86
+ }
87
+ });
@@ -0,0 +1,64 @@
1
+ /// <reference types="node" />
2
+ import { ApolloClient, ApolloLink, MutationOptions, NextLink, Observable, Operation } from '@apollo/client';
3
+ import AsyncStorage from '@react-native-async-storage/async-storage';
4
+ import Localforage from 'localforage';
5
+ export interface IOfflineLinkParam {
6
+ storage: typeof Localforage | typeof AsyncStorage;
7
+ retryInterval?: number;
8
+ sequential?: boolean;
9
+ retryOnServerError?: boolean;
10
+ }
11
+ export declare class OfflineLink extends ApolloLink {
12
+ storage: typeof Localforage | typeof AsyncStorage;
13
+ retryInterval: number;
14
+ sequential: boolean;
15
+ retryOnServerError: boolean;
16
+ queue: Map<string, MutationOptions>;
17
+ prefix: string;
18
+ client?: ApolloClient<any>;
19
+ timeoutId?: NodeJS.Timeout;
20
+ /**
21
+ * storage
22
+ * Provider that will persist the mutation queue. This can be any AsyncStorage compatible storage instance.
23
+ *
24
+ * retryInterval
25
+ * Milliseconds between attempts to retry failed mutations. Defaults to 0, which disables automatic retry.
26
+ *
27
+ * sequential
28
+ * Indicates if the attempts should be retried in order. Defaults to false which retries all failed mutations in parallel.
29
+ *
30
+ * retryOnServerError
31
+ * Indicates if mutations should be reattempted if there are server side errors, useful to retry mutations on session expiration. Defaults to false.
32
+ */
33
+ constructor({ storage, retryInterval, sequential, retryOnServerError, }: IOfflineLinkParam);
34
+ request(operation: Operation, forward: NextLink): Observable<any>;
35
+ /**
36
+ * Obtains the queue of mutations that must be sent to the server.
37
+ * These are kept in a Map to preserve the order of the mutations in the queue.
38
+ */
39
+ getQueue(): Promise<Map<any, any>>;
40
+ /**
41
+ * Persist the queue so mutations can be retried at a later point in time.
42
+ */
43
+ private saveQueue;
44
+ /**
45
+ * Add a mutation attempt to the queue so that it can be retried at a later point in time.
46
+ */
47
+ private add;
48
+ /**
49
+ * Remove a mutation attempt from the queue.
50
+ */
51
+ private remove;
52
+ /**
53
+ * Takes the mutations in the queue and try to send them to the server again.
54
+ */
55
+ sync(): Promise<void>;
56
+ /**
57
+ * Runs sync() after the retryInterval
58
+ */
59
+ private delayedSync;
60
+ /**
61
+ * Configure the link to use Apollo Client and immediately try to sync the queue (if there's anything there).
62
+ */
63
+ setup(client: ApolloClient<any>): Promise<void>;
64
+ }