import React from 'react';
import { useLanguageContext } from '../pdf/languageContext';
import { useDateTime } from '../pdf/withDateTimeContext';
import { Divider } from './Divider';
import { Col, Row } from '../patientCertificates/Layout';
import { P } from '../patientCertificates/Typography';
import { getDob, getName, getSex } from '../patientAccessors';
const PATIENT_FIELDS = [
    {
        key: 'name',
        label: 'Patient Name',
        accessor: getName,
        percentageWidth: 40
    },
    {
        key: 'displayId',
        label: 'Patient ID',
        percentageWidth: 40
    },
    {
        key: 'dateOfBirth',
        label: 'DOB',
        accessor: getDob,
        percentageWidth: 20
    },
    {
        key: 'sex',
        label: 'Sex',
        accessor: getSex,
        percentageWidth: 40
    }
];
const ValueDisplay = ({ width, title, value })=>/*#__PURE__*/ React.createElement(Col, {
        style: {
            width
        }
    }, /*#__PURE__*/ React.createElement(P, {
        mb: 5,
        style: {
            fontSize: 10
        }
    }, /*#__PURE__*/ React.createElement(P, {
        style: {
            fontSize: 10
        },
        bold: true
    }, title, ":"), ' ', value));
export const HandoverPatient = ({ patient, location, arrivalDate, diagnosis, notes, getSetting, createdAt, isEdited })=>{
    const { getTranslation } = useLanguageContext();
    const { formatShort, formatShortest, formatShortDateTime } = useDateTime();
    const detailsToDisplay = PATIENT_FIELDS.filter(({ key })=>!getSetting(`fields.${key}.hidden`));
    return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Row, {
        style: {
            width: '100%',
            marginBottom: 40
        }
    }, /*#__PURE__*/ React.createElement(Col, {
        style: {
            width: '100%'
        }
    }, /*#__PURE__*/ React.createElement(Row, null, detailsToDisplay.map(({ key, label: defaultLabel, accessor, percentageWidth = 33 })=>{
        const value = (accessor ? accessor(patient, {
            getTranslation,
            formatShort
        }) : patient[key]) || '';
        const label = defaultLabel || getTranslation(`general.localisedField.${key}.label.short`) || getTranslation(`general.localisedField.${key}.label`);
        return /*#__PURE__*/ React.createElement(ValueDisplay, {
            key: key,
            width: `${percentageWidth}%`,
            title: label,
            value: value
        });
    }), /*#__PURE__*/ React.createElement(ValueDisplay, {
        width: "40%",
        title: "Location",
        value: location
    }), /*#__PURE__*/ React.createElement(ValueDisplay, {
        width: "20%",
        title: "Arrival date",
        value: formatShortest(arrivalDate)
    })), diagnosis && /*#__PURE__*/ React.createElement(ValueDisplay, {
        width: "100%",
        title: "Diagnosis",
        value: diagnosis
    }), /*#__PURE__*/ React.createElement(Row, null, /*#__PURE__*/ React.createElement(ValueDisplay, {
        width: "100%",
        title: "Notes",
        value: notes || 'N/A'
    }), !!notes && !!createdAt && /*#__PURE__*/ React.createElement(Col, {
        style: {
            width: '100%'
        }
    }, /*#__PURE__*/ React.createElement(P, {
        style: {
            fontSize: 8
        }
    }, `${formatShortDateTime(createdAt)}${isEdited ? ' (edited)' : ''}`))))), /*#__PURE__*/ React.createElement(Divider, null));
};

//# sourceMappingURL=HandoverPatient.js.map