@quesmed/types 1.3.17 → 1.4.0

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 (186) 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 +4 -2
  57. package/resolvers/apollo.js +2 -1
  58. package/resolvers/apollo.mjs +1 -0
  59. package/resolvers/fragments/chapter.d.ts +2 -0
  60. package/resolvers/fragments/chapter.js +31 -0
  61. package/resolvers/fragments/chapter.mjs +28 -0
  62. package/resolvers/fragments/concept.d.ts +3 -0
  63. package/resolvers/fragments/concept.js +79 -0
  64. package/resolvers/fragments/concept.mjs +76 -0
  65. package/resolvers/fragments/osce.d.ts +10 -0
  66. package/resolvers/fragments/osce.js +171 -0
  67. package/resolvers/fragments/osce.mjs +168 -0
  68. package/resolvers/fragments/picture.d.ts +3 -0
  69. package/resolvers/fragments/picture.js +44 -0
  70. package/resolvers/fragments/picture.mjs +41 -0
  71. package/resolvers/fragments/user.d.ts +1 -0
  72. package/resolvers/fragments/user.js +26 -0
  73. package/resolvers/fragments/user.mjs +23 -0
  74. package/resolvers/fragments/video.d.ts +2 -0
  75. package/resolvers/fragments/video.js +49 -0
  76. package/resolvers/fragments/video.mjs +46 -0
  77. package/resolvers/mutation/admin/algoliaSync.js +2 -1
  78. package/resolvers/mutation/admin/algoliaSync.mjs +1 -0
  79. package/resolvers/mutation/admin/index.js +14 -2
  80. package/resolvers/mutation/admin/index.mjs +2 -0
  81. package/resolvers/mutation/admin/token.js +2 -1
  82. package/resolvers/mutation/admin/token.mjs +1 -0
  83. package/resolvers/mutation/index.js +14 -2
  84. package/resolvers/mutation/index.mjs +2 -0
  85. package/resolvers/mutation/restricted/agora.js +2 -1
  86. package/resolvers/mutation/restricted/agora.mjs +1 -0
  87. package/resolvers/mutation/restricted/contactUs.js +2 -1
  88. package/resolvers/mutation/restricted/contactUs.mjs +1 -0
  89. package/resolvers/mutation/restricted/index.js +22 -10
  90. package/resolvers/mutation/restricted/index.mjs +10 -0
  91. package/resolvers/mutation/restricted/marksheet.js +2 -1
  92. package/resolvers/mutation/restricted/marksheet.mjs +1 -0
  93. package/resolvers/mutation/restricted/mockTest.js +2 -1
  94. package/resolvers/mutation/restricted/mockTest.mjs +1 -0
  95. package/resolvers/mutation/restricted/osce.d.ts +36 -8
  96. package/resolvers/mutation/restricted/osce.js +202 -1
  97. package/resolvers/mutation/restricted/osce.mjs +198 -0
  98. package/resolvers/mutation/restricted/questionDiscussion.js +2 -1
  99. package/resolvers/mutation/restricted/questionDiscussion.mjs +1 -0
  100. package/resolvers/mutation/restricted/todo.js +7 -3
  101. package/resolvers/mutation/restricted/todo.mjs +25 -0
  102. package/resolvers/mutation/restricted/token.js +2 -1
  103. package/resolvers/mutation/restricted/token.mjs +1 -0
  104. package/resolvers/mutation/restricted/users.js +2 -1
  105. package/resolvers/mutation/restricted/users.mjs +1 -0
  106. package/resolvers/mutation/restricted/video.js +2 -1
  107. package/resolvers/mutation/restricted/video.mjs +1 -0
  108. package/resolvers/mutation/stripe.js +2 -1
  109. package/resolvers/mutation/stripe.mjs +1 -0
  110. package/resolvers/mutation/users.js +2 -1
  111. package/resolvers/mutation/users.mjs +1 -0
  112. package/resolvers/mutation/validUserToken/index.js +13 -1
  113. package/resolvers/mutation/validUserToken/index.mjs +1 -0
  114. package/resolvers/mutation/validUserToken/user.js +2 -1
  115. package/resolvers/mutation/validUserToken/user.mjs +1 -0
  116. package/resolvers/query/admin/getUserToken.js +2 -1
  117. package/resolvers/query/admin/getUserToken.mjs +1 -0
  118. package/resolvers/query/admin/index.js +13 -1
  119. package/resolvers/query/admin/index.mjs +1 -0
  120. package/resolvers/query/author.js +2 -1
  121. package/resolvers/query/author.mjs +1 -0
  122. package/resolvers/query/book.js +2 -1
  123. package/resolvers/query/book.mjs +1 -0
  124. package/resolvers/query/feedback.js +2 -1
  125. package/resolvers/query/feedback.mjs +1 -0
  126. package/resolvers/query/index.js +21 -9
  127. package/resolvers/query/index.mjs +9 -0
  128. package/resolvers/query/restricted/anatomy.js +2 -1
  129. package/resolvers/query/restricted/anatomy.mjs +1 -0
  130. package/resolvers/query/restricted/index.d.ts +1 -0
  131. package/resolvers/query/restricted/index.js +23 -10
  132. package/resolvers/query/restricted/index.mjs +11 -0
  133. package/resolvers/query/restricted/marksheet.js +2 -1
  134. package/resolvers/query/restricted/marksheet.mjs +1 -0
  135. package/resolvers/query/restricted/mockTests.js +2 -1
  136. package/resolvers/query/restricted/mockTests.mjs +1 -0
  137. package/resolvers/query/restricted/osce.d.ts +20 -12
  138. package/resolvers/query/restricted/osce.js +93 -1
  139. package/resolvers/query/restricted/osce.mjs +90 -0
  140. package/resolvers/query/restricted/quesBook.d.ts +1 -0
  141. package/resolvers/query/restricted/quesBook.js +15 -1
  142. package/resolvers/query/restricted/quesBook.mjs +12 -0
  143. package/resolvers/query/restricted/replication.d.ts +33 -0
  144. package/resolvers/query/restricted/replication.js +184 -0
  145. package/resolvers/query/restricted/replication.mjs +178 -0
  146. package/resolvers/query/restricted/todos.js +2 -1
  147. package/resolvers/query/restricted/todos.mjs +1 -0
  148. package/resolvers/query/restricted/topics.js +2 -1
  149. package/resolvers/query/restricted/topics.mjs +1 -0
  150. package/resolvers/query/restricted/university.js +2 -1
  151. package/resolvers/query/restricted/university.mjs +1 -0
  152. package/resolvers/query/restricted/user.js +2 -1
  153. package/resolvers/query/restricted/user.mjs +1 -0
  154. package/resolvers/query/restricted/video.js +2 -1
  155. package/resolvers/query/restricted/video.mjs +1 -0
  156. package/resolvers/query/sampleCards.js +2 -1
  157. package/resolvers/query/sampleCards.mjs +1 -0
  158. package/resolvers/query/sampleQuestions.js +2 -1
  159. package/resolvers/query/sampleQuestions.mjs +1 -0
  160. package/resolvers/query/subscription.js +2 -1
  161. package/resolvers/query/subscription.mjs +1 -0
  162. package/resolvers/query/university.js +2 -1
  163. package/resolvers/query/university.mjs +1 -0
  164. package/resolvers/query/user.js +2 -1
  165. package/resolvers/query/user.mjs +1 -0
  166. package/resolvers/query/video.js +2 -1
  167. package/resolvers/query/video.mjs +1 -0
  168. package/resolvers/subscription/index.js +13 -1
  169. package/resolvers/subscription/index.mjs +1 -0
  170. package/resolvers/subscription/osce.d.ts +14 -7
  171. package/resolvers/subscription/osce.js +45 -10
  172. package/resolvers/subscription/osce.mjs +70 -0
  173. package/utils/commonFunctions.js +17 -11
  174. package/utils/commonFunctions.mjs +217 -0
  175. package/utils/index.d.ts +5 -0
  176. package/utils/index.js +17 -0
  177. package/utils/index.mjs +5 -0
  178. package/utils/lightgallery.js +5 -1
  179. package/utils/lightgallery.mjs +87 -0
  180. package/{resolvers → utils}/offlineLink.d.ts +0 -0
  181. package/utils/offlineLink.js +237 -0
  182. package/{resolvers/offlineLink.js → utils/offlineLink.mjs} +4 -4
  183. package/utils/uuid4.js +3 -1
  184. package/utils/uuid4.mjs +285 -0
  185. package/utils/wordsToNumber.js +5 -1
  186. package/utils/wordsToNumber.mjs +44 -0
@@ -1,16 +1,21 @@
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.OSCE_MATCHMAKING_USERS = exports.OSCE_MATCHMAKING = exports.OSCE_MARKSHEET_ACTION = exports.OSCE_ROLE_CHANGE = exports.OsceGroupInit = exports.OSCE_MATCHMAKING_USERS_KEY = exports.OSCE_MATCHMAKING_KEY = exports.OSCE_MARKSHEET_ACTION_KEY = exports.OSCE_ROLE_CHANGE_KEY = void 0;
4
+ const client_1 = require("@apollo/client");
5
+ const models_1 = require("../../models");
6
+ const osce_1 = require("../fragments/osce");
7
+ exports.OSCE_ROLE_CHANGE_KEY = 'OSCE_ROLE_CHANGE';
8
+ exports.OSCE_MARKSHEET_ACTION_KEY = 'OSCE_MARKSHEET_ACTION';
9
+ exports.OSCE_MATCHMAKING_KEY = 'OSCE_MATCHMAKING';
10
+ exports.OSCE_MATCHMAKING_USERS_KEY = 'OSCE_MATCHMAKING_USERS';
11
+ const OsceGroupInit = (osceMarksheetId) => [
7
12
  {
8
13
  id: null,
9
14
  createdAt: null,
10
15
  osceMarksheetId,
11
16
  userId: null,
12
17
  user: null,
13
- role: EOsceRoles.CANDIDATE,
18
+ role: models_1.EOsceRoles.CANDIDATE,
14
19
  },
15
20
  {
16
21
  id: null,
@@ -18,7 +23,7 @@ export const OsceGroupInit = (osceMarksheetId) => [
18
23
  osceMarksheetId,
19
24
  userId: null,
20
25
  user: null,
21
- role: EOsceRoles.EXAMINER,
26
+ role: models_1.EOsceRoles.EXAMINER,
22
27
  },
23
28
  {
24
29
  id: null,
@@ -26,7 +31,7 @@ export const OsceGroupInit = (osceMarksheetId) => [
26
31
  osceMarksheetId,
27
32
  userId: null,
28
33
  user: null,
29
- role: EOsceRoles.ACTOR,
34
+ role: models_1.EOsceRoles.ACTOR,
30
35
  },
31
36
  {
32
37
  id: null,
@@ -34,6 +39,36 @@ export const OsceGroupInit = (osceMarksheetId) => [
34
39
  osceMarksheetId,
35
40
  userId: null,
36
41
  user: null,
37
- role: EOsceRoles.OBSERVER,
42
+ role: models_1.EOsceRoles.OBSERVER,
38
43
  },
39
44
  ];
45
+ exports.OsceGroupInit = OsceGroupInit;
46
+ exports.OSCE_ROLE_CHANGE = (0, client_1.gql) `
47
+ ${osce_1.OSCE_GROUP_FIELDS}
48
+ subscription osceRoleChangeSubscription($osceMarksheetId: Int!) {
49
+ osceRoleChange(osceMarksheetId: $osceMarksheetId) {
50
+ ...OsceGroupFields
51
+ }
52
+ }
53
+ `;
54
+ exports.OSCE_MARKSHEET_ACTION = (0, client_1.gql) `
55
+ ${osce_1.OSCE_MARKSHEET_ACTION_FIELDS}
56
+ subscription OsceMarksheetAction($osceMarksheetId: Int!) {
57
+ osceMarksheetAction(osceMarksheetId: $osceMarksheetId) {
58
+ ...OsceMarksheetActionFields
59
+ }
60
+ }
61
+ `;
62
+ exports.OSCE_MATCHMAKING = (0, client_1.gql) `
63
+ ${osce_1.OSCE_MATCHMAKING_ACTION_FIELDS}
64
+ subscription OsceMatchmaking($userId: Int!) {
65
+ osceMatchmaking(userId: $userId) {
66
+ ...OsceMatchmakingActionFields
67
+ }
68
+ }
69
+ `;
70
+ exports.OSCE_MATCHMAKING_USERS = (0, client_1.gql) `
71
+ subscription OsceMatchmakingUsers {
72
+ osceMatchmakingUsers
73
+ }
74
+ `;
@@ -0,0 +1,70 @@
1
+ import { gql } from '@apollo/client';
2
+ import { EOsceRoles, } from '../../models';
3
+ import { OSCE_GROUP_FIELDS, OSCE_MARKSHEET_ACTION_FIELDS, OSCE_MATCHMAKING_ACTION_FIELDS, } from '../fragments/osce';
4
+ export const OSCE_ROLE_CHANGE_KEY = 'OSCE_ROLE_CHANGE';
5
+ export const OSCE_MARKSHEET_ACTION_KEY = 'OSCE_MARKSHEET_ACTION';
6
+ export const OSCE_MATCHMAKING_KEY = 'OSCE_MATCHMAKING';
7
+ export const OSCE_MATCHMAKING_USERS_KEY = 'OSCE_MATCHMAKING_USERS';
8
+ export const OsceGroupInit = (osceMarksheetId) => [
9
+ {
10
+ id: null,
11
+ createdAt: null,
12
+ osceMarksheetId,
13
+ userId: null,
14
+ user: null,
15
+ role: EOsceRoles.CANDIDATE,
16
+ },
17
+ {
18
+ id: null,
19
+ createdAt: null,
20
+ osceMarksheetId,
21
+ userId: null,
22
+ user: null,
23
+ role: EOsceRoles.EXAMINER,
24
+ },
25
+ {
26
+ id: null,
27
+ createdAt: null,
28
+ osceMarksheetId,
29
+ userId: null,
30
+ user: null,
31
+ role: EOsceRoles.ACTOR,
32
+ },
33
+ {
34
+ id: null,
35
+ createdAt: null,
36
+ osceMarksheetId,
37
+ userId: null,
38
+ user: null,
39
+ role: EOsceRoles.OBSERVER,
40
+ },
41
+ ];
42
+ export const OSCE_ROLE_CHANGE = gql `
43
+ ${OSCE_GROUP_FIELDS}
44
+ subscription osceRoleChangeSubscription($osceMarksheetId: Int!) {
45
+ osceRoleChange(osceMarksheetId: $osceMarksheetId) {
46
+ ...OsceGroupFields
47
+ }
48
+ }
49
+ `;
50
+ export const OSCE_MARKSHEET_ACTION = gql `
51
+ ${OSCE_MARKSHEET_ACTION_FIELDS}
52
+ subscription OsceMarksheetAction($osceMarksheetId: Int!) {
53
+ osceMarksheetAction(osceMarksheetId: $osceMarksheetId) {
54
+ ...OsceMarksheetActionFields
55
+ }
56
+ }
57
+ `;
58
+ export const OSCE_MATCHMAKING = gql `
59
+ ${OSCE_MATCHMAKING_ACTION_FIELDS}
60
+ subscription OsceMatchmaking($userId: Int!) {
61
+ osceMatchmaking(userId: $userId) {
62
+ ...OsceMatchmakingActionFields
63
+ }
64
+ }
65
+ `;
66
+ export const OSCE_MATCHMAKING_USERS = gql `
67
+ subscription OsceMatchmakingUsers {
68
+ osceMatchmakingUsers
69
+ }
70
+ `;
@@ -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) {
@@ -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
+ });
File without changes