Commit 12973dd0 authored by Almouhannad's avatar Almouhannad

(B) Update medical related entities

parent 56b44861
using Domain.Entities.People.Patients.Relations.PatientDiseases; using Domain.Entities.People.Patients.Relations.PatientDiseases;
using Domain.Exceptions.InvalidValue;
using Domain.Primitives; using Domain.Primitives;
namespace Domain.Entities.Medicals.Diseases; namespace Domain.Entities.Medicals.Diseases;
public sealed class Disease(int id) : Entity(id) public sealed class Disease : Entity
{ {
#region Private ctor
private Disease(int id) : base(id) { }
private Disease(int id, string name) : base(id)
{
Name = name;
}
#endregion
#region Properties #region Properties
public string Name { get; set; } = null!; public string Name { get; set; } = null!;
...@@ -16,4 +27,17 @@ public sealed class Disease(int id) : Entity(id) ...@@ -16,4 +27,17 @@ public sealed class Disease(int id) : Entity(id)
#endregion #endregion
#endregion #endregion
#region Methods
#region Static factory
public static Disease Create(string name)
{
if (name is null)
throw new InvalidValuesDomainException<Disease>();
return new Disease(0, name);
}
#endregion
#endregion
} }
using Domain.Primitives; using Domain.Exceptions.InvalidValue;
using Domain.Primitives;
namespace Domain.Entities.Medicals.Hospitals; namespace Domain.Entities.Medicals.Hospitals;
public sealed class Hospital(int id) : Entity(id) public sealed class Hospital : Entity
{ {
#region Private ctor
private Hospital(int id) : base(id) { }
private Hospital(int id, string name) : base(id)
{
Name = name;
}
#endregion
#region Properties #region Properties
public string Name { get; set; } = null!; public string Name { get; set; } = null!;
#endregion #endregion
#region Methods
#region Static factory
public static Hospital Create(string name)
{
if (name is null)
throw new InvalidValuesDomainException<Hospital>();
return new Hospital(0, name);
}
#endregion
#endregion
} }
using Domain.Primitives; using Domain.Exceptions.InvalidValue;
using Domain.Primitives;
namespace Domain.Entities.Medicals.MedicalImages; namespace Domain.Entities.Medicals.MedicalImages;
public sealed class MedicalImage(int id) : Entity(id) public sealed class MedicalImage : Entity
{ {
#region Private ctor
private MedicalImage(int id) : base(id) { }
private MedicalImage(int id, string name, string? description = null) : base(id)
{
Name = name;
Description = description;
}
#endregion
#region Properties #region Properties
public string Name { get; set; } = null!; public string Name { get; set; } = null!;
...@@ -11,4 +22,17 @@ public sealed class MedicalImage(int id) : Entity(id) ...@@ -11,4 +22,17 @@ public sealed class MedicalImage(int id) : Entity(id)
public string? Description { get; set; } public string? Description { get; set; }
#endregion #endregion
#region Methods
#region Static factory
public static MedicalImage Create(string name, string? description = null)
{
if (name is null)
throw new InvalidValuesDomainException<MedicalImage>();
return new MedicalImage(0, name, description);
}
#endregion
#endregion
} }
using Domain.Primitives; using Domain.Exceptions.InvalidValue;
using Domain.Primitives;
namespace Domain.Entities.Medicals.MedicalTests; namespace Domain.Entities.Medicals.MedicalTests;
public sealed class MedicalTest(int id) : Entity(id) public sealed class MedicalTest : Entity
{ {
#region Private ctor
private MedicalTest(int id) : base(id) { }
private MedicalTest(int id, string name, string? description = null) : base(id)
{
Name = name;
Description = description;
}
#endregion
#region Properties #region Properties
public string Name { get; set; } = null!; public string Name { get; set; } = null!;
...@@ -11,4 +22,17 @@ public sealed class MedicalTest(int id) : Entity(id) ...@@ -11,4 +22,17 @@ public sealed class MedicalTest(int id) : Entity(id)
public string? Description { get; set; } public string? Description { get; set; }
#endregion #endregion
#region Methods
#region Static factory
public static MedicalTest Create(string name, string description)
{
if (name is null)
throw new InvalidValuesDomainException<MedicalTest>();
return new MedicalTest(0, name, description);
}
#endregion
#endregion
} }
using Domain.Entities.Medicals.Medicines.MedicineFormValues; using Domain.Entities.Medicals.Medicines.MedicineFormValues;
using Domain.Entities.People.Patients.Relations.PatientMedicines; using Domain.Entities.People.Patients.Relations.PatientMedicines;
using Domain.Exceptions.InvalidValue;
using Domain.Primitives; using Domain.Primitives;
namespace Domain.Entities.Medicals.Medicines; namespace Domain.Entities.Medicals.Medicines;
// TODO: Convert Dosage to value object // TODO: Convert Dosage to value object
public sealed class Medicine(int id) : Entity(id) public sealed class Medicine : Entity
{ {
#region Private ctor
private Medicine(int id) : base(id) { }
private Medicine(int id, MedicineForm medicineForm, int amount, string name, decimal dosage) : base(id)
{
MedicineForm = medicineForm;
Amount = amount;
Name = name;
Dosage = dosage;
}
#endregion
#region Properties #region Properties
public MedicineForm MedicineForm { get; set; } = null!; public MedicineForm MedicineForm { get; set; } = null!;
...@@ -24,4 +39,33 @@ public sealed class Medicine(int id) : Entity(id) ...@@ -24,4 +39,33 @@ public sealed class Medicine(int id) : Entity(id)
#endregion #endregion
#endregion #endregion
#region Methods
#region Static factory
public static Medicine Create(string form, int amount, string name, decimal dosage)
{
if (form is null || name is null || amount < 0 || dosage < 0)
throw new InvalidValuesDomainException<Medicine>();
#region Check form
MedicineForm selectedMedicineForm;
MedicineForm tablet = MedicineForms.Tablet;
MedicineForm syrup = MedicineForms.Syrup;
if (form == tablet.Name)
selectedMedicineForm = tablet;
else if (form == syrup.Name)
selectedMedicineForm = syrup;
else throw new InvalidValuesDomainException<MedicineForm>();
#endregion
return new Medicine(0, selectedMedicineForm, amount, name, dosage);
}
#endregion
#endregion
} }
using Domain.Primitives; using Domain.Exceptions.InvalidValue;
using Domain.Primitives;
namespace Domain.Entities.Medicals.Medicines.MedicineFormValues; namespace Domain.Entities.Medicals.Medicines.MedicineFormValues;
public sealed class MedicineForm(int id) : Entity(id) public sealed class MedicineForm : Entity
{ {
#region Private ctor
private MedicineForm(int id) : base(id) { }
private MedicineForm(int id, string name) : base(id)
{
Name = name;
}
#endregion
#region Properties #region Properties
public string Name { get; set; } = null!; public string Name { get; set; } = null!;
#endregion #endregion
#region Methods
#region Static factory
public static MedicineForm Create(string name, int? id)
{
if (name is null)
throw new InvalidValuesDomainException<MedicineForm>();
if (id is not null)
{
if (id < 0)
throw new InvalidValuesDomainException<MedicineForm>();
return new MedicineForm(id.Value, name);
}
return new MedicineForm(0, name);
}
#endregion
#endregion
} }
...@@ -4,9 +4,9 @@ public static class MedicineForms ...@@ -4,9 +4,9 @@ public static class MedicineForms
{ {
#region Constant id values #region Constant id values
public static int Tablet => 1; public static MedicineForm Tablet => MedicineForm.Create("حبوب", 1);
public static int Syrup => 2; public static MedicineForm Syrup => MedicineForm.Create("شراب", 2);
#endregion #endregion
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment