improvement: v1 standalone treatment/case creation made possible.
This commit is contained in:
@@ -43,9 +43,10 @@ export class PatientsService {
|
||||
const { page = 1, limit = 10, q } = query;
|
||||
const skip = (page - 1) * limit;
|
||||
|
||||
const where = q?.trim()
|
||||
? this.buildSearchWhere(q.trim())
|
||||
: {};
|
||||
const where = {
|
||||
isWalkIn: false,
|
||||
...(q?.trim() ? this.buildSearchWhere(q.trim()) : {}),
|
||||
};
|
||||
|
||||
const [items, total] = await Promise.all([
|
||||
this.prisma.patient.findMany({
|
||||
@@ -76,7 +77,7 @@ export class PatientsService {
|
||||
where: { id },
|
||||
});
|
||||
|
||||
if (!patient) {
|
||||
if (!patient || patient.isWalkIn) {
|
||||
throw new AppException(ErrorCode.PATIENT_NOT_FOUND, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
@@ -85,6 +86,13 @@ export class PatientsService {
|
||||
|
||||
async update(id: string, updatePatientDto: UpdatePatientDto) {
|
||||
await this.ensurePatient(id);
|
||||
const patient = await this.prisma.patient.findUnique({
|
||||
where: { id },
|
||||
select: { isWalkIn: true },
|
||||
});
|
||||
if (patient?.isWalkIn) {
|
||||
throw new AppException(ErrorCode.PATIENT_NOT_FOUND, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
const data: {
|
||||
firstName?: string;
|
||||
@@ -116,12 +124,12 @@ export class PatientsService {
|
||||
: null;
|
||||
}
|
||||
|
||||
const patient = await this.prisma.patient.update({
|
||||
const updated = await this.prisma.patient.update({
|
||||
where: { id },
|
||||
data,
|
||||
});
|
||||
|
||||
return { success: true, data: patient };
|
||||
return { success: true, data: updated };
|
||||
}
|
||||
|
||||
async listAppointments(
|
||||
|
||||
Reference in New Issue
Block a user