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
de273e03
Commit
de273e03
authored
Aug 18, 2024
by
Almouhannad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(B) Apply result on visit, waitingList entities
parent
7198c837
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
103 additions
and
85 deletions
+103
-85
Employee.cs
Clinics.Backend/Domain/Entities/People/Employees/Employee.cs
+3
-3
VisitMedicalImage.cs
.../Visits/Relations/VisitMedicalImages/VisitMedicalImage.cs
+11
-10
VisitMedicalTest.cs
...es/Visits/Relations/VisitMedicalTests/VisitMedicalTest.cs
+11
-11
VisitMedicine.cs
...Entities/Visits/Relations/VisitMedicines/VisitMedicine.cs
+8
-8
Visit.cs
Clinics.Backend/Domain/Entities/Visits/Visit.cs
+56
-48
WaitingListRecord.cs
....Backend/Domain/Entities/WaitingList/WaitingListRecord.cs
+7
-5
DomainErrors.cs
Clinics.Backend/Domain/Errors/DomainErrors.cs
+7
-0
No files found.
Clinics.Backend/Domain/Entities/People/Employees/Employee.cs
View file @
de273e03
...
@@ -124,7 +124,7 @@ public sealed class Employee : Entity
...
@@ -124,7 +124,7 @@ public sealed class Employee : Entity
#
endregion
#
endregion
#
region
Check
duplicate
#
region
Check
duplicate
if
(
FamilyMembers
.
Where
(
fm
=>
fm
.
FamilyMember
Id
==
familyMember
.
Id
).
ToList
().
Count
>
0
)
if
(
FamilyMembers
.
Where
(
fm
=>
fm
.
FamilyMember
==
familyMember
).
ToList
().
Count
>
0
)
return
Result
.
Failure
(
Errors
.
DomainErrors
.
RelationAlreadyExist
);
return
Result
.
Failure
(
Errors
.
DomainErrors
.
RelationAlreadyExist
);
#
endregion
#
endregion
...
@@ -151,8 +151,8 @@ public sealed class Employee : Entity
...
@@ -151,8 +151,8 @@ public sealed class Employee : Entity
#
region
Check
duplicate
#
region
Check
duplicate
if
(
RelatedEmployees
.
Where
(
re
=>
re
.
Id
==
employee
.
Id
).
ToList
().
Count
>
0
if
(
RelatedEmployees
.
Where
(
re
=>
re
==
employee
).
ToList
().
Count
>
0
||
RelatedTo
.
Where
(
rt
=>
rt
.
Id
==
employee
.
Id
).
ToList
().
Count
>
0
||
RelatedTo
.
Where
(
rt
=>
rt
==
employee
).
ToList
().
Count
>
0
)
)
return
Result
.
Failure
(
Errors
.
DomainErrors
.
RelationAlreadyExist
);
return
Result
.
Failure
(
Errors
.
DomainErrors
.
RelationAlreadyExist
);
...
...
Clinics.Backend/Domain/Entities/Visits/Relations/VisitMedicalImages/VisitMedicalImage.cs
View file @
de273e03
using
Domain.Entities.Medicals.MedicalImages
;
using
Domain.Entities.Medicals.MedicalImages
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
using
Domain.Primitives
;
using
Domain.Shared
;
namespace
Domain.Entities.Visits.Relations.VisitMedicalImages
;
namespace
Domain.Entities.Visits.Relations.VisitMedicalImages
;
...
@@ -25,21 +25,21 @@ public sealed class VisitMedicalImage : Entity
...
@@ -25,21 +25,21 @@ public sealed class VisitMedicalImage : Entity
#
region
Visit
#
region
Visit
public
int
VisitId
{
get
;
set
;
}
public
int
VisitId
{
get
;
private
set
;
}
public
Visit
Visit
{
get
;
set
;
}
=
null
!;
public
Visit
Visit
{
get
;
private
set
;
}
=
null
!;
#
endregion
#
endregion
#
region
Medical
image
#
region
Medical
image
public
int
MedicalImageId
{
get
;
set
;
}
public
int
MedicalImageId
{
get
;
private
set
;
}
public
MedicalImage
MedicalImage
{
get
;
set
;
}
=
null
!;
public
MedicalImage
MedicalImage
{
get
;
private
set
;
}
=
null
!;
#
endregion
#
endregion
#
region
Additional
#
region
Additional
public
string
?
Result
{
get
;
set
;
}
public
string
?
Result
{
get
;
private
set
;
}
#
endregion
#
endregion
...
@@ -48,22 +48,23 @@ public sealed class VisitMedicalImage : Entity
...
@@ -48,22 +48,23 @@ public sealed class VisitMedicalImage : Entity
#
region
Methods
#
region
Methods
#
region
Static
factory
#
region
Static
factory
public
static
VisitMedicalImage
Create
(
int
visitId
,
int
medicalImageId
)
public
static
Result
<
VisitMedicalImage
>
Create
(
int
visitId
,
int
medicalImageId
)
{
{
if
(
visitId
<=
0
||
medicalImageId
<=
0
)
if
(
visitId
<=
0
||
medicalImageId
<=
0
)
throw
new
InvalidValuesDomainException
<
VisitMedicalImage
>(
);
return
Shared
.
Result
.
Failure
<
VisitMedicalImage
>(
Errors
.
DomainErrors
.
InvalidValuesError
);
return
new
VisitMedicalImage
(
0
,
visitId
,
medicalImageId
);
return
new
VisitMedicalImage
(
0
,
visitId
,
medicalImageId
);
}
}
#
endregion
#
endregion
#
region
Add
result
#
region
Add
result
public
void
AddResult
(
string
result
)
public
Result
AddResult
(
string
result
)
{
{
if
(
result
is
null
)
if
(
result
is
null
)
throw
new
InvalidValuesDomainException
<
VisitMedicalImage
>(
);
return
Shared
.
Result
.
Failure
(
Errors
.
DomainErrors
.
InvalidValuesError
);
Result
=
result
;
Result
=
result
;
return
Shared
.
Result
.
Success
();
}
}
#
endregion
#
endregion
...
...
Clinics.Backend/Domain/Entities/Visits/Relations/VisitMedicalTests/VisitMedicalTest.cs
View file @
de273e03
using
Domain.Entities.Medicals.MedicalTests
;
using
Domain.Entities.Medicals.MedicalTests
;
using
Domain.Entities.Visits.Relations.VisitMedicalImages
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
using
Domain.Primitives
;
using
Domain.Shared
;
namespace
Domain.Entities.Visits.Relations.VisitMedicalTests
;
namespace
Domain.Entities.Visits.Relations.VisitMedicalTests
;
...
@@ -26,21 +25,21 @@ public sealed class VisitMedicalTest : Entity
...
@@ -26,21 +25,21 @@ public sealed class VisitMedicalTest : Entity
#
region
Visit
#
region
Visit
public
int
VisitId
{
get
;
set
;
}
public
int
VisitId
{
get
;
private
set
;
}
public
Visit
Visit
{
get
;
set
;
}
=
null
!;
public
Visit
Visit
{
get
;
private
set
;
}
=
null
!;
#
endregion
#
endregion
#
region
Medical
test
#
region
Medical
test
public
int
MedicalTestId
{
get
;
set
;
}
public
int
MedicalTestId
{
get
;
private
set
;
}
public
MedicalTest
MedicalTest
{
get
;
set
;
}
=
null
!;
public
MedicalTest
MedicalTest
{
get
;
private
set
;
}
=
null
!;
#
endregion
#
endregion
#
region
Additional
#
region
Additional
public
string
?
Result
{
get
;
set
;
}
public
string
?
Result
{
get
;
private
set
;
}
#
endregion
#
endregion
...
@@ -49,22 +48,23 @@ public sealed class VisitMedicalTest : Entity
...
@@ -49,22 +48,23 @@ public sealed class VisitMedicalTest : Entity
#
region
Methods
#
region
Methods
#
region
Static
factory
#
region
Static
factory
public
static
VisitMedicalTest
Create
(
int
visitId
,
int
medicalTestId
)
public
static
Result
<
VisitMedicalTest
>
Create
(
int
visitId
,
int
medicalTestId
)
{
{
if
(
visitId
<=
0
||
medicalTestId
<=
0
)
if
(
visitId
<=
0
||
medicalTestId
<=
0
)
throw
new
InvalidValuesDomainException
<
VisitMedicalTest
>(
);
return
Shared
.
Result
.
Failure
<
VisitMedicalTest
>(
Errors
.
DomainErrors
.
InvalidValuesError
);
return
new
VisitMedicalTest
(
0
,
visitId
,
medicalTestId
);
return
new
VisitMedicalTest
(
0
,
visitId
,
medicalTestId
);
}
}
#
endregion
#
endregion
#
region
Add
result
#
region
Add
result
public
void
AddResult
(
string
result
)
public
Result
AddResult
(
string
result
)
{
{
if
(
result
is
null
)
if
(
result
is
null
)
throw
new
InvalidValuesDomainException
<
VisitMedicalTest
>(
);
return
Shared
.
Result
.
Failure
(
Errors
.
DomainErrors
.
InvalidValuesError
);
Result
=
result
;
Result
=
result
;
return
Shared
.
Result
.
Success
();
}
}
#
endregion
#
endregion
...
...
Clinics.Backend/Domain/Entities/Visits/Relations/VisitMedicines/VisitMedicine.cs
View file @
de273e03
using
Domain.Entities.Medicals.Medicines
;
using
Domain.Entities.Medicals.Medicines
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
using
Domain.Primitives
;
using
Domain.Shared
;
namespace
Domain.Entities.Visits.Relations.VisitMedicines
;
namespace
Domain.Entities.Visits.Relations.VisitMedicines
;
...
@@ -23,21 +23,21 @@ public sealed class VisitMedicine : Entity
...
@@ -23,21 +23,21 @@ public sealed class VisitMedicine : Entity
#
region
Visit
#
region
Visit
public
int
VisitId
{
get
;
set
;
}
public
int
VisitId
{
get
;
private
set
;
}
public
Visit
Visit
{
get
;
set
;
}
=
null
!;
public
Visit
Visit
{
get
;
private
set
;
}
=
null
!;
#
endregion
#
endregion
#
region
Medicine
#
region
Medicine
public
int
MedicineId
{
get
;
set
;
}
public
int
MedicineId
{
get
;
private
set
;
}
public
Medicine
Medicine
{
get
;
set
;
}
=
null
!;
public
Medicine
Medicine
{
get
;
private
set
;
}
=
null
!;
#
endregion
#
endregion
#
region
Additional
#
region
Additional
public
int
Number
{
get
;
set
;
}
public
int
Number
{
get
;
private
set
;
}
#
endregion
#
endregion
...
@@ -46,10 +46,10 @@ public sealed class VisitMedicine : Entity
...
@@ -46,10 +46,10 @@ public sealed class VisitMedicine : Entity
#
region
Methods
#
region
Methods
#
region
Static
factory
#
region
Static
factory
public
static
VisitMedicine
Create
(
int
visitId
,
int
medicineId
,
int
number
)
public
static
Result
<
VisitMedicine
>
Create
(
int
visitId
,
int
medicineId
,
int
number
)
{
{
if
(
visitId
<=
0
||
medicineId
<=
0
||
number
<=
0
)
if
(
visitId
<=
0
||
medicineId
<=
0
||
number
<=
0
)
throw
new
InvalidValuesDomainException
<
VisitMedicine
>(
);
return
Result
.
Failure
<
VisitMedicine
>(
Errors
.
DomainErrors
.
InvalidValuesError
);
return
new
VisitMedicine
(
0
,
visitId
,
medicineId
,
number
);
return
new
VisitMedicine
(
0
,
visitId
,
medicineId
,
number
);
}
}
...
...
Clinics.Backend/Domain/Entities/Visits/Visit.cs
View file @
de273e03
...
@@ -7,8 +7,8 @@ using Domain.Entities.People.Patients;
...
@@ -7,8 +7,8 @@ using Domain.Entities.People.Patients;
using
Domain.Entities.Visits.Relations.VisitMedicalImages
;
using
Domain.Entities.Visits.Relations.VisitMedicalImages
;
using
Domain.Entities.Visits.Relations.VisitMedicalTests
;
using
Domain.Entities.Visits.Relations.VisitMedicalTests
;
using
Domain.Entities.Visits.Relations.VisitMedicines
;
using
Domain.Entities.Visits.Relations.VisitMedicines
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
using
Domain.Primitives
;
using
Domain.Shared
;
namespace
Domain.Entities.Visits
;
namespace
Domain.Entities.Visits
;
...
@@ -34,23 +34,23 @@ public sealed class Visit : Entity
...
@@ -34,23 +34,23 @@ public sealed class Visit : Entity
#
region
Patient
#
region
Patient
public
int
PatientId
{
get
;
set
;
}
public
int
PatientId
{
get
;
private
set
;
}
public
Patient
Patient
{
get
;
set
;
}
=
null
!;
public
Patient
Patient
{
get
;
private
set
;
}
=
null
!;
#
endregion
#
endregion
#
region
Doctor
#
region
Doctor
public
int
DoctorId
{
get
;
set
;
}
public
int
DoctorId
{
get
;
private
set
;
}
public
Doctor
Doctor
{
get
;
set
;
}
=
null
!;
public
Doctor
Doctor
{
get
;
private
set
;
}
=
null
!;
#
endregion
#
endregion
#
region
Additional
#
region
Additional
public
DateOnly
Date
{
get
;
set
;
}
public
DateOnly
Date
{
get
;
private
set
;
}
public
string
Diagnosis
{
get
;
set
;
}
=
null
!;
public
string
Diagnosis
{
get
;
private
set
;
}
=
null
!;
#
region
Hospital
#
region
Hospital
...
@@ -88,73 +88,81 @@ public sealed class Visit : Entity
...
@@ -88,73 +88,81 @@ public sealed class Visit : Entity
#
region
Methods
#
region
Methods
#
region
Static
factory
#
region
Static
factory
public
static
Visit
Create
(
int
patientId
,
int
doctorId
,
DateOnly
date
,
string
diagnosis
)
public
static
Result
<
Visit
>
Create
(
int
patientId
,
int
doctorId
,
DateOnly
date
,
string
diagnosis
)
{
{
if
(
patientId
<=
0
||
doctorId
<=
0
||
diagnosis
is
null
)
if
(
patientId
<=
0
||
doctorId
<=
0
||
diagnosis
is
null
)
throw
new
InvalidValuesDomainException
<
Visit
>(
);
return
Result
.
Failure
<
Visit
>(
Errors
.
DomainErrors
.
InvalidValuesError
);
return
new
Visit
(
0
,
patientId
,
doctorId
,
date
,
diagnosis
);
return
new
Visit
(
0
,
patientId
,
doctorId
,
date
,
diagnosis
);
}
}
#
endregion
#
endregion
#
region
Add
medical
image
#
region
Add
medical
image
public
void
AddMedicalImage
(
MedicalImage
medicalImage
)
public
Result
AddMedicalImage
(
MedicalImage
medicalImage
)
{
{
VisitMedicalImage
entry
;
#
region
Create
medical
image
to
attach
try
Result
<
VisitMedicalImage
>
entry
=
VisitMedicalImage
.
Create
(
Id
,
medicalImage
.
Id
);
{
if
(
entry
.
IsFailure
)
entry
=
VisitMedicalImage
.
Create
(
Id
,
medicalImage
.
Id
);
return
Result
.
Failure
(
Errors
.
DomainErrors
.
InvalidValuesError
);
}
#
endregion
catch
{
#
region
Check
duplicate
throw
;
if
(
MedicalImages
.
Where
(
mi
=>
mi
.
MedicalImage
==
medicalImage
).
ToList
().
Count
>
0
)
}
return
Result
.
Failure
(
Errors
.
DomainErrors
.
VisitAlreadyHasThisMedicalImage
);
#
endregion
_medicalImages
.
Add
(
entry
);
_medicalImages
.
Add
(
entry
.
Value
);
return
Result
.
Success
();
}
}
#
endregion
#
endregion
#
region
Add
medical
test
#
region
Add
medical
test
public
void
AddMedicalTest
(
MedicalTest
medicalTest
)
public
Result
AddMedicalTest
(
MedicalTest
medicalTest
)
{
{
VisitMedicalTest
entry
;
#
region
Create
medical
test
to
attach
try
Result
<
VisitMedicalTest
>
entry
=
VisitMedicalTest
.
Create
(
Id
,
medicalTest
.
Id
);
{
if
(
entry
.
IsFailure
)
entry
=
VisitMedicalTest
.
Create
(
Id
,
medicalTest
.
Id
);
return
Result
.
Failure
(
Errors
.
DomainErrors
.
InvalidValuesError
);
}
#
endregion
catch
{
#
region
Check
duplicate
throw
;
if
(
MedicalTests
.
Where
(
mt
=>
mt
.
MedicalTest
==
medicalTest
).
ToList
().
Count
>
0
)
}
return
Result
.
Failure
(
Errors
.
DomainErrors
.
VisitAlreadyHasThisMedicalTest
);
#
endregion
_medicalTests
.
Add
(
entry
);
_medicalTests
.
Add
(
entry
.
Value
);
return
Result
.
Success
();
}
}
#
endregion
#
endregion
#
region
Add
medicine
#
region
Add
medicine
public
void
AddMedicine
(
Medicine
medicine
,
int
number
)
public
Result
AddMedicine
(
Medicine
medicine
,
int
number
)
{
{
VisitMedicine
entry
;
#
region
Create
medicine
to
attach
try
Result
<
VisitMedicine
>
entry
=
VisitMedicine
.
Create
(
Id
,
medicine
.
Id
,
number
);
{
if
(
entry
.
IsFailure
)
entry
=
VisitMedicine
.
Create
(
Id
,
medicine
.
Id
,
number
);
return
Result
.
Failure
(
Errors
.
DomainErrors
.
InvalidValuesError
);
}
#
endregion
catch
{
#
region
Check
duplicate
throw
;
if
(
Medicines
.
Where
(
m
=>
m
.
Medicine
==
medicine
).
ToList
().
Count
>
0
)
}
return
Result
.
Failure
(
Errors
.
DomainErrors
.
VisitAlreadyHasThisMedicine
);
#
endregion
_medicines
.
Add
(
entry
);
_medicines
.
Add
(
entry
.
Value
);
return
Result
.
Success
();
}
}
#
endregion
#
endregion
#
region
Add
hospital
#
region
Add
hospital
public
void
AddHospital
(
Hospital
hospital
)
public
Result
AddHospital
(
Hospital
hospital
)
{
{
if
(
hospital
is
null
)
if
(
hospital
is
null
)
throw
new
InvalidValuesDomainException
<
Visit
>();
return
Result
.
Failure
(
Errors
.
DomainErrors
.
InvalidValuesError
);
Hospital
=
hospital
;
Hospital
=
hospital
;
HospitalId
=
hospital
.
Id
;
HospitalId
=
hospital
.
Id
;
return
Result
.
Success
();
}
}
#
endregion
#
endregion
...
...
Clinics.Backend/Domain/Entities/WaitingList/WaitingListRecord.cs
View file @
de273e03
using
Domain.Entities.People.Doctors
;
using
Domain.Entities.People.Doctors
;
using
Domain.Entities.People.Patients
;
using
Domain.Entities.People.Patients
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
using
Domain.Primitives
;
using
Domain.Shared
;
namespace
Domain.Entities.WaitingList
;
namespace
Domain.Entities.WaitingList
;
...
@@ -46,21 +46,23 @@ public sealed class WaitingListRecord : Entity
...
@@ -46,21 +46,23 @@ public sealed class WaitingListRecord : Entity
#
region
Static
factory
#
region
Static
factory
public
static
WaitingListRecord
Create
(
int
patientId
)
public
static
Result
<
WaitingListRecord
>
Create
(
int
patientId
)
{
{
if
(
patientId
<=
0
)
if
(
patientId
<=
0
)
throw
new
InvalidValuesDomainException
<
WaitingListRecord
>(
);
return
Result
.
Failure
<
WaitingListRecord
>(
Errors
.
DomainErrors
.
InvalidValuesError
);
return
new
WaitingListRecord
(
0
,
patientId
);
return
new
WaitingListRecord
(
0
,
patientId
);
}
}
#
endregion
#
endregion
#
region
Link
to
doctor
#
region
Link
to
doctor
public
void
LinkToDoctor
(
int
doctorId
)
public
Result
LinkToDoctor
(
int
doctorId
)
{
{
if
(
doctorId
<=
0
)
if
(
doctorId
<=
0
)
throw
new
InvalidValuesDomainException
<
WaitingListRecord
>();
return
Result
.
Failure
(
Errors
.
DomainErrors
.
InvalidValuesError
);
DoctorId
=
doctorId
;
DoctorId
=
doctorId
;
return
Result
.
Success
();
}
}
#
endregion
#
endregion
...
...
Clinics.Backend/Domain/Errors/DomainErrors.cs
View file @
de273e03
...
@@ -25,6 +25,13 @@ public static class DomainErrors
...
@@ -25,6 +25,13 @@ public static class DomainErrors
public
static
Error
PhoneAlreadyExist
=>
public
static
Error
PhoneAlreadyExist
=>
new
(
"Domain.PhoneAlreadyExist"
,
"رقم الهاتف موجود بالفعل"
);
new
(
"Domain.PhoneAlreadyExist"
,
"رقم الهاتف موجود بالفعل"
);
public
static
Error
VisitAlreadyHasThisMedicine
=>
new
(
"Domain.VisitAlreadyHasThisMedicine"
,
"تحتوي الوصفة الطبية بالفعل على الدواء الذي تحاول اضافته"
);
public
static
Error
VisitAlreadyHasThisMedicalTest
=>
new
(
"Domain.VisitAlreadyHasThisMedicalTest"
,
"تحتوي هذه الزيارة بالفعل على التحليل الطبي الذي تحاول اضافته"
);
public
static
Error
VisitAlreadyHasThisMedicalImage
=>
new
(
"Domain.PatientAlreadyHasThisMedicine"
,
"تحتوي هذه الزيارة بالفعل على الصورة التي تحاول اضافتها"
);
}
}
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