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
Show 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
#
endregion
#
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
);
#
endregion
...
...
@@ -151,8 +151,8 @@ public sealed class Employee : Entity
#
region
Check
duplicate
if
(
RelatedEmployees
.
Where
(
re
=>
re
.
Id
==
employee
.
Id
).
ToList
().
Count
>
0
||
RelatedTo
.
Where
(
rt
=>
rt
.
Id
==
employee
.
Id
).
ToList
().
Count
>
0
if
(
RelatedEmployees
.
Where
(
re
=>
re
==
employee
).
ToList
().
Count
>
0
||
RelatedTo
.
Where
(
rt
=>
rt
==
employee
).
ToList
().
Count
>
0
)
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.Exceptions.InvalidValue
;
using
Domain.Primitives
;
using
Domain.Shared
;
namespace
Domain.Entities.Visits.Relations.VisitMedicalImages
;
...
...
@@ -25,21 +25,21 @@ public sealed class VisitMedicalImage : Entity
#
region
Visit
public
int
VisitId
{
get
;
set
;
}
public
Visit
Visit
{
get
;
set
;
}
=
null
!;
public
int
VisitId
{
get
;
private
set
;
}
public
Visit
Visit
{
get
;
private
set
;
}
=
null
!;
#
endregion
#
region
Medical
image
public
int
MedicalImageId
{
get
;
set
;
}
public
MedicalImage
MedicalImage
{
get
;
set
;
}
=
null
!;
public
int
MedicalImageId
{
get
;
private
set
;
}
public
MedicalImage
MedicalImage
{
get
;
private
set
;
}
=
null
!;
#
endregion
#
region
Additional
public
string
?
Result
{
get
;
set
;
}
public
string
?
Result
{
get
;
private
set
;
}
#
endregion
...
...
@@ -48,22 +48,23 @@ public sealed class VisitMedicalImage : Entity
#
region
Methods
#
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
)
throw
new
InvalidValuesDomainException
<
VisitMedicalImage
>(
);
return
Shared
.
Result
.
Failure
<
VisitMedicalImage
>(
Errors
.
DomainErrors
.
InvalidValuesError
);
return
new
VisitMedicalImage
(
0
,
visitId
,
medicalImageId
);
}
#
endregion
#
region
Add
result
public
void
AddResult
(
string
result
)
public
Result
AddResult
(
string
result
)
{
if
(
result
is
null
)
throw
new
InvalidValuesDomainException
<
VisitMedicalImage
>(
);
return
Shared
.
Result
.
Failure
(
Errors
.
DomainErrors
.
InvalidValuesError
);
Result
=
result
;
return
Shared
.
Result
.
Success
();
}
#
endregion
...
...
Clinics.Backend/Domain/Entities/Visits/Relations/VisitMedicalTests/VisitMedicalTest.cs
View file @
de273e03
using
Domain.Entities.Medicals.MedicalTests
;
using
Domain.Entities.Visits.Relations.VisitMedicalImages
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
using
Domain.Shared
;
namespace
Domain.Entities.Visits.Relations.VisitMedicalTests
;
...
...
@@ -26,21 +25,21 @@ public sealed class VisitMedicalTest : Entity
#
region
Visit
public
int
VisitId
{
get
;
set
;
}
public
Visit
Visit
{
get
;
set
;
}
=
null
!;
public
int
VisitId
{
get
;
private
set
;
}
public
Visit
Visit
{
get
;
private
set
;
}
=
null
!;
#
endregion
#
region
Medical
test
public
int
MedicalTestId
{
get
;
set
;
}
public
MedicalTest
MedicalTest
{
get
;
set
;
}
=
null
!;
public
int
MedicalTestId
{
get
;
private
set
;
}
public
MedicalTest
MedicalTest
{
get
;
private
set
;
}
=
null
!;
#
endregion
#
region
Additional
public
string
?
Result
{
get
;
set
;
}
public
string
?
Result
{
get
;
private
set
;
}
#
endregion
...
...
@@ -49,22 +48,23 @@ public sealed class VisitMedicalTest : Entity
#
region
Methods
#
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
)
throw
new
InvalidValuesDomainException
<
VisitMedicalTest
>(
);
return
Shared
.
Result
.
Failure
<
VisitMedicalTest
>(
Errors
.
DomainErrors
.
InvalidValuesError
);
return
new
VisitMedicalTest
(
0
,
visitId
,
medicalTestId
);
}
#
endregion
#
region
Add
result
public
void
AddResult
(
string
result
)
public
Result
AddResult
(
string
result
)
{
if
(
result
is
null
)
throw
new
InvalidValuesDomainException
<
VisitMedicalTest
>(
);
return
Shared
.
Result
.
Failure
(
Errors
.
DomainErrors
.
InvalidValuesError
);
Result
=
result
;
return
Shared
.
Result
.
Success
();
}
#
endregion
...
...
Clinics.Backend/Domain/Entities/Visits/Relations/VisitMedicines/VisitMedicine.cs
View file @
de273e03
using
Domain.Entities.Medicals.Medicines
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
using
Domain.Shared
;
namespace
Domain.Entities.Visits.Relations.VisitMedicines
;
...
...
@@ -23,21 +23,21 @@ public sealed class VisitMedicine : Entity
#
region
Visit
public
int
VisitId
{
get
;
set
;
}
public
Visit
Visit
{
get
;
set
;
}
=
null
!;
public
int
VisitId
{
get
;
private
set
;
}
public
Visit
Visit
{
get
;
private
set
;
}
=
null
!;
#
endregion
#
region
Medicine
public
int
MedicineId
{
get
;
set
;
}
public
Medicine
Medicine
{
get
;
set
;
}
=
null
!;
public
int
MedicineId
{
get
;
private
set
;
}
public
Medicine
Medicine
{
get
;
private
set
;
}
=
null
!;
#
endregion
#
region
Additional
public
int
Number
{
get
;
set
;
}
public
int
Number
{
get
;
private
set
;
}
#
endregion
...
...
@@ -46,10 +46,10 @@ public sealed class VisitMedicine : Entity
#
region
Methods
#
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
)
throw
new
InvalidValuesDomainException
<
VisitMedicine
>(
);
return
Result
.
Failure
<
VisitMedicine
>(
Errors
.
DomainErrors
.
InvalidValuesError
);
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;
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
;
using
Domain.Shared
;
namespace
Domain.Entities.Visits
;
...
...
@@ -34,23 +34,23 @@ public sealed class Visit : Entity
#
region
Patient
public
int
PatientId
{
get
;
set
;
}
public
Patient
Patient
{
get
;
set
;
}
=
null
!;
public
int
PatientId
{
get
;
private
set
;
}
public
Patient
Patient
{
get
;
private
set
;
}
=
null
!;
#
endregion
#
region
Doctor
public
int
DoctorId
{
get
;
set
;
}
public
Doctor
Doctor
{
get
;
set
;
}
=
null
!;
public
int
DoctorId
{
get
;
private
set
;
}
public
Doctor
Doctor
{
get
;
private
set
;
}
=
null
!;
#
endregion
#
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
...
...
@@ -88,73 +88,81 @@ public sealed class Visit : Entity
#
region
Methods
#
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
)
throw
new
InvalidValuesDomainException
<
Visit
>(
);
return
Result
.
Failure
<
Visit
>(
Errors
.
DomainErrors
.
InvalidValuesError
);
return
new
Visit
(
0
,
patientId
,
doctorId
,
date
,
diagnosis
);
}
#
endregion
#
region
Add
medical
image
public
void
AddMedicalImage
(
MedicalImage
medicalImage
)
public
Result
AddMedicalImage
(
MedicalImage
medicalImage
)
{
VisitMedicalImage
entry
;
try
{
entry
=
VisitMedicalImage
.
Create
(
Id
,
medicalImage
.
Id
);
}
catch
{
throw
;
}
#
region
Create
medical
image
to
attach
Result
<
VisitMedicalImage
>
entry
=
VisitMedicalImage
.
Create
(
Id
,
medicalImage
.
Id
);
if
(
entry
.
IsFailure
)
return
Result
.
Failure
(
Errors
.
DomainErrors
.
InvalidValuesError
);
#
endregion
_medicalImages
.
Add
(
entry
);
#
region
Check
duplicate
if
(
MedicalImages
.
Where
(
mi
=>
mi
.
MedicalImage
==
medicalImage
).
ToList
().
Count
>
0
)
return
Result
.
Failure
(
Errors
.
DomainErrors
.
VisitAlreadyHasThisMedicalImage
);
#
endregion
_medicalImages
.
Add
(
entry
.
Value
);
return
Result
.
Success
();
}
#
endregion
#
region
Add
medical
test
public
void
AddMedicalTest
(
MedicalTest
medicalTest
)
{
VisitMedicalTest
entry
;
try
public
Result
AddMedicalTest
(
MedicalTest
medicalTest
)
{
entry
=
VisitMedicalTest
.
Create
(
Id
,
medicalTest
.
Id
);
}
catch
{
throw
;
}
#
region
Create
medical
test
to
attach
Result
<
VisitMedicalTest
>
entry
=
VisitMedicalTest
.
Create
(
Id
,
medicalTest
.
Id
);
if
(
entry
.
IsFailure
)
return
Result
.
Failure
(
Errors
.
DomainErrors
.
InvalidValuesError
);
#
endregion
#
region
Check
duplicate
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
#
region
Add
medicine
public
void
AddMedicine
(
Medicine
medicine
,
int
number
)
{
VisitMedicine
entry
;
try
{
entry
=
VisitMedicine
.
Create
(
Id
,
medicine
.
Id
,
number
);
}
catch
public
Result
AddMedicine
(
Medicine
medicine
,
int
number
)
{
throw
;
}
#
region
Create
medicine
to
attach
Result
<
VisitMedicine
>
entry
=
VisitMedicine
.
Create
(
Id
,
medicine
.
Id
,
number
);
if
(
entry
.
IsFailure
)
return
Result
.
Failure
(
Errors
.
DomainErrors
.
InvalidValuesError
);
#
endregion
_medicines
.
Add
(
entry
);
#
region
Check
duplicate
if
(
Medicines
.
Where
(
m
=>
m
.
Medicine
==
medicine
).
ToList
().
Count
>
0
)
return
Result
.
Failure
(
Errors
.
DomainErrors
.
VisitAlreadyHasThisMedicine
);
#
endregion
_medicines
.
Add
(
entry
.
Value
);
return
Result
.
Success
();
}
#
endregion
#
region
Add
hospital
public
void
AddHospital
(
Hospital
hospital
)
public
Result
AddHospital
(
Hospital
hospital
)
{
if
(
hospital
is
null
)
throw
new
InvalidValuesDomainException
<
Visit
>();
return
Result
.
Failure
(
Errors
.
DomainErrors
.
InvalidValuesError
);
Hospital
=
hospital
;
HospitalId
=
hospital
.
Id
;
return
Result
.
Success
();
}
#
endregion
...
...
Clinics.Backend/Domain/Entities/WaitingList/WaitingListRecord.cs
View file @
de273e03
using
Domain.Entities.People.Doctors
;
using
Domain.Entities.People.Patients
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
using
Domain.Shared
;
namespace
Domain.Entities.WaitingList
;
...
...
@@ -46,21 +46,23 @@ public sealed class WaitingListRecord : Entity
#
region
Static
factory
public
static
WaitingListRecord
Create
(
int
patientId
)
public
static
Result
<
WaitingListRecord
>
Create
(
int
patientId
)
{
if
(
patientId
<=
0
)
throw
new
InvalidValuesDomainException
<
WaitingListRecord
>(
);
return
Result
.
Failure
<
WaitingListRecord
>(
Errors
.
DomainErrors
.
InvalidValuesError
);
return
new
WaitingListRecord
(
0
,
patientId
);
}
#
endregion
#
region
Link
to
doctor
public
void
LinkToDoctor
(
int
doctorId
)
public
Result
LinkToDoctor
(
int
doctorId
)
{
if
(
doctorId
<=
0
)
throw
new
InvalidValuesDomainException
<
WaitingListRecord
>();
return
Result
.
Failure
(
Errors
.
DomainErrors
.
InvalidValuesError
);
DoctorId
=
doctorId
;
return
Result
.
Success
();
}
#
endregion
...
...
Clinics.Backend/Domain/Errors/DomainErrors.cs
View file @
de273e03
...
...
@@ -25,6 +25,13 @@ public static class DomainErrors
public
static
Error
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