/** * The NPI route answers `503 { reason: 'npi-registry-unavailable' }` when the national registry could not be reached. * That attempt claimed and wrote nothing, so it is a definite answer rather than a save that may have landed. Keyed on * the code, never the sentence; any other 503 (a gateway, or one sent after the record was written) may have saved. */ const NPI_REGISTRY_UNAVAILABLE = 'npi-registry-unavailable'; export const FRESH_REGISTRY_OUTAGE_NOTICE = 'We could not check that NPI with the national registry just now, so it was not saved. Please try again in a few minutes.'; export const HELD_REGISTRY_OUTAGE_NOTICE = 'We could not check that NPI with the national registry just now. Your earlier save of it may still have gone through; try again in a few minutes.'; export const isNpiRegistryUnavailable = (error: unknown): boolean => { const candidate = error as | { status?: number; statusCode?: number; body?: { reason?: unknown }; response?: { status?: number } } | null | undefined; const status = candidate?.status ?? candidate?.statusCode ?? candidate?.response?.status; return status === 503 && candidate?.body?.reason === NPI_REGISTRY_UNAVAILABLE; };