Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
HIAST-Clinics
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
almohanad.hafez
HIAST-Clinics
Commits
77bcfade
Commit
77bcfade
authored
Aug 16, 2024
by
Almouhannad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(B) Update Gender, Personal info, Patient domain objects
parent
6874b64f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
166 additions
and
17 deletions
+166
-17
Patient.cs
Clinics.Backend/Domain/Entities/People/Patients/Patient.cs
+83
-7
Gender.cs
...kend/Domain/Entities/People/Shared/GenderValues/Gender.cs
+35
-3
Genders.cs
...end/Domain/Entities/People/Shared/GenderValues/Genders.cs
+2
-2
PersonalInfo.cs
...ics.Backend/Domain/Entities/People/Shared/PersonalInfo.cs
+40
-5
PatientConfiguration.cs
...ce/Configurations/People/Patients/PatientConfiguration.cs
+2
-0
PersonalInfoConfiguration.cs
...Configurations/People/Shared/PersonalInfoConfiguration.cs
+4
-0
No files found.
Clinics.Backend/Domain/Entities/People/Patients/Patient.cs
View file @
77bcfade
...
@@ -3,29 +3,105 @@ using Domain.Entities.People.Patients.Relations.PatientMedicines;
...
@@ -3,29 +3,105 @@ using Domain.Entities.People.Patients.Relations.PatientMedicines;
using
Domain.Entities.People.Shared
;
using
Domain.Entities.People.Shared
;
using
Domain.Entities.People.Shared.GenderValues
;
using
Domain.Entities.People.Shared.GenderValues
;
using
Domain.Entities.Visits
;
using
Domain.Entities.Visits
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
using
Domain.Primitives
;
namespace
Domain.Entities.People.Patients
;
namespace
Domain.Entities.People.Patients
;
// TODO: Potential aggregate?
// TODO: Potential aggregate?
public
sealed
class
Patient
(
int
id
)
:
Entity
(
id
)
public
sealed
class
Patient
:
Entity
{
{
#
region
Private
ctor
private
Patient
(
int
id
)
:
base
(
id
)
{
}
private
Patient
(
int
id
,
PersonalInfo
personalInfo
,
DateOnly
dateOfBirth
,
Gender
gender
)
:
base
(
id
)
{
PersonalInfo
=
personalInfo
;
DateOfBirth
=
dateOfBirth
;
Gender
=
gender
;
Diseases
=
[];
Medicines
=
[];
Visits
=
[];
}
#
endregion
#
region
Properties
#
region
Properties
public
PersonalInfo
PersonalInfo
{
get
;
set
;
}
=
null
!;
public
PersonalInfo
PersonalInfo
{
get
;
private
set
;
}
=
null
!;
public
DateOnly
DateOfBirth
{
get
;
private
set
;
}
public
DateOnly
DateOfBirth
{
get
;
set
;
}
public
int
Age
{
get
{
var
today
=
DateOnly
.
FromDateTime
(
DateTime
.
Today
);
var
age
=
today
.
Year
-
DateOfBirth
.
Year
;
if
(
today
.
Month
<
DateOfBirth
.
Month
||
(
today
.
Month
==
DateOfBirth
.
Month
&&
today
.
Day
<
DateOfBirth
.
Day
))
{
age
--;
}
return
age
;
}
}
public
Gender
Gender
{
get
;
set
;
}
=
null
!;
public
Gender
Gender
{
get
;
private
set
;
}
=
null
!;
#
region
Navigations
#
region
Navigations
public
ICollection
<
PatientDisease
>
Diseases
{
get
;
set
;
}
=
[];
public
ICollection
<
PatientDisease
>
Diseases
{
get
;
set
;
}
public
ICollection
<
PatientMedicine
>
Medicines
{
get
;
set
;
}
public
ICollection
<
Visit
>
Visits
{
get
;
set
;
}
#
endregion
#
endregion
#
region
Methods
#
region
Static
factory
public
static
Patient
Create
(
string
firstName
,
string
middleName
,
string
lastName
,
DateOnly
dateOfBirth
,
string
gender
)
{
#
region
Personal
info
PersonalInfo
?
personalInfo
;
try
{
personalInfo
=
PersonalInfo
.
Create
(
firstName
,
middleName
,
lastName
);
}
catch
{
throw
;
}
#
endregion
#
region
Gender
Gender
?
selectedGender
;
Gender
male
=
Genders
.
Male
;
Gender
female
=
Genders
.
Female
;
if
(
gender
==
male
.
Name
)
selectedGender
=
male
;
else
if
(
gender
==
female
.
Name
)
selectedGender
=
female
;
else
selectedGender
=
null
;
public
ICollection
<
PatientMedicine
>
Medicines
{
get
;
set
;
}
=
[];
if
(
selectedGender
is
null
)
throw
new
InvalidValuesDomainException
<
Gender
>();
#
endregion
public
ICollection
<
Visit
>
Visits
{
get
;
set
;
}
=
[]
;
return
new
Patient
(
0
,
personalInfo
,
dateOfBirth
,
selectedGender
)
;
}
#
endregion
#
endregion
#
endregion
#
endregion
...
...
Clinics.Backend/Domain/Entities/People/Shared/GenderValues/Gender.cs
View file @
77bcfade
using
Domain.Primitives
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.People.Shared.GenderValues
;
namespace
Domain.Entities.People.Shared.GenderValues
;
// TODO: Convert to a value object
// TODO: Convert to a value object
public
sealed
class
Gender
(
int
id
)
:
Entity
(
id
)
public
sealed
class
Gender
:
Entity
{
{
#
region
Private
ctor
private
Gender
(
int
id
)
:
base
(
id
)
{
}
private
Gender
(
int
id
,
string
name
)
:
base
(
id
)
{
Name
=
name
;
}
#
endregion
#
region
Properties
#
region
Properties
public
string
Name
{
get
;
set
;
}
=
null
!;
public
string
Name
{
get
;
private
set
;
}
=
null
!;
#
endregion
#
region
Methods
#
region
Static
factory
public
static
Gender
Create
(
string
name
,
int
?
id
)
{
if
(
name
is
null
)
throw
new
InvalidValuesDomainException
<
Gender
>();
if
(
id
<
0
)
throw
new
InvalidValuesDomainException
<
Gender
>();
if
(
id
is
not
null
)
return
new
Gender
(
id
.
Value
,
name
);
return
new
Gender
(
0
,
name
);
}
#
endregion
#
endregion
#
endregion
}
}
Clinics.Backend/Domain/Entities/People/Shared/GenderValues/Genders.cs
View file @
77bcfade
...
@@ -4,9 +4,9 @@ public static class Genders
...
@@ -4,9 +4,9 @@ public static class Genders
{
{
#
region
Constant
id
values
#
region
Constant
id
values
public
static
int
Male
=>
1
;
public
static
Gender
Male
=>
Gender
.
Create
(
"ذكر"
,
1
)
;
public
static
int
Female
=>
2
;
public
static
Gender
Female
=>
Gender
.
Create
(
"أنثى"
,
2
)
;
#
endregion
#
endregion
}
}
Clinics.Backend/Domain/Entities/People/Shared/PersonalInfo.cs
View file @
77bcfade
using
Domain.Primitives
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.People.Shared
;
namespace
Domain.Entities.People.Shared
;
// TODO: Convert props to value objects
// TODO: Convert props to value objects
public
sealed
class
PersonalInfo
(
int
id
)
:
Entity
(
id
)
public
sealed
class
PersonalInfo
:
Entity
{
{
#
region
Private
ctor
private
PersonalInfo
(
int
id
)
:
base
(
id
)
{
}
private
PersonalInfo
(
int
id
,
string
firstName
,
string
middleName
,
string
lastName
)
:
base
(
id
)
{
FirstName
=
firstName
;
MiddleName
=
middleName
;
LastName
=
lastName
;
}
#
endregion
#
region
Properties
#
region
Properties
public
string
FirstName
{
get
;
set
;
}
=
null
!;
public
string
FirstName
{
get
;
private
set
;
}
=
null
!;
public
string
MiddleName
{
get
;
private
set
;
}
=
null
!;
public
string
MiddleName
{
get
;
set
;
}
=
null
!;
public
string
LastName
{
get
;
private
set
;
}
=
null
!;
public
string
LastName
{
get
;
set
;
}
=
null
!;
public
string
FullName
{
get
{
return
$"
{
FirstName
}
{
MiddleName
}
{
LastName
}
"
;
}
}
#
endregion
#
endregion
#
region
Methods
#
region
Static
factory
public
static
PersonalInfo
Create
(
string
firstName
,
string
middleName
,
string
lastName
)
{
if
(
firstName
is
null
||
middleName
is
null
||
lastName
is
null
)
throw
new
InvalidValuesDomainException
<
PersonalInfo
>();
return
new
PersonalInfo
(
0
,
firstName
,
middleName
,
lastName
);
}
#
endregion
#
endregion
}
}
Clinics.Backend/Persistence/Configurations/People/Patients/PatientConfiguration.cs
View file @
77bcfade
...
@@ -10,6 +10,8 @@ internal class PatientConfiguration : IEntityTypeConfiguration<Patient>
...
@@ -10,6 +10,8 @@ internal class PatientConfiguration : IEntityTypeConfiguration<Patient>
{
{
builder
.
ToTable
(
nameof
(
Patient
));
builder
.
ToTable
(
nameof
(
Patient
));
builder
.
Ignore
(
patient
=>
patient
.
Age
);
builder
.
HasOne
(
patient
=>
patient
.
PersonalInfo
)
builder
.
HasOne
(
patient
=>
patient
.
PersonalInfo
)
.
WithOne
()
.
WithOne
()
.
HasForeignKey
<
Patient
>(
"PersonalInfoId"
)
.
HasForeignKey
<
Patient
>(
"PersonalInfoId"
)
...
...
Clinics.Backend/Persistence/Configurations/People/Shared/PersonalInfoConfiguration.cs
View file @
77bcfade
...
@@ -10,8 +10,12 @@ internal class PersonalInfoConfiguration : IEntityTypeConfiguration<PersonalInfo
...
@@ -10,8 +10,12 @@ internal class PersonalInfoConfiguration : IEntityTypeConfiguration<PersonalInfo
{
{
builder
.
ToTable
(
nameof
(
PersonalInfo
));
builder
.
ToTable
(
nameof
(
PersonalInfo
));
builder
.
Ignore
(
personalInfo
=>
personalInfo
.
FullName
);
builder
.
Property
(
personalInfo
=>
personalInfo
.
FirstName
).
HasMaxLength
(
50
);
builder
.
Property
(
personalInfo
=>
personalInfo
.
FirstName
).
HasMaxLength
(
50
);
builder
.
Property
(
personalInfo
=>
personalInfo
.
LastName
).
HasMaxLength
(
50
);
builder
.
Property
(
personalInfo
=>
personalInfo
.
LastName
).
HasMaxLength
(
50
);
builder
.
Property
(
personalInfo
=>
personalInfo
.
MiddleName
).
HasMaxLength
(
50
);
builder
.
Property
(
personalInfo
=>
personalInfo
.
MiddleName
).
HasMaxLength
(
50
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment