import React from 'react';
import { Col, Row } from './Layout';
import { P } from './Typography';
import { getDobWithAge, getNationality, getPassportNumber } from '../patientAccessors';
import { useLanguageContext } from '../pdf/languageContext';
import { useDateTime } from '../pdf/withDateTimeContext';
const PATIENT_FIELDS = [
    {
        key: 'firstName',
        label: 'First name'
    },
    {
        key: 'lastName',
        label: 'Last name'
    },
    {
        key: 'dateOfBirth',
        label: 'Date of birth',
        accessor: getDobWithAge
    },
    {
        key: 'sex',
        label: 'Sex'
    },
    {
        key: 'displayId',
        label: 'NHN'
    },
    {
        key: 'passport',
        label: 'Passport number',
        accessor: getPassportNumber
    },
    {
        key: 'nationality',
        label: 'Nationality',
        accessor: getNationality
    }
];
export const CovidPatientDetailsSection = ({ patient, getSetting, extraFields = [] })=>{
    const { getTranslation } = useLanguageContext();
    const { formatShort } = useDateTime();
    const detailsToDisplay = [
        ...PATIENT_FIELDS,
        ...extraFields
    ].filter(({ key })=>!getSetting(`fields.${key}.hidden`));
    return /*#__PURE__*/ React.createElement(Row, null, /*#__PURE__*/ React.createElement(Col, {
        style: {
            width: '88%'
        }
    }, /*#__PURE__*/ React.createElement(Row, null, detailsToDisplay.map(({ key, label: defaultLabel, accessor })=>{
        const value = accessor?.(patient, {
            getTranslation,
            getSetting,
            formatShort
        }) ?? (patient[key] || '');
        const label = getTranslation(`general.localisedField.${key}.label.short`) || getTranslation(`general.localisedField.${key}.label`) || defaultLabel;
        return /*#__PURE__*/ React.createElement(Col, {
            key: key
        }, /*#__PURE__*/ React.createElement(P, {
            mb: 5
        }, /*#__PURE__*/ React.createElement(P, {
            bold: true
        }, label, ":"), " ", value));
    }))));
};

//# sourceMappingURL=CovidPatientDetailsSection.js.map