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 HospitalDischarge : IUnionId
{
	public object GetId() => HospitalDischargeId;

    public int HospitalDischargeId { get; set; }

    public int HospitalAdmissionId { get; set; }

    public DateTime DischargeDatetime { get; set; }

    public int FinalDiseaseId { get; set; }

	public string Reason { get; set; } = null!;

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

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

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

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

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

	[Display(Name = "Предв. заболевание")]
	public string DiseasePrName { get; set; } = null!;

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

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

	[Display(Name = "Причина завершения")]
	public string Reason { get; set; } = null!;

	public HospitalDischargeWrapper(HospitalDischarge src)
	{
		HospitalAdmissionId = src.HospitalAdmissionId;
		HospitalDischargeId = src.HospitalDischargeId;
		DiseasePrName = src.HospitalAdmission.PreliminaryDisease.Name;
		DiseaseFinName = src.FinalDisease.Name;
		DischargeDatetime = src.DischargeDatetime;
		Reason = src.Reason;
		Person p = src.HospitalAdmission.Patient.PatientNavigation;
		PatientName = p.LastName + " " + p.FirstName + " " + p.MiddleName;
	}

	internal static List<HospitalDischargeWrapper> ToList(List<HospitalDischarge> src)
	{
		List<HospitalDischargeWrapper> res = [];

		foreach (HospitalDischarge lst in src)
		{
			res.Add(new HospitalDischargeWrapper(lst));
		}

		return res;
	}
}