Skip to content
Snippets Groups Projects
Commit c7e32212 authored by Prathviraj Suryakant Thokal's avatar Prathviraj Suryakant Thokal
Browse files

Merge branch 'develop-beta' of...

Merge branch 'develop-beta' of https://gitlab.niveussolutions.com/roshan.suvarnkar/hospital-service into hotFixHospitalTestCases
parents a5e88873 1a6b774e
No related branches found
No related tags found
1 merge request!32Hot fix hospital test cases
......@@ -13,6 +13,7 @@ import {
errorCode,
handlePrismaError,
Logger,
fuzzySearch
} from 'nest-common-utilities';
import { UpdateDoctorRequestDto } from './dto/update-doctor-request.dto';
import { UpdateDoctorResponseDto } from './dto/update-doctor-response.dto';
......@@ -256,71 +257,34 @@ export class DoctorService {
listDoctorsRequestDto: ListDoctorsRequestDto,
): Promise<PaginatedDoctorsResponseDto> {
try {
const { doctorName, doctorRegNo, emailId, mobileNo, page, limit } =
const { doctorName, doctorRegNo, emailId, mobileNo, hprCode, panNo, page, limit } =
listDoctorsRequestDto;
const whereCondition: any = {};
const whereCondition: Record<string, string> = {};
if (doctorName) {
whereCondition.name = {
contains: doctorName,
mode: 'insensitive',
};
}
if (doctorRegNo) {
whereCondition.registration_no = {
contains: doctorRegNo,
mode: 'insensitive',
};
}
if (emailId) {
whereCondition.doctor_email_id = {
contains: emailId,
mode: 'insensitive',
};
}
if (mobileNo) {
whereCondition.doctor_contact = {
contains: mobileNo,
mode: 'insensitive',
};
}
if (doctorRegNo) whereCondition.registration_no = doctorRegNo;
if (emailId) whereCondition.doctor_email_id = emailId;
if (mobileNo) whereCondition.doctor_contact = mobileNo;
if (hprCode) whereCondition.hpr_code = hprCode;
if (panNo) whereCondition.pan_no = panNo;
const { offset: skip, limit: take } = await this.pagination(page, limit);
const [doctors, totalCount] = await Promise.all([
this.prisma.doctor_master.findMany({
const data = await fuzzySearch<any>(this.prisma, 'doctor_master', {
searchFields: ['name'],
searchTerm: doctorName || '',
limit: take,
offset: skip,
similarityThreshold: 0.1,
where: whereCondition,
include: {
doctor_speciality_master: {
select: { id: true, name: true },
doctor_speciality_master: true,
qualifications: true,
pincode_master: true,
},
qualifications: {
select: {
id: true,
qualification: {
select: { id: true, name: true },
},
},
},
pincode_master: {
select: { id: true, name: true },
},
},
skip,
take,
orderBy: { name: 'asc' },
}),
this.prisma.doctor_master.count({
where: whereCondition,
}),
]);
});
const transformedDoctors = doctors.map((doctor) => ({
const transformedDoctors = data.data.map((doctor) => ({
id: doctor.id ?? '',
doctorName: doctor.name ?? '',
doctorRegNo: doctor.registration_no ?? '',
......@@ -342,12 +306,14 @@ export class DoctorService {
longitude: doctor.longitude?.toString() ?? null,
}));
return {
totalCount: data.total,
data: transformedDoctors,
totalCount,
};
} catch (error) {
this.logger.error('Error fetching doctors:', error);
}
catch (error) {
this.logger.error('Error fetching hospitals:', error);
handlePrismaError(error);
}
}
}
......@@ -51,6 +51,24 @@ export class ListDoctorsRequestDto {
})
mobileNo?: string;
@ApiProperty({
description: 'HPR code',
example: 'ADCVB987GH',
required: false,
})
@IsOptional()
@IsString()
hprCode?: string;
@ApiProperty({
description: 'PAN number',
example: 'CHPI789323',
required: false,
})
@IsOptional()
@IsString()
panNo?: string;
@IsNumber()
@ApiProperty({
example: 1,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment