@crvouga/mockingbird-service-junction 0.8.0 → 1.0.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.
- package/CHANGELOG.md +13 -1
- package/README.md +63 -6
- package/dist/{chunk-TG2EOH3J.js → chunk-2YNUCD2S.js} +22 -2
- package/dist/chunk-2YNUCD2S.js.map +7 -0
- package/dist/{chunk-MS774AJA.js → chunk-KEP42KKR.js} +170 -19
- package/dist/chunk-KEP42KKR.js.map +7 -0
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +41 -6
- package/dist/index.js +7 -1
- package/dist/server.d.ts +29 -3
- package/dist/server.js +2 -2
- package/package.json +6 -2
- package/dist/chunk-MS774AJA.js.map +0 -7
- package/dist/chunk-TG2EOH3J.js.map +0 -7
|
@@ -1296,7 +1296,7 @@ var restoreNamespace = (sqlite, namespace, snapshot) => {
|
|
|
1296
1296
|
};
|
|
1297
1297
|
|
|
1298
1298
|
// ../core/dist/version.js
|
|
1299
|
-
var PACKAGE_VERSION = true ? "0.
|
|
1299
|
+
var PACKAGE_VERSION = true ? "1.0.1" : UNRELEASED_VERSION;
|
|
1300
1300
|
|
|
1301
1301
|
// ../core/dist/webhooks.js
|
|
1302
1302
|
var json2 = (status, body) => new Response(JSON.stringify(body), { status, headers: { "content-type": "application/json" } });
|
|
@@ -2808,6 +2808,11 @@ var JunctionState = class {
|
|
|
2808
2808
|
bookingKeys;
|
|
2809
2809
|
pendingSimulateTransitions;
|
|
2810
2810
|
orderByTransaction;
|
|
2811
|
+
/**
|
|
2812
|
+
* The lab account each order was placed with (`null`: Junction's platform account). Kept
|
|
2813
|
+
* off the order record: Junction's `ClientFacingOrder` has no `lab_account_id`.
|
|
2814
|
+
*/
|
|
2815
|
+
orderLabAccounts;
|
|
2811
2816
|
webhookEvents;
|
|
2812
2817
|
webhookDeliveryAttempts;
|
|
2813
2818
|
labTests;
|
|
@@ -2822,6 +2827,8 @@ var JunctionState = class {
|
|
|
2822
2827
|
teamId = MOCK_TEAM_ID;
|
|
2823
2828
|
/** Sandbox-only restrictions to enforce; every one is off by default. */
|
|
2824
2829
|
limits = { ...DEFAULT_LIMITS };
|
|
2830
|
+
/** Lab slug → the `billing_type` an order for that lab gets when it omits one. */
|
|
2831
|
+
defaultBillingTypes = {};
|
|
2825
2832
|
/** Whether an unknown `user_id` is refused (`strict`) or created on first use. */
|
|
2826
2833
|
identity = "strict";
|
|
2827
2834
|
webhooksMuted = 0;
|
|
@@ -2857,6 +2864,7 @@ var JunctionState = class {
|
|
|
2857
2864
|
"pending_simulate_transitions"
|
|
2858
2865
|
);
|
|
2859
2866
|
this.orderByTransaction = new Collection(sqlite, namespace, "orders_by_transaction");
|
|
2867
|
+
this.orderLabAccounts = new Collection(sqlite, namespace, "order_lab_accounts");
|
|
2860
2868
|
this.webhookEvents = new Collection(sqlite, namespace, "webhook_events");
|
|
2861
2869
|
this.webhookDeliveryAttempts = new Collection(sqlite, namespace, "webhook_delivery_attempts");
|
|
2862
2870
|
this.labTests = new Collection(sqlite, namespace, "lab_tests");
|
|
@@ -3256,6 +3264,20 @@ var BILLING_TYPES = [
|
|
|
3256
3264
|
"patient_bill",
|
|
3257
3265
|
"upfront_payment"
|
|
3258
3266
|
];
|
|
3267
|
+
var defaultBillingTypesFrom = (input) => {
|
|
3268
|
+
if (typeof input !== "object" || input === null || Array.isArray(input))
|
|
3269
|
+
throw new TypeError("default billing types must map lab slugs to billing types");
|
|
3270
|
+
const out = {};
|
|
3271
|
+
for (const [lab, type] of Object.entries(input)) {
|
|
3272
|
+
if (lab.trim() === "") throw new TypeError("default billing types: lab slug is empty");
|
|
3273
|
+
if (!BILLING_TYPES.includes(type))
|
|
3274
|
+
throw new TypeError(
|
|
3275
|
+
`default billing type for ${lab}: ${String(type)} is not a billing type (${BILLING_TYPES.join(", ")})`
|
|
3276
|
+
);
|
|
3277
|
+
out[lab.trim().toLowerCase()] = type;
|
|
3278
|
+
}
|
|
3279
|
+
return out;
|
|
3280
|
+
};
|
|
3259
3281
|
var LAB_ACCOUNT_STATUSES = [
|
|
3260
3282
|
"active",
|
|
3261
3283
|
"pending",
|
|
@@ -3498,7 +3520,7 @@ var labAccountFromClientFacing = (value, recordedTeamId) => {
|
|
|
3498
3520
|
var except = (...excluded) => US_STATES.filter((state) => !excluded.includes(state));
|
|
3499
3521
|
var PLATFORM_ACCOUNT_STATES = except("NJ", "NY", "RI");
|
|
3500
3522
|
var DELEGATED_ACCOUNT_STATES = except("NJ", "NY");
|
|
3501
|
-
var
|
|
3523
|
+
var bioreferencePlatform = {
|
|
3502
3524
|
lab: "bioreference",
|
|
3503
3525
|
account_name: "Junction BioReference Account",
|
|
3504
3526
|
delegated_flow: "not_delegated",
|
|
@@ -3533,7 +3555,7 @@ var LAB_ACCOUNT_PRESETS = {
|
|
|
3533
3555
|
delegated_flow: "order_delegated",
|
|
3534
3556
|
allowed_billing: { client_bill: DELEGATED_ACCOUNT_STATES }
|
|
3535
3557
|
},
|
|
3536
|
-
|
|
3558
|
+
bioreference_platform: bioreferencePlatform,
|
|
3537
3559
|
bioreference_patient_bill_passthrough: {
|
|
3538
3560
|
lab: "bioreference",
|
|
3539
3561
|
delegated_flow: "not_delegated",
|
|
@@ -3541,13 +3563,22 @@ var LAB_ACCOUNT_PRESETS = {
|
|
|
3541
3563
|
},
|
|
3542
3564
|
quest_platform: questPlatform,
|
|
3543
3565
|
labcorp_platform: labcorpPlatform,
|
|
3544
|
-
suspended_bioreference: { ...
|
|
3566
|
+
suspended_bioreference: { ...bioreferencePlatform, status: "suspended" },
|
|
3545
3567
|
suspended_quest: { ...questPlatform, status: "suspended" },
|
|
3546
3568
|
suspended_labcorp: { ...labcorpPlatform, status: "suspended" }
|
|
3547
3569
|
};
|
|
3570
|
+
var LAB_ACCOUNT_PRESET_ALIASES = {
|
|
3571
|
+
/** Misnamed: the record is Junction's platform account, not a customer-owned one. */
|
|
3572
|
+
bioreference_customer_multi_state: "bioreference_platform"
|
|
3573
|
+
};
|
|
3574
|
+
var SYNTHETIC_LAB_ACCOUNT_PRESETS = ["bioreference_ny_nj_delegated"];
|
|
3575
|
+
var presetNamed = (name) => {
|
|
3576
|
+
const target = Object.hasOwn(LAB_ACCOUNT_PRESET_ALIASES, name) ? LAB_ACCOUNT_PRESET_ALIASES[name] : name;
|
|
3577
|
+
return target !== void 0 && Object.hasOwn(LAB_ACCOUNT_PRESETS, target) ? LAB_ACCOUNT_PRESETS[target] : void 0;
|
|
3578
|
+
};
|
|
3548
3579
|
var presetAccountId = (name) => deterministicUuid(`junction:lab-account:${name}`);
|
|
3549
3580
|
var labAccountFromPreset = (name, options) => {
|
|
3550
|
-
const preset =
|
|
3581
|
+
const preset = presetNamed(name);
|
|
3551
3582
|
if (!preset) return void 0;
|
|
3552
3583
|
return labAccountFromInput({ ...preset, id: options.id ?? presetAccountId(name) }, options.teamId);
|
|
3553
3584
|
};
|
|
@@ -3749,7 +3780,8 @@ var junctionAdminRoutes = (options) => (runtime) => {
|
|
|
3749
3780
|
user_id: order.user_id,
|
|
3750
3781
|
method: methodOf(order),
|
|
3751
3782
|
status: order.last_event.status,
|
|
3752
|
-
updated_at: order.updated_at
|
|
3783
|
+
updated_at: order.updated_at,
|
|
3784
|
+
lab_account_id: api(request2).orderLabAccount(order.id) ?? null
|
|
3753
3785
|
}))
|
|
3754
3786
|
}),
|
|
3755
3787
|
"POST /orders/:id/transition": (request2) => {
|
|
@@ -3834,7 +3866,9 @@ var junctionAdminRoutes = (options) => (runtime) => {
|
|
|
3834
3866
|
const record = labAccountFromPreset(name, { teamId: api(request2).teamId });
|
|
3835
3867
|
return [name, record ? renderLabAccount(record) : null];
|
|
3836
3868
|
})
|
|
3837
|
-
)
|
|
3869
|
+
),
|
|
3870
|
+
aliases: LAB_ACCOUNT_PRESET_ALIASES,
|
|
3871
|
+
synthetic: SYNTHETIC_LAB_ACCOUNT_PRESETS
|
|
3838
3872
|
}),
|
|
3839
3873
|
"POST /lab-accounts/presets/:name": (request2) => {
|
|
3840
3874
|
const body = isRecord5(request2.body) ? request2.body : {};
|
|
@@ -3857,6 +3891,19 @@ var junctionAdminRoutes = (options) => (runtime) => {
|
|
|
3857
3891
|
const input = request2.body;
|
|
3858
3892
|
return guarded(() => jsonRes(200, { limits: api(request2).configureLimits(input) }));
|
|
3859
3893
|
},
|
|
3894
|
+
"GET /default-billing-types": (request2) => jsonRes(200, { defaultBillingTypes: api(request2).defaultBillingTypes }),
|
|
3895
|
+
"PUT /default-billing-types": (request2) => {
|
|
3896
|
+
const input = isRecord5(request2.body) ? request2.body.defaultBillingTypes : void 0;
|
|
3897
|
+
if (!isRecord5(input))
|
|
3898
|
+
return adminError3(
|
|
3899
|
+
400,
|
|
3900
|
+
'body needs "defaultBillingTypes": { "<lab slug>": "<billing_type>" } ({} restores client_bill)'
|
|
3901
|
+
);
|
|
3902
|
+
return guarded(() => {
|
|
3903
|
+
api(request2).defaultBillingTypes = input;
|
|
3904
|
+
return jsonRes(200, { defaultBillingTypes: api(request2).defaultBillingTypes });
|
|
3905
|
+
});
|
|
3906
|
+
},
|
|
3860
3907
|
"GET /identity": (request2) => jsonRes(200, { identity: api(request2).identity }),
|
|
3861
3908
|
"PUT /identity": (request2) => {
|
|
3862
3909
|
const mode = isRecord5(request2.body) ? request2.body.mode : void 0;
|
|
@@ -4014,6 +4061,9 @@ var cachedResponse = (state, context) => {
|
|
|
4014
4061
|
materializeAvailabilityBookingKeys(state, context, cached.body);
|
|
4015
4062
|
rotateAvailabilityBookingKeys(state, cached.body, context.now());
|
|
4016
4063
|
}
|
|
4064
|
+
return responseFromCache(cached);
|
|
4065
|
+
};
|
|
4066
|
+
var responseFromCache = (cached) => {
|
|
4017
4067
|
const headers = new Headers(cached.headers);
|
|
4018
4068
|
headers.delete("content-encoding");
|
|
4019
4069
|
headers.delete("content-length");
|
|
@@ -4417,6 +4467,47 @@ var radiusOf = (context) => {
|
|
|
4417
4467
|
}
|
|
4418
4468
|
return value;
|
|
4419
4469
|
};
|
|
4470
|
+
var recordedAtRadius = (state, context, radius) => {
|
|
4471
|
+
const params = new URLSearchParams(context.url.searchParams);
|
|
4472
|
+
params.delete("radius");
|
|
4473
|
+
const lookup = (query) => state.getGetCache(state.cacheKeyForRequest("GET", context.url.pathname, query));
|
|
4474
|
+
if (radius === DEFAULT_RADIUS) {
|
|
4475
|
+
const bare = lookup(params);
|
|
4476
|
+
if (bare) return bare;
|
|
4477
|
+
}
|
|
4478
|
+
params.set("radius", String(radius));
|
|
4479
|
+
return lookup(params);
|
|
4480
|
+
};
|
|
4481
|
+
var derivedFromRecording = (state, context, radius) => {
|
|
4482
|
+
const same = recordedAtRadius(state, context, radius);
|
|
4483
|
+
if (same) return responseFromCache(same);
|
|
4484
|
+
if (!context.url.pathname.endsWith("/psc/info")) return void 0;
|
|
4485
|
+
for (const wider of ALLOWED_RADII) {
|
|
4486
|
+
if (wider <= radius) continue;
|
|
4487
|
+
const recorded = recordedAtRadius(state, context, wider);
|
|
4488
|
+
if (!recorded) continue;
|
|
4489
|
+
const body = recorded.body;
|
|
4490
|
+
if (recorded.status !== 200 || !body || !Array.isArray(body.patient_service_centers))
|
|
4491
|
+
return void 0;
|
|
4492
|
+
const centers = body.patient_service_centers.filter(
|
|
4493
|
+
(center) => Number(center.distance) < radius
|
|
4494
|
+
);
|
|
4495
|
+
return responseFromCache({ ...recorded, body: { ...body, patient_service_centers: centers } });
|
|
4496
|
+
}
|
|
4497
|
+
return void 0;
|
|
4498
|
+
};
|
|
4499
|
+
var requireRecordedRead = (state, context, zip) => {
|
|
4500
|
+
if (state.geoMode !== "corpus") return;
|
|
4501
|
+
const query = [...context.url.searchParams.entries()].map(([key, value]) => `${key}=${value}`).join("&");
|
|
4502
|
+
throw new HttpError(UNKNOWN_ZIP_STATUS, {
|
|
4503
|
+
detail: {
|
|
4504
|
+
error_type: UNKNOWN_ZIP_ERROR_TYPE,
|
|
4505
|
+
error_message: `ZIP ${zip} is in the loaded Junction corpus, but GET ${context.url.pathname}?${query} was not recorded and cannot be derived from what was (a smaller psc/info radius is filtered from a wider recording; area/info needs its own). Record it, or serve with --geo synthetic to invent coverage.`,
|
|
4506
|
+
zip_code: zip,
|
|
4507
|
+
corpus: state.corpusLabel ?? null
|
|
4508
|
+
}
|
|
4509
|
+
});
|
|
4510
|
+
};
|
|
4420
4511
|
var zipCodeOf = (context, required) => {
|
|
4421
4512
|
const raw = context.query.zip_code;
|
|
4422
4513
|
if (raw === void 0) {
|
|
@@ -4875,7 +4966,11 @@ var schedulingHandlers = (state) => ({
|
|
|
4875
4966
|
}
|
|
4876
4967
|
const zip = rawZip.slice(0, 5);
|
|
4877
4968
|
requireCoveredZip(state, zip);
|
|
4878
|
-
|
|
4969
|
+
const account2 = labAccountOf(state, context);
|
|
4970
|
+
const derived = derivedFromRecording(state, context, radius);
|
|
4971
|
+
if (derived) return derived;
|
|
4972
|
+
requireRecordedRead(state, context, zip);
|
|
4973
|
+
return jsonRes(200, areaInfoFor(zip, radius, account2));
|
|
4879
4974
|
},
|
|
4880
4975
|
get_psc_info_v3_order_psc_info_get: async (context) => {
|
|
4881
4976
|
const hit = cachedResponse(state, context);
|
|
@@ -4952,6 +5047,9 @@ var schedulingHandlers = (state) => ({
|
|
|
4952
5047
|
throw new HttpError(404, { detail: "Lab not found." });
|
|
4953
5048
|
}
|
|
4954
5049
|
requireCoveredZip(state, zip);
|
|
5050
|
+
const derived = derivedFromRecording(state, context, radius);
|
|
5051
|
+
if (derived) return derived;
|
|
5052
|
+
requireRecordedRead(state, context, zip);
|
|
4955
5053
|
const within = withinRadiusFor(zip, lab.slug, radius);
|
|
4956
5054
|
const centerCount = Math.min(within, 30);
|
|
4957
5055
|
const centers = Array.from({ length: centerCount }, (_, index) => {
|
|
@@ -5684,6 +5782,13 @@ var orderValidation = (body, now = Date.now) => {
|
|
|
5684
5782
|
input: labAccountId
|
|
5685
5783
|
});
|
|
5686
5784
|
}
|
|
5785
|
+
const labTestId = body.lab_test_id;
|
|
5786
|
+
if (labTestId !== void 0 && labTestId !== null) {
|
|
5787
|
+
if (typeof labTestId !== "string")
|
|
5788
|
+
errors.push(stringTypeError(["body", "lab_test_id"], labTestId));
|
|
5789
|
+
else if (!isUuid2(labTestId))
|
|
5790
|
+
errors.push(uuidError2(labTestId, void 0, ["body", "lab_test_id"]));
|
|
5791
|
+
}
|
|
5687
5792
|
const os = body.order_set;
|
|
5688
5793
|
const osWrongType = os !== void 0 && (typeof os !== "object" || os === null || Array.isArray(os));
|
|
5689
5794
|
if (osWrongType) {
|
|
@@ -6113,7 +6218,8 @@ var orderHandlers = (state) => ({
|
|
|
6113
6218
|
const aoeError = aoeValidationError(state, body);
|
|
6114
6219
|
if (aoeError) throw new HttpError(400, { detail: aoeError });
|
|
6115
6220
|
const rawOrderSet = body.order_set;
|
|
6116
|
-
|
|
6221
|
+
const singleLabTestId = typeof body.lab_test_id === "string" ? body.lab_test_id : void 0;
|
|
6222
|
+
if (rawOrderSet === void 0 && singleLabTestId === void 0) {
|
|
6117
6223
|
throw new HttpError(400, { detail: "Either lab_test_id or order_set must be set" });
|
|
6118
6224
|
}
|
|
6119
6225
|
if (typeof rawOrderSet === "object" && rawOrderSet !== null && !Array.isArray(rawOrderSet) && rawOrderSet.lab_test_ids === void 0 && rawOrderSet.add_on === void 0) {
|
|
@@ -6121,7 +6227,8 @@ var orderHandlers = (state) => ({
|
|
|
6121
6227
|
}
|
|
6122
6228
|
const details = body.patient_details;
|
|
6123
6229
|
const address = body.patient_address;
|
|
6124
|
-
const
|
|
6230
|
+
const orderSetIds = typeof rawOrderSet === "object" && rawOrderSet !== null ? rawOrderSet.lab_test_ids : void 0;
|
|
6231
|
+
const labTestIds = Array.isArray(orderSetIds) ? orderSetIds : rawOrderSet === void 0 && singleLabTestId !== void 0 ? [singleLabTestId] : [];
|
|
6125
6232
|
if (labTestIds.length === 0) {
|
|
6126
6233
|
throw new HttpError(400, {
|
|
6127
6234
|
detail: "No markers found for the supplied lab tests. Please check the lab test ids"
|
|
@@ -6155,11 +6262,14 @@ var orderHandlers = (state) => ({
|
|
|
6155
6262
|
state.teamId,
|
|
6156
6263
|
state.listLabAccounts()
|
|
6157
6264
|
);
|
|
6158
|
-
const
|
|
6265
|
+
const requestedBilling = typeof body.billing_type === "string" && body.billing_type !== "" ? body.billing_type : void 0;
|
|
6266
|
+
const billingType = requestedBilling ?? state.defaultBillingTypes[labSlug] ?? "client_bill";
|
|
6159
6267
|
const allowedStates = effectiveBilling(labAccount)[billingType];
|
|
6160
6268
|
if (!allowedStates)
|
|
6161
6269
|
throw new HttpError(400, {
|
|
6162
|
-
|
|
6270
|
+
// An omitted billing_type that resolves to one the account lacks is reported against
|
|
6271
|
+
// the lab, as the sandbox words it.
|
|
6272
|
+
detail: requestedBilling === void 0 ? `Lab ${String(labTest.lab?.id ?? labSlug)} does not support billing type ${billingType}` : `Billing type ${billingType} is not supported by the lab account used for this order`
|
|
6163
6273
|
});
|
|
6164
6274
|
const patientState = String(address.state ?? "").trim().toUpperCase();
|
|
6165
6275
|
if (patientState !== "" && !allowedStates.includes(patientState))
|
|
@@ -6204,12 +6314,14 @@ var orderHandlers = (state) => ({
|
|
|
6204
6314
|
billingType,
|
|
6205
6315
|
icdCodes,
|
|
6206
6316
|
clinicalNotes: typeof body.clinical_notes === "string" ? body.clinical_notes : null,
|
|
6207
|
-
passthrough: typeof body.passthrough === "string" ? body.passthrough : null
|
|
6208
|
-
...typeof body.lab_account_id === "string" ? { labAccountId: body.lab_account_id } : {}
|
|
6317
|
+
passthrough: typeof body.passthrough === "string" ? body.passthrough : null
|
|
6209
6318
|
},
|
|
6210
6319
|
context.now
|
|
6211
6320
|
);
|
|
6212
6321
|
persistOrderRecord(state, order, labTest, details, address);
|
|
6322
|
+
state.orderLabAccounts.insert(orderId, {
|
|
6323
|
+
lab_account_id: labAccount === "platform" ? null : labAccount.id
|
|
6324
|
+
});
|
|
6213
6325
|
const responseOrder = { ...order };
|
|
6214
6326
|
if (responseOrder.result_types === null) delete responseOrder.result_types;
|
|
6215
6327
|
const response = {
|
|
@@ -6456,7 +6568,6 @@ var buildOrderRecord = (state, draft, now) => {
|
|
|
6456
6568
|
notes: null,
|
|
6457
6569
|
clinical_notes: draft.clinicalNotes,
|
|
6458
6570
|
passthrough: draft.passthrough,
|
|
6459
|
-
...draft.labAccountId !== void 0 ? { lab_account_id: draft.labAccountId } : {},
|
|
6460
6571
|
created_at: nowIso,
|
|
6461
6572
|
updated_at: nowIso,
|
|
6462
6573
|
events: [event],
|
|
@@ -6678,8 +6789,7 @@ var insertOrders = (state, inputs, now, options = {}) => {
|
|
|
6678
6789
|
billingType: input.billing_type ?? "client_bill",
|
|
6679
6790
|
icdCodes: input.icd_codes ?? null,
|
|
6680
6791
|
clinicalNotes: input.clinical_notes ?? null,
|
|
6681
|
-
passthrough: input.passthrough ?? null
|
|
6682
|
-
...input.lab_account_id !== void 0 ? { labAccountId: input.lab_account_id } : {}
|
|
6792
|
+
passthrough: input.passthrough ?? null
|
|
6683
6793
|
},
|
|
6684
6794
|
createdMs === void 0 ? now : () => createdMs
|
|
6685
6795
|
);
|
|
@@ -6688,6 +6798,7 @@ var insertOrders = (state, inputs, now, options = {}) => {
|
|
|
6688
6798
|
const run = () => {
|
|
6689
6799
|
for (const { input, order, labTest, details, address, status } of prepared) {
|
|
6690
6800
|
persistOrderRecord(state, order, labTest, details, address);
|
|
6801
|
+
state.orderLabAccounts.insert(order.id, { lab_account_id: input.lab_account_id ?? null });
|
|
6691
6802
|
state.publishOrderWebhook(order, "labtest.order.created", now());
|
|
6692
6803
|
if (status !== void 0) {
|
|
6693
6804
|
const stored = state.orders.get(order.id);
|
|
@@ -8774,6 +8885,7 @@ var createRuntime2 = (options = {}) => {
|
|
|
8774
8885
|
...options.teamId !== void 0 ? { teamId: options.teamId } : {},
|
|
8775
8886
|
...options.limits ? { limits: options.limits } : {},
|
|
8776
8887
|
...options.identity ? { identity: options.identity } : {},
|
|
8888
|
+
...options.defaultBillingTypes ? { defaultBillingTypes: options.defaultBillingTypes } : {},
|
|
8777
8889
|
...options.fixtures ? { fixtures: options.fixtures } : {},
|
|
8778
8890
|
onWebhook: (event) => {
|
|
8779
8891
|
options.onWebhook?.(event, publicNamespace);
|
|
@@ -9058,6 +9170,25 @@ var scenario = (corpus, withOrders) => {
|
|
|
9058
9170
|
}
|
|
9059
9171
|
);
|
|
9060
9172
|
}
|
|
9173
|
+
if (withOrders) {
|
|
9174
|
+
const labTestFor = (lab) => corpus.catalog.labTests.find(
|
|
9175
|
+
(test) => String(test.lab?.slug ?? "").toLowerCase() === String(lab).toLowerCase()
|
|
9176
|
+
);
|
|
9177
|
+
for (const account2 of corpus.labAccounts) {
|
|
9178
|
+
const labTest = labTestFor(account2.lab);
|
|
9179
|
+
if (account2.status !== "active" || account2 === openAccount || !labTest) continue;
|
|
9180
|
+
steps.push({
|
|
9181
|
+
name: `order.create via ${String(account2.lab)} account ${String(account2.id)} with billing_type omitted`,
|
|
9182
|
+
compare: "shape",
|
|
9183
|
+
request: (ctx) => ({
|
|
9184
|
+
method: "POST",
|
|
9185
|
+
path: "/v3/order",
|
|
9186
|
+
body: orderBody(ctx.userId, labTest.id, { lab_account_id: account2.id })
|
|
9187
|
+
}),
|
|
9188
|
+
capture: captureExtraOrder
|
|
9189
|
+
});
|
|
9190
|
+
}
|
|
9191
|
+
}
|
|
9061
9192
|
steps.push({
|
|
9062
9193
|
name: "user.delete",
|
|
9063
9194
|
compare: "shape",
|
|
@@ -9249,6 +9380,7 @@ var JunctionAPI = class {
|
|
|
9249
9380
|
if (options.identity !== void 0 && !IDENTITY_MODES.includes(options.identity))
|
|
9250
9381
|
throw new TypeError(`identity must be one of ${IDENTITY_MODES.join(", ")}`);
|
|
9251
9382
|
state.identity = options.identity ?? "strict";
|
|
9383
|
+
state.defaultBillingTypes = defaultBillingTypesFrom(options.defaultBillingTypes ?? {});
|
|
9252
9384
|
const handlers = defineOperations({
|
|
9253
9385
|
...userHandlers(state),
|
|
9254
9386
|
...orderHandlers(state),
|
|
@@ -9383,6 +9515,14 @@ var JunctionAPI = class {
|
|
|
9383
9515
|
this.state.limits = mergeLimits(this.state.limits, input);
|
|
9384
9516
|
return this.limits;
|
|
9385
9517
|
}
|
|
9518
|
+
/** Lab slug → the `billing_type` an order gets when it omits one. Kept across `reset()`. */
|
|
9519
|
+
get defaultBillingTypes() {
|
|
9520
|
+
return { ...this.state.defaultBillingTypes };
|
|
9521
|
+
}
|
|
9522
|
+
/** Replace the per-lab default billing types (`{}` restores `client_bill` everywhere). */
|
|
9523
|
+
set defaultBillingTypes(input) {
|
|
9524
|
+
this.state.defaultBillingTypes = defaultBillingTypesFrom(input);
|
|
9525
|
+
}
|
|
9386
9526
|
get identity() {
|
|
9387
9527
|
return this.state.identity;
|
|
9388
9528
|
}
|
|
@@ -9433,6 +9573,14 @@ var JunctionAPI = class {
|
|
|
9433
9573
|
orders() {
|
|
9434
9574
|
return this.state.orders.list({ order: "oldest" }).map((entry) => entry.value);
|
|
9435
9575
|
}
|
|
9576
|
+
/**
|
|
9577
|
+
* The lab account an order was placed with: its id, `null` for Junction's platform account,
|
|
9578
|
+
* or `undefined` for an unknown order. Junction's order has no such field, so this is the
|
|
9579
|
+
* only place the mock reports it.
|
|
9580
|
+
*/
|
|
9581
|
+
orderLabAccount(id) {
|
|
9582
|
+
return this.state.orderLabAccounts.get(id)?.lab_account_id;
|
|
9583
|
+
}
|
|
9436
9584
|
/**
|
|
9437
9585
|
* Put an order straight into a status (a full `<status>.<method>.<event>` value) and
|
|
9438
9586
|
* publish the webhook a real transition would. `flags` takes the same keys as
|
|
@@ -9526,7 +9674,6 @@ var touchedIds = async (request2, body, response) => {
|
|
|
9526
9674
|
const order = asRecord3(created?.order);
|
|
9527
9675
|
put2("orderId", order?.id);
|
|
9528
9676
|
put2("userId", order?.user_id);
|
|
9529
|
-
put2("labAccountId", order?.lab_account_id);
|
|
9530
9677
|
put2("userId", created?.user_id);
|
|
9531
9678
|
}
|
|
9532
9679
|
return ids;
|
|
@@ -9563,6 +9710,8 @@ export {
|
|
|
9563
9710
|
observationCacheKey,
|
|
9564
9711
|
MOCK_TEAM_ID,
|
|
9565
9712
|
US_STATES,
|
|
9713
|
+
BILLING_TYPES,
|
|
9714
|
+
defaultBillingTypesFrom,
|
|
9566
9715
|
OTHER_TEAM_ID,
|
|
9567
9716
|
TEAM_LAB_ACCOUNTS,
|
|
9568
9717
|
isLinkedToTeam,
|
|
@@ -9570,6 +9719,8 @@ export {
|
|
|
9570
9719
|
PLATFORM_ACCOUNT_STATES,
|
|
9571
9720
|
DELEGATED_ACCOUNT_STATES,
|
|
9572
9721
|
LAB_ACCOUNT_PRESETS,
|
|
9722
|
+
LAB_ACCOUNT_PRESET_ALIASES,
|
|
9723
|
+
SYNTHETIC_LAB_ACCOUNT_PRESETS,
|
|
9573
9724
|
presetAccountId,
|
|
9574
9725
|
ORDER_STATUSES_BY_METHOD,
|
|
9575
9726
|
TRANSITION_ALIASES,
|
|
@@ -9608,4 +9759,4 @@ export {
|
|
|
9608
9759
|
JunctionAPI,
|
|
9609
9760
|
LabAccountConflict
|
|
9610
9761
|
};
|
|
9611
|
-
//# sourceMappingURL=chunk-
|
|
9762
|
+
//# sourceMappingURL=chunk-KEP42KKR.js.map
|