Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
Medic
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
hasan.bahjat
Medic
Commits
9eece958
Commit
9eece958
authored
Jun 16, 2024
by
hasan khaddour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update domain models
parent
451f93a6
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
76 additions
and
86 deletions
+76
-86
MedicalStateModel.cs
...e/Domain Model/Patients Domain Model/MedicalStateModel.cs
+1
-1
IIngredientService.cs
ApplicationCore/Interfaces/IServices/IIngredientService.cs
+1
-2
IMedicalStateService.cs
ApplicationCore/Interfaces/IServices/IMedicalStateService.cs
+3
-8
IMedicineService.cs
ApplicationCore/Interfaces/IServices/IMedicineService.cs
+3
-4
IPatientService.cs
ApplicationCore/Interfaces/IServices/IPatientService.cs
+1
-0
ServiceBase.cs
ApplicationCore/Services/Base/ServiceBase.cs
+8
-8
IngredientService.cs
...ationCore/Services/IngredientService/IngredientService.cs
+8
-6
MedicalStateService.cs
...nCore/Services/MedicalStateService/MedicalStateService.cs
+4
-28
MedicineService.cs
ApplicationCore/Services/MedicineService/MedicineService.cs
+38
-25
PatientService.cs
ApplicationCore/Services/PatientService/PatientService.cs
+9
-4
ApplicationCore.csproj.AssemblyReference.cache
...bug/net5.0/ApplicationCore.csproj.AssemblyReference.cache
+0
-0
No files found.
ApplicationCore/Domain Model/Patients Domain Model/MedicalStateModel.cs
View file @
9eece958
...
...
@@ -9,7 +9,7 @@ namespace ApplicationCore.DomainModel
public
class
MedicalStateModel
:
DomainBase
{
public
int
PatientId
{
get
;
set
;
}
// public PatientModel Patient { get; set; }
public
String
StateName
{
get
;
set
;
}
public
String
StateDescription
{
get
;
set
;
}
public
DateTime
PrescriptionTime
{
get
;
set
;
}
...
...
ApplicationCore/Interfaces/IServices/IIngredientService.cs
View file @
9eece958
...
...
@@ -10,7 +10,6 @@ namespace ApplicationCore.Interfaces.IServices
{
public
interface
IIngredientService
:
IService
<
IngredientModel
>
{
// public Task<IEnumerable<IngredientModel>> GetAllIngredients();
public
void
AddToMedicine
(
int
ingredientId
,
int
medicineId
,
int
ratio
);
public
void
AddToMedicine
(
MedicineIngredientModel
medicineIngredientModel
);
}
}
ApplicationCore/Interfaces/IServices/IMedicalStateService.cs
View file @
9eece958
...
...
@@ -11,13 +11,8 @@ namespace ApplicationCore.Interfaces.IServices
public
interface
IMedicalStateService
:
IService
<
MedicalStateModel
>
{
public
IEnumerable
<
MedicalStateModel
>
GetAllPatientMedicalStates
(
int
patientId
);
public
MedicalStateModel
AddMedicalStateToPateint
(
int
patientId
,
MedicalStateModel
medicalState
);
public
void
AddMedicine
(
int
medicalStateId
,
int
medicineId
);
public
void
RemoveMedicine
(
int
medicalStateId
,
int
medicineId
);
public
MedicalStateModel
AddToPateint
(
int
patientId
,
MedicalStateModel
medicalState
);
// public MedicalState Update(MedicalState medicalState);
//public MedicalState GetDetails(int medicalStateId);
//public void Delete(int id);
}
}
ApplicationCore/Interfaces/IServices/IMedicineService.cs
View file @
9eece958
...
...
@@ -10,10 +10,9 @@ namespace ApplicationCore.Interfaces.IServices
{
public
interface
IMedicineService
:
IService
<
MedicineModel
>
{
// public Task<IEnumerable<MedicineModel>> GetAllMedicines();
// public void AddMedicine(MedicineModel medicine);
public
void
AddMedicineIngredient
(
int
medicineId
,
IngredientModel
ingredient
);
public
MedicineModel
GetMedicineIngredentisDetails
(
int
medicineId
);
public
void
AddToMedicalState
(
MedicalStateMedicineModel
medicalStateMedicineModel
);
public
void
RemoveFromMedicalState
(
MedicalStateMedicineModel
medicalStateMedicineModel
);
}
}
ApplicationCore/Interfaces/IServices/IPatientService.cs
View file @
9eece958
...
...
@@ -14,6 +14,7 @@ namespace ApplicationCore.Interfaces.IServices
public
IEnumerable
<
MedicalStateModel
>
GetPatientMedicalStates
(
int
patientId
);
public
Task
<
MedicalStateModel
>
GetMedicalStateDetails
(
int
id
);
public
Task
<
Patient
>
GetByUserID
(
String
id
);
// public Task<IEnumerable<PatientModel>>GetAll();
public
void
AddMedicalState
(
int
patientId
,
MedicalStateModel
medicalState
);
// public Patient GetDetails(int id);
...
...
ApplicationCore/Services/Base/ServiceBase.cs
View file @
9eece958
...
...
@@ -11,16 +11,16 @@ using System.Threading.Tasks;
namespace
ApplicationCore.Services
{
public
class
ServiceBase
<
T
,
TModel
>
:
IService
<
TModel
>
where
T
:
EntityBase
where
TModel
:
DomainBase
public
class
ServiceBase
<
T
Entity
,
TModel
>
:
IService
<
TModel
>
where
TEntity
:
EntityBase
where
TModel
:
DomainBase
{
protected
readonly
IMapper
_mapper
;
protected
readonly
IUnitOfWork
<
T
>
_unitOfWork
;
protected
readonly
IUnitOfWork
<
T
Entity
>
_unitOfWork
;
protected
ISpecification
<
T
>
_specification
;
protected
ISpecification
<
T
Entity
>
_specification
;
public
ServiceBase
(
IUnitOfWork
<
T
>
unitOfWork
,
IUnitOfWork
<
T
Entity
>
unitOfWork
,
IMapper
mapper
)
{
...
...
@@ -38,17 +38,17 @@ namespace ApplicationCore.Services
public
TModel
Create
(
TModel
model
)
{
var
ing
=
_unitOfWork
.
Entity
.
Insert
(
_mapper
.
Map
<
T
>(
model
));
TEntity
entity
=
_unitOfWork
.
Entity
.
Insert
(
_mapper
.
Map
<
TEntity
>(
model
));
_unitOfWork
.
Save
();
return
_mapper
.
Map
<
TModel
>(
ing
);
return
_mapper
.
Map
<
TModel
>(
entity
);
}
public
TModel
Update
(
TModel
model
)
{
var
r
=
_unitOfWork
.
Entity
.
Update
(
_mapper
.
Map
<
T
>(
model
));
TEntity
entity
=
_unitOfWork
.
Entity
.
Update
(
_mapper
.
Map
<
TEntity
>(
model
));
_unitOfWork
.
Save
();
return
_mapper
.
Map
<
TModel
>(
r
);
return
_mapper
.
Map
<
TModel
>(
entity
);
}
public
async
Task
<
TModel
>
GetDetails
(
int
id
)
...
...
ApplicationCore/Services/IngredientService/IngredientService.cs
View file @
9eece958
...
...
@@ -20,16 +20,18 @@ namespace ApplicationCore.Services
IMapper
mapper
):
base
(
ingredientUnitOfWork
,
mapper
)
{
_specification
=
new
IngredientSpecification
();
_specification
=
new
Ingredient
WithMedicines
Specification
();
}
public
void
AddToMedicine
(
int
ingredientId
,
int
medicineId
,
int
ratio
)
{
var
r
=
_unitOfWork
.
Entity
.
GetById
(
ingredientId
,
_specification
).
Result
;
r
.
MedicineIngredients
.
Add
(
new
MedicineIngredient
{
IngredientId
=
ingredientId
,
MedicineId
=
medicineId
,
Ratio
=
ratio
}
public
async
void
AddToMedicine
(
MedicineIngredientModel
medicineIngredientModel
)
{
var
medicine
=
await
_unitOfWork
.
Entity
.
GetById
(
medicineIngredientModel
.
IngredientId
,
_specification
);
MedicineIngredient
medicineIngredient
=
_mapper
.
Map
<
MedicineIngredient
>(
medicineIngredientModel
);
medicine
.
MedicineIngredients
.
Add
(
medicineIngredient
);
_unitOfWork
.
Entity
.
Update
(
r
);
_unitOfWork
.
Entity
.
Update
(
medicine
);
_unitOfWork
.
Save
();
}
...
...
ApplicationCore/Services/MedicalStateService/MedicalStateService.cs
View file @
9eece958
...
...
@@ -13,7 +13,7 @@ namespace ApplicationCore.Services
{
private
readonly
PatientService
_patientService
;
private
readonly
IUnitOfWork
<
Medicine
>
_medicineUnitOfWork
;
private
readonly
Medicine
Ingredient
Specification
_medicineSpecification
;
private
readonly
Medicine
WithIngredients
Specification
_medicineSpecification
;
public
MedicalStateService
(
IUnitOfWork
<
MedicalState
>
medicalUnitOfWork
,
...
...
@@ -22,12 +22,12 @@ namespace ApplicationCore.Services
IMapper
Mapper
):
base
(
medicalUnitOfWork
,
Mapper
)
{
_specification
=
new
MedicalStateSpecification
();
_specification
=
new
MedicalState
WithMedicines
Specification
();
_medicineUnitOfWork
=
medicineUnitOfWork
;
_patientService
=
new
PatientService
(
patientUnitOfWork
,
medicalUnitOfWork
,
Mapper
);
_medicineSpecification
=
new
Medicine
Ingredient
Specification
();
_medicineSpecification
=
new
Medicine
WithIngredients
Specification
();
}
public
MedicalStateModel
Add
MedicalState
ToPateint
(
int
patientId
,
MedicalStateModel
medicalStateModel
)
public
MedicalStateModel
AddToPateint
(
int
patientId
,
MedicalStateModel
medicalStateModel
)
{
medicalStateModel
.
PatientId
=
patientId
;
...
...
@@ -39,30 +39,6 @@ namespace ApplicationCore.Services
}
public
void
AddMedicine
(
int
MedicalStateId
,
int
medicineId
)
{
var
m
=
_unitOfWork
.
Entity
.
GetById
(
MedicalStateId
,
_specification
).
Result
;
if
(
m
.
Medicines
is
null
)
m
.
Medicines
=
new
List
<
Medicine
>();
var
d
=
_medicineUnitOfWork
.
Entity
.
GetById
(
medicineId
,
_medicineSpecification
).
Result
;
m
.
Medicines
.
Add
(
d
);
_unitOfWork
.
Entity
.
Update
(
m
);
_unitOfWork
.
Save
();
}
public
void
RemoveMedicine
(
int
MedicalStateId
,
int
medicineId
)
{
var
m
=
_unitOfWork
.
Entity
.
GetById
(
MedicalStateId
,
_specification
).
Result
;
if
(
m
.
Medicines
is
null
)
m
.
Medicines
=
new
List
<
Medicine
>();
var
d
=
_medicineUnitOfWork
.
Entity
.
GetById
(
medicineId
,
_medicineSpecification
).
Result
;
m
.
Medicines
.
Remove
(
d
);
_unitOfWork
.
Entity
.
Update
(
m
);
_unitOfWork
.
Save
();
}
public
IEnumerable
<
MedicalStateModel
>
GetAllPatientMedicalStates
(
int
patientId
)
{
return
_mapper
.
Map
<
IEnumerable
<
MedicalStateModel
>>(
_patientService
.
GetPatientMedicalStates
(
patientId
));
...
...
ApplicationCore/Services/MedicineService/MedicineService.cs
View file @
9eece958
...
...
@@ -16,25 +16,55 @@ namespace ApplicationCore.Services
{
public
class
MedicineService
:
ServiceBase
<
Medicine
,
MedicineModel
>,
IMedicineService
{
private
IUnitOfWork
<
MedicalState
>
_medicalStateUnitOfWork
;
private
MedicalStateWithMedicinesSpecification
_medicalSpecification
;
public
MedicineService
(
IUnitOfWork
<
Medicine
>
medicineUnitOfWork
,
IUnitOfWork
<
MedicalState
>
medicalStateUnitOfWork
,
IMapper
Mapper
)
:
base
(
medicineUnitOfWork
,
Mapper
)
{
_specification
=
new
MedicineIngredientSpecification
();
_medicalStateUnitOfWork
=
medicalStateUnitOfWork
;
_specification
=
new
MedicineWithIngredientsSpecification
();
_medicalSpecification
=
new
MedicalStateWithMedicinesSpecification
();
}
public
void
AddMedicineIngredient
(
int
medicineId
,
IngredientModel
ingredientModel
)
{
var
s
=
_unitOfWork
.
Entity
.
GetById
(
medicineId
,
_specification
).
Result
;
s
.
Ingredients
.
Add
(
_mapper
.
Map
<
Ingredient
>(
ingredientModel
));
_unitOfWork
.
Entity
.
Update
(
s
);
_unitOfWork
.
Save
();
public
void
AddToMedicalState
(
MedicalStateMedicineModel
medicalStateMedicineModel
)
{
var
medicine
=
_unitOfWork
.
Entity
.
GetById
(
medicalStateMedicineModel
.
MedicineId
,
_specification
).
Result
;
//if (medicalState.Medicines is null)
// medicalState.Medicines = new List<Medicine>();
//var medicine = await _medicineUnitOfWork.Entity.GetById(medicalStateMedicineModel.MedicineId, _medicineSpecification);
if
(
medicine
.
MedicalStateMedicines
is
null
)
medicine
.
MedicalStateMedicines
=
new
List
<
MedicalStateMedicine
>();
medicine
.
MedicalStateMedicines
.
Add
(
_mapper
.
Map
<
MedicalStateMedicine
>(
medicalStateMedicineModel
)
);
_unitOfWork
.
Entity
.
Update
(
medicine
);
_unitOfWork
.
Save
();
}
public
void
RemoveFromMedicalState
(
MedicalStateMedicineModel
medicalStateMedicineModel
)
{
var
m
=
_medicalStateUnitOfWork
.
Entity
.
GetById
(
medicalStateMedicineModel
.
MedicalStateId
,
_medicalSpecification
).
Result
;
//// throw an exception
//if (m.Medicines is null)
// m.Medicines = new List<Medicine>();
var
d
=
_unitOfWork
.
Entity
.
GetById
(
medicalStateMedicineModel
.
MedicineId
,
_specification
).
Result
;
m
.
Medicines
.
Remove
(
d
);
_medicalStateUnitOfWork
.
Entity
.
Update
(
m
);
_medicalStateUnitOfWork
.
Save
();
}
public
MedicineModel
GetMedicineIngredentisDetails
(
int
medicineId
)
{
return
_mapper
.
Map
<
MedicineModel
>(
_unitOfWork
.
Entity
...
...
@@ -43,22 +73,5 @@ namespace ApplicationCore.Services
}
//public void AddIngredient(int medicineId, int ratio , IngredientModel ingredient)
//{
// // var m = _mapper.Map<Medicine>(GetMedicineIngredentisDetails(medicineId));
// var m = _unitOfWork.Entity.GetById(medicineId,_specification).Result;
// _unitOfWork.Save();
// if (ingredient.Id != 0)
// foreach (var i in m.Ingredients)
// {
// if (i.Id.Equals(ingredient.Id))
// return;
// }
// m.AddIngredient(_mapper.Map<Ingredient>(ingredient), ratio);
// _unitOfWork.Entity.Update(m);
// _unitOfWork.Save();
//}
}
}
ApplicationCore/Services/PatientService/PatientService.cs
View file @
9eece958
...
...
@@ -17,7 +17,7 @@ namespace ApplicationCore.Services
public
class
PatientService
:
ServiceBase
<
Patient
,
PatientModel
>
,
IPatientService
{
private
readonly
IUnitOfWork
<
MedicalState
>
_medicalStateUnitOfWork
;
private
MedicalStateSpecification
_medicalStateSpecification
;
private
MedicalState
WithMedicines
Specification
_medicalStateSpecification
;
public
PatientService
(
IUnitOfWork
<
Patient
>
patientUnitOfWork
,
...
...
@@ -26,8 +26,8 @@ namespace ApplicationCore.Services
:
base
(
patientUnitOfWork
,
mapper
)
{
_medicalStateUnitOfWork
=
medicalStateUnitOfWork
;
_specification
=
new
PatientMedicinesSpecification
();
_medicalStateSpecification
=
new
MedicalStateSpecification
();
_specification
=
new
Patient
With
MedicinesSpecification
();
_medicalStateSpecification
=
new
MedicalState
WithMedicines
Specification
();
}
public
IEnumerable
<
MedicalStateModel
>
GetPatientMedicalStates
(
int
patientId
)
{
...
...
@@ -60,6 +60,11 @@ namespace ApplicationCore.Services
return
_unitOfWork
.
Entity
.
GetById
(
id
)
is
null
?
false
:
true
;
}
public
async
Task
<
Patient
>
GetByUserID
(
string
id
)
{
var
ps
=
await
_unitOfWork
.
Entity
.
GetAll
(
_specification
);
return
ps
.
Where
(
p
=>
p
.
UserId
==
id
).
FirstOrDefault
();
}
}
}
ApplicationCore/obj/Debug/net5.0/ApplicationCore.csproj.AssemblyReference.cache
View file @
9eece958
No preview for this file type
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