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
47d96d17
Commit
47d96d17
authored
Aug 25, 2024
by
Almouhannad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(B) Add receptionist use cases commands and queries
parent
65bc5fc3
Changes
31
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
1851 additions
and
22 deletions
+1851
-22
Application.csproj
Clinics.Backend/Application/Application.csproj
+0
-4
GetAllDoctorsHandler.cs
...ion/Doctors/Queries/GetAllDoctors/GetAllDoctorsHandler.cs
+28
-0
GetAllDoctorsQuery.cs
...ation/Doctors/Queries/GetAllDoctors/GetAllDoctorsQuery.cs
+7
-0
GetAllDoctorsResponse.cs
...on/Doctors/Queries/GetAllDoctors/GetAllDoctorsResponse.cs
+50
-0
GetEmployeeBySerialNumberHandler.cs
...ies/GetBySerialNumber/GetEmployeeBySerialNumberHandler.cs
+29
-0
GetEmployeeBySerialNumberQuery.cs
...eries/GetBySerialNumber/GetEmployeeBySerialNumberQuery.cs
+8
-0
GetEmployeeBySerialNumberResponse.cs
...es/GetBySerialNumber/GetEmployeeBySerialNumberResponse.cs
+31
-0
CreateWaitingListRecordCommand.cs
...CreateWaitingListRecord/CreateWaitingListRecordCommand.cs
+8
-0
CreateWaitingListRecordHandler.cs
...CreateWaitingListRecord/CreateWaitingListRecordHandler.cs
+56
-0
DeleteWaitingListRecordCommand.cs
...DeleteWaitingListRecord/DeleteWaitingListRecordCommand.cs
+8
-0
DeleteWaitingListRecordHandler.cs
...DeleteWaitingListRecord/DeleteWaitingListRecordHandler.cs
+36
-0
GetAllWaitingListRecordsQuery.cs
...tion/WaitingList/Queries/GetAllWaitingListRecordsQuery.cs
+7
-0
GetAllWaitingListRecordsQueryHandler.cs
...itingList/Queries/GetAllWaitingListRecordsQueryHandler.cs
+57
-0
GetAllWaitingListRecordsResponse.cs
...n/WaitingList/Queries/GetAllWaitingListRecordsResponse.cs
+15
-0
WaitingListRecord.cs
....Backend/Domain/Entities/WaitingList/WaitingListRecord.cs
+4
-3
DomainErrors.cs
Clinics.Backend/Domain/Errors/DomainErrors.cs
+6
-0
IDoctorsRepository.cs
Clinics.Backend/Domain/Repositories/IDoctorsRepository.cs
+8
-0
IPatientsRepository.cs
Clinics.Backend/Domain/Repositories/IPatientsRepository.cs
+14
-1
IWaitingListRepository.cs
...ics.Backend/Domain/Repositories/IWaitingListRepository.cs
+10
-0
20240825003317_Fix_Waiting_List.Designer.cs
...ce/Migrations/20240825003317_Fix_Waiting_List.Designer.cs
+1089
-0
20240825003317_Fix_Waiting_List.cs
...Persistence/Migrations/20240825003317_Fix_Waiting_List.cs
+30
-0
ClinicsDbContextModelSnapshot.cs
...d/Persistence/Migrations/ClinicsDbContextModelSnapshot.cs
+3
-0
DoctorsRepository.cs
...end/Persistence/Repositories/Doctors/DoctorsRepository.cs
+36
-0
FullDoctorSpecification.cs
...itories/Doctors/Specifications/FullDoctorSpecification.cs
+15
-0
EmployeesRepository.cs
...Persistence/Repositories/Employees/EmployeesRepository.cs
+11
-4
PatientsRepository.cs
...d/Persistence/Repositories/Patients/PatientsRepository.cs
+99
-1
WaitingListRepository.cs
...istence/Repositories/WaitingList/WaitingListRepository.cs
+78
-0
DoctorsController.cs
...ics.Backend/Presentation/Controllers/DoctorsController.cs
+28
-0
EmployeesController.cs
...s.Backend/Presentation/Controllers/EmployeesController.cs
+14
-2
UsersController.cs
Clinics.Backend/Presentation/Controllers/UsersController.cs
+7
-7
WaitingListController.cs
...Backend/Presentation/Controllers/WaitingListController.cs
+59
-0
No files found.
Clinics.Backend/Application/Application.csproj
View file @
47d96d17
...
...
@@ -14,8 +14,4 @@
<ItemGroup>
<ProjectReference Include="..\Domain\Domain.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Employees\Queries\" />
</ItemGroup>
</Project>
Clinics.Backend/Application/Doctors/Queries/GetAllDoctors/GetAllDoctorsHandler.cs
0 → 100644
View file @
47d96d17
using
Application.Abstractions.CQRS.Queries
;
using
Domain.Repositories
;
using
Domain.Shared
;
namespace
Application.Doctors.Queries.GetAllDoctors
;
public
class
GetAllDoctorsHandler
:
IQueryHandler
<
GetAllDoctorsQuery
,
GetAllDoctorsResponse
>
{
#
region
CTOR
DI
private
readonly
IDoctorsRepository
_doctorsRepository
;
public
GetAllDoctorsHandler
(
IDoctorsRepository
doctorsRepository
)
{
_doctorsRepository
=
doctorsRepository
;
}
#
endregion
public
async
Task
<
Result
<
GetAllDoctorsResponse
>>
Handle
(
GetAllDoctorsQuery
request
,
CancellationToken
cancellationToken
)
{
#
region
1.
Fetch
data
from
persistence
var
dataFromPersistenceResult
=
await
_doctorsRepository
.
GetAllAsync
();
if
(
dataFromPersistenceResult
.
IsFailure
)
return
Result
.
Failure
<
GetAllDoctorsResponse
>(
dataFromPersistenceResult
.
Error
);
var
doctors
=
dataFromPersistenceResult
.
Value
;
#
endregion
return
Result
.
Success
<
GetAllDoctorsResponse
>(
GetAllDoctorsResponse
.
GetResponse
(
doctors
));
}
}
Clinics.Backend/Application/Doctors/Queries/GetAllDoctors/GetAllDoctorsQuery.cs
0 → 100644
View file @
47d96d17
using
Application.Abstractions.CQRS.Queries
;
namespace
Application.Doctors.Queries.GetAllDoctors
;
public
class
GetAllDoctorsQuery
:
IQuery
<
GetAllDoctorsResponse
>
{
}
Clinics.Backend/Application/Doctors/Queries/GetAllDoctors/GetAllDoctorsResponse.cs
0 → 100644
View file @
47d96d17
using
Domain.Entities.People.Doctors
;
namespace
Application.Doctors.Queries.GetAllDoctors
;
public
class
GetAllDoctorsResponse
{
public
class
GetAllDoctorsResponseItem
{
public
string
FullName
{
get
;
set
;
}
=
null
!;
public
string
Status
{
get
;
set
;
}
=
null
!;
public
ICollection
<
PhoneItem
>
Phones
{
get
;
set
;
}
=
null
!;
}
public
class
PhoneItem
{
public
string
Name
{
get
;
set
;
}
=
null
!;
public
string
Phone
{
get
;
set
;
}
=
null
!;
}
public
ICollection
<
GetAllDoctorsResponseItem
>
Doctors
{
get
;
set
;
}
=
null
!;
public
static
GetAllDoctorsResponse
GetResponse
(
ICollection
<
Doctor
>
doctors
)
{
List
<
GetAllDoctorsResponseItem
>
response
=
new
();
foreach
(
var
doctor
in
doctors
)
{
List
<
PhoneItem
>
phones
=
new
();
foreach
(
var
phone
in
doctor
.
Phones
)
{
phones
.
Add
(
new
PhoneItem
{
Name
=
phone
.
Name
!,
Phone
=
phone
.
Phone
,
});
}
response
.
Add
(
new
GetAllDoctorsResponseItem
{
FullName
=
doctor
.
PersonalInfo
.
FullName
,
Status
=
doctor
.
Status
.
Name
,
Phones
=
phones
});
}
return
new
GetAllDoctorsResponse
{
Doctors
=
response
};
}
}
Clinics.Backend/Application/Employees/Queries/GetBySerialNumber/GetEmployeeBySerialNumberHandler.cs
0 → 100644
View file @
47d96d17
using
Application.Abstractions.CQRS.Queries
;
using
Domain.Repositories
;
using
Domain.Shared
;
namespace
Application.Employees.Queries.GetBySerialNumber
;
public
class
GetEmployeeBySerialNumberHandler
:
IQueryHandler
<
GetEmployeeBySerialNumberQuery
,
GetEmployeeBySerialNumberResponse
>
{
#
region
CTOR
DI
private
readonly
IEmployeesRepository
_employeesRepository
;
public
GetEmployeeBySerialNumberHandler
(
IEmployeesRepository
employeesRepository
)
{
_employeesRepository
=
employeesRepository
;
}
#
endregion
public
async
Task
<
Result
<
GetEmployeeBySerialNumberResponse
>>
Handle
(
GetEmployeeBySerialNumberQuery
request
,
CancellationToken
cancellationToken
)
{
#
region
1.
Fetch
from
persistence
var
employeeFromPersistenceResult
=
await
_employeesRepository
.
GetEmployeeBySerialNumberAsync
(
request
.
SerialNumber
);
if
(
employeeFromPersistenceResult
.
IsFailure
)
return
Result
.
Failure
<
GetEmployeeBySerialNumberResponse
>(
employeeFromPersistenceResult
.
Error
);
var
employee
=
employeeFromPersistenceResult
.
Value
;
#
endregion
return
Result
.
Success
<
GetEmployeeBySerialNumberResponse
>
(
GetEmployeeBySerialNumberResponse
.
GetResponse
(
employee
));
}
}
Clinics.Backend/Application/Employees/Queries/GetBySerialNumber/GetEmployeeBySerialNumberQuery.cs
0 → 100644
View file @
47d96d17
using
Application.Abstractions.CQRS.Queries
;
namespace
Application.Employees.Queries.GetBySerialNumber
;
public
class
GetEmployeeBySerialNumberQuery
:
IQuery
<
GetEmployeeBySerialNumberResponse
>
{
public
string
SerialNumber
{
get
;
set
;
}
=
null
!;
}
Clinics.Backend/Application/Employees/Queries/GetBySerialNumber/GetEmployeeBySerialNumberResponse.cs
0 → 100644
View file @
47d96d17
using
Domain.Entities.People.Employees
;
namespace
Application.Employees.Queries.GetBySerialNumber
;
public
class
GetEmployeeBySerialNumberResponse
{
public
int
Id
{
get
;
set
;
}
public
string
FirstName
{
get
;
set
;
}
=
null
!;
public
string
MiddleName
{
get
;
set
;
}
=
null
!;
public
string
LastName
{
get
;
set
;
}
=
null
!;
public
string
Gender
{
get
;
set
;
}
=
null
!;
public
DateOnly
DateOfBirth
{
get
;
set
;
}
public
string
SerialNumber
{
get
;
set
;
}
=
null
!;
public
string
CenterStatus
{
get
;
set
;
}
=
null
!;
public
static
GetEmployeeBySerialNumberResponse
GetResponse
(
Employee
employee
)
{
return
new
GetEmployeeBySerialNumberResponse
{
Id
=
employee
.
Id
,
FirstName
=
employee
.
Patient
.
PersonalInfo
.
FirstName
,
MiddleName
=
employee
.
Patient
.
PersonalInfo
.
MiddleName
,
LastName
=
employee
.
Patient
.
PersonalInfo
.
LastName
,
Gender
=
employee
.
Patient
.
Gender
.
Name
,
DateOfBirth
=
employee
.
Patient
.
DateOfBirth
,
SerialNumber
=
employee
.
SerialNumber
,
CenterStatus
=
employee
.
CenterStatus
};
}
}
Clinics.Backend/Application/WaitingList/Commands/CreateWaitingListRecord/CreateWaitingListRecordCommand.cs
0 → 100644
View file @
47d96d17
using
Application.Abstractions.CQRS.Commands
;
namespace
Application.WaitingList.Commands.CreateWaitingListRecord
;
public
class
CreateWaitingListRecordCommand
:
ICommand
{
public
string
SerialNumber
{
get
;
set
;
}
=
null
!;
}
Clinics.Backend/Application/WaitingList/Commands/CreateWaitingListRecord/CreateWaitingListRecordHandler.cs
0 → 100644
View file @
47d96d17
using
Application.Abstractions.CQRS.Commands
;
using
Domain.Entities.WaitingList
;
using
Domain.Errors
;
using
Domain.Repositories
;
using
Domain.Shared
;
using
Domain.UnitOfWork
;
namespace
Application.WaitingList.Commands.CreateWaitingListRecord
;
public
class
CreateWaitingListRecordHandler
:
CommandHandlerBase
<
CreateWaitingListRecordCommand
>
{
#
region
CTOR
DI
private
readonly
IEmployeesRepository
_employeesRepository
;
private
readonly
IWaitingListRepository
_waitingListRepository
;
public
CreateWaitingListRecordHandler
(
IUnitOfWork
unitOfWork
,
IWaitingListRepository
waitingListRepository
,
IEmployeesRepository
employeesRepository
)
:
base
(
unitOfWork
)
{
_waitingListRepository
=
waitingListRepository
;
_employeesRepository
=
employeesRepository
;
}
#
endregion
public
override
async
Task
<
Result
>
HandleHelper
(
CreateWaitingListRecordCommand
request
,
CancellationToken
cancellationToken
)
{
#
region
1.
Fetch
employee
from
persistence
var
employeeFromPersistenceResult
=
await
_employeesRepository
.
GetEmployeeBySerialNumberAsync
(
request
.
SerialNumber
);
if
(
employeeFromPersistenceResult
.
IsFailure
)
return
Result
.
Failure
(
employeeFromPersistenceResult
.
Error
);
var
employee
=
employeeFromPersistenceResult
.
Value
;
#
endregion
#
region
2.
Check
duplicate
var
duplicateResult
=
await
_waitingListRepository
.
IsEmployeeInWaitingListAsync
(
request
.
SerialNumber
);
if
(
duplicateResult
.
IsFailure
)
return
Result
.
Failure
(
duplicateResult
.
Error
);
if
(
duplicateResult
.
Value
)
return
Result
.
Failure
(
DomainErrors
.
PatientAlreadyInWaitingList
);
#
endregion
#
region
3.
Create
waiting
list
record
var
waitingListRecordResult
=
WaitingListRecord
.
Create
(
employee
.
Id
);
if
(
waitingListRecordResult
.
IsFailure
)
return
Result
.
Failure
(
waitingListRecordResult
.
Error
);
var
waitingListRecord
=
waitingListRecordResult
.
Value
;
#
endregion
#
region
4.
save
changes
var
saveChangesResult
=
await
_waitingListRepository
.
CreateAsync
(
waitingListRecord
);
if
(
saveChangesResult
.
IsFailure
)
return
Result
.
Failure
(
saveChangesResult
.
Error
);
#
endregion
return
Result
.
Success
();
}
}
Clinics.Backend/Application/WaitingList/Commands/DeleteWaitingListRecord/DeleteWaitingListRecordCommand.cs
0 → 100644
View file @
47d96d17
using
Application.Abstractions.CQRS.Commands
;
namespace
Application.WaitingList.Commands.DeleteWaitingListRecord
;
public
class
DeleteWaitingListRecordCommand
:
ICommand
{
public
int
Id
{
get
;
set
;
}
}
Clinics.Backend/Application/WaitingList/Commands/DeleteWaitingListRecord/DeleteWaitingListRecordHandler.cs
0 → 100644
View file @
47d96d17
using
Application.Abstractions.CQRS.Commands
;
using
Domain.Repositories
;
using
Domain.Shared
;
using
Domain.UnitOfWork
;
namespace
Application.WaitingList.Commands.DeleteWaitingListRecord
;
public
class
DeleteWaitingListRecordHandler
:
CommandHandlerBase
<
DeleteWaitingListRecordCommand
>
{
#
region
CTOR
DI
private
readonly
IWaitingListRepository
_waitingListRepository
;
public
DeleteWaitingListRecordHandler
(
IUnitOfWork
unitOfWork
,
IWaitingListRepository
waitingListRepository
)
:
base
(
unitOfWork
)
{
_waitingListRepository
=
waitingListRepository
;
}
#
endregion
public
override
async
Task
<
Result
>
HandleHelper
(
DeleteWaitingListRecordCommand
request
,
CancellationToken
cancellationToken
)
{
#
region
1.
Fetch
from
persistence
var
recordFromPersistenceResult
=
await
_waitingListRepository
.
GetByIdAsync
(
request
.
Id
);
if
(
recordFromPersistenceResult
.
IsFailure
)
return
Result
.
Failure
(
recordFromPersistenceResult
.
Error
);
var
record
=
recordFromPersistenceResult
.
Value
;
#
endregion
#
region
2.
Perform
delete
var
deleteResult
=
await
_waitingListRepository
.
DeleteAsync
(
record
);
if
(
deleteResult
.
IsFailure
)
return
Result
.
Failure
(
deleteResult
.
Error
);
#
endregion
return
Result
.
Success
();
}
}
Clinics.Backend/Application/WaitingList/Queries/GetAllWaitingListRecordsQuery.cs
0 → 100644
View file @
47d96d17
using
Application.Abstractions.CQRS.Queries
;
namespace
Application.WaitingList.Queries
;
public
class
GetAllWaitingListRecordsQuery
:
IQuery
<
GetAllWaitingListRecordsResponse
>
{
}
Clinics.Backend/Application/WaitingList/Queries/GetAllWaitingListRecordsQueryHandler.cs
0 → 100644
View file @
47d96d17
using
Application.Abstractions.CQRS.Queries
;
using
Domain.Entities.WaitingList
;
using
Domain.Repositories
;
using
Domain.Shared
;
using
static
Application
.
WaitingList
.
Queries
.
GetAllWaitingListRecordsResponse
;
namespace
Application.WaitingList.Queries
;
public
class
GetAllWaitingListRecordsQueryHandler
:
IQueryHandler
<
GetAllWaitingListRecordsQuery
,
GetAllWaitingListRecordsResponse
>
{
#
region
CTOR
DI
private
readonly
IWaitingListRepository
_waitingListRepository
;
private
readonly
IPatientsRepository
_petientsRepository
;
public
GetAllWaitingListRecordsQueryHandler
(
IWaitingListRepository
waitingListRepository
,
IPatientsRepository
petientsRepository
)
{
_waitingListRepository
=
waitingListRepository
;
_petientsRepository
=
petientsRepository
;
}
#
endregion
public
async
Task
<
Result
<
GetAllWaitingListRecordsResponse
>>
Handle
(
GetAllWaitingListRecordsQuery
request
,
CancellationToken
cancellationToken
)
{
#
region
1.
Fetch
all
from
persistence
var
fetchAllResult
=
await
_waitingListRepository
.
GetAllAsync
();
if
(
fetchAllResult
.
IsFailure
)
return
Result
.
Failure
<
GetAllWaitingListRecordsResponse
>(
fetchAllResult
.
Error
);
var
allRecords
=
fetchAllResult
.
Value
;
#
endregion
#
region
2.
Generate
response
List
<
GetAllWaitingListRecordsResponseItem
>
response
=
[];
foreach
(
WaitingListRecord
record
in
allRecords
)
{
var
isEmployee
=
await
_petientsRepository
.
IsEmployeeByIdAsync
(
record
.
PatientId
);
if
(
isEmployee
.
IsFailure
)
return
Result
.
Failure
<
GetAllWaitingListRecordsResponse
>(
isEmployee
.
Error
);
var
responseItem
=
new
GetAllWaitingListRecordsResponseItem
{
Id
=
record
.
Id
,
PatientId
=
record
.
PatientId
,
IsEmployee
=
isEmployee
.
Value
,
FullName
=
record
.
Patient
.
PersonalInfo
.
FullName
,
ArrivalTime
=
record
.
ArrivalTime
};
response
.
Add
(
responseItem
);
}
#
endregion
return
Result
.
Success
<
GetAllWaitingListRecordsResponse
>
(
new
GetAllWaitingListRecordsResponse
{
WaitingListRecords
=
response
});
}
}
Clinics.Backend/Application/WaitingList/Queries/GetAllWaitingListRecordsResponse.cs
0 → 100644
View file @
47d96d17
namespace
Application.WaitingList.Queries
;
public
class
GetAllWaitingListRecordsResponse
{
public
class
GetAllWaitingListRecordsResponseItem
{
public
int
Id
{
get
;
set
;
}
public
int
PatientId
{
get
;
set
;
}
public
string
FullName
{
get
;
set
;
}
=
null
!;
public
bool
IsEmployee
{
get
;
set
;
}
public
DateTime
ArrivalTime
{
get
;
set
;
}
}
public
ICollection
<
GetAllWaitingListRecordsResponseItem
>
WaitingListRecords
{
get
;
set
;
}
=
null
!;
}
Clinics.Backend/Domain/Entities/WaitingList/WaitingListRecord.cs
View file @
47d96d17
...
...
@@ -10,9 +10,10 @@ public sealed class WaitingListRecord : Entity
#
region
Private
ctor
private
WaitingListRecord
(
int
id
)
:
base
(
id
)
{
}
private
WaitingListRecord
(
int
id
,
int
patientId
)
:
base
(
id
)
private
WaitingListRecord
(
int
id
,
int
patientId
,
DateTime
arrivalTime
)
:
base
(
id
)
{
PatientId
=
patientId
;
ArrivalTime
=
arrivalTime
;
}
#
endregion
...
...
@@ -28,7 +29,7 @@ public sealed class WaitingListRecord : Entity
#
region
Additional
DateTime
ArrivalTime
{
get
;
set
;
}
public
DateTime
ArrivalTime
{
get
;
set
;
}
#
endregion
...
...
@@ -42,7 +43,7 @@ public sealed class WaitingListRecord : Entity
{
if
(
patientId
<=
0
)
return
Result
.
Failure
<
WaitingListRecord
>(
Errors
.
DomainErrors
.
InvalidValuesError
);
return
new
WaitingListRecord
(
0
,
patientId
);
return
new
WaitingListRecord
(
0
,
patientId
,
DateTime
.
Now
);
}
#
endregion
...
...
Clinics.Backend/Domain/Errors/DomainErrors.cs
View file @
47d96d17
...
...
@@ -40,4 +40,10 @@ public static class DomainErrors
public
static
Error
InvalidHolidayDuration
=>
new
(
"Domain.InvalidHolidayDuration"
,
"الحد الأقصى للإجازة المرضية هو خمس أيام"
);
public
static
Error
SerialNumberNotFound
=>
new
(
"Domain.SerialNumberNotFound"
,
"لا يوجد موظف بهذا الرقم الذاتي"
);
public
static
Error
PatientAlreadyInWaitingList
=>
new
(
"Domain.PatientAlreadyInWaitingList"
,
"المريض موجود في قائمة الانتظار بالفعل"
);
}
Clinics.Backend/Domain/Repositories/IDoctorsRepository.cs
0 → 100644
View file @
47d96d17
using
Domain.Entities.People.Doctors
;
using
Domain.Repositories.Base
;
namespace
Domain.Repositories
;
public
interface
IDoctorsRepository
:
IRepository
<
Doctor
>
{
}
Clinics.Backend/Domain/Repositories/IPatientsRepository.cs
View file @
47d96d17
using
Domain.Entities.People.Patients
;
using
Domain.Entities.People.Employees
;
using
Domain.Entities.People.FamilyMembers
;
using
Domain.Entities.People.Patients
;
using
Domain.Repositories.Base
;
using
Domain.Shared
;
...
...
@@ -11,4 +13,15 @@ public interface IPatientsRepository : IRepository<Patient>
public
Task
<
Result
<
ICollection
<
Patient
>>>
GetAllFullAsync
(
int
id
);
#
endregion
#
region
IsEmployee
public
Task
<
Result
<
bool
>>
IsEmployeeByIdAsync
(
int
id
);
public
Task
<
Result
<
Employee
>>
GetEmployeeByIdAsync
(
int
id
);
#
endregion
#
region
FamilyMember
public
Task
<
Result
<
bool
>>
IsFamilyMemberByIdAsync
(
int
id
);
public
Task
<
Result
<
FamilyMember
>>
GetFamilyMemberByIdAsync
(
int
id
);
#
endregion
}
Clinics.Backend/Domain/Repositories/IWaitingListRepository.cs
0 → 100644
View file @
47d96d17
using
Domain.Entities.WaitingList
;
using
Domain.Repositories.Base
;
using
Domain.Shared
;
namespace
Domain.Repositories
;
public
interface
IWaitingListRepository
:
IRepository
<
WaitingListRecord
>
{
public
Task
<
Result
<
bool
>>
IsEmployeeInWaitingListAsync
(
string
serialNumber
);
}
Clinics.Backend/Persistence/Migrations/20240825003317_Fix_Waiting_List.Designer.cs
0 → 100644
View file @
47d96d17
This diff is collapsed.
Click to expand it.
Clinics.Backend/Persistence/Migrations/20240825003317_Fix_Waiting_List.cs
0 → 100644
View file @
47d96d17
using
System
;
using
Microsoft.EntityFrameworkCore.Migrations
;
#
nullable
disable
namespace
Persistence.Migrations
{
/// <inheritdoc />
public
partial
class
Fix_Waiting_List
:
Migration
{
/// <inheritdoc />
protected
override
void
Up
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
AddColumn
<
DateTime
>(
name
:
"ArrivalTime"
,
table
:
"WaitingListRecord"
,
type
:
"datetime2"
,
nullable
:
false
,
defaultValue
:
new
DateTime
(
1
,
1
,
1
,
0
,
0
,
0
,
0
,
DateTimeKind
.
Unspecified
));
}
/// <inheritdoc />
protected
override
void
Down
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
DropColumn
(
name
:
"ArrivalTime"
,
table
:
"WaitingListRecord"
);
}
}
}
Clinics.Backend/Persistence/Migrations/ClinicsDbContextModelSnapshot.cs
View file @
47d96d17
...
...
@@ -695,6 +695,9 @@ namespace Persistence.Migrations
SqlServerPropertyBuilderExtensions
.
UseIdentityColumn
(
b
.
Property
<
int
>(
"Id"
));
b
.
Property
<
DateTime
>(
"ArrivalTime"
)
.
HasColumnType
(
"datetime2"
);
b
.
Property
<
int
>(
"PatientId"
)
.
HasColumnType
(
"int"
);
...
...
Clinics.Backend/Persistence/Repositories/Doctors/DoctorsRepository.cs
0 → 100644
View file @
47d96d17
using
Domain.Entities.People.Doctors
;
using
Domain.Errors
;
using
Domain.Repositories
;
using
Domain.Shared
;
using
Microsoft.EntityFrameworkCore
;
using
Persistence.Context
;
using
Persistence.Repositories.Base
;
using
Persistence.Repositories.Doctors.Specifications
;
using
System.Collections.Generic
;
namespace
Persistence.Repositories.Doctors
;
public
class
DoctorsRepository
:
Repositroy
<
Doctor
>,
IDoctorsRepository
{
#
region
CTOR
DI
public
DoctorsRepository
(
ClinicsDbContext
context
)
:
base
(
context
)
{
}
#
endregion
#
region
Read
methods
public
override
async
Task
<
Result
<
ICollection
<
Doctor
>>>
GetAllAsync
()
{
try
{
var
query
=
ApplySpecification
(
new
FullDoctorSpecification
(
doctor
=>
true
));
return
await
query
.
ToListAsync
();
}
catch
(
Exception
)
{
return
Result
.
Failure
<
ICollection
<
Doctor
>>(
PersistenceErrors
.
Unknown
);
}
}
#
endregion
}
Clinics.Backend/Persistence/Repositories/Doctors/Specifications/FullDoctorSpecification.cs
0 → 100644
View file @
47d96d17
using
Domain.Entities.People.Doctors
;
using
Persistence.Repositories.Specifications.Base
;
using
System.Linq.Expressions
;
namespace
Persistence.Repositories.Doctors.Specifications
;
public
class
FullDoctorSpecification
:
Specification
<
Doctor
>
{
public
FullDoctorSpecification
(
Expression
<
Func
<
Doctor
,
bool
>>?
criteria
)
:
base
(
criteria
)
{
AddInclude
(
doctor
=>
doctor
.
PersonalInfo
);
AddInclude
(
doctor
=>
doctor
.
Status
);
AddInclude
(
doctor
=>
doctor
.
Phones
);
}
}
Clinics.Backend/Persistence/Repositories/Employees/EmployeesRepository.cs
View file @
47d96d17
...
...
@@ -24,10 +24,17 @@ public class EmployeesRepository : Repositroy<Employee>, IEmployeesRepository
#
region
Get
by
serial
Number
public
async
Task
<
Result
<
Employee
>>
GetEmployeeBySerialNumberAsync
(
string
serialNumber
)
{
var
all
=
await
_context
.
Set
<
Employee
>().
Where
(
employee
=>
employee
.
SerialNumber
==
serialNumber
).
ToListAsync
();
if
(
all
.
Count
!=
1
)
return
Result
.
Failure
<
Employee
>(
PersistenceErrors
.
NotFound
);
return
Result
.
Success
(
all
.
First
());
var
query
=
_context
.
Set
<
Employee
>()
.
Where
(
employee
=>
employee
.
SerialNumber
==
serialNumber
)
.
Include
(
employee
=>
employee
.
Patient
)
.
ThenInclude
(
patient
=>
patient
.
PersonalInfo
)
.
Include
(
employee
=>
employee
.
Patient
)
.
ThenInclude
(
patient
=>
patient
.
Gender
);
var
result
=
await
query
.
ToListAsync
();
if
(
result
.
Count
!=
1
)
return
Result
.
Failure
<
Employee
>(
DomainErrors
.
SerialNumberNotFound
);
return
Result
.
Success
(
result
.
First
());
}
#
endregion
}
Clinics.Backend/Persistence/Repositories/Patients/PatientsRepository.cs
View file @
47d96d17
using
Domain.Entities.People.Patients
;
using
Domain.Entities.People.Employees
;
using
Domain.Entities.People.FamilyMembers
;
using
Domain.Entities.People.Patients
;
using
Domain.Errors
;
using
Domain.Repositories
;
using
Domain.Shared
;
...
...
@@ -47,5 +49,101 @@ public class PatientsRepository : Repositroy<Patient>, IPatientsRepository
}
#
endregion
#
region
Create
operation
public
override
Task
<
Result
<
Patient
>>
CreateAsync
(
Patient
entity
)
{
_context
.
Entry
(
entity
.
Gender
).
State
=
EntityState
.
Unchanged
;
return
base
.
CreateAsync
(
entity
);
}
#
endregion
#
region
IsEmployee
public
async
Task
<
Result
<
bool
>>
IsEmployeeByIdAsync
(
int
id
)
{
try
{
var
query
=
_context
.
Set
<
Employee
>()
.
Where
(
employee
=>
employee
.
Id
==
id
);
var
result
=
await
query
.
ToListAsync
();
return
result
.
Count
==
1
;
}
catch
(
Exception
)
{
return
Result
.
Failure
<
bool
>(
PersistenceErrors
.
NotFound
);
}
}
public
async
Task
<
Result
<
Employee
>>
GetEmployeeByIdAsync
(
int
id
)
{
try
{
var
query
=
_context
.
Set
<
Employee
>()
.
Where
(
employee
=>
employee
.
Id
==
id
)
// Note that this is only one row
.
Include
(
employee
=>
employee
.
Patient
)
// so, join is effecient
.
ThenInclude
(
patient
=>
patient
.
PersonalInfo
)
.
Include
(
employee
=>
employee
.
Patient
)
.
ThenInclude
(
patient
=>
patient
.
Gender
)
.
Include
(
employee
=>
employee
.
Patient
)
.
ThenInclude
(
patient
=>
patient
.
Diseases
)
.
Include
(
employee
=>
employee
.
Patient
)
.
ThenInclude
(
patient
=>
patient
.
Medicines
)
.
Include
(
employee
=>
employee
.
Patient
)
.
ThenInclude
(
patient
=>
patient
.
Visits
)
.
Include
(
employee
=>
employee
.
AdditionalInfo
)
.
Include
(
employee
=>
employee
.
FamilyMembers
)
.
Include
(
employee
=>
employee
.
RelatedEmployees
)
.
Include
(
employee
=>
employee
.
RelatedTo
);
return
await
query
.
FirstAsync
();
}
catch
(
Exception
)
{
return
Result
.
Failure
<
Employee
>(
PersistenceErrors
.
NotFound
);
}
}
#
endregion
#
region
FamilyMember
public
async
Task
<
Result
<
bool
>>
IsFamilyMemberByIdAsync
(
int
id
)
{
try
{
var
query
=
_context
.
Set
<
FamilyMember
>()
.
Where
(
familyMember
=>
familyMember
.
Id
==
id
);
var
result
=
await
query
.
ToListAsync
();
return
result
.
Count
==
1
;
}
catch
(
Exception
)
{
return
Result
.
Failure
<
bool
>(
PersistenceErrors
.
NotFound
);
}
}
public
async
Task
<
Result
<
FamilyMember
>>
GetFamilyMemberByIdAsync
(
int
id
)
{
try
{
var
query
=
_context
.
Set
<
FamilyMember
>()
.
Where
(
familyMember
=>
familyMember
.
Id
==
id
)
// Note that this is only one row
.
Include
(
familyMember
=>
familyMember
.
Patient
)
// so, join is effecient
.
ThenInclude
(
patient
=>
patient
.
PersonalInfo
)
.
Include
(
familyMember
=>
familyMember
.
Patient
)
.
ThenInclude
(
patient
=>
patient
.
Gender
)
.
Include
(
familyMember
=>
familyMember
.
Patient
)
.
ThenInclude
(
patient
=>
patient
.
Diseases
)
.
Include
(
familyMember
=>
familyMember
.
Patient
)
.
ThenInclude
(
patient
=>
patient
.
Medicines
)
.
Include
(
familyMember
=>
familyMember
.
Patient
)
.
ThenInclude
(
patient
=>
patient
.
Visits
);
return
await
query
.
FirstAsync
();
}
catch
(
Exception
)
{
return
Result
.
Failure
<
FamilyMember
>(
PersistenceErrors
.
NotFound
);
}
}
#
endregion
}
Clinics.Backend/Persistence/Repositories/WaitingList/WaitingListRepository.cs
0 → 100644
View file @
47d96d17
using
Domain.Entities.People.Employees
;
using
Domain.Entities.WaitingList
;
using
Domain.Errors
;
using
Domain.Repositories
;
using
Domain.Shared
;
using
Microsoft.EntityFrameworkCore
;
using
Persistence.Context
;
using
Persistence.Repositories.Base
;
namespace
Persistence.Repositories.WaitingList
;
public
class
WaitingListRepository
:
Repositroy
<
WaitingListRecord
>,
IWaitingListRepository
{
#
region
CTOR
DI
public
WaitingListRepository
(
ClinicsDbContext
context
)
:
base
(
context
)
{
}
#
endregion
#
region
Read
methods
public
override
async
Task
<
Result
<
WaitingListRecord
>>
GetByIdAsync
(
int
id
)
{
try
{
var
query
=
_context
.
Set
<
WaitingListRecord
>()
.
Where
(
waitingListRecord
=>
waitingListRecord
.
Id
==
id
)
.
Include
(
witingListRecord
=>
witingListRecord
.
Patient
)
.
ThenInclude
(
patient
=>
patient
.
PersonalInfo
)
.
Include
(
witingListRecord
=>
witingListRecord
.
Patient
)
.
ThenInclude
(
patient
=>
patient
.
Gender
);
return
await
query
.
FirstAsync
();
}
catch
(
Exception
)
{
return
Result
.
Failure
<
WaitingListRecord
>(
PersistenceErrors
.
NotFound
);
}
}
public
override
async
Task
<
Result
<
ICollection
<
WaitingListRecord
>>>
GetAllAsync
()
{
try
{
var
query
=
_context
.
Set
<
WaitingListRecord
>()
.
Include
(
waitingListRecord
=>
waitingListRecord
.
Patient
)
.
ThenInclude
(
patient
=>
patient
.
PersonalInfo
)
.
Include
(
waitingListRecord
=>
waitingListRecord
.
Patient
)
.
ThenInclude
(
patient
=>
patient
.
Gender
);
return
await
query
.
ToListAsync
();
}
catch
(
Exception
)
{
return
Result
.
Failure
<
ICollection
<
WaitingListRecord
>>(
PersistenceErrors
.
Unknown
);
}
}
#
endregion
#
region
Is
employee
in
list
public
async
Task
<
Result
<
bool
>>
IsEmployeeInWaitingListAsync
(
string
serialNumber
)
{
try
{
var
employee
=
await
_context
.
Set
<
Employee
>()
.
Where
(
employee
=>
employee
.
SerialNumber
==
serialNumber
)
.
FirstAsync
();
var
query
=
_context
.
Set
<
WaitingListRecord
>()
.
Where
(
waitingListRecord
=>
waitingListRecord
.
PatientId
==
employee
.
Id
);
var
result
=
await
query
.
ToListAsync
();
return
result
.
Count
==
1
;
}
catch
(
Exception
)
{
return
Result
.
Failure
<
bool
>(
PersistenceErrors
.
NotFound
);
}
}
#
endregion
}
Clinics.Backend/Presentation/Controllers/DoctorsController.cs
0 → 100644
View file @
47d96d17
using
Application.Doctors.Queries.GetAllDoctors
;
using
MediatR
;
using
Microsoft.AspNetCore.Mvc
;
using
Presentation.Controllers.Base
;
namespace
Presentation.Controllers
;
[Route("api/Doctors")]
public
class
DoctorsController
:
ApiController
{
#
region
DI
for
MeditR
sender
public
DoctorsController
(
ISender
sender
)
:
base
(
sender
)
{
}
#
endregion
//[Authorize(Roles = Roles.ReceptionistName)]
[
HttpGet
]
public
async
Task
<
IActionResult
>
GetAll
()
{
var
query
=
new
GetAllDoctorsQuery
();
var
result
=
await
_sender
.
Send
(
query
);
if
(
result
.
IsFailure
)
return
HandleFailure
(
result
);
return
Ok
(
result
.
Value
);
}
}
Clinics.Backend/Presentation/Controllers/EmployeesController.cs
View file @
47d96d17
using
Application.Employees.Commands.AttachFamilyMemberToEmployee
;
using
Application.Employees.Commands.CreateEmployee
;
using
Application.Employees.Queries.GetBySerialNumber
;
using
Domain.Entities.Identity.UserRoles
;
using
MediatR
;
using
Microsoft.AspNetCore.Authorization
;
...
...
@@ -18,7 +19,7 @@ public class EmployeesController : ApiController
}
#
endregion
[
Authorize
(
Roles
=
Roles
.
Admin
Name
)]
//[Authorize(Roles = Roles.Receptionist
Name)]
[
HttpPost
]
public
async
Task
<
IActionResult
>
Create
([
FromBody
]
CreateEmployeeCommand
command
)
{
...
...
@@ -27,7 +28,18 @@ public class EmployeesController : ApiController
return
HandleFailure
(
result
);
return
Created
();
}
[
Authorize
(
Roles
=
Roles
.
DoctorName
)]
//[Authorize(Roles = Roles.ReceptionistName)]
[
HttpPost
(
"SerialNumber"
)]
// It's a get, but serial number shouldn't be sent via routing, so we'll use post
public
async
Task
<
IActionResult
>
GetBySerialNumber
([
FromBody
]
GetEmployeeBySerialNumberQuery
query
)
{
var
result
=
await
_sender
.
Send
(
query
);
if
(
result
.
IsFailure
)
return
HandleFailure
(
result
);
return
Ok
(
result
.
Value
);
}
//[Authorize(Roles = Roles.ReceptionistName)]
[
HttpPut
(
"FamilyMembers"
)]
public
async
Task
<
IActionResult
>
AttachFamilyMember
([
FromBody
]
AttachFamilyMemberToEmployeeCommand
command
)
{
...
...
Clinics.Backend/Presentation/Controllers/UsersController.cs
View file @
47d96d17
...
...
@@ -39,7 +39,7 @@ public class UsersController : ApiController
#
endregion
#
region
Doctors
[
Authorize
(
Roles
=
Roles
.
AdminName
)]
//
[Authorize(Roles = Roles.AdminName)]
[
HttpPost
(
"Doctors"
)]
public
async
Task
<
IActionResult
>
RegisterDoctor
([
FromBody
]
RegisterDoctorCommand
command
)
{
...
...
@@ -51,7 +51,7 @@ public class UsersController : ApiController
return
Created
();
}
[
Authorize
(
Roles
=
Roles
.
AdminName
)]
//
[Authorize(Roles = Roles.AdminName)]
[
HttpGet
(
"Doctors"
)]
public
async
Task
<
IActionResult
>
GetAllDoctorUsers
()
{
...
...
@@ -62,7 +62,7 @@ public class UsersController : ApiController
return
Ok
(
result
.
Value
);
}
[
Authorize
(
Roles
=
Roles
.
AdminName
)]
//
[Authorize(Roles = Roles.AdminName)]
[
HttpGet
(
"Doctors/{id:int}"
)]
public
async
Task
<
IActionResult
>
GetDoctorUserById
([
FromRoute
(
Name
=
"id"
)]
int
id
)
{
...
...
@@ -73,7 +73,7 @@ public class UsersController : ApiController
return
Ok
(
result
.
Value
);
}
[
Authorize
(
Roles
=
Roles
.
AdminName
)]
//
[Authorize(Roles = Roles.AdminName)]
[
HttpPut
(
"Doctors"
)]
public
async
Task
<
IActionResult
>
UpdateDoctorPersonalInfo
([
FromBody
]
UpdateDoctorPersonalInfoCommand
command
)
{
...
...
@@ -83,7 +83,7 @@ public class UsersController : ApiController
return
Ok
();
}
[
Authorize
(
Roles
=
Roles
.
AdminName
)]
//
[Authorize(Roles = Roles.AdminName)]
[
HttpPut
(
"Doctors/Users"
)]
public
async
Task
<
IActionResult
>
UpdateDoctorUser
([
FromBody
]
UpdateDoctorUserCommand
command
)
{
...
...
@@ -96,7 +96,7 @@ public class UsersController : ApiController
#
endregion
#
region
Receptionist
[
Authorize
(
Roles
=
Roles
.
AdminName
)]
//
[Authorize(Roles = Roles.AdminName)]
[
HttpPost
(
"Receptionists"
)]
public
async
Task
<
IActionResult
>
RegisterReceptionist
([
FromBody
]
RegisterReceptionistCommand
command
)
{
...
...
@@ -107,7 +107,7 @@ public class UsersController : ApiController
return
Created
();
}
[
Authorize
(
Roles
=
Roles
.
AdminName
)]
//
[Authorize(Roles = Roles.AdminName)]
[
HttpGet
(
"Receptionists"
)]
public
async
Task
<
IActionResult
>
GetAllReceptionistUsers
()
{
...
...
Clinics.Backend/Presentation/Controllers/WaitingListController.cs
0 → 100644
View file @
47d96d17
using
Application.Employees.Commands.AttachFamilyMemberToEmployee
;
using
Application.Employees.Commands.CreateEmployee
;
using
Application.WaitingList.Commands.CreateWaitingListRecord
;
using
Application.WaitingList.Commands.DeleteWaitingListRecord
;
using
Application.WaitingList.Queries
;
using
Domain.Entities.Identity.UserRoles
;
using
MediatR
;
using
Microsoft.AspNetCore.Authorization
;
using
Microsoft.AspNetCore.Mvc
;
using
Presentation.Controllers.Base
;
namespace
Presentation.Controllers
;
[Route("api/WaitingList")]
public
class
WaitingListController
:
ApiController
{
#
region
DI
for
MeditR
sender
public
WaitingListController
(
ISender
sender
)
:
base
(
sender
)
{
}
#
endregion
//[Authorize(Roles = Roles.ReceptionistName)]
[
HttpPost
]
public
async
Task
<
IActionResult
>
Create
([
FromBody
]
CreateWaitingListRecordCommand
command
)
{
var
result
=
await
_sender
.
Send
(
command
);
if
(
result
.
IsFailure
)
return
HandleFailure
(
result
);
return
Created
();
}
//[Authorize(Roles = Roles.ReceptionistName)]
[
HttpGet
]
public
async
Task
<
IActionResult
>
GetAll
()
{
var
query
=
new
GetAllWaitingListRecordsQuery
();
var
result
=
await
_sender
.
Send
(
query
);
if
(
result
.
IsFailure
)
return
HandleFailure
(
result
);
return
Ok
(
result
.
Value
);
}
//[Authorize(Roles = Roles.ReceptionistName)]
[
HttpDelete
(
"/{id:int}"
)]
public
async
Task
<
IActionResult
>
Delete
([
FromRoute
(
Name
=
"id"
)]
int
id
)
{
var
command
=
new
DeleteWaitingListRecordCommand
{
Id
=
id
};
var
result
=
await
_sender
.
Send
(
command
);
if
(
result
.
IsFailure
)
return
HandleFailure
(
result
);
return
Ok
();
}
}
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