feat(kesehatan): slim ringkasan kesehatan schema + tambah seeder balita & ibu hamil - bump 0.1.52
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,45 +1,28 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Context } from "elysia";
|
||||
|
||||
async function ringkasanKesehatanUpdate(context: Context) {
|
||||
const body = context.body as any;
|
||||
const body = context.body as { targetStuntingPct: number };
|
||||
|
||||
try {
|
||||
const existing = await prisma.ringkasanKesehatanDesa.findFirst({
|
||||
where: { isActive: true },
|
||||
orderBy: { createdAt: 'desc' },
|
||||
orderBy: { createdAt: "desc" },
|
||||
});
|
||||
|
||||
const data = existing
|
||||
? await prisma.ringkasanKesehatanDesa.update({
|
||||
where: { id: existing.id },
|
||||
data: {
|
||||
ibuHamilAkh: Number(body.ibuHamilAkh),
|
||||
balitaTerdaftar: Number(body.balitaTerdaftar),
|
||||
alertStunting: Number(body.alertStunting),
|
||||
imunisasiLengkapPct: Number(body.imunisasiLengkapPct),
|
||||
pemeriksaanRutinPct: Number(body.pemeriksaanRutinPct),
|
||||
giziBaikPct: Number(body.giziBaikPct),
|
||||
targetStuntingPct: Number(body.targetStuntingPct),
|
||||
},
|
||||
data: { targetStuntingPct: Number(body.targetStuntingPct) },
|
||||
})
|
||||
: await prisma.ringkasanKesehatanDesa.create({
|
||||
data: {
|
||||
ibuHamilAkh: Number(body.ibuHamilAkh),
|
||||
balitaTerdaftar: Number(body.balitaTerdaftar),
|
||||
alertStunting: Number(body.alertStunting),
|
||||
imunisasiLengkapPct: Number(body.imunisasiLengkapPct),
|
||||
pemeriksaanRutinPct: Number(body.pemeriksaanRutinPct),
|
||||
giziBaikPct: Number(body.giziBaikPct),
|
||||
targetStuntingPct: Number(body.targetStuntingPct),
|
||||
},
|
||||
data: { targetStuntingPct: Number(body.targetStuntingPct) },
|
||||
});
|
||||
|
||||
return { success: true, message: "Ringkasan kesehatan berhasil disimpan", data };
|
||||
return { success: true, message: "Target stunting berhasil disimpan", data };
|
||||
} catch (e) {
|
||||
console.error("Error di ringkasanKesehatanUpdate:", e);
|
||||
return { success: false, message: "Gagal menyimpan ringkasan kesehatan" };
|
||||
return { success: false, message: "Gagal menyimpan target stunting" };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user