using Baya.Domain.Common;

namespace Baya.Domain.Entities.Identity;

/// <summary>
/// The person receiving care — a first-class entity separate from the payer, because the customer
/// (an adult child, a spouse) is frequently not the patient (an elderly parent, a newborn, a
/// post-surgical adult). One customer registers many patients. Every read/write is tenancy-scoped to the
/// owning <see cref="CustomerId"/>.
/// </summary>
public class Patient : BaseEntity<long>
{
    public long CustomerId { get; set; }
    public CustomerProfile Customer { get; set; }

    public string DisplayName { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public DateOnly BirthDate { get; set; }

    /// <summary>"male" / "female". Required — load-bearing for same-gender caregiver matching.</summary>
    public string Gender { get; set; }

    public string BloodType { get; set; }

    /// <summary>The care recipient's relation to the paying customer — a stable code
    /// (<c>parent</c>/<c>spouse</c>/<c>child</c>/<c>self</c>). NULL when unspecified.</summary>
    public string Relation { get; set; }

    /// <summary>The patient's care conditions as a JSON array of stable codes
    /// (e.g. <c>["elderly","post_surgery"]</c>). Stored as JSON rather than a child table because it is
    /// only ever read/written whole with the patient (no server-side filtering on conditions at MVP).</summary>
    public string ConditionsJson { get; set; }

    /// <summary>Encrypted at rest.</summary>
    public string InitialMedicalNotes { get; set; }

    /// <summary>Archive flag — a patient is soft-archived (not hard-deleted) so the longitudinal care
    /// record (b14) is preserved.</summary>
    public bool IsActive { get; set; }
}
