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

    public int PrescriptionId { get; set; }

    public int PatientId { get; set; }

    public int DoctorId { get; set; }

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

    public virtual DrugTypePrescription? DrugTypePrescription { get; set; }

    public virtual ExaminationTypePrescription? ExaminationTypePrescription { get; set; }

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

    public virtual ProcedureTypePrescription? ProcedureTypePrescription { get; set; }
}

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

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

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

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

	public PrescriptionWrapper(Prescription src)
	{
		PrescriptionId = src.PrescriptionId;
		PatientId = src.PatientId;
		DoctorId = src.DoctorId;
		Person p = src.Patient.PatientNavigation;
		PatientName = p.LastName + " " + p.FirstName + " " + p.MiddleName;
	}

	internal static List<PrescriptionWrapper> ToList(List<Prescription> src)
	{
		List<PrescriptionWrapper> res = [];

		foreach (Prescription lst in src)
		{
			res.Add(new PrescriptionWrapper(lst));
		}

		return res;
	}
}
