import type { QuestionnaireResponse } from 'fhir/r4'; // Written by the server on a response's first successful send and kept across amendments. const FIRST_SUBMITTED_EXTENSION_URL = 'https://akashichealthrecords.com/fhir/StructureDefinition/questionnaire-response-first-submitted'; /** * When the patient first sent this response, from the server's record only. `authored` moves with every * amendment and the page's history read cannot prove a response was never amended, so without the record * the time stays unknown. */ export const submittedAtOf = (response: QuestionnaireResponse | undefined): string | undefined => response?.extension?.find((ext) => ext.url === FIRST_SUBMITTED_EXTENSION_URL)?.valueDateTime;