using Register_office.BaseClasses;
using Register_office.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace Register_office;

public partial class HospitalAdmission : IUnionId
{
	public object GetId() => HospitalAdmissionId;

    public int HospitalAdmissionId { get; set; }

    public int PatientId { get; set; }

    public int PreliminaryDiseaseId { get; set; }

    public DateTime AdmissionDatetime { get; set; }

    public virtual ICollection<HospitalDischarge> HospitalDischarges { get; set; } = new List<HospitalDischarge>();

    public virtual Patient Patient { get; set; } = null!;

    public virtual Disease PreliminaryDisease { get; set; } = null!;
}

internal class HospitalAdmissionWrapper
{
	[Display(Name = "hide")]
	public int HospitalAdmissionId { get; set; }

	[Display(Name = "hide")]
	public int PatientId { get; set; }

	[Display(Name = "hide")]
	public int PreliminaryDiseaseId { get; set; }

	[Display(Name = "Пациент")]
	public string PatientName { get; set; } = null!;

	[Display(Name = "Заболевание")]
	public string DiseaseName { get; set; } = null!;

	[Display(Name = "Время")]
	public DateTime AdmissionDatetime { get; set; }

	public HospitalAdmissionWrapper(HospitalAdmission src)
	{
		HospitalAdmissionId = src.HospitalAdmissionId;
		PatientId = src.PatientId;
		PreliminaryDiseaseId = src.PreliminaryDiseaseId;
		DiseaseName = src.PreliminaryDisease.Name;
		AdmissionDatetime = src.AdmissionDatetime;
		Person p = src.Patient.PatientNavigation;
		PatientName = p.LastName + " " + p.FirstName + " " + p.MiddleName;
	}

	internal static List<HospitalAdmissionWrapper> ToList(List<HospitalAdmission> src)
	{
		List<HospitalAdmissionWrapper> res = [];

		foreach (HospitalAdmission lst in src)
		{
			res.Add(new HospitalAdmissionWrapper(lst));
		}

		return res;
	}
}