Created Department Module

This commit is contained in:
Sk Shaifat Murshed 2025-02-11 19:02:38 +05:30
parent fa1430fb17
commit 8545975107
28 changed files with 1055 additions and 587 deletions

View File

@ -44,6 +44,10 @@ const routes: Routes = [
path: 'patients',
loadChildren: () => import('./patients/patients.module').then(m => m.PatientsModule),
},
{
path: 'departments',
loadChildren: () => import('./departments/departments.module').then(m => m.DepartmentsModule),
},
];
@NgModule({

View File

@ -49,7 +49,7 @@ import { CommonModule } from '@angular/common';
templateUrl: './appointment-dialog.component.html',
styleUrl: './appointment-dialog.component.scss',
})
export class AppointmentDialogComponent implements OnInit, OnChanges {
export class AppointmentDialogComponent implements OnInit {
@Input() visible: boolean = false; // Control modal visibility
@Input() name: string;
@Input() isEditMode: boolean = false; // Determine if it's for edit or create
@ -70,8 +70,6 @@ export class AppointmentDialogComponent implements OnInit, OnChanges {
constructor(
private DoctorService: DoctorService,
private AppointmentService: AppointmentService,
private http: HttpClient,
private confirmation: ConfirmationService,
private toaster: ToasterService
) {}
@ -101,15 +99,9 @@ export class AppointmentDialogComponent implements OnInit, OnChanges {
}
else{
this.fetchAppointmentData();
}
}
}
}
ngOnChanges(changes: SimpleChanges): void {
// if (changes['appointmentId'] && this.appointmentId) {
// this.fetchAppointmentData();
// }
}
fetchAppointmentData() {
this.AppointmentService.getAppointmentById(this.appointmentId).subscribe(result => {
@ -161,7 +153,6 @@ export class AppointmentDialogComponent implements OnInit, OnChanges {
() => {
this.toaster.success('Appointment created successfully', 'Success');
this.AppointmentDialog = false;
this.onClose();
},
error => {

View File

@ -16,7 +16,6 @@ import { appointmentStatus, Gender, paymentStatus, visitType } from '@proxy/glob
export class ViewAppointmentComponent {
totalRecords: number = 0;
appointmentIdToEdit: string;
AppointmentDialogTitle: string = '';
AppointmentDialog: boolean = false;
patients: [];
@ -71,7 +70,6 @@ export class ViewAppointmentComponent {
doctors = [];
doctorOptions = [];
createPermission = true;
editPermission = true;
deletePermission = true;
@ -165,7 +163,6 @@ export class ViewAppointmentComponent {
defaultValue: 'Are you sure?',
})
.subscribe((status: Confirmation.Status) => {
// your code here
if (status == 'confirm') {
this.AppointmentService.deleteAppointmentRecord(id).subscribe(() => {
this.toaster.success('Appointment deleted successfully', 'Success');

View File

@ -0,0 +1,145 @@
<div
class="modal fade show d-block"
tabindex="-1"
role="dialog"
style="background: rgba(0, 0, 0, 0.5)"
*ngIf="visible"
aria-label="l('name')"
>
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header py-4">
<h4 class="text-success mb-0 fs-3 fw-normal">
{{ isEditMode ? 'Edit ' : 'Create ' }}{{name}}
</h4>
<button
tabindex="0"
type="button"
(click)="onClose()"
class="btn-close"
aria-label="Close"
></button>
</div>
<form #departmentForm="ngForm" (ngSubmit)="saveDepartment(departmentForm)">
<div class="p-fluid grid justify-content-center">
<div class="field col-md-5">
<label for="departmentNo">Department No <span class="text-danger">*</span></label>
<span class="p-input-icon-left p-input-icon-right">
<i class="pi pi-hashtag"></i>
<input
pInputText
id="departmentNo"
name="departmentNo"
[(ngModel)]="department.departmentNo"
#departmentNoCtrl="ngModel"
required
[ngClass]="{ 'is-valid': departmentNoCtrl.valid && departmentNoCtrl.touched, 'is-invalid': departmentNoCtrl.invalid && departmentNoCtrl.touched }"
/>
<i *ngIf="departmentNoCtrl.valid && departmentNoCtrl.touched" class="pi pi-check text-success"></i>
<i *ngIf="departmentNoCtrl.invalid && departmentNoCtrl.touched" class="pi pi-times text-danger"></i>
</span>
<small class="text-danger" *ngIf="departmentNoCtrl.invalid && departmentNoCtrl.touched">
<span *ngIf="departmentNoCtrl.errors?.required">Department No is required.</span>
</small>
</div>
<div class="field col-md-1"></div>
<div class="field col-md-5">
<label for="departmentName">Department Name <span class="text-danger">*</span></label>
<span class="p-input-icon-left p-input-icon-right">
<i class="pi pi-building"></i>
<input
pInputText
id="departmentName"
name="departmentName"
[(ngModel)]="department.departmentName"
#departmentNameCtrl="ngModel"
required
/>
</span>
<small class="text-danger" *ngIf="departmentNameCtrl.invalid && departmentNameCtrl.touched">
<span *ngIf="departmentNameCtrl.errors?.required">Department Name is required.</span>
</small>
</div>
<div class="field col-md-5">
<label for="departmentDate">Department Date</label>
<p-calendar
id="departmentDate"
name="departmentDate"
[(ngModel)]="Departmentdate"
[showIcon]="true">
</p-calendar>
</div>
<div class="field col-md-1"></div>
<div class="field col-md-5">
<label for="departmentHead">Department Head</label>
<span class="p-input-icon-left">
<i class="pi pi-user"></i>
<input
pInputText
id="departmentHead"
name="departmentHead"
[(ngModel)]="department.departmentHead"
/>
</span>
</div>
<div class="field col-md-5">
<label>Status</label>
<div class="flex align-items-center p-input-icon-right">
<p-radioButton
name="status"
value="Active"
[(ngModel)]="department.status"
inputId="active"
></p-radioButton>
<label for="active" class="ml-2 mr-3">Active</label>
<p-radioButton
name="status"
value="Inactive"
[(ngModel)]="department.status"
inputId="inactive"
></p-radioButton>
<label for="inactive" class="ml-2">Inactive</label>
</div>
</div>
<div class="field col-md-6"></div>
<div class="field col-11">
<label for="description">Description</label>
<textarea
id="description"
name="description"
[(ngModel)]="department.description"
rows="5"
cols="30"
pInputTextarea>
</textarea>
</div>
<div class="field col-11 flex justify-content-end">
<button
pButton
type="submit"
label="Save"
class="p-button-success"
[disabled]="departmentForm.invalid">
</button>
<button
pButton
type="button"
label="Cancel"
class="p-button-secondary ml-2"
(click)="onClose()">
</button>
</div>
</div>
</form>
</div>
</div>
</div>

View File

@ -0,0 +1,23 @@
.hide_body{
scrollbar-width: auto !important;
min-height: 150px;
max-height: calc(100vh - 13rem);
overflow-y: auto;
}
.is-valid {
border-color: green !important;
}
.is-invalid {
border-color: red !important;
}
/* Adjust the z-index of the calendar dropdown */
.p-calendar .p-datepicker {
z-index: 1050 !important; /* Make sure it's above other elements */
}
/* You can also adjust modal z-index if necessary */
.modal {
z-index: 1040; /* Set lower z-index to ensure modal is behind the calendar */
}

View File

@ -0,0 +1,109 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { DepartmentsRoutingModule } from './departments-routing.module';
import { CommonModule } from '@angular/common';
import { FormsModule, NgForm } from '@angular/forms';
import { ButtonModule } from 'primeng/button';
import { CalendarModule } from 'primeng/calendar';
import { ChipModule } from 'primeng/chip';
import { DialogModule } from 'primeng/dialog';
import { DropdownModule } from 'primeng/dropdown';
import { InputTextModule } from 'primeng/inputtext';
import { InputTextareaModule } from 'primeng/inputtextarea';
import { RadioButtonModule } from 'primeng/radiobutton';
import { TableModule } from 'primeng/table';
import { CreateDepartmentDto } from '@proxy/dtos';
import { DepartmentService } from '@proxy/departments';
import { ConfirmationService, ToasterService } from '@abp/ng.theme.shared';
@Component({
selector: 'app-department-dialog',
standalone: true,
imports: [
TableModule,
DialogModule,
FormsModule,
TableModule,
ButtonModule,
DialogModule,
InputTextModule,
CalendarModule,
DropdownModule,
RadioButtonModule,
InputTextareaModule,
ChipModule,
CommonModule,
],
templateUrl: './department-dialog.component.html',
styleUrl: './department-dialog.component.scss',
})
export class DepartmentDialogComponent implements OnInit {
@Input() visible: boolean = false;
@Input() name: string;
@Input() isEditMode: boolean = false;
@Output() save = new EventEmitter<any>();
@Output() close = new EventEmitter<void>();
@Input() Id: string;
DepartmentDialog: boolean;
Departmentdate: Date;
constructor(
private DepartmentService: DepartmentService,
private toaster: ToasterService
) {}
ngOnInit(): void {
debugger;
if(this.isEditMode){
this.fetchDepartmentData();
}
}
department: CreateDepartmentDto = {
departmentNo: '',
departmentName: '',
departmentDate: '',
departmentHead: '',
description: '',
status: '',
};
fetchDepartmentData() {
this.DepartmentService.getDepartmentById(this.Id).subscribe(result => {
this.department = result;
this.Departmentdate = new Date(result.departmentDate);
});
}
saveDepartment(form: NgForm) {
if (form.invalid) {
Object.values(form.controls).forEach(control => control.markAsTouched());
return;
}
this.department.departmentDate = this.Departmentdate.toDateString();
if (this.isEditMode) {
this.DepartmentService.updateDepartment(this.department).subscribe(
() => {
this.toaster.success('Department updated successfully', 'Success');
this.onClose();
},
error => {
this.toaster.error(error, 'Error');
}
);
} else {
this.DepartmentService.createDepartment(this.department).subscribe(
() => {
this.toaster.success('Department created successfully', 'Success');
this.onClose();
},
error => {
this.toaster.error(error, 'Error');
}
);
}
}
onClose() {
this.Id = '';
this.close.emit();
}
}

View File

@ -0,0 +1,16 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { DepartmentsComponent } from './departments.component';
const routes: Routes = [
{ path: '', component: DepartmentsComponent },
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class DepartmentsRoutingModule { }

View File

@ -0,0 +1,97 @@
<div>
<p-table
#dt2
dataKey="id"
[value]="departments"
[paginator]="true"
[rows]="10"
[totalRecords]="totalRecords"
[lazy]="true"
(onLazyLoad)="loaddepartments($event)"
[rowsPerPageOptions]="[10, 20, 50]"
[responsiveLayout]="'scroll'"
[globalFilterFields]="['id', 'name', 'status']"
[filters]="{ global: { value: '', matchMode: 'contains' } }"
class="table table-striped"
>
<ng-template pTemplate="caption">
<div class="flex align-items-center justify-content-between mb-3 gap-3">
<h4 class="m-0">Department List</h4>
<div class="flex-grow-1 flex justify-content-center">
<div class="input-group">
<span class="input-group-text"><i class="pi pi-search"></i></span>
<input
pInputText
type="text"
class="form-control"
(input)="dt2.filterGlobal($event.target.value, 'contains')"
[(ngModel)]="globalFilter"
placeholder="Search keyword"
/>
</div>
</div>
<div>
<button
pButton
class="p-button-rounded p-button-secondary ml-2"
(click)="loaddepartments($event)"
>
<i class="pi pi-refresh"></i>
</button>
<button
pButton
class="p-button-rounded p-button-success ml-2"
(click)="openNewDepartmentDialog()"
pTooltip="Add Department"
tooltipPosition="left"
>
<i class="pi pi-plus-circle"></i>
</button>
<button
pButton
class="p-button-rounded p-button-warning ml-2"
(click)="exportDepartments()"
>
<i class="pi pi-download"></i>
</button>
</div>
</div>
</ng-template>
<ng-template pTemplate="header">
<tr>
<th pSortableColumn="departmentNo">Department Number <p-sortIcon field="departmentNo" /></th>
<th pSortableColumn="departmentName">Department Name <p-sortIcon field="departmentName" /></th>
<th pSortableColumn="description">Description <p-sortIcon field="description" /></th>
<th pSortableColumn="departmentDate">Date <p-sortIcon field="departmentDate" /></th>
<th pSortableColumn="departmentHead">Department Head<p-sortIcon field="departmentHead" /></th>
<th pSortableColumn="status">Status <p-sortIcon field="status" /></th>
<th>Actions</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-department>
<tr>
<td>{{ department.departmentNo }}</td>
<td>{{ department.departmentName }}</td>
<td>{{ department.description }}</td>
<td>{{ department.departmentDate | date }}</td>
<td>{{ department.departmentHead }}</td>
<td>
<span class="badge" [ngClass]="department.status === 'Active' ? 'bg-primary' : 'bg-danger'">
{{ department.status }}
</span>
</td>
<td class="d-flex">
<button class="btn btn-warning btn-sm ml-1" (click)="editDepartment(department)">
<i class="pi pi-pencil"></i>
</button>
<button class="btn btn-danger btn-sm ml-1" (click)="deletedepartment(department.id)">
<i class="pi pi-trash"></i>
</button>
</td>
</tr>
</ng-template>
</p-table>
</div>
<app-department-dialog [Id]="DepartmentIdToEdit"[isEditMode]="isEditMode"
[visible]="isModalVisible"*ngIf="isModalVisible" [name]="'Department'" (close)="closeDialog()"></app-department-dialog >

View File

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DepartmentsComponent } from './departments.component';
describe('DepartmentsComponent', () => {
let component: DepartmentsComponent;
let fixture: ComponentFixture<DepartmentsComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [DepartmentsComponent]
})
.compileComponents();
fixture = TestBed.createComponent(DepartmentsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,115 @@
import { Confirmation, ConfirmationService, ToasterService } from '@abp/ng.theme.shared';
import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { DepartmentService } from '@proxy/departments';
import { PagingSortResultDto } from '@proxy/dto';
@Component({
selector: 'app-departments',
templateUrl: './departments.component.html',
styleUrl: './departments.component.scss',
})
export class DepartmentsComponent implements OnInit {
totalRecords: number = 0;
departments= [];
loading: boolean = false;
params: PagingSortResultDto;
isModalVisible: boolean;
isEditMode: boolean = false;
DepartmentIdToEdit: string;
ngOnInit(): void {
this.loaddepartments({
first: 0,
rows: 10,
sortField: 'id',
sortOrder: 1,
globalFilter: null,
});
}
constructor(
private DepartmentService: DepartmentService,
private http: HttpClient,
private confirmation: ConfirmationService,
private toaster: ToasterService
) {}
loaddepartments(event: any) {
this.loading = true;
let order = event.sortOrder == 1 ? ' asc' : ' desc';
event.sortField = event.sortField == undefined ? 'id' : event.sortField;
this.params = {
skipCount: event.first,
maxResultCount: event.rows,
sorting: event.sortField + order,
search: event.globalFilter == null ? '' : event.globalFilter,
};
this.DepartmentService.getDepartmentList(this.params).subscribe(data => {
this.departments = data.items;
this.totalRecords = data.totalCount;
this.loading = false;
});
}
openNewDepartmentDialog() {
this.isModalVisible=true;
this.isEditMode = false;
}
editDepartment(Department: any) {
this.isEditMode = true;
this.DepartmentIdToEdit = Department.id;
this.isModalVisible=true;
}
deletedepartment(id: string) {
this.confirmation
.warn('Do you really want to delete this Department?', {
key: '::AreYouSure',
defaultValue: 'Are you sure?',
})
.subscribe((status: Confirmation.Status) => {
if (status == 'confirm') {
this.DepartmentService.deleteDepartmentRecord(id).subscribe(() => {
this.toaster.success('Deleted successfully', 'Success');
this.loaddepartments(this.params);
});
}
});
}
closeDialog() {
this.isModalVisible = false;
this.loaddepartments({
first: 0,
rows: 10,
sortField: 'id',
sortOrder: 1,
globalFilter: null,
});
}
exportDepartments() {
this.DepartmentService.getExportDepartmentRecord().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);
});
}
}

View File

@ -0,0 +1,39 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { DepartmentsRoutingModule } from './departments-routing.module';
import { DepartmentsComponent } from './departments.component';
import { FormsModule } from '@angular/forms';
import { ButtonModule } from 'primeng/button';
import { CalendarModule } from 'primeng/calendar';
import { ChipModule } from 'primeng/chip';
import { DialogModule } from 'primeng/dialog';
import { DropdownModule } from 'primeng/dropdown';
import { InputTextModule } from 'primeng/inputtext';
import { InputTextareaModule } from 'primeng/inputtextarea';
import { RadioButtonModule } from 'primeng/radiobutton';
import { TableModule } from 'primeng/table';
import { DepartmentDialogComponent } from "./department-dialog.component";
@NgModule({
declarations: [DepartmentsComponent],
imports: [
CommonModule,
DepartmentsRoutingModule,
TableModule,
DialogModule,
FormsModule,
TableModule,
ButtonModule,
DialogModule,
InputTextModule,
CalendarModule,
DropdownModule,
RadioButtonModule,
InputTextareaModule,
ChipModule,
DepartmentDialogComponent
]
})
export class DepartmentsModule { }

View File

@ -2,7 +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';
import type { DoctorDto } from '../../doctors/dto/models';
export interface AppointmentDto {
id?: string;
@ -22,7 +22,7 @@ export interface AppointmentDto {
appointmentStatus: appointmentStatus;
visitType: visitType;
paymentStatus: paymentStatus;
doctor: Doctor;
doctor: DoctorDto;
}
export interface CreateOrUpdateAppointmentDto {

View File

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

View File

@ -1,25 +0,0 @@
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,5 +1,7 @@
import { RestService, Rest } from '@abp/ng.core';
import { Injectable } from '@angular/core';
import type { PagedResultDto } from '../abp/application/services/dto/models';
import type { FileDownloadDto, PagingSortResultDto } from '../dto/models';
import type { CreateDepartmentDto, DepartmentDto } from '../dtos/models';
@Injectable({
@ -9,19 +11,53 @@ export class DepartmentService {
apiName = 'Default';
create = (input: CreateDepartmentDto, config?: Partial<Rest.Config>) =>
this.restService.request<any, DepartmentDto>({
createDepartment = (input: CreateDepartmentDto, config?: Partial<Rest.Config>) =>
this.restService.request<any, void>({
method: 'POST',
url: '/api/app/department',
url: '/api/app/department/department',
body: input,
},
{ apiName: this.apiName,...config });
get = (config?: Partial<Rest.Config>) =>
this.restService.request<any, DepartmentDto[]>({
deleteDepartmentRecord = (id: string, config?: Partial<Rest.Config>) =>
this.restService.request<any, void>({
method: 'DELETE',
url: `/api/app/department/${id}/department-record`,
},
{ apiName: this.apiName,...config });
getDepartmentById = (id: string, config?: Partial<Rest.Config>) =>
this.restService.request<any, DepartmentDto>({
method: 'GET',
url: '/api/app/department',
url: `/api/app/department/${id}/department-by-id`,
},
{ apiName: this.apiName,...config });
getDepartmentList = (input: PagingSortResultDto, config?: Partial<Rest.Config>) =>
this.restService.request<any, PagedResultDto<DepartmentDto>>({
method: 'GET',
url: '/api/app/department/department-list',
params: { search: input.search, sorting: input.sorting, skipCount: input.skipCount, maxResultCount: input.maxResultCount },
},
{ apiName: this.apiName,...config });
getExportDepartmentRecord = (config?: Partial<Rest.Config>) =>
this.restService.request<any, FileDownloadDto>({
method: 'GET',
url: '/api/app/department/export-department-record',
},
{ apiName: this.apiName,...config });
updateDepartment = (input: CreateDepartmentDto, config?: Partial<Rest.Config>) =>
this.restService.request<any, void>({
method: 'PUT',
url: '/api/app/department/department',
body: input,
},
{ apiName: this.apiName,...config });

View File

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

View File

@ -1,10 +0,0 @@
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,4 +1,3 @@
import * as Dto from './dto';
export * from './doctor.service';
export * from './models';
export { Dto };

View File

@ -1,19 +0,0 @@
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

@ -1,11 +1,13 @@
import type { FullAuditedEntity } from '../volo/abp/domain/entities/auditing/models';
export interface CreateDepartmentDto {
id?: string;
departmentNo?: string;
departmentName?: string;
departmentDate?: string;
departmentHead?: string;
description?: string;
status?: string;
}
export interface CreateDoctorDto {

View File

@ -1157,60 +1157,138 @@
"isIntegrationService": false,
"apiVersion": null,
"type": "HospitalManagementSystem.Departments.DepartmentAppService",
"interfaces": [
{
"type": "HospitalManagementSystem.Departments.IDepartmentAppService",
"name": "IDepartmentAppService",
"methods": [
{
"name": "GetAsync",
"parametersOnMethod": [],
"returnValue": {
"type": "System.Collections.Generic.List<HospitalManagementSystem.Dtos.DepartmentDto>",
"typeSimple": "[HospitalManagementSystem.Dtos.DepartmentDto]"
}
},
{
"name": "CreateAsync",
"interfaces": [],
"actions": {
"GetDepartmentListAsyncByInput": {
"uniqueName": "GetDepartmentListAsyncByInput",
"name": "GetDepartmentListAsync",
"httpMethod": "GET",
"url": "api/app/department/department-list",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "input",
"typeAsString": "HospitalManagementSystem.Dtos.CreateDepartmentDto, HospitalManagementSystem.Application",
"type": "HospitalManagementSystem.Dtos.CreateDepartmentDto",
"typeSimple": "HospitalManagementSystem.Dtos.CreateDepartmentDto",
"typeAsString": "HospitalManagementSystem.Dto.PagingSortResultDto, HospitalManagementSystem.Domain.Shared",
"type": "HospitalManagementSystem.Dto.PagingSortResultDto",
"typeSimple": "HospitalManagementSystem.Dto.PagingSortResultDto",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "input",
"name": "Search",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": "input"
},
{
"nameOnMethod": "input",
"name": "Sorting",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": "input"
},
{
"nameOnMethod": "input",
"name": "SkipCount",
"jsonName": null,
"type": "System.Int32",
"typeSimple": "number",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": "input"
},
{
"nameOnMethod": "input",
"name": "MaxResultCount",
"jsonName": null,
"type": "System.Int32",
"typeSimple": "number",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": "input"
}
],
"returnValue": {
"type": "Abp.Application.Services.Dto.PagedResultDto<HospitalManagementSystem.Dtos.DepartmentDto>",
"typeSimple": "Abp.Application.Services.Dto.PagedResultDto<HospitalManagementSystem.Dtos.DepartmentDto>"
},
"allowAnonymous": false,
"implementFrom": "HospitalManagementSystem.Departments.DepartmentAppService"
},
"GetDepartmentByIdAsyncById": {
"uniqueName": "GetDepartmentByIdAsyncById",
"name": "GetDepartmentByIdAsync",
"httpMethod": "GET",
"url": "api/app/department/{id}/department-by-id",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "id",
"typeAsString": "System.Guid, System.Private.CoreLib",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "id",
"name": "id",
"jsonName": null,
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null,
"constraintTypes": [],
"bindingSourceId": "Path",
"descriptorName": ""
}
],
"returnValue": {
"type": "HospitalManagementSystem.Dtos.DepartmentDto",
"typeSimple": "HospitalManagementSystem.Dtos.DepartmentDto"
}
}
]
}
],
"actions": {
"GetAsync": {
"uniqueName": "GetAsync",
"name": "GetAsync",
},
"allowAnonymous": false,
"implementFrom": "HospitalManagementSystem.Departments.DepartmentAppService"
},
"GetExportDepartmentRecordAsync": {
"uniqueName": "GetExportDepartmentRecordAsync",
"name": "GetExportDepartmentRecordAsync",
"httpMethod": "GET",
"url": "api/app/department",
"url": "api/app/department/export-department-record",
"supportedVersions": [],
"parametersOnMethod": [],
"parameters": [],
"returnValue": {
"type": "System.Collections.Generic.List<HospitalManagementSystem.Dtos.DepartmentDto>",
"typeSimple": "[HospitalManagementSystem.Dtos.DepartmentDto]"
"type": "HospitalManagementSystem.Dto.FileDownloadDto",
"typeSimple": "HospitalManagementSystem.Dto.FileDownloadDto"
},
"allowAnonymous": null,
"implementFrom": "HospitalManagementSystem.Departments.IDepartmentAppService"
"allowAnonymous": false,
"implementFrom": "HospitalManagementSystem.Departments.DepartmentAppService"
},
"CreateAsyncByInput": {
"uniqueName": "CreateAsyncByInput",
"name": "CreateAsync",
"CreateDepartmentAsyncByInput": {
"uniqueName": "CreateDepartmentAsyncByInput",
"name": "CreateDepartmentAsync",
"httpMethod": "POST",
"url": "api/app/department",
"url": "api/app/department/department",
"supportedVersions": [],
"parametersOnMethod": [
{
@ -1237,11 +1315,85 @@
}
],
"returnValue": {
"type": "HospitalManagementSystem.Dtos.DepartmentDto",
"typeSimple": "HospitalManagementSystem.Dtos.DepartmentDto"
"type": "System.Void",
"typeSimple": "System.Void"
},
"allowAnonymous": null,
"implementFrom": "HospitalManagementSystem.Departments.IDepartmentAppService"
"allowAnonymous": false,
"implementFrom": "HospitalManagementSystem.Departments.DepartmentAppService"
},
"UpdateDepartmentAsyncByInput": {
"uniqueName": "UpdateDepartmentAsyncByInput",
"name": "UpdateDepartmentAsync",
"httpMethod": "PUT",
"url": "api/app/department/department",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "input",
"typeAsString": "HospitalManagementSystem.Dtos.CreateDepartmentDto, HospitalManagementSystem.Application",
"type": "HospitalManagementSystem.Dtos.CreateDepartmentDto",
"typeSimple": "HospitalManagementSystem.Dtos.CreateDepartmentDto",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "input",
"name": "input",
"jsonName": null,
"type": "HospitalManagementSystem.Dtos.CreateDepartmentDto",
"typeSimple": "HospitalManagementSystem.Dtos.CreateDepartmentDto",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "Body",
"descriptorName": ""
}
],
"returnValue": {
"type": "System.Void",
"typeSimple": "System.Void"
},
"allowAnonymous": false,
"implementFrom": "HospitalManagementSystem.Departments.DepartmentAppService"
},
"DeleteDepartmentRecordAsyncById": {
"uniqueName": "DeleteDepartmentRecordAsyncById",
"name": "DeleteDepartmentRecordAsync",
"httpMethod": "DELETE",
"url": "api/app/department/{id}/department-record",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "id",
"typeAsString": "System.Guid, System.Private.CoreLib",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "id",
"name": "id",
"jsonName": null,
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null,
"constraintTypes": [],
"bindingSourceId": "Path",
"descriptorName": ""
}
],
"returnValue": {
"type": "System.Void",
"typeSimple": "System.Void"
},
"allowAnonymous": false,
"implementFrom": "HospitalManagementSystem.Departments.DepartmentAppService"
}
}
},
@ -4953,8 +5105,8 @@
{
"name": "Doctor",
"jsonName": null,
"type": "HospitalManagementSystem.Doctors.Doctor",
"typeSimple": "HospitalManagementSystem.Doctors.Doctor",
"type": "HospitalManagementSystem.Doctors.Dto.DoctorDto",
"typeSimple": "HospitalManagementSystem.Doctors.Dto.DoctorDto",
"isRequired": false,
"minLength": null,
"maxLength": null,
@ -5177,453 +5329,6 @@
}
]
},
"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.Doctors.Dto.DoctorDto": {
"baseType": "Volo.Abp.Domain.Entities.Auditing.FullAuditedEntity<System.Guid>",
"isEnum": false,
@ -5952,6 +5657,18 @@
"enumValues": null,
"genericArguments": null,
"properties": [
{
"name": "Id",
"jsonName": null,
"type": "System.Guid",
"typeSimple": "string",
"isRequired": false,
"minLength": null,
"maxLength": null,
"minimum": null,
"maximum": null,
"regex": null
},
{
"name": "DepartmentNo",
"jsonName": null,
@ -6011,6 +5728,18 @@
"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
}
]
},

View File

@ -61,6 +61,22 @@ function configureRoutes(routesService: RoutesService) {
// order: 203,
// requiredPolicy:'HospitalManagementSystem.Patient'
// },
{
path: '',
name: 'Departments',
order: 301,
iconClass: 'fa fa-building-o',
layout: eLayoutType.application,
},
{
path: '/departments',
name: 'All Departments',
parentName: 'Departments',
iconClass: 'fas fa-clock',
order: 302,
requiredPolicy:'HospitalManagementSystem.Department'
},
]);
};
}

View File

@ -9,11 +9,23 @@ public class HospitalManagementSystemPermissionDefinitionProvider : PermissionDe
public override void Define(IPermissionDefinitionContext context)
{
var HostipalManagementGroup = context.AddGroup(HospitalManagementSystemPermissions.GroupName);
//patient
var PatientPermission = HostipalManagementGroup.AddPermission(HospitalManagementSystemPermissions.Patient.Default);
PatientPermission.AddChild(HospitalManagementSystemPermissions.Patient.Create);
PatientPermission.AddChild(HospitalManagementSystemPermissions.Patient.Edit);
PatientPermission.AddChild(HospitalManagementSystemPermissions.Patient.Delete);
//Department
var DepartmentPermission = HostipalManagementGroup.AddPermission(HospitalManagementSystemPermissions.Department.Default);
DepartmentPermission.AddChild(HospitalManagementSystemPermissions.Department.Create);
DepartmentPermission.AddChild(HospitalManagementSystemPermissions.Department.Edit);
DepartmentPermission.AddChild(HospitalManagementSystemPermissions.Department.Delete);
//Define your own permissions here. Example:
//myGroup.AddPermission(HospitalManagementSystemPermissions.MyPermission1, L("Permission:MyPermission1"));
}

View File

@ -13,4 +13,11 @@ public static class HospitalManagementSystemPermissions
public const string Edit = Default + ".Edit";
public const string Delete = Default + ".Delete";
}
public static class Department
{
public const string Default = GroupName + ".Department";
public const string Create = Default + ".Create";
public const string Edit = Default + ".Edit";
public const string Delete = Default + ".Delete";
}
}

View File

@ -1,31 +1,189 @@
using HospitalManagementSystem.Dtos;
using Abp.Application.Services.Dto;
using HospitalManagementSystem.Appoinments.Dto;
using HospitalManagementSystem.Appointments;
using HospitalManagementSystem.Dto;
using HospitalManagementSystem.Dtos;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
using System.IO;
using System.Linq;
using System.Linq.Dynamic.Core;
using Abp.UI;
using ClosedXML.Excel;
using Microsoft.AspNetCore.Hosting;
using HospitalManagementSystem.Permissions;
using Microsoft.AspNetCore.Authorization;
namespace HospitalManagementSystem.Departments
{
public class DepartmentAppService : ApplicationService, IDepartmentAppService
public class DepartmentAppService : ApplicationService
{
private readonly IRepository<Department, Guid> _departmentRepository;
public DepartmentAppService(IRepository<Department, Guid> departmentRepository)
private readonly IWebHostEnvironment _env;
public DepartmentAppService(IRepository<Department, Guid> departmentRepository, IWebHostEnvironment env)
{
_departmentRepository = departmentRepository;
_env = env;
}
public async Task<List<DepartmentDto>> GetAsync()
//public async Task<List<DepartmentDto>> GetAsync()
//{
// var departmentDtos = new List<DepartmentDto>();
// var data = await _departmentRepository.GetListAsync();
// departmentDtos = ObjectMapper.Map<List<Department>, List<DepartmentDto>>(data);
// return departmentDtos;
//}
#region Get Department List with Paging and Searching
[Authorize(HospitalManagementSystemPermissions.Department.Default)]
public async Task<PagedResultDto<DepartmentDto>> GetDepartmentListAsync(PagingSortResultDto input)
{
var departmentDtos = new List<DepartmentDto>();
var data = await _departmentRepository.GetListAsync();
departmentDtos = ObjectMapper.Map<List<Department>, List<DepartmentDto>>(data);
return departmentDtos;
var queryable = await _departmentRepository.GetQueryableAsync();
var filteredQuery = queryable
.WhereIf(!string.IsNullOrEmpty(input.Search), x => x.DepartmentName.ToLower().Contains(input.Search.ToLower()) || x.DepartmentHead.ToLower().Contains(input.Search.ToLower()));
var totalCount = await filteredQuery.CountAsync();
filteredQuery = !string.IsNullOrEmpty(input.Sorting)
? filteredQuery.OrderBy(input.Sorting)
: filteredQuery.OrderBy(x => x.Id);
var pagedQuery = await filteredQuery
.Skip(input.SkipCount)
.Take(input.MaxResultCount)
.ToListAsync();
var appoinmentdto = ObjectMapper.Map<List<Department>, List<DepartmentDto>>(pagedQuery);
return new PagedResultDto<DepartmentDto>(
totalCount,
appoinmentdto
);
}
#endregion
#region Get Department by ID
[Authorize(HospitalManagementSystemPermissions.Department.Default)]
public async Task<DepartmentDto> GetDepartmentByIdAsync(Guid id)
{
var department = await _departmentRepository.FirstOrDefaultAsync(x => x.Id == id);
if (department == null)
{
throw new UserFriendlyException("Department Details not found");
}
public async Task<DepartmentDto> CreateAsync(CreateDepartmentDto input)
{
var department = new Department(Guid.NewGuid(), input.DepartmentNo, input.DepartmentName, input.DepartmentDate, input.DepartmentHead, "Active", input.Description);
await _departmentRepository.InsertAsync(department);
return ObjectMapper.Map<Department, DepartmentDto>(department);
}
#endregion
#region Export Department Data to Excel
[Authorize(HospitalManagementSystemPermissions.Department.Default)]
public async Task<FileDownloadDto> GetExportDepartmentRecordAsync()
{
var DepartmentRecord = await _departmentRepository.ToListAsync();
var folderPath = Path.Combine(_env.WebRootPath, "temp");
if (!Directory.Exists(folderPath))
{
Directory.CreateDirectory(folderPath);
}
var filename = "Departments_" + 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("Department");
// Add headers
worksheet.Cell(1, 1).Value = "Department Number";
worksheet.Cell(1, 2).Value = "Department Name";
worksheet.Cell(1, 3).Value = "Description";
worksheet.Cell(1, 4).Value = "Date";
worksheet.Cell(1, 5).Value = "Department Head";
worksheet.Cell(1, 6).Value = "Status";
for (int i = 0; i < DepartmentRecord.Count; i++)
{
worksheet.Cell(i + 2, 1).Value = DepartmentRecord[i].DepartmentNo;
worksheet.Cell(i + 2, 2).Value = DepartmentRecord[i].DepartmentName;
worksheet.Cell(i + 2, 3).Value = DepartmentRecord[i].Description;
worksheet.Cell(i + 2, 4).Value = DepartmentRecord[i].DepartmentDate?.ToShortDateString();
worksheet.Cell(i + 2, 5).Value = DepartmentRecord[i].DepartmentHead;
worksheet.Cell(i + 2, 6).Value = DepartmentRecord[i].Status;
}
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
//public async Task<DepartmentDto> CreateAsync(CreateDepartmentDto input)
//{
// var department = new Department(Guid.NewGuid(), input.DepartmentNo, input.DepartmentName, input.DepartmentDate, input.DepartmentHead, "Active", input.Description);
// await _departmentRepository.InsertAsync(department);
// return ObjectMapper.Map<Department, DepartmentDto>(department);
//}
#region Create Department
[Authorize(HospitalManagementSystemPermissions.Department.Create)]
public async Task CreateDepartmentAsync(CreateDepartmentDto input)
{
var newdata = ObjectMapper.Map<CreateDepartmentDto, Department>(input);
await _departmentRepository.InsertAsync(newdata);
}
#endregion
#region Update Department
[Authorize(HospitalManagementSystemPermissions.Department.Edit)]
public async Task UpdateDepartmentAsync(CreateDepartmentDto input)
{
try
{
var newdata = ObjectMapper.Map<CreateDepartmentDto, Department>(input);
await _departmentRepository.UpdateAsync(newdata);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
#endregion
#region Delete Department
[Authorize(HospitalManagementSystemPermissions.Department.Delete)]
public async Task DeleteDepartmentRecordAsync(Guid id)
{
await _departmentRepository.DeleteAsync(id);
}
#endregion
}
}

View File

@ -8,10 +8,14 @@ namespace HospitalManagementSystem.Dtos
{
public class CreateDepartmentDto
{
public Guid Id { get; set; }
public string? DepartmentNo { get; set; }
public string? DepartmentName { get; set; }
public DateTime? DepartmentDate { get; set; }
public string? DepartmentHead { get; set; }
public string? Description { get; set; }
public string? Status { get; set; }
}
}

View File

@ -43,6 +43,8 @@ namespace HospitalManagementSystem
#region Department
CreateMap<Department, DepartmentDto>();
CreateMap<Department, CreateDepartmentDto>();
CreateMap<CreateDepartmentDto, Department>();
#endregion
#region Doctor