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
42981ba9
Commit
42981ba9
authored
Aug 18, 2024
by
Almouhannad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(B) Apply result on creation of medicals entities
parent
3164d1b2
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
53 additions
and
31 deletions
+53
-31
Disease.cs
Clinics.Backend/Domain/Entities/Medicals/Diseases/Disease.cs
+3
-3
Hospital.cs
...cs.Backend/Domain/Entities/Medicals/Hospitals/Hospital.cs
+4
-4
MedicalImage.cs
...nd/Domain/Entities/Medicals/MedicalImages/MedicalImage.cs
+4
-4
MedicalTest.cs
...kend/Domain/Entities/Medicals/MedicalTests/MedicalTest.cs
+4
-4
Medicine.cs
...cs.Backend/Domain/Entities/Medicals/Medicines/Medicine.cs
+9
-7
MedicineForm.cs
...ies/Medicals/Medicines/MedicineFormValues/MedicineForm.cs
+5
-5
MedicineForms.cs
...es/Medicals/Medicines/MedicineFormValues/MedicineForms.cs
+24
-4
No files found.
Clinics.Backend/Domain/Entities/Medicals/Diseases/Disease.cs
View file @
42981ba9
using
Domain.Entities.People.Patients.Relations.PatientDiseases
;
using
Domain.Entities.People.Patients.Relations.PatientDiseases
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
using
Domain.Primitives
;
using
Domain.Shared
;
namespace
Domain.Entities.Medicals.Diseases
;
namespace
Domain.Entities.Medicals.Diseases
;
...
@@ -35,10 +35,10 @@ public sealed class Disease : Entity
...
@@ -35,10 +35,10 @@ public sealed class Disease : Entity
#
region
Methods
#
region
Methods
#
region
Static
factory
#
region
Static
factory
public
static
Disease
Create
(
string
name
)
public
static
Result
<
Disease
>
Create
(
string
name
)
{
{
if
(
name
is
null
)
if
(
name
is
null
)
throw
new
InvalidValuesDomainException
<
Disease
>(
);
return
Result
.
Failure
<
Disease
>(
Errors
.
DomainErrors
.
InvalidValuesError
);
return
new
Disease
(
0
,
name
);
return
new
Disease
(
0
,
name
);
}
}
#
endregion
#
endregion
...
...
Clinics.Backend/Domain/Entities/Medicals/Hospitals/Hospital.cs
View file @
42981ba9
using
Domain.
Exceptions.InvalidValue
;
using
Domain.
Primitives
;
using
Domain.
Primitives
;
using
Domain.
Shared
;
namespace
Domain.Entities.Medicals.Hospitals
;
namespace
Domain.Entities.Medicals.Hospitals
;
...
@@ -25,10 +25,10 @@ public sealed class Hospital : Entity
...
@@ -25,10 +25,10 @@ public sealed class Hospital : Entity
#
region
Methods
#
region
Methods
#
region
Static
factory
#
region
Static
factory
public
static
Hospital
Create
(
string
name
)
public
static
Result
<
Hospital
>
Create
(
string
name
)
{
{
if
(
name
is
null
)
if
(
name
is
null
)
throw
new
InvalidValuesDomainException
<
Hospital
>(
);
return
Result
.
Failure
<
Hospital
>(
Errors
.
DomainErrors
.
InvalidValuesError
);
return
new
Hospital
(
0
,
name
);
return
new
Hospital
(
0
,
name
);
}
}
#
endregion
#
endregion
...
...
Clinics.Backend/Domain/Entities/Medicals/MedicalImages/MedicalImage.cs
View file @
42981ba9
using
Domain.
Exceptions.InvalidValue
;
using
Domain.
Primitives
;
using
Domain.
Primitives
;
using
Domain.
Shared
;
namespace
Domain.Entities.Medicals.MedicalImages
;
namespace
Domain.Entities.Medicals.MedicalImages
;
...
@@ -26,10 +26,10 @@ public sealed class MedicalImage : Entity
...
@@ -26,10 +26,10 @@ public sealed class MedicalImage : Entity
#
region
Methods
#
region
Methods
#
region
Static
factory
#
region
Static
factory
public
static
MedicalImage
Create
(
string
name
,
string
?
description
=
null
)
public
static
Result
<
MedicalImage
>
Create
(
string
name
,
string
?
description
=
null
)
{
{
if
(
name
is
null
)
if
(
name
is
null
)
throw
new
InvalidValuesDomainException
<
MedicalImage
>(
);
return
Result
.
Failure
<
MedicalImage
>(
Errors
.
DomainErrors
.
InvalidValuesError
);
return
new
MedicalImage
(
0
,
name
,
description
);
return
new
MedicalImage
(
0
,
name
,
description
);
}
}
#
endregion
#
endregion
...
...
Clinics.Backend/Domain/Entities/Medicals/MedicalTests/MedicalTest.cs
View file @
42981ba9
using
Domain.
Exceptions.InvalidValue
;
using
Domain.
Primitives
;
using
Domain.
Primitives
;
using
Domain.
Shared
;
namespace
Domain.Entities.Medicals.MedicalTests
;
namespace
Domain.Entities.Medicals.MedicalTests
;
...
@@ -26,10 +26,10 @@ public sealed class MedicalTest : Entity
...
@@ -26,10 +26,10 @@ public sealed class MedicalTest : Entity
#
region
Methods
#
region
Methods
#
region
Static
factory
#
region
Static
factory
public
static
MedicalTest
Create
(
string
name
,
string
description
)
public
static
Result
<
MedicalTest
>
Create
(
string
name
,
string
description
)
{
{
if
(
name
is
null
)
if
(
name
is
null
)
throw
new
InvalidValuesDomainException
<
MedicalTest
>(
);
return
Result
.
Failure
<
MedicalTest
>(
Errors
.
DomainErrors
.
InvalidValuesError
);
return
new
MedicalTest
(
0
,
name
,
description
);
return
new
MedicalTest
(
0
,
name
,
description
);
}
}
#
endregion
#
endregion
...
...
Clinics.Backend/Domain/Entities/Medicals/Medicines/Medicine.cs
View file @
42981ba9
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
using
Domain.Entities.People.Patients.Relations.PatientMedicines
;
using
Domain.Entities.People.Patients.Relations.PatientMedicines
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Exceptions.InvalidValue
;
using
Domain.Primitives
;
using
Domain.Primitives
;
using
Domain.Shared
;
namespace
Domain.Entities.Medicals.Medicines
;
namespace
Domain.Entities.Medicals.Medicines
;
...
@@ -48,26 +49,27 @@ public sealed class Medicine : Entity
...
@@ -48,26 +49,27 @@ public sealed class Medicine : Entity
#
region
Methods
#
region
Methods
#
region
Static
factory
#
region
Static
factory
public
static
Medicine
Create
(
string
form
,
int
amount
,
string
name
,
decimal
dosage
)
public
static
Result
<
Medicine
>
Create
(
string
form
,
int
amount
,
string
name
,
decimal
dosage
)
{
{
if
(
form
is
null
||
name
is
null
||
amount
<
0
||
dosage
<
0
)
if
(
form
is
null
||
name
is
null
||
amount
<
0
||
dosage
<
0
)
throw
new
InvalidValuesDomainException
<
Medicine
>(
);
return
Result
.
Failure
<
Medicine
>(
Errors
.
DomainErrors
.
InvalidValuesError
);
#
region
Check
form
#
region
Check
form
MedicineForm
selectedMedicineForm
;
Result
<
MedicineForm
>
selectedMedicineForm
=
new
(
null
,
false
,
Errors
.
DomainErrors
.
InvalidValuesError
)
;
MedicineForm
tablet
=
MedicineForms
.
Tablet
;
MedicineForm
tablet
=
MedicineForms
.
Tablet
;
MedicineForm
syrup
=
MedicineForms
.
Syrup
;
MedicineForm
syrup
=
MedicineForms
.
Syrup
;
if
(
form
==
tablet
.
Name
)
if
(
form
==
tablet
.
Name
)
selectedMedicineForm
=
tablet
;
selectedMedicineForm
=
Result
.
Success
<
MedicineForm
>(
tablet
)
;
else
if
(
form
==
syrup
.
Name
)
else
if
(
form
==
syrup
.
Name
)
selectedMedicineForm
=
syrup
;
selectedMedicineForm
=
Result
.
Success
<
MedicineForm
>(
syrup
);
else
throw
new
InvalidValuesDomainException
<
MedicineForm
>();
if
(
selectedMedicineForm
.
IsFailure
)
return
Result
.
Failure
<
Medicine
>(
Errors
.
DomainErrors
.
InvalidValuesError
);
#
endregion
#
endregion
return
new
Medicine
(
0
,
selectedMedicineForm
,
amount
,
name
,
dosage
);
return
new
Medicine
(
0
,
selectedMedicineForm
.
Value
,
amount
,
name
,
dosage
);
}
}
#
endregion
#
endregion
...
...
Clinics.Backend/Domain/Entities/Medicals/Medicines/MedicineFormValues/MedicineForm.cs
View file @
42981ba9
using
Domain.
Exceptions.InvalidValue
;
using
Domain.
Primitives
;
using
Domain.
Primitives
;
using
Domain.
Shared
;
namespace
Domain.Entities.Medicals.Medicines.MedicineFormValues
;
namespace
Domain.Entities.Medicals.Medicines.MedicineFormValues
;
...
@@ -23,15 +23,15 @@ public sealed class MedicineForm : Entity
...
@@ -23,15 +23,15 @@ public sealed class MedicineForm : Entity
#
region
Methods
#
region
Methods
#
region
Static
factory
#
region
Static
factory
public
static
MedicineForm
Create
(
string
name
,
int
?
id
)
public
static
Result
<
MedicineForm
>
Create
(
string
name
,
int
?
id
)
{
{
if
(
name
is
null
)
if
(
name
is
null
)
throw
new
InvalidValuesDomainException
<
MedicineForm
>(
);
return
Result
.
Failure
<
MedicineForm
>(
Errors
.
DomainErrors
.
InvalidValuesError
);
if
(
id
is
not
null
)
if
(
id
is
not
null
)
{
{
if
(
id
<
0
)
if
(
id
<
0
)
throw
new
InvalidValuesDomainException
<
MedicineForm
>(
);
return
Result
.
Failure
<
MedicineForm
>(
Errors
.
DomainErrors
.
InvalidValuesError
);
return
new
MedicineForm
(
id
.
Value
,
name
);
return
new
MedicineForm
(
id
.
Value
,
name
);
}
}
return
new
MedicineForm
(
0
,
name
);
return
new
MedicineForm
(
0
,
name
);
...
...
Clinics.Backend/Domain/Entities/Medicals/Medicines/MedicineFormValues/MedicineForms.cs
View file @
42981ba9
namespace
Domain.Entities.Medicals.Medicines.MedicineFormValues
;
using
Domain.Exceptions.InvalidValue
;
namespace
Domain.Entities.Medicals.Medicines.MedicineFormValues
;
public
static
class
MedicineForms
public
static
class
MedicineForms
{
{
#
region
Constant
id
values
#
region
Constant
values
public
static
MedicineForm
Tablet
=>
MedicineForm
.
Create
(
"حبوب"
,
1
);
public
static
MedicineForm
Tablet
{
get
{
var
result
=
MedicineForm
.
Create
(
"حبوب"
,
1
);
if
(
result
.
IsFailure
)
throw
new
InvalidValuesDomainException
<
MedicineForm
>();
return
result
.
Value
;
}
}
public
static
MedicineForm
Syrup
=>
MedicineForm
.
Create
(
"شراب"
,
2
);
public
static
MedicineForm
Syrup
{
get
{
var
result
=
MedicineForm
.
Create
(
"شراب"
,
2
);
if
(
result
.
IsFailure
)
throw
new
InvalidValuesDomainException
<
MedicineForm
>();
return
result
.
Value
;
}
}
#
endregion
#
endregion
}
}
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