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
051a3ae6
Commit
051a3ae6
authored
Aug 16, 2024
by
Almouhannad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(B) Update visit-related entities, add FKs to visit
parent
9e7dc695
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
234 additions
and
5 deletions
+234
-5
VisitMedicalImage.cs
.../Visits/Relations/VisitMedicalImages/VisitMedicalImage.cs
+40
-1
VisitMedicalTest.cs
...es/Visits/Relations/VisitMedicalTests/VisitMedicalTest.cs
+41
-1
VisitMedicine.cs
...Entities/Visits/Relations/VisitMedicines/VisitMedicine.cs
+29
-1
Visit.cs
Clinics.Backend/Domain/Entities/Visits/Visit.cs
+121
-2
PatientConfiguration.cs
...ce/Configurations/People/Patients/PatientConfiguration.cs
+1
-0
VisitConfiguration.cs
...d/Persistence/Configurations/Visits/VisitConfiguration.cs
+2
-0
No files found.
Clinics.Backend/Domain/Entities/Visits/Relations/VisitMedicalImages/VisitMedicalImage.cs
View file @
051a3ae6
using
Domain.Entities.Medicals.MedicalImages
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.Visits.Relations.VisitMedicalImages
;
// TODO: Convert result to a value object
public
sealed
class
VisitMedicalImage
(
int
id
)
:
Entity
(
id
)
public
sealed
class
VisitMedicalImage
:
Entity
{
#
region
Private
ctor
private
VisitMedicalImage
(
int
id
)
:
base
(
id
)
{
}
private
VisitMedicalImage
(
int
id
,
int
visitId
,
int
medicalImageId
)
:
base
(
id
)
{
VisitId
=
visitId
;
MedicalImageId
=
medicalImageId
;
Result
=
null
;
}
#
endregion
#
region
Properties
#
region
Visit
...
...
@@ -29,4 +44,28 @@ public sealed class VisitMedicalImage(int id) : Entity(id)
#
endregion
#
endregion
#
region
Methods
#
region
Static
factory
public
static
VisitMedicalImage
Create
(
int
visitId
,
int
medicalImageId
)
{
if
(
visitId
<=
0
||
medicalImageId
<=
0
)
throw
new
InvalidValuesDomainException
<
VisitMedicalImage
>();
return
new
VisitMedicalImage
(
0
,
visitId
,
medicalImageId
);
}
#
endregion
#
region
Add
result
public
void
AddResult
(
string
result
)
{
if
(
result
is
null
)
throw
new
InvalidValuesDomainException
<
VisitMedicalImage
>();
Result
=
result
;
}
#
endregion
#
endregion
}
Clinics.Backend/Domain/Entities/Visits/Relations/VisitMedicalTests/VisitMedicalTest.cs
View file @
051a3ae6
using
Domain.Entities.Medicals.MedicalTests
;
using
Domain.Entities.Visits.Relations.VisitMedicalImages
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.Visits.Relations.VisitMedicalTests
;
// TODO: Convert result to a value object
public
sealed
class
VisitMedicalTest
(
int
id
)
:
Entity
(
id
)
public
sealed
class
VisitMedicalTest
:
Entity
{
#
region
Private
ctor
private
VisitMedicalTest
(
int
id
)
:
base
(
id
)
{
}
private
VisitMedicalTest
(
int
id
,
int
visitId
,
int
medicalTestId
)
:
base
(
id
)
{
VisitId
=
visitId
;
MedicalTestId
=
medicalTestId
;
Result
=
null
;
}
#
endregion
#
region
Properties
#
region
Visit
...
...
@@ -29,4 +45,28 @@ public sealed class VisitMedicalTest(int id) : Entity(id)
#
endregion
#
endregion
#
region
Methods
#
region
Static
factory
public
static
VisitMedicalTest
Create
(
int
visitId
,
int
medicalTestId
)
{
if
(
visitId
<=
0
||
medicalTestId
<=
0
)
throw
new
InvalidValuesDomainException
<
VisitMedicalTest
>();
return
new
VisitMedicalTest
(
0
,
visitId
,
medicalTestId
);
}
#
endregion
#
region
Add
result
public
void
AddResult
(
string
result
)
{
if
(
result
is
null
)
throw
new
InvalidValuesDomainException
<
VisitMedicalTest
>();
Result
=
result
;
}
#
endregion
#
endregion
}
Clinics.Backend/Domain/Entities/Visits/Relations/VisitMedicines/VisitMedicine.cs
View file @
051a3ae6
using
Domain.Entities.Medicals.Medicines
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.Visits.Relations.VisitMedicines
;
public
sealed
class
VisitMedicine
(
int
id
)
:
Entity
(
id
)
public
sealed
class
VisitMedicine
:
Entity
{
#
region
Private
ctor
private
VisitMedicine
(
int
id
)
:
base
(
id
)
{
}
private
VisitMedicine
(
int
id
,
int
visitId
,
int
medicineId
,
int
number
)
:
base
(
id
)
{
VisitId
=
visitId
;
MedicineId
=
medicineId
;
Number
=
number
;
}
#
endregion
#
region
Properties
#
region
Visit
...
...
@@ -28,4 +42,18 @@ public sealed class VisitMedicine(int id) : Entity(id)
#
endregion
#
endregion
#
region
Methods
#
region
Static
factory
public
static
VisitMedicine
Create
(
int
visitId
,
int
medicineId
,
int
number
)
{
if
(
visitId
<=
0
||
medicineId
<=
0
||
number
<=
0
)
throw
new
InvalidValuesDomainException
<
VisitMedicine
>();
return
new
VisitMedicine
(
0
,
visitId
,
medicineId
,
number
);
}
#
endregion
#
endregion
}
Clinics.Backend/Domain/Entities/Visits/Visit.cs
View file @
051a3ae6
using
Domain.Entities.Medicals.Hospitals
;
using
Domain.Entities.Medicals.MedicalImages
;
using
Domain.Entities.Medicals.MedicalTests
;
using
Domain.Entities.Medicals.Medicines
;
using
Domain.Entities.People.Doctors
;
using
Domain.Entities.People.Patients
;
using
Domain.Entities.Visits.Relations.VisitMedicalImages
;
using
Domain.Entities.Visits.Relations.VisitMedicalTests
;
using
Domain.Entities.Visits.Relations.VisitMedicines
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
namespace
Domain.Entities.Visits
;
public
sealed
class
Visit
(
int
id
)
:
Entity
(
id
)
public
sealed
class
Visit
:
Entity
{
#
region
Private
ctor
private
Visit
(
int
id
)
:
base
(
id
)
{
}
private
Visit
(
int
id
,
int
patientId
,
int
doctorId
,
DateOnly
date
,
string
diagnosis
)
:
base
(
id
)
{
PatientId
=
patientId
;
DoctorId
=
doctorId
;
Date
=
date
;
Diagnosis
=
diagnosis
;
HospitalId
=
null
;
}
#
endregion
#
region
Properties
#
region
Patient
public
int
PatientId
{
get
;
set
;
}
public
Patient
Patient
{
get
;
set
;
}
=
null
!;
#
endregion
#
region
Doctor
public
int
DoctorId
{
get
;
set
;
}
public
Doctor
Doctor
{
get
;
set
;
}
=
null
!;
public
Hospital
?
Hospital
{
get
;
set
;
}
#
endregion
#
region
Additional
public
DateOnly
Date
{
get
;
set
;
}
public
string
Diagnosis
{
get
;
set
;
}
=
null
!;
#
region
Hospital
public
int
?
HospitalId
{
get
;
set
;
}
public
Hospital
?
Hospital
{
get
;
set
;
}
#
endregion
#
endregion
#
region
Navigations
public
ICollection
<
VisitMedicalImage
>
MedicalImages
{
get
;
set
;
}
=
[];
...
...
@@ -31,4 +70,84 @@ public sealed class Visit(int id) : Entity(id)
#
endregion
#
endregion
#
region
Methods
#
region
Static
factory
public
static
Visit
Create
(
int
patientId
,
int
doctorId
,
DateOnly
date
,
string
diagnosis
)
{
if
(
patientId
<=
0
||
doctorId
<=
0
||
diagnosis
is
null
)
throw
new
InvalidValuesDomainException
<
Visit
>();
return
new
Visit
(
0
,
patientId
,
doctorId
,
date
,
diagnosis
);
}
#
endregion
#
region
Add
medical
image
public
void
AddMedicalImage
(
MedicalImage
medicalImage
)
{
VisitMedicalImage
entry
;
try
{
entry
=
VisitMedicalImage
.
Create
(
Id
,
medicalImage
.
Id
);
}
catch
{
throw
;
}
if
(
MedicalImages
is
null
)
MedicalImages
=
[];
MedicalImages
.
Add
(
entry
);
}
#
endregion
#
region
Add
medical
test
public
void
AddMedicalTest
(
MedicalTest
medicalTest
)
{
VisitMedicalTest
entry
;
try
{
entry
=
VisitMedicalTest
.
Create
(
Id
,
medicalTest
.
Id
);
}
catch
{
throw
;
}
if
(
MedicalTests
is
null
)
MedicalTests
=
[];
MedicalTests
.
Add
(
entry
);
}
#
endregion
#
region
Add
medicine
public
void
AddMedicine
(
Medicine
medicine
,
int
number
)
{
VisitMedicine
entry
;
try
{
entry
=
VisitMedicine
.
Create
(
Id
,
medicine
.
Id
,
number
);
}
catch
{
throw
;
}
if
(
Medicines
is
null
)
Medicines
=
[];
Medicines
.
Add
(
entry
);
}
#
endregion
#
region
Add
hospital
public
void
AddHospital
(
Hospital
hospital
)
{
if
(
hospital
is
null
)
throw
new
InvalidValuesDomainException
<
Visit
>();
Hospital
=
hospital
;
HospitalId
=
hospital
.
Id
;
}
#
endregion
#
endregion
}
Clinics.Backend/Persistence/Configurations/People/Patients/PatientConfiguration.cs
View file @
051a3ae6
...
...
@@ -23,6 +23,7 @@ internal class PatientConfiguration : IEntityTypeConfiguration<Patient>
builder
.
HasMany
(
patient
=>
patient
.
Visits
)
.
WithOne
(
visit
=>
visit
.
Patient
)
.
HasForeignKey
(
visit
=>
visit
.
PatientId
)
.
OnDelete
(
DeleteBehavior
.
NoAction
);
}
}
\ No newline at end of file
Clinics.Backend/Persistence/Configurations/Visits/VisitConfiguration.cs
View file @
051a3ae6
...
...
@@ -14,10 +14,12 @@ internal class VisitConfiguration : IEntityTypeConfiguration<Visit>
builder
.
HasOne
(
visit
=>
visit
.
Doctor
)
.
WithMany
()
.
HasForeignKey
(
visit
=>
visit
.
DoctorId
)
.
OnDelete
(
DeleteBehavior
.
NoAction
);
builder
.
HasOne
(
visit
=>
visit
.
Hospital
)
.
WithMany
()
.
HasForeignKey
(
visit
=>
visit
.
HospitalId
)
.
OnDelete
(
DeleteBehavior
.
NoAction
);
}
}
\ No newline at end of file
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