-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
203 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,38 @@ | ||
import { AppointmentStatus } from "../domain/entities/IAppointment"; | ||
|
||
export enum Months { | ||
January = "January", | ||
February = "February", | ||
March = "March", | ||
April = "April", | ||
May = "May", | ||
June = "June", | ||
July = "July", | ||
August = "August", | ||
September = "September", | ||
October = "October", | ||
November = "November", | ||
December = "December", | ||
} | ||
|
||
export type PatientGenderStatics = { | ||
male: number; | ||
female: number; | ||
others: number; | ||
} | ||
|
||
export type UserStatistics = { | ||
month: Months; | ||
doctors: number; | ||
patients: number; | ||
}; | ||
|
||
export type AppointmentsPerMonthStatics = { | ||
month:Months; | ||
count:number; | ||
} | ||
|
||
export type AppointmentsByStatusStatistics = { | ||
status:AppointmentStatus; | ||
count:number | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,70 @@ | ||
import IAppointmentRepository from "../../domain/interface/repositories/IAppointmentRepository"; | ||
import IDoctorRepository from "../../domain/interface/repositories/IDoctorRepository"; | ||
import IPatientRepository from "../../domain/interface/repositories/IPatientRepository"; | ||
import IDoctorRepository from "../../domain/interface/repositories/IDoctorRepository"; | ||
import { Months, PatientGenderStatics, UserStatistics, AppointmentsPerMonthStatics, AppointmentsByStatusStatistics } from "../../types/statics"; | ||
import IValidatorService from "../../domain/interface/services/IValidatorService"; | ||
import { PatientGenderStatics } from "../../types/statics"; | ||
import { endOfMonth, startOfMonth } from "../../utils/date-formatter"; | ||
import { AppointmentStatus } from "../../domain/entities/IAppointment"; | ||
|
||
export default class DashboardUseCase { | ||
constructor( | ||
private validatorService: IValidatorService, | ||
private patientRepository: IPatientRepository, | ||
private appointmentRepository: IAppointmentRepository, | ||
private doctorRepository: IDoctorRepository | ||
){} | ||
) { } | ||
|
||
async getPatientGenderStatics():Promise<PatientGenderStatics>{ | ||
async getPatientGenderStatics(): Promise<PatientGenderStatics> { | ||
return await this.patientRepository.findPatientGenders(); | ||
} | ||
async getUsersStatics(): Promise<UserStatistics[]> { | ||
const year = new Date().getFullYear(); | ||
const statistics: UserStatistics[] = []; | ||
|
||
for (const month of Object.values(Months)) { | ||
const startTime = startOfMonth(new Date(year, Object.keys(Months).indexOf(month), 1)); | ||
const endTime = endOfMonth(startTime); | ||
|
||
const patients = await this.patientRepository.getCountInTimeRange(startTime, endTime); | ||
const doctors = await this.doctorRepository.getCountInTimeRange(startTime, endTime); | ||
|
||
statistics.push({ | ||
month, | ||
doctors, | ||
patients, | ||
}); | ||
} | ||
return statistics; | ||
} | ||
|
||
async getAppointmentsPerMonthStatics(): Promise<AppointmentsPerMonthStatics[]> { | ||
const year = new Date().getFullYear(); | ||
const statistics: AppointmentsPerMonthStatics[] = []; | ||
|
||
for (const month of Object.values(Months)) { | ||
const startTime = startOfMonth(new Date(year, Object.keys(Months).indexOf(month), 1)); | ||
const endTime = endOfMonth(startTime); | ||
|
||
const count = await this.appointmentRepository.getCountByRange(startTime, endTime); | ||
|
||
statistics.push({ | ||
month, | ||
count | ||
}) | ||
}; | ||
|
||
return statistics; | ||
} | ||
|
||
async getAppointmentsStatisticsByStatus(): Promise<AppointmentsByStatusStatistics[]> { | ||
const statistics: AppointmentsByStatusStatistics[] = []; | ||
for (let status of Object.values(AppointmentStatus)) { | ||
const count = await this.appointmentRepository.getCountsByStatus(status) | ||
statistics.push({ | ||
status, | ||
count | ||
}) | ||
} | ||
return statistics; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { parse, format, addMinutes, addHours, addDays, getDay, getDate, isAfter } from "date-fns"; | ||
export { parse, format, addMinutes, addHours, addDays, getDay, getDate, isAfter, endOfMonth, startOfMonth } from "date-fns"; |
8b051c4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
avm-care – ./
avm-care-git-main-sinans-projects-8d312afe.vercel.app
avm-care.vercel.app
avm-care-sinans-projects-8d312afe.vercel.app