<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>
        <!-- Vista de árbol para Pacientes -->
        <record id="view_patient_tree" model="ir.ui.view">
            <field name="name">res.partner.tree.patient</field>
            <field name="model">res.partner</field>
            <field name="arch" type="xml">
                <list string="Pacientes">
                    <field name="patient_identifier"/>
                    <field name="name"/>
                    <field name="gender"/>
                    <field name="birthdate_date"/>
                    <field name="age" optional="show"/>
                    <field name="is_pregnant" optional="show"/>
                </list>
            </field>
        </record>

        <!-- Vista de lista para Doctores -->
        <record id="view_doctor_tree" model="ir.ui.view">
            <field name="name">res.partner.tree.doctor</field>
            <field name="model">res.partner</field>
            <field name="arch" type="xml">
                <list string="Doctores">
                    <field name="name"/>
                    <field name="doctor_license"/>
                    <field name="phone"/>
                    <field name="email"/>
                </list>
            </field>
        </record>

        <!-- Hereda la vista de formulario para añadir una pestaña de "Información Clínica" -->
        <record id="view_partner_form_lims" model="ir.ui.view">
            <field name="name">res.partner.form.lims</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_form"/>
            <field name="arch" type="xml">
                <xpath expr="//page[@name='internal_notes']" position="before">
                    <page string="Información Clínica" name="clinical_info">
                        <group>
                            <group>
                                <field name="is_patient"/>
                                <field name="patient_identifier" invisible="not is_patient" readonly="patient_identifier"/>
                                <field name="origin" readonly="id" invisible="not is_patient"/>
                                <field name="birthdate_date" invisible="not is_patient"/>
                                <field name="age" invisible="not is_patient or not birthdate_date"/>
                                <field name="gender" invisible="not is_patient"/>
                                <field name="is_pregnant" invisible="not is_patient or gender != 'female'"/>
                            </group>
                            <group>
                                <field name="is_doctor"/>
                                <field name="doctor_license" invisible="not is_doctor"/>
                            </group>
                        </group>
                        <group string="Relación Tutor/Paciente" name="tutor_info">
                            <field name="parent_id" string="Tutor / Responsable"/>
                            <field name="child_ids" string="Pacientes a Cargo"/>
                        </group>
                    </page>
                </xpath>
            </field>
        </record>
    </data>
</odoo>
