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

namespace Register_office.Model;

public partial class DrugTypePrescription : IUnionId
{
	public object GetId() => DrugPrescriptionId;

    public int DrugPrescriptionId { get; set; }

    public int PrescriptionId { get; set; }

    public int DrugTypeId { get; set; }

    public decimal Dose { get; set; }

    public int DoseUnitId { get; set; }

    public int IntakeMethodId { get; set; }

    public int DurationDays { get; set; }

    public virtual Unit DoseUnit { get; set; } = null!;

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

    public virtual DrugIntakeMethod IntakeMethod { get; set; } = null!;

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

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

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

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

	[Display(Name = "Лекарства")]
	public string DrugName { get; set; } = null!;

	[Display(Name = "Количество")]
	public decimal Dose { get; set; }

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

	[Display(Name = "Единица изм.")]
	public string UnitName { get; set; } = null!;

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

	[Display(Name = "Способ приема")]
	public string IntakeMethodName { get; set; } = null!;

	[Display(Name = "Длительность")]
	public int DurationDays { get; set; }

	public DrugTypePrescriptionWrapper(DrugTypePrescription src)
	{
		DrugPrescriptionId = src.DrugPrescriptionId;
		PrescriptionId = src.PrescriptionId;
		DrugTypeId = src.DrugTypeId;
		DrugName = src.DrugType.InternationalNameRu;
		Dose = src.Dose;
		DoseUnitId = src.DoseUnitId;
		UnitName = src.DoseUnit.Name;
		IntakeMethodId = src.IntakeMethodId;
		IntakeMethodName = src.IntakeMethod.Name;
		DurationDays = src.DurationDays;
	}

	internal static List<DrugTypePrescriptionWrapper> ToList(List<DrugTypePrescription> src)
	{
		List<DrugTypePrescriptionWrapper> res = [];

		foreach (DrugTypePrescription lst in src)
		{
			res.Add(new DrugTypePrescriptionWrapper(lst));
		}

		return res;
	}
}