fix: fix bug record_id not showing on validation table after approving validation
This commit is contained in:
parent
756bb6ee09
commit
0487f50c53
|
|
@ -51,7 +51,6 @@ export class TindakanDokterController {
|
||||||
@Body() data: CreateTindakanDokterDto,
|
@Body() data: CreateTindakanDokterDto,
|
||||||
@CurrentUser() user: ActiveUserPayload,
|
@CurrentUser() user: ActiveUserPayload,
|
||||||
) {
|
) {
|
||||||
// console.log('APASIH');
|
|
||||||
return await this.tindakanDokterService.createTindakanDokter(data, user);
|
return await this.tindakanDokterService.createTindakanDokter(data, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -115,9 +115,7 @@ export class TindakanDokterService {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!visitExists) {
|
if (!visitExists) {
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(`ID Visit ${dto.id_visit} tidak ditemukan`);
|
||||||
`Visit dengan ID ${dto.id_visit} tidak ditemukan`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await this.prisma.validation_queue.create({
|
const response = await this.prisma.validation_queue.create({
|
||||||
|
|
@ -135,45 +133,6 @@ export class TindakanDokterService {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// const createValidate = await this.validationService.storeQueueValidation(
|
|
||||||
// {
|
|
||||||
// table_name: 'pemberian_tindakan',
|
|
||||||
// record_id: null,
|
|
||||||
// dataPayload: {
|
|
||||||
// id_visit: dto.id_visit,
|
|
||||||
// tindakan: dto.tindakan,
|
|
||||||
// kategori_tindakan: dto.kategori_tindakan ?? null,
|
|
||||||
// kelompok_tindakan: dto.kelompok_tindakan ?? null,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// user,
|
|
||||||
// );
|
|
||||||
|
|
||||||
// const createdTindakan = await this.prisma.pemberian_tindakan.create({
|
|
||||||
// data: {
|
|
||||||
// id_visit: dto.id_visit,
|
|
||||||
// tindakan: dto.tindakan,
|
|
||||||
// kategori_tindakan: dto.kategori_tindakan ?? null,
|
|
||||||
// kelompok_tindakan: dto.kelompok_tindakan ?? null,
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
|
|
||||||
// const hashingPayload = this.createHashingPayload({
|
|
||||||
// id_visit: createdTindakan.id_visit,
|
|
||||||
// tindakan: createdTindakan.tindakan,
|
|
||||||
// kategori_tindakan: createdTindakan.kategori_tindakan ?? null,
|
|
||||||
// kelompok_tindakan: createdTindakan.kelompok_tindakan ?? null,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// const logPayloadHash = hashingPayload;
|
|
||||||
|
|
||||||
// const logResult = await this.logService.storeLog({
|
|
||||||
// id: `TINDAKAN_${createdTindakan.id}`,
|
|
||||||
// event: 'tindakan_dokter_created',
|
|
||||||
// user_id: user.sub,
|
|
||||||
// payload: logPayloadHash,
|
|
||||||
// });
|
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -264,30 +223,6 @@ export class TindakanDokterService {
|
||||||
});
|
});
|
||||||
|
|
||||||
return validationQueue;
|
return validationQueue;
|
||||||
|
|
||||||
// const updatedTindakan = await this.prisma.pemberian_tindakan.update({
|
|
||||||
// where: { id: tindakanId },
|
|
||||||
// data: updateData,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// const hashingPayload = this.createHashingPayload({
|
|
||||||
// id_visit: updatedTindakan.id_visit,
|
|
||||||
// tindakan: updatedTindakan.tindakan,
|
|
||||||
// kategori_tindakan: updatedTindakan.kategori_tindakan ?? null,
|
|
||||||
// kelompok_tindakan: updatedTindakan.kelompok_tindakan ?? null,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// const logResult = await this.logService.storeLog({
|
|
||||||
// id: `TINDAKAN_${tindakanId}`,
|
|
||||||
// event: 'tindakan_dokter_updated',
|
|
||||||
// user_id: user.sub,
|
|
||||||
// payload: hashingPayload,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// return {
|
|
||||||
// ...updatedTindakan,
|
|
||||||
// log: logResult,
|
|
||||||
// };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getTindakanLogById(id: string) {
|
async getTindakanLogById(id: string) {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
import { BadRequestException, Injectable } from '@nestjs/common';
|
||||||
import { PrismaService } from '../prisma/prisma.service';
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
import { ActiveUserPayload } from '../auth/decorator/current-user.decorator';
|
import { ActiveUserPayload } from '../auth/decorator/current-user.decorator';
|
||||||
import { RekammedisService } from '../rekammedis/rekammedis.service';
|
import { RekammedisService } from '../rekammedis/rekammedis.service';
|
||||||
|
|
@ -22,10 +22,16 @@ export class ValidationService {
|
||||||
rekam_medis: {
|
rekam_medis: {
|
||||||
approveCreate: async (queue: any) => {
|
approveCreate: async (queue: any) => {
|
||||||
const payload = queue.dataPayload as Partial<CreateRekamMedisDto>;
|
const payload = queue.dataPayload as Partial<CreateRekamMedisDto>;
|
||||||
return this.rekamMedisService.createRekamMedisToDBAndBlockchain(
|
const result =
|
||||||
payload as CreateRekamMedisDto,
|
await this.rekamMedisService.createRekamMedisToDBAndBlockchain(
|
||||||
Number(queue.user_id_request),
|
payload as CreateRekamMedisDto,
|
||||||
);
|
Number(queue.user_id_request),
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
...result,
|
||||||
|
id: result.id_visit,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
approveUpdate: async (queue: any) => {
|
approveUpdate: async (queue: any) => {
|
||||||
const payload = queue.dataPayload as Partial<CreateRekamMedisDto>;
|
const payload = queue.dataPayload as Partial<CreateRekamMedisDto>;
|
||||||
|
|
@ -41,7 +47,17 @@ export class ValidationService {
|
||||||
} as ActiveUserPayload);
|
} as ActiveUserPayload);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
pemberian_tindakan: {},
|
pemberian_tindakan: {
|
||||||
|
approveCreate: async (queue: any) => {
|
||||||
|
const payload = queue.dataPayload;
|
||||||
|
console.log('Approving create for pemberian_tindakan:', payload);
|
||||||
|
// return this.prisma.pemberian_tindakan.create({
|
||||||
|
// data: {
|
||||||
|
// ...payload,
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
},
|
||||||
|
},
|
||||||
pemberian_obat: {},
|
pemberian_obat: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -67,12 +83,14 @@ export class ValidationService {
|
||||||
return { data: result, totalCount };
|
return { data: result, totalCount };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For service internal use
|
||||||
async getValidationQueueById(id: number) {
|
async getValidationQueueById(id: number) {
|
||||||
return await this.prisma.validation_queue.findUnique({
|
return await this.prisma.validation_queue.findUnique({
|
||||||
where: { id },
|
where: { id },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For front-end detail view
|
||||||
async getValidationQueue(id: number) {
|
async getValidationQueue(id: number) {
|
||||||
const result = await this.getValidationQueueById(id);
|
const result = await this.getValidationQueueById(id);
|
||||||
if (!result) return null;
|
if (!result) return null;
|
||||||
|
|
@ -128,16 +146,18 @@ export class ValidationService {
|
||||||
async approveValidation(id: number, user: ActiveUserPayload) {
|
async approveValidation(id: number, user: ActiveUserPayload) {
|
||||||
const validationQueue = await this.getValidationQueueById(id);
|
const validationQueue = await this.getValidationQueueById(id);
|
||||||
if (!validationQueue) {
|
if (!validationQueue) {
|
||||||
throw new Error('Validation queue not found');
|
throw new BadRequestException('Validation queue not found');
|
||||||
}
|
}
|
||||||
if (!validationQueue.dataPayload) {
|
if (!validationQueue.dataPayload) {
|
||||||
throw new Error('Data payload is missing');
|
throw new Error('Data payload is missing');
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const approvalResult = await this.approveWithHandler(validationQueue);
|
const approvalResult = await this.approveWithHandler(validationQueue);
|
||||||
|
console.log('Approval result:', approvalResult);
|
||||||
const updated = await this.prisma.validation_queue.update({
|
const updated = await this.prisma.validation_queue.update({
|
||||||
where: { id: validationQueue.id },
|
where: { id: validationQueue.id },
|
||||||
data: {
|
data: {
|
||||||
|
record_id: approvalResult.id,
|
||||||
status: 'APPROVED',
|
status: 'APPROVED',
|
||||||
user_id_process: Number(user.sub),
|
user_id_process: Number(user.sub),
|
||||||
processed_at: new Date(),
|
processed_at: new Date(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user