diff --git a/package-lock.json b/package-lock.json index 6df342b..8b9036f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "@nuxt/devtools": "^1.6.3", "@nuxtjs/color-mode": "^3.5.2", "@pinia/nuxt": "^0.5.5", + "@vuepic/vue-datepicker": "^10.0.0", "axios": "^1.7.7", "nuxt": "^3.13.0", "nuxt-sweetalert2": "^1.0.0", @@ -3701,6 +3702,21 @@ "integrity": "sha512-L2RPSAwUFbgZH20etwrXyVyCBu9OxRSi8T/38QsvnkJyvq2LufW2lDCOzm7t/U9C1mkhJGWYfCuFBCmIuNivrg==", "license": "MIT" }, + "node_modules/@vuepic/vue-datepicker": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@vuepic/vue-datepicker/-/vue-datepicker-10.0.0.tgz", + "integrity": "sha512-ujlk3ahftVQpyCJ8hq7TmOOHrf/XFJI1ZcAh/FRB5Ci62Vq5HmHf6xux5KVi5SPUFRTJY78m+uDhYy1M+8RZ9w==", + "license": "MIT", + "dependencies": { + "date-fns": "^4.1.0" + }, + "engines": { + "node": ">=18.12.0" + }, + "peerDependencies": { + "vue": ">=3.2.0" + } + }, "node_modules/@vuetify/loader-shared": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@vuetify/loader-shared/-/loader-shared-2.0.3.tgz", @@ -5501,6 +5517,16 @@ "url": "https://opencollective.com/daisyui" } }, + "node_modules/date-fns": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-4.1.0.tgz", + "integrity": "sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/kossnocorp" + } + }, "node_modules/db0": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/db0/-/db0-0.2.1.tgz", diff --git a/package.json b/package.json index 3a368bf..afc2044 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "@nuxt/devtools": "^1.6.3", "@nuxtjs/color-mode": "^3.5.2", "@pinia/nuxt": "^0.5.5", + "@vuepic/vue-datepicker": "^10.0.0", "axios": "^1.7.7", "nuxt": "^3.13.0", "nuxt-sweetalert2": "^1.0.0", diff --git a/pages/satu_rssa/kunjungan_pasien/index.vue b/pages/satu_rssa/kunjungan_pasien/index.vue index 8bcaf88..6772893 100644 --- a/pages/satu_rssa/kunjungan_pasien/index.vue +++ b/pages/satu_rssa/kunjungan_pasien/index.vue @@ -1,166 +1,108 @@ diff --git a/pages/satu_rssa/kunjungan_pasien/index2.vue b/pages/satu_rssa/kunjungan_pasien/index2.vue new file mode 100644 index 0000000..152d843 --- /dev/null +++ b/pages/satu_rssa/kunjungan_pasien/index2.vue @@ -0,0 +1,130 @@ + + diff --git a/server/api/satu_rssa/kunjungan_pasien/index.post.ts b/server/api/satu_rssa/kunjungan_pasien/index.post.ts new file mode 100644 index 0000000..f09d625 --- /dev/null +++ b/server/api/satu_rssa/kunjungan_pasien/index.post.ts @@ -0,0 +1,23 @@ +import axios from "axios"; +export default defineEventHandler(async (event) => { + const body = await readBody(event) + console.log(body) + try { + console.log("MASUK DALAM SINI") + const response = await axios.post("http://10.10.150.129:8082/api/kunjunganpasien/listkunjunganpasien", body); + console.log(response.data) + + + + return response.data + } catch (error) { + console.error("Error posting to API:", error); + + throw createError({ + statusCode: 500, + statusMessage: "Failed to fetch data from API", + }); + } +}); + + diff --git a/stores/users.ts b/stores/users.ts index a370fe6..6b27e3e 100644 --- a/stores/users.ts +++ b/stores/users.ts @@ -149,7 +149,65 @@ export const useDataLogAPIGet = defineStore("DataLogAPI", () => { dataLogAPI, loadDataLogAPI, } -}) +}); + +export const useDataKunjunganPasien = defineStore("DataKunjunganPasien", () => { + const dataKunjunganPasien = ref([]); + + const calculateAge = (tanggalLahir: string) => { + const today = new Date(); + const birthDate = new Date(tanggalLahir); + + if (isNaN(birthDate.getTime())) { + console.error("Tanggal lahir tidak valid:", tanggalLahir); + return null; + } + + let age = today.getFullYear() - birthDate.getFullYear(); + const m = today.getMonth() - birthDate.getMonth(); + + + if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) { + age--; + } + + return age; + }; + + + const loadDataKunjunganPasien = async (reqDataKunjunganPasien: Record) => { + try { + console.log("REQ", reqDataKunjunganPasien); + const response = await $fetch("/api/satu_rssa/kunjungan_pasien", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(reqDataKunjunganPasien), + }); + + console.log("Response Data:", response); + + + dataKunjunganPasien.value = response.map((item: any) => { + const tanggalLahir = item.tanggallahir; + const umur = tanggalLahir ? calculateAge(tanggalLahir) : null; + + + return { ...item, umur }; + }); + + console.log("Data Kunjungan Pasien dengan Umur:", dataKunjunganPasien.value); + } catch (error) { + console.error("Failed to load data log api:", error); + } + }; + + return { + dataKunjunganPasien, + loadDataKunjunganPasien, + }; +}); export const useJadwalDokter = defineStore("JadwalDokter", () => {