Modified Appointment Module

This commit is contained in:
Sk Shaifat Murshed 2025-02-06 18:42:32 +05:30
parent 91bfc622d1
commit 4876806860
16 changed files with 691 additions and 41 deletions

View File

@ -51,7 +51,7 @@
>
<i class="pi pi-plus-circle"></i>
</button>
<button pButton class="p-button-rounded p-button-warning ml-2" (click)="exportPatient()">
<button pButton class="p-button-rounded p-button-warning ml-2" (click)="exportAppointments()">
<i class="pi pi-download"></i>
</button>
</div>
@ -132,7 +132,7 @@
<form #appointmentForm="ngForm" (ngSubmit)="saveAppointment(appointmentForm)">
<div class="p-fluid grid justify-content-center">
<div class="field col-md-5">
<label for="fname">First Name</label>
<label for="fname">First Name <span class="text-danger">*</span></label>
<span class="p-input-icon-left">
<i class="pi pi-user"></i>
<input pInputText id="fname" name="fname" [(ngModel)]="appointment.firstName" required />
@ -141,7 +141,7 @@
<div class="field col-md-1"></div>
<div class="field col-md-5">
<label for="lname">Last Name</label>
<label for="lname">Last Name <span class="text-danger">*</span></label>
<span class="p-input-icon-left">
<i class="pi pi-user"></i>
<input pInputText id="lname" name="lname" [(ngModel)]="appointment.lastName" required />
@ -149,7 +149,7 @@
</div>
<div class="field col-md-5">
<label>Gender</label>
<label>Gender <span class="text-danger">*</span></label>
<div class="flex align-items-center">
<p-radioButton
name="gender"
@ -172,7 +172,7 @@
<div class="field col-md-1"></div>
<div class="field col-md-5">
<label for="mobile">Mobile No</label>
<label for="mobile">Mobile No <span class="text-danger">*</span></label>
<span class="p-input-icon-left">
<i class="pi pi-phone"></i>
<input pInputText id="mobile" name="mobile" [(ngModel)]="appointment.mobile" required />
@ -186,7 +186,7 @@
>
</div>
<div class="field col-md-11">
<label for="mobile">Address</label>
<label for="mobile">Address <span class="text-danger">*</span></label>
<span class="p-input-icon-left">
<i class="pi pi-map-marker"></i>
<input
@ -200,7 +200,7 @@
</div>
<div class="field col-md-5">
<label for="email">Email ID</label>
<label for="email">Email ID <span class="text-danger">*</span></label>
<span class="p-input-icon-left">
<i class="pi pi-envelope"></i>
<input pInputText id="email" name="email" [(ngModel)]="appointment.email" required />
@ -214,13 +214,14 @@
<div class="field col-md-1"></div>
<div class="field col-md-5">
<label for="dob">Date of Birth</label>
<label for="dob">Date of Birth <span class="text-danger">*</span></label>
<p-calendar
id="dob"
required
name="dob"
[(ngModel)]="appointment.dob"
[(ngModel)]="Dateofbirth"
[showIcon]="true"
appendTo="body"
required
></p-calendar>
<small
@ -231,7 +232,7 @@
</div>
<div class="field col-md-5">
<label for="doctor">Consulting Doctor</label>
<label for="doctor">Consulting Doctor <span class="text-danger">*</span></label>
<p-dropdown
id="doctor"
name="doctor"
@ -246,18 +247,19 @@
<div class="field col-md-1"></div>
<div class="field col-md-5">
<label for="date">Date of Appointment</label>
<label for="date">Date of Appointment <span class="text-danger">*</span></label>
<p-calendar
id="date"
name="date"
[(ngModel)]="appointment.dateOfAppointment"
[(ngModel)]="AppointmentDate"
[showIcon]="true"
appendTo="body"
required
></p-calendar>
</div>
<div class="field col-md-5">
<label for="time">Time Of Appointment</label>
<label for="time">Time Of Appointment <span class="text-danger">*</span></label>
<span class="p-input-icon-left">
<i class="pi pi-clock"></i>
<input

View File

@ -20,6 +20,9 @@ export class ViewAppointmentComponent {
patients: [];
appointmentDialog = false;
genders = Gender;
Dateofbirth: Date = new Date();
AppointmentDate: Date = new Date();
appointmentStatuses = Object.keys(appointmentStatus)
.filter(key => !isNaN(Number(key)))
.map(key => ({
@ -141,10 +144,33 @@ export class ViewAppointmentComponent {
};
}
exportAppointments() {
console.log('Exporting appointment data');
}
exportAppointments() {
debugger
this.AppointmentService.getExportAppointmentRecord().subscribe(result => {
const binary = atob(result.fileContent);
const len = binary.length;
const bytes = new Uint8Array(len);
for (let i = 0; i < len; i++) {
bytes[i] = binary.charCodeAt(i);
}
const blob = new Blob([bytes], { type: 'application/xlsx' });
const url = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = result.fileName;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
window.URL.revokeObjectURL(url);
});
}
editAppointment(appointment: any) {
debugger;
this.isEditMode = true;
@ -153,8 +179,8 @@ export class ViewAppointmentComponent {
this.AppointmentService.getAppointmentById(appointment.id).subscribe(result => {
debugger;
this.appointment = result;
this.appointment.dateOfAppointment = new Date(result.dateOfAppointment).toISOString().split('T')[0];;
this.appointment.dob = new Date(result.dob).toISOString().split('T')[0];;
this.AppointmentDate = new Date(result.dateOfAppointment);
this.Dateofbirth = new Date(result.dob);
});
}
@ -181,6 +207,8 @@ export class ViewAppointmentComponent {
Object.values(form.controls).forEach(control => control.markAsTouched());
return;
}
this.appointment.dob = this.Dateofbirth.toDateString();
this.appointment.dateOfAppointment = this.AppointmentDate.toDateString();
if (this.isEditMode) {
this.AppointmentService.updateAppointment(this.appointment).subscribe(
() => {
@ -197,7 +225,7 @@ export class ViewAppointmentComponent {
},
error => {
console.log(error);
this.toaster.error(error.error.error.message, 'Error');
this.toaster.error(error, 'Error');
}
);
} else {

View File

@ -226,7 +226,7 @@
<div class="col-6">
<div class="field">
<label for="admissionDate"><i class="pi pi-calendar"></i> Admission Date</label>
<p-calendar id="admissionDate" name="admissionDate" [(ngModel)]="selectadmissionDate" showIcon
<p-calendar appendTo="body" id="admissionDate" name="admissionDate" [(ngModel)]="selectadmissionDate" showIcon
styleClass="small-calendar" required #admissionDate="ngModel"></p-calendar>
<small *ngIf="admissionDate.invalid && admissionDate.touched" class="p-error">
Admission Date is required

View File

@ -141,7 +141,7 @@
<div class="col-6">
<div class="field">
<label for="admissionDate"><i class="pi pi-calendar"></i> Admission Date</label>
<p-calendar id="admissionDate" name="admissionDate" [(ngModel)]="selectdateOfAdmission" showIcon required
<p-calendar appendTo="body" id="admissionDate" name="admissionDate" [(ngModel)]="selectdateOfAdmission" showIcon required
#admissionDate="ngModel"></p-calendar>
<small *ngIf="admissionDate.invalid && admissionDate.touched" class="p-error">
Admission Date is required.
@ -153,7 +153,7 @@
<div class="col-6">
<div class="field">
<label for="nextFollowUp"><i class="pi pi-calendar-plus"></i> Next Follow-Up Date</label>
<p-calendar id="nextFollowUp" name="nextFollowUp" [(ngModel)]="selectnextFollowUp" showIcon required
<p-calendar appendTo="body" id="nextFollowUp" name="nextFollowUp" [(ngModel)]="selectnextFollowUp" showIcon required
#nextFollowUp="ngModel"></p-calendar>
<small *ngIf="nextFollowUp.invalid && nextFollowUp.touched" class="p-error">
Next Follow-Up Date is required.

View File

@ -2,6 +2,7 @@ import type { Gender } from '../../global-enum/gender.enum';
import type { appointmentStatus } from '../../global-enum/appointment-status.enum';
import type { visitType } from '../../global-enum/visit-type.enum';
import type { paymentStatus } from '../../global-enum/payment-status.enum';
import type { Doctor } from '../../doctors/models';
export interface AppointmentDto {
id?: string;
@ -21,6 +22,7 @@ export interface AppointmentDto {
appointmentStatus: appointmentStatus;
visitType: visitType;
paymentStatus: paymentStatus;
doctor: Doctor;
}
export interface CreateOrUpdateAppointmentDto {

View File

@ -2,7 +2,7 @@ import { RestService, Rest } from '@abp/ng.core';
import { Injectable } from '@angular/core';
import type { PagedResultDto } from '../abp/application/services/dto/models';
import type { AppointmentDto, CreateOrUpdateAppointmentDto } from '../appoinments/dto/models';
import type { PagingSortResultDto } from '../dto/models';
import type { FileDownloadDto, PagingSortResultDto } from '../dto/models';
@Injectable({
providedIn: 'root',
@ -12,7 +12,7 @@ export class AppointmentService {
createAppointment = (input: CreateOrUpdateAppointmentDto, config?: Partial<Rest.Config>) =>
this.restService.request<any, AppointmentDto>({
this.restService.request<any, void>({
method: 'POST',
url: '/api/app/appointment/appointment',
body: input,
@ -54,8 +54,16 @@ export class AppointmentService {
{ apiName: this.apiName,...config });
getExportAppointmentRecord = (config?: Partial<Rest.Config>) =>
this.restService.request<any, FileDownloadDto>({
method: 'GET',
url: '/api/app/appointment/export-appointment-record',
},
{ apiName: this.apiName,...config });
updateAppointment = (input: CreateOrUpdateAppointmentDto, config?: Partial<Rest.Config>) =>
this.restService.request<any, AppointmentDto>({
this.restService.request<any, void>({
method: 'PUT',
url: '/api/app/appointment/appointment',
body: input,

View File

@ -1 +1,2 @@
export * from './appointment.service';
export * from './models';

View File

@ -0,0 +1,25 @@
import type { FullAuditedEntity } from '../volo/abp/domain/entities/auditing/models';
import type { Gender } from '../global-enum/gender.enum';
import type { Doctor } from '../doctors/models';
import type { appointmentStatus } from '../global-enum/appointment-status.enum';
import type { visitType } from '../global-enum/visit-type.enum';
import type { paymentStatus } from '../global-enum/payment-status.enum';
export interface Appointment extends FullAuditedEntity<string> {
firstName?: string;
lastName?: string;
gender: Gender;
mobile?: string;
address?: string;
email?: string;
dob?: string;
doctor: Doctor;
dateOfAppointment?: string;
timeOfAppointment?: string;
injuryORContion?: string;
note?: string;
insuranceProvider?: string;
appointmentStatus: appointmentStatus;
visitType: visitType;
paymentStatus: paymentStatus;
}

View File

@ -1 +1,2 @@
export * from './department.service';
export * from './models';

View File

@ -0,0 +1,10 @@
import type { FullAuditedEntity } from '../volo/abp/domain/entities/auditing/models';
export interface Department extends FullAuditedEntity<string> {
departmentNo?: string;
departmentName?: string;
departmentDate?: string;
departmentHead?: string;
status?: string;
description?: string;
}

View File

@ -1 +1,2 @@
export * from './doctor.service';
export * from './models';

View File

@ -0,0 +1,19 @@
import type { FullAuditedEntity } from '../volo/abp/domain/entities/auditing/models';
import type { Department } from '../departments/models';
import type { Appointment } from '../appointments/models';
export interface Doctor extends FullAuditedEntity<string> {
firstName?: string;
lastName?: string;
gender?: string;
mobile?: string;
password?: string;
designation?: string;
departmentId?: string;
department: Department;
address?: string;
email?: string;
dob?: string;
education?: string;
appointments: Appointment[];
}

View File

@ -1053,8 +1053,8 @@
}
],
"returnValue": {
"type": "HospitalManagementSystem.Appoinments.Dto.AppointmentDto",
"typeSimple": "HospitalManagementSystem.Appoinments.Dto.AppointmentDto"
"type": "System.Void",
"typeSimple": "System.Void"
},
"allowAnonymous": null,
"implementFrom": "HospitalManagementSystem.Appointments.AppointmentAppService"
@ -1090,8 +1090,8 @@
}
],
"returnValue": {
"type": "HospitalManagementSystem.Appoinments.Dto.AppointmentDto",
"typeSimple": "HospitalManagementSystem.Appoinments.Dto.AppointmentDto"
"type": "System.Void",
"typeSimple": "System.Void"
},
"allowAnonymous": null,
"implementFrom": "HospitalManagementSystem.Appointments.AppointmentAppService"
@ -1132,6 +1132,21 @@
},
"allowAnonymous": false,
"implementFrom": "HospitalManagementSystem.Appointments.AppointmentAppService"
},
"GetExportAppointmentRecordAsync": {
"uniqueName": "GetExportAppointmentRecordAsync",
"name": "GetExportAppointmentRecordAsync",
"httpMethod": "GET",
"url": "api/app/appointment/export-appointment-record",
"supportedVersions": [],
"parametersOnMethod": [],
"parameters": [],
"returnValue": {
"type": "HospitalManagementSystem.Dto.FileDownloadDto",
"typeSimple": "HospitalManagementSystem.Dto.FileDownloadDto"
},
"allowAnonymous": null,
"implementFrom": "HospitalManagementSystem.Appointments.AppointmentAppService"
}
}
},
@ -4901,6 +4916,18 @@
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "Doctor",
"jsonName": null,
"type": "HospitalManagementSystem.Doctors.Doctor",
"typeSimple": "HospitalManagementSystem.Doctors.Doctor",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
}
]
},
@ -5117,6 +5144,453 @@
}
]
},
"HospitalManagementSystem.Appointments.Appointment": {
"baseType": "Volo.Abp.Domain.Entities.Auditing.FullAuditedEntity<System.Guid>",
"isEnum": false,
"enumNames": null,
"enumValues": null,
"genericArguments": null,
"properties": [
{
"name": "FirstName",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "LastName",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "Gender",
"jsonName": null,
"type": "HospitalManagementSystem.GlobalEnum.Gender",
"typeSimple": "HospitalManagementSystem.GlobalEnum.Gender",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "Mobile",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "Address",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "Email",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "DOB",
"jsonName": null,
"type": "System.DateTime?",
"typeSimple": "string?",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "Doctor",
"jsonName": null,
"type": "HospitalManagementSystem.Doctors.Doctor",
"typeSimple": "HospitalManagementSystem.Doctors.Doctor",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "DateOfAppointment",
"jsonName": null,
"type": "System.DateTime?",
"typeSimple": "string?",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "TimeOfAppointment",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "InjuryORContion",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "Note",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "InsuranceProvider",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "AppointmentStatus",
"jsonName": null,
"type": "HospitalManagementSystem.GlobalEnum.appointmentStatus",
"typeSimple": "HospitalManagementSystem.GlobalEnum.appointmentStatus",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "VisitType",
"jsonName": null,
"type": "HospitalManagementSystem.GlobalEnum.visitType",
"typeSimple": "HospitalManagementSystem.GlobalEnum.visitType",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "PaymentStatus",
"jsonName": null,
"type": "HospitalManagementSystem.GlobalEnum.paymentStatus",
"typeSimple": "HospitalManagementSystem.GlobalEnum.paymentStatus",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
}
]
},
"HospitalManagementSystem.Departments.Department": {
"baseType": "Volo.Abp.Domain.Entities.Auditing.FullAuditedEntity<System.Guid>",
"isEnum": false,
"enumNames": null,
"enumValues": null,
"genericArguments": null,
"properties": [
{
"name": "DepartmentNo",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "DepartmentName",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "DepartmentDate",
"jsonName": null,
"type": "System.DateTime?",
"typeSimple": "string?",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "DepartmentHead",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "Status",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "Description",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
}
]
},
"HospitalManagementSystem.Doctors.Doctor": {
"baseType": "Volo.Abp.Domain.Entities.Auditing.FullAuditedEntity<System.Guid>",
"isEnum": false,
"enumNames": null,
"enumValues": null,
"genericArguments": null,
"properties": [
{
"name": "FirstName",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "LastName",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "Gender",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "Mobile",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "Password",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "Designation",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "DepartmentId",
"jsonName": null,
"type": "System.Guid?",
"typeSimple": "string?",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "Department",
"jsonName": null,
"type": "HospitalManagementSystem.Departments.Department",
"typeSimple": "HospitalManagementSystem.Departments.Department",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "Address",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "Email",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "DOB",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "Education",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "Appointments",
"jsonName": null,
"type": "[HospitalManagementSystem.Appointments.Appointment]",
"typeSimple": "[HospitalManagementSystem.Appointments.Appointment]",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
}
]
},
"HospitalManagementSystem.Documents.EntityDocument": {
"baseType": "Volo.Abp.Domain.Entities.Auditing.AuditedAggregateRoot<System.Guid>",
"isEnum": false,

View File

@ -1,4 +1,5 @@
using HospitalManagementSystem.GlobalEnum;
using HospitalManagementSystem.Doctors;
using HospitalManagementSystem.GlobalEnum;
using System;
using System.Collections.Generic;
using System.Linq;
@ -26,5 +27,7 @@ namespace HospitalManagementSystem.Appoinments.Dto
public appointmentStatus AppointmentStatus { get; set; }
public visitType VisitType { get; set; }
public paymentStatus PaymentStatus { get; set; }
public Doctor? Doctor { get; set; }
}
}

View File

@ -10,6 +10,7 @@
<ItemGroup>
<ProjectReference Include="..\HospitalManagementSystem.Domain.Shared\HospitalManagementSystem.Domain.Shared.csproj" />
<ProjectReference Include="..\HospitalManagementSystem.Domain\HospitalManagementSystem.Domain.csproj" />
</ItemGroup>
<ItemGroup>

View File

@ -20,6 +20,9 @@ using Microsoft.EntityFrameworkCore;
using System.Linq.Dynamic.Core;
using Abp.UI;
using HospitalManagementSystem.Doctors;
using ClosedXML.Excel;
using System.IO;
using Microsoft.AspNetCore.Hosting;
namespace HospitalManagementSystem.Appointments
{
@ -29,6 +32,7 @@ namespace HospitalManagementSystem.Appointments
private readonly ICurrentTenant _currentTenant;
private IRepository<Appointment, Guid> _appointmentsRepository;
private readonly IRepository<Doctor, Guid> _doctorRepository;
private readonly IWebHostEnvironment _env;
public AppointmentAppService(ICurrentUser currentUser, ICurrentTenant currentTenant, IRepository<Appointment, Guid> appointmentsRepository, IRepository<Doctor, Guid> doctorRepository)
{
@ -62,6 +66,7 @@ namespace HospitalManagementSystem.Appointments
.Take(input.MaxResultCount)
.ToListAsync();
var appoinmentdto = ObjectMapper.Map<List<Appointment>, List<AppointmentDto>>(pagedQuery);
return new PagedResultDto<AppointmentDto>(
totalCount,
appoinmentdto
@ -84,26 +89,34 @@ namespace HospitalManagementSystem.Appointments
#endregion
#region Create Appointment
public async Task<AppointmentDto> CreateAppointmentAsync(CreateOrUpdateAppointmentDto input)
public async Task CreateAppointmentAsync(CreateOrUpdateAppointmentDto input)
{
var appointment = ObjectMapper.Map<CreateOrUpdateAppointmentDto, Appointment>(input);
Appointment appointment = new Appointment();
var newdata = ObjectMapper.Map<CreateOrUpdateAppointmentDto, Appointment>(input);
newdata.Doctor = await _doctorRepository.GetAsync(input.DoctorId.Value);
appointment = newdata;
appointment = await _appointmentsRepository.InsertAsync(appointment);
return ObjectMapper.Map<Appointment, AppointmentDto>(appointment);
}
#endregion
#region Update Appointment
public async Task<AppointmentDto> UpdateAppointmentAsync(CreateOrUpdateAppointmentDto input)
public async Task UpdateAppointmentAsync(CreateOrUpdateAppointmentDto input)
{
//var appointment = await _appointmentsRepository.GetAsync(input.Id);
Appointment appointment = new Appointment();
var newdata = ObjectMapper.Map<CreateOrUpdateAppointmentDto, Appointment>(input);
newdata.Doctor = await _doctorRepository.GetAsync(input.DoctorId.Value);
appointment = newdata;
appointment = await _appointmentsRepository.UpdateAsync(appointment);
return ObjectMapper.Map<Appointment, AppointmentDto>(appointment);
try
{
//var appointment = await _appointmentsRepository.GetAsync(input.Id);
Appointment appointment = new Appointment();
var newdata = ObjectMapper.Map<CreateOrUpdateAppointmentDto, Appointment>(input);
newdata.Doctor = await _doctorRepository.GetAsync(input.DoctorId.Value);
appointment = newdata;
appointment = await _appointmentsRepository.UpdateAsync(appointment);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
#endregion
@ -114,5 +127,67 @@ namespace HospitalManagementSystem.Appointments
await _appointmentsRepository.DeleteAsync(id);
}
#endregion
#region Export Appointment Data to Excel
public async Task<FileDownloadDto> GetExportAppointmentRecordAsync()
{
var Appointmentrecord = await _appointmentsRepository.GetQueryableAsync().Result.ToListAsync();
var folderPath = Path.Combine(_env.WebRootPath, "temp");
if (!Directory.Exists(folderPath))
{
Directory.CreateDirectory(folderPath); // Ensure the folder exists
}
var filename = "Appointments_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".xlsx";
var filePath = Path.Combine(folderPath, filename);
// Create a workbook and worksheet
using (var workbook = new XLWorkbook())
{
var worksheet = workbook.Worksheets.Add("Appointment");
// Add headers
worksheet.Cell(1, 1).Value = "Name";
worksheet.Cell(1, 2).Value = "Email";
worksheet.Cell(1, 3).Value = "Gender";
worksheet.Cell(1, 4).Value = "Date";
worksheet.Cell(1, 5).Value = "Time";
worksheet.Cell(1, 6).Value = "Mobile";
worksheet.Cell(1, 7).Value = "Doctor";
worksheet.Cell(1, 8).Value = "Injury";
worksheet.Cell(1, 9).Value = "Appointment Status";
worksheet.Cell(1, 10).Value = "Visit Type";
worksheet.Cell(1, 11).Value = "Payment Status";
worksheet.Cell(1, 12).Value = "Insurance Provider";
worksheet.Cell(1, 13).Value = "Notes";
for (int i = 0; i < Appointmentrecord.Count; i++)
{
//worksheet.Cell(i + 2, 1).Value = Appointmentrecord[i].Patients.Name;
//worksheet.Cell(i + 2, 2).Value = Appointmentrecord[i].Patients.Gender.ToString();
//worksheet.Cell(i + 2, 3).Value = Appointmentrecord[i].DateOfAdmission.ToShortDateString();
//worksheet.Cell(i + 2, 4).Value = Appointmentrecord[i].Diagnosis;
//worksheet.Cell(i + 2, 5).Value = Appointmentrecord[i].NextFollowUp?.ToShortDateString();
//worksheet.Cell(i + 2, 6).Value = Appointmentrecord[i].InsuranceProvider;
//worksheet.Cell(i + 2, 7).Value = Appointmentrecord[i].InsuranceProvider;
//worksheet.Cell(i + 2, 8).Value = Appointmentrecord[i].InsuranceProvider;
//worksheet.Cell(i + 2, 9).Value = Appointmentrecord[i].Status.ToString();
}
worksheet.Columns().AdjustToContents();
workbook.SaveAs(filePath);
}
byte[] fileBytes = await File.ReadAllBytesAsync(filePath);
File.Delete(filePath);
return new FileDownloadDto
{
FileName = filename,
FileContent = Convert.ToBase64String(fileBytes) // Use Base64 encoding for file content
};
}
#endregion
}
}