fix: preserve legacy compliance response contract

This commit is contained in:
muhdusama committed 2026-09-21 07:17:13 +10:00
1 parent 41d47c3184
commit 24ff031f7a
9 files changed
+119 -44

No files matched your search

+2 -2
View File
@@ -1413,7 +1413,7 @@ export const medicationPaths: NonNullable<ZodOpenApiObject["paths"]> = {
tags: ["Medications"],
summary: "Batched adherence read for every medication of the caller",
description:
"Returns one compact row per non-PRN medication. A scheduled medication with no local schedule remains in the array with applicable=false, reason NO_LOCAL_SCHEDULE, and null percentage/display fields so card and table clients do not mistake it for 100 percent or leave it loading.",
"Returns one compact row per non-PRN medication. A scheduled medication with no local schedule remains in the array with applicable=false and reason NO_LOCAL_SCHEDULE. compliance7/compliance30 stay non-null as all-zero compatibility placeholders for released clients; aware clients must ignore those percentages when applicable=false. complianceDisplay is null.",
responses: {
...recordRefusal(),
"200": {
@@ -1436,7 +1436,7 @@ export const medicationPaths: NonNullable<ZodOpenApiObject["paths"]> = {
tags: ["Medications"],
summary: "Adherence read for a medication",
description:
"Returns the cadence-aware adherence payload. A scheduled medication with no local schedule returns applicable=false, reason NO_LOCAL_SCHEDULE, null percentage/display fields, and an empty daily grid. Medications with a local schedule preserve the existing arithmetic, including windows in which no dose is due.",
"Returns the cadence-aware adherence payload. A scheduled medication with no local schedule returns applicable=false, reason NO_LOCAL_SCHEDULE, non-null all-zero compliance7/compliance30 compatibility placeholders, a null display block, and an empty daily grid. Aware clients must not render the placeholder percentages. Medications with a local schedule preserve the existing arithmetic, including windows in which no dose is due.",
requestParams: {
path: z.object({ id: z.string() }),
},
+12 -12
View File
@@ -766,16 +766,12 @@ export const medicationComplianceResponse = z
.describe(
"Reason adherence is not applicable. NO_LOCAL_SCHEDULE means the medication has no HealthLog-owned expected-dose grid.",
),
compliance7: complianceResult
.nullable()
.describe(
"Seven-day adherence summary, or null when applicable is false.",
),
compliance30: complianceResult
.nullable()
.describe(
"Thirty-day adherence summary, or null when applicable is false.",
),
compliance7: complianceResult.describe(
"Seven-day adherence summary. When applicable is false, this remains a non-null all-zero compatibility placeholder for released clients and must not be rendered as a percentage.",
),
compliance30: complianceResult.describe(
"Thirty-day adherence summary. When applicable is false, this remains a non-null all-zero compatibility placeholder for released clients and must not be rendered as a percentage.",
),
dailyCompliance: z
.record(z.string(), dailyComplianceEntry)
.describe(
@@ -802,8 +798,12 @@ export const medicationComplianceSummaryEntry = z
"Whether this medication has a local expected-dose grid and therefore a displayable adherence percentage.",
),
notApplicableReason: z.literal("NO_LOCAL_SCHEDULE").nullable(),
compliance7: complianceResult.nullable(),
compliance30: complianceResult.nullable(),
compliance7: complianceResult.describe(
"Seven-day adherence summary, or an all-zero compatibility placeholder when applicable is false.",
),
compliance30: complianceResult.describe(
"Thirty-day adherence summary, or an all-zero compatibility placeholder when applicable is false.",
),
complianceDisplay: complianceDisplay.nullable(),
})
.meta({