@crvouga/mockingbird-service-junction 2.3.0 → 2.3.1

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.
@@ -6,10 +6,10 @@ import {
6
6
  parseDuration,
7
7
  pullCorpus,
8
8
  resolveAdminPrefix
9
- } from "./chunk-UXBNCMYV.js";
9
+ } from "./chunk-UHZKTYBX.js";
10
10
  import {
11
11
  defaultCorpus
12
- } from "./chunk-C2UGIPPM.js";
12
+ } from "./chunk-2FZJPMTR.js";
13
13
  import {
14
14
  parseSealedCorpus
15
15
  } from "./chunk-ISDNA2TU.js";
@@ -1024,4 +1024,4 @@ export {
1024
1024
  createServer2 as createServer,
1025
1025
  serveTarget
1026
1026
  };
1027
- //# sourceMappingURL=chunk-TRSGVIZL.js.map
1027
+ //# sourceMappingURL=chunk-RLSHRM7U.js.map
@@ -2108,7 +2108,7 @@ var stateAdminRoutes = (routes) => {
2108
2108
  };
2109
2109
 
2110
2110
  // ../core/dist/version.js
2111
- var PACKAGE_VERSION = true ? "2.3.0" : UNRELEASED_VERSION;
2111
+ var PACKAGE_VERSION = true ? "2.3.1" : UNRELEASED_VERSION;
2112
2112
 
2113
2113
  // ../core/dist/webhooks.js
2114
2114
  var json4 = (status, body) => new Response(JSON.stringify(body), {
@@ -6638,8 +6638,10 @@ var patientDetails = (input) => ({
6638
6638
  sexual_orientation: null,
6639
6639
  gender_identity: null
6640
6640
  });
6641
- var patientAddress = (input) => ({
6641
+ var patientAddress = (input, details) => ({
6642
6642
  ...input,
6643
+ receiver_name: input.receiver_name ?? `${details.first_name} ${details.last_name}`,
6644
+ phone_number: input.phone_number ?? details.phone_number,
6643
6645
  second_line: null,
6644
6646
  access_notes: null
6645
6647
  });
@@ -7194,9 +7196,24 @@ var orderHandlers = (state) => ({
7194
7196
  data: state.listLabTests().filter((test) => test.auto_generated !== true),
7195
7197
  next_cursor: null
7196
7198
  }),
7197
- // Deprecated upstream but still what team-catalog readers call: the same records as the
7198
- // paged `/v3/lab_test`, as a bare array, filtered the way the real endpoint documents.
7199
- get_lab_tests_for_team_v3_lab_tests_get: async (context) => jsonRes(200, filterLabTests(state.listLabTests(), context.url.searchParams)),
7199
+ // The legacy endpoint orders the same records differently from the paginated catalog.
7200
+ // Use its recorded order while retaining the current state of each test.
7201
+ get_lab_tests_for_team_v3_lab_tests_get: async (context) => {
7202
+ const recorded2 = state.getGetCache("GET /v3/lab_tests")?.body;
7203
+ const positions = new Map(
7204
+ (Array.isArray(recorded2) ? recorded2 : []).map((test, index) => [
7205
+ typeof test === "object" && test !== null && "id" in test ? String(test.id) : "",
7206
+ index
7207
+ ])
7208
+ );
7209
+ const tests = state.listLabTests();
7210
+ if (positions.size > 0) {
7211
+ tests.sort(
7212
+ (a, b) => (positions.get(a.id) ?? positions.size) - (positions.get(b.id) ?? positions.size)
7213
+ );
7214
+ }
7215
+ return jsonRes(200, filterLabTests(tests, context.url.searchParams));
7216
+ },
7200
7217
  get_lab_test_for_team_v3_lab_tests__lab_test_id__get: async (context) => {
7201
7218
  const id = context.params.lab_test_id ?? "";
7202
7219
  const test = state.labTestById(id);
@@ -7632,7 +7649,7 @@ var buildOrderRecord = (state, draft, now) => {
7632
7649
  user_id: userId,
7633
7650
  team_id: state.teamId,
7634
7651
  patient_details: patientDetails(details),
7635
- patient_address: patientAddress(draft.patientAddress),
7652
+ patient_address: patientAddress(draft.patientAddress, details),
7636
7653
  lab_test: orderLabTest,
7637
7654
  details: METHOD_DETAILS(method, state.testkitIdFor(orderId), nowIso),
7638
7655
  sample_id: null,
@@ -9691,6 +9708,7 @@ var pullCorpus = async (options) => {
9691
9708
  if (cursor === null) break;
9692
9709
  await sleep(gap);
9693
9710
  }
9711
+ await recordObservation(real, "GET", "/v3/lab_tests", getCache);
9694
9712
  const labs = listOf(await recordObservation(real, "GET", "/v3/lab_tests/labs", getCache));
9695
9713
  const expectedResults = {};
9696
9714
  for (const test of labTests) {
@@ -10207,6 +10225,13 @@ var scenario = (corpus, withOrders) => {
10207
10225
  skip: (ctx) => !ctx.real.orderId || !ctx.mock.orderId,
10208
10226
  request: (ctx) => ({ method: "GET", path: `/v3/order/${ctx.orderId}` })
10209
10227
  },
10228
+ {
10229
+ name: "order.address",
10230
+ compare: "exact",
10231
+ skip: (ctx) => !ctx.real.orderId || !ctx.mock.orderId,
10232
+ request: (ctx) => ({ method: "GET", path: `/v3/order/${ctx.orderId}` }),
10233
+ project: (body) => body?.patient_address ?? null
10234
+ },
10210
10235
  {
10211
10236
  name: "order.cancel",
10212
10237
  compare: "shape",
@@ -10394,22 +10419,23 @@ var verifyAgainstReal = async (options) => {
10394
10419
  step.capture?.(replies[side], ctx[side]);
10395
10420
  }
10396
10421
  const { real, mock } = replies;
10422
+ const realBody = step.project ? step.project(real.body) : real.body;
10423
+ const mockBody = step.project ? step.project(mock.body) : mock.body;
10397
10424
  let divergence;
10398
10425
  if (real.status !== mock.status) {
10399
10426
  divergence = { check: step.name, kind: "status", real: real.status, mock: mock.status };
10400
10427
  } else if (step.compare === "exact") {
10401
- const at = firstDifference(real.body, mock.body);
10402
- if (at)
10403
- divergence = { check: step.name, kind: "body", at, real: real.body, mock: mock.body };
10428
+ const at = firstDifference(realBody, mockBody);
10429
+ if (at) divergence = { check: step.name, kind: "body", at, real: realBody, mock: mockBody };
10404
10430
  } else {
10405
- const at = firstDifference(shapeOf(real.body), shapeOf(mock.body));
10431
+ const at = firstDifference(shapeOf(realBody), shapeOf(mockBody));
10406
10432
  if (at) {
10407
10433
  divergence = {
10408
10434
  check: step.name,
10409
10435
  kind: "shape",
10410
10436
  at,
10411
- real: shapeOf(real.body),
10412
- mock: shapeOf(mock.body)
10437
+ real: shapeOf(realBody),
10438
+ mock: shapeOf(mockBody)
10413
10439
  };
10414
10440
  }
10415
10441
  }
@@ -10873,4 +10899,4 @@ export {
10873
10899
  JunctionAPI,
10874
10900
  LabAccountConflict
10875
10901
  };
10876
- //# sourceMappingURL=chunk-UXBNCMYV.js.map
10902
+ //# sourceMappingURL=chunk-UHZKTYBX.js.map