refactor(patient): rename PatientEntity to Patient and update related components
Update interface name from PatientEntity to Patient for better clarity and consistency. Modify all related components and models to use the new interface name. Also includes minor improvements to address handling in patient forms.
This commit is contained in:
No files matched your search
@@ -6,7 +6,7 @@ import type {
|
|||||||
RecStrFuncUnknown,
|
RecStrFuncUnknown,
|
||||||
Th,
|
Th,
|
||||||
} from '~/components/pub/my-ui/data/types'
|
} from '~/components/pub/my-ui/data/types'
|
||||||
import type { PatientEntity } from '~/models/patient'
|
import type { Patient } from '~/models/patient'
|
||||||
import { defineAsyncComponent } from 'vue'
|
import { defineAsyncComponent } from 'vue'
|
||||||
import { educationCodes, genderCodes } from '~/lib/constants'
|
import { educationCodes, genderCodes } from '~/lib/constants'
|
||||||
import { calculateAge } from '~/lib/utils'
|
import { calculateAge } from '~/lib/utils'
|
||||||
@@ -36,11 +36,11 @@ export const delKeyNames: KeyLabel[] = [
|
|||||||
|
|
||||||
export const funcParsed: RecStrFuncUnknown = {
|
export const funcParsed: RecStrFuncUnknown = {
|
||||||
name: (rec: unknown): unknown => {
|
name: (rec: unknown): unknown => {
|
||||||
const { person } = rec as PatientEntity
|
const { person } = rec as Patient
|
||||||
return person.name.trim()
|
return person.name.trim()
|
||||||
},
|
},
|
||||||
identity_number: (rec: unknown): unknown => {
|
identity_number: (rec: unknown): unknown => {
|
||||||
const { person } = rec as PatientEntity
|
const { person } = rec as Patient
|
||||||
|
|
||||||
if (person?.residentIdentityNumber?.substring(0, 5) === 'BLANK') {
|
if (person?.residentIdentityNumber?.substring(0, 5) === 'BLANK') {
|
||||||
return '(TANPA NIK)'
|
return '(TANPA NIK)'
|
||||||
@@ -48,7 +48,7 @@ export const funcParsed: RecStrFuncUnknown = {
|
|||||||
return person.residentIdentityNumber
|
return person.residentIdentityNumber
|
||||||
},
|
},
|
||||||
birth_date: (rec: unknown): unknown => {
|
birth_date: (rec: unknown): unknown => {
|
||||||
const { person } = rec as PatientEntity
|
const { person } = rec as Patient
|
||||||
|
|
||||||
if (typeof person.birthDate == 'object' && person.birthDate) {
|
if (typeof person.birthDate == 'object' && person.birthDate) {
|
||||||
return (person.birthDate as Date).toLocaleDateString()
|
return (person.birthDate as Date).toLocaleDateString()
|
||||||
@@ -58,11 +58,11 @@ export const funcParsed: RecStrFuncUnknown = {
|
|||||||
return person.birthDate
|
return person.birthDate
|
||||||
},
|
},
|
||||||
patient_age: (rec: unknown): unknown => {
|
patient_age: (rec: unknown): unknown => {
|
||||||
const { person } = rec as PatientEntity
|
const { person } = rec as Patient
|
||||||
return calculateAge(person.birthDate)
|
return calculateAge(person.birthDate)
|
||||||
},
|
},
|
||||||
gender: (rec: unknown): unknown => {
|
gender: (rec: unknown): unknown => {
|
||||||
const { person } = rec as PatientEntity
|
const { person } = rec as Patient
|
||||||
|
|
||||||
if (typeof person.gender_code == 'number' && person.gender_code >= 0) {
|
if (typeof person.gender_code == 'number' && person.gender_code >= 0) {
|
||||||
return person.gender_code
|
return person.gender_code
|
||||||
@@ -72,7 +72,7 @@ export const funcParsed: RecStrFuncUnknown = {
|
|||||||
return '-'
|
return '-'
|
||||||
},
|
},
|
||||||
education: (rec: unknown): unknown => {
|
education: (rec: unknown): unknown => {
|
||||||
const { person } = rec as PatientEntity
|
const { person } = rec as Patient
|
||||||
if (typeof person.education_code == 'number' && person.education_code >= 0) {
|
if (typeof person.education_code == 'number' && person.education_code >= 0) {
|
||||||
return person.education_code
|
return person.education_code
|
||||||
} else if (typeof person.education_code === 'string' && person.education_code) {
|
} else if (typeof person.education_code === 'string' && person.education_code) {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Person } from '~/models/person'
|
import type { Patient } from '~/models/patient'
|
||||||
import DetailRow from '~/components/pub/my-ui/form/view/detail-row.vue'
|
import DetailRow from '~/components/pub/my-ui/form/view/detail-row.vue'
|
||||||
import DetailSection from '~/components/pub/my-ui/form/view/detail-section.vue'
|
import DetailSection from '~/components/pub/my-ui/form/view/detail-section.vue'
|
||||||
import { type PersonAddress, formatAddress } from '~/models/person-address'
|
import { formatAddress } from '~/models/person-address'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
addressLocationTypeCode,
|
addressLocationTypeCode,
|
||||||
@@ -17,7 +17,7 @@ import { mapToComboboxOptList } from '~/lib/utils'
|
|||||||
|
|
||||||
// #region Props & Emits
|
// #region Props & Emits
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
person: Person
|
patient: Patient
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
@@ -36,22 +36,22 @@ const personContactTypeOptions = mapToComboboxOptList(personContactTypes)
|
|||||||
|
|
||||||
// Computed addresses from nested data
|
// Computed addresses from nested data
|
||||||
const domicileAddress = computed(() => {
|
const domicileAddress = computed(() => {
|
||||||
const addresses = props.person.addresses
|
const addresses = props.patient.person.addresses
|
||||||
const resident = addresses?.find((addr) => addr.locationType === 'domicile')
|
const resident = addresses?.find((addr) => addr.locationType === 'domicile')
|
||||||
return formatAddress(resident)
|
return formatAddress(resident)
|
||||||
})
|
})
|
||||||
|
|
||||||
const identityAddress = computed(() => {
|
const identityAddress = computed(() => {
|
||||||
const addresses = props.person.addresses
|
const addresses = props.patient.person.addresses
|
||||||
const primary = addresses?.find((addr) => addr.locationType === 'identity')
|
const primary = addresses?.find((addr) => addr.locationType === 'identity')
|
||||||
return formatAddress(primary)
|
return formatAddress(primary)
|
||||||
})
|
})
|
||||||
|
|
||||||
const patientAge = computed(() => {
|
const patientAge = computed(() => {
|
||||||
if (!props.person.birthDate) {
|
if (!props.patient.person.birthDate) {
|
||||||
return '-'
|
return '-'
|
||||||
}
|
}
|
||||||
const birthDate = new Date(props.person.birthDate)
|
const birthDate = new Date(props.patient.person.birthDate)
|
||||||
const today = new Date()
|
const today = new Date()
|
||||||
let age = today.getFullYear() - birthDate.getFullYear()
|
let age = today.getFullYear() - birthDate.getFullYear()
|
||||||
const monthDiff = today.getMonth() - birthDate.getMonth()
|
const monthDiff = today.getMonth() - birthDate.getMonth()
|
||||||
@@ -81,35 +81,37 @@ function onClick(type: string) {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<DetailSection title="Data Pasien">
|
<DetailSection title="Data Pasien">
|
||||||
<DetailRow label="Nomor ID">{{ person.id || '-' }}</DetailRow>
|
<DetailRow label="Nomor">{{ patient.number || '-' }}</DetailRow>
|
||||||
<DetailRow label="Nama Lengkap">{{ person.name || '-' }}</DetailRow>
|
<DetailRow label="Nama Lengkap">{{ patient.person.name || '-' }}</DetailRow>
|
||||||
<DetailRow label="Tempat, tanggal lahir">
|
<DetailRow label="Tempat, tanggal lahir">
|
||||||
{{ person.birthRegency?.name || '-' }},
|
{{ patient.person.birthRegency?.name || '-' }},
|
||||||
{{ person.birthDate ? new Date(person.birthDate).toLocaleDateString() : '-' }}
|
{{ patient.person.birthDate ? new Date(patient.person.birthDate).toLocaleDateString() : '-' }}
|
||||||
</DetailRow>
|
</DetailRow>
|
||||||
<DetailRow label="Usia">{{ patientAge || '-' }}</DetailRow>
|
<DetailRow label="Usia">{{ patientAge || '-' }} Tahun</DetailRow>
|
||||||
<DetailRow label="Tanggal Daftar">
|
<DetailRow label="Tanggal Daftar">
|
||||||
{{ person.createdAt ? new Date(person.createdAt).toLocaleDateString() : '-' }}
|
{{ patient.person.createdAt ? new Date(patient.person.createdAt).toLocaleDateString() : '-' }}
|
||||||
</DetailRow>
|
</DetailRow>
|
||||||
<DetailRow label="Jenis Kelamin">
|
<DetailRow label="Jenis Kelamin">
|
||||||
{{ genderOptions.find((item) => item.code === person.gender_code)?.label || '-' }}
|
{{ genderOptions.find((item) => item.code === patient.person.gender_code)?.label || '-' }}
|
||||||
</DetailRow>
|
</DetailRow>
|
||||||
|
|
||||||
<DetailRow label="NIK">{{ person.residentIdentityNumber || '-' }}</DetailRow>
|
<DetailRow label="NIK">{{ patient.person.residentIdentityNumber || '-' }}</DetailRow>
|
||||||
<DetailRow label="No. SIM">{{ person.drivingLicenseNumber || '-' }}</DetailRow>
|
<DetailRow label="No. SIM">{{ patient.person.drivingLicenseNumber || '-' }}</DetailRow>
|
||||||
<DetailRow label="No. Paspor">{{ person.passportNumber || '-' }}</DetailRow>
|
<DetailRow label="No. Paspor">{{ patient.person.passportNumber || '-' }}</DetailRow>
|
||||||
|
|
||||||
<DetailRow label="Agama">
|
<DetailRow label="Agama">
|
||||||
{{ religionOptions.find((item) => item.code === person.religion_code)?.label || '-' }}
|
{{ religionOptions.find((item) => item.code === patient.person.religion_code)?.label || '-' }}
|
||||||
</DetailRow>
|
</DetailRow>
|
||||||
<DetailRow label="Suku">{{ person.ethnic_code || '-' }}</DetailRow>
|
<DetailRow label="Suku">{{ patient.person.ethnic?.name || '-' }}</DetailRow>
|
||||||
<DetailRow label="Bahasa">{{ person.language_code || '-' }}</DetailRow>
|
<DetailRow label="Bahasa">{{ patient.person.language?.name || '-' }}</DetailRow>
|
||||||
<DetailRow label="Pendidikan">
|
<DetailRow label="Pendidikan">
|
||||||
{{ educationOptions.find((item) => item.code === person.education_code)?.label || '-' }}
|
{{ educationOptions.find((item) => item.code === patient.person.education_code)?.label || '-' }}
|
||||||
</DetailRow>
|
</DetailRow>
|
||||||
<DetailRow label="Pekerjaan">
|
<DetailRow label="Pekerjaan">
|
||||||
{{
|
{{
|
||||||
occupationOptions.find((item) => item.code === person.occupation_code)?.label || person.occupation_name || '-'
|
occupationOptions.find((item) => item.code === patient.person.occupation_code)?.label ||
|
||||||
|
patient.person.occupation_name ||
|
||||||
|
'-'
|
||||||
}}
|
}}
|
||||||
</DetailRow>
|
</DetailRow>
|
||||||
</DetailSection>
|
</DetailSection>
|
||||||
@@ -119,13 +121,13 @@ function onClick(type: string) {
|
|||||||
<DetailRow :label="addressLocationTypeCode.identity || 'Alamat KTP'">{{ identityAddress || '-' }}</DetailRow>
|
<DetailRow :label="addressLocationTypeCode.identity || 'Alamat KTP'">{{ identityAddress || '-' }}</DetailRow>
|
||||||
</DetailSection>
|
</DetailSection>
|
||||||
<DetailSection title="Kontak">
|
<DetailSection title="Kontak">
|
||||||
<template v-if="person.contacts && person.contacts.length > 0">
|
<template v-if="patient.person.contacts && patient.person.contacts.length > 0">
|
||||||
<template
|
<template
|
||||||
v-for="contactType in personContactTypeOptions"
|
v-for="contactType in personContactTypeOptions"
|
||||||
:key="contactType.code"
|
:key="contactType.code"
|
||||||
>
|
>
|
||||||
<DetailRow :label="contactType.label">
|
<DetailRow :label="contactType.label">
|
||||||
{{ person.contacts.find((item) => item.type_code === contactType.code)?.value || '-' }}
|
{{ patient.person.contacts.find((item) => item.type_code === contactType.code)?.value || '-' }}
|
||||||
</DetailRow>
|
</DetailRow>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
@@ -133,10 +135,45 @@ function onClick(type: string) {
|
|||||||
<DetailRow label="Kontak">-</DetailRow>
|
<DetailRow label="Kontak">-</DetailRow>
|
||||||
</template>
|
</template>
|
||||||
</DetailSection>
|
</DetailSection>
|
||||||
<DetailSection title="Penanggung Jawab">
|
<DetailSection title="Orang Tua">
|
||||||
<template v-if="person.relatives && person.relatives.filter((rel) => rel.responsible).length > 0">
|
<template v-if="patient.person.relatives && patient.person.relatives.filter((rel) => !rel.responsible).length > 0">
|
||||||
<template
|
<template
|
||||||
v-for="(relative, index) in person.relatives.filter((rel) => rel.responsible)"
|
v-for="(relative, index) in patient.person.relatives.filter((rel) => !rel.responsible)"
|
||||||
|
:key="relative.id"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-if="index > 0"
|
||||||
|
class="mt-3 border-t border-gray-200 pt-3"
|
||||||
|
></div>
|
||||||
|
<DetailRow label="Nama">{{ relative.name || '-' }}</DetailRow>
|
||||||
|
<DetailRow label="Hubungan">
|
||||||
|
{{ relationshipOptions.find((item) => item.code === relative.relationship_code)?.label || '-' }}
|
||||||
|
</DetailRow>
|
||||||
|
<!-- <DetailRow label="Jenis Kelamin">
|
||||||
|
{{ genderOptions.find((item) => item.code === relative.gender_code)?.label || '-' }}
|
||||||
|
</DetailRow> -->
|
||||||
|
<DetailRow label="Pendidikan">
|
||||||
|
{{ educationOptions.find((item) => item.code === relative.education_code)?.label || '-' }}
|
||||||
|
</DetailRow>
|
||||||
|
<DetailRow label="Pekerjaan">
|
||||||
|
{{
|
||||||
|
occupationOptions.find((item) => item.code === relative.occupation_code)?.label ||
|
||||||
|
relative.occupation_name ||
|
||||||
|
'-'
|
||||||
|
}}
|
||||||
|
</DetailRow>
|
||||||
|
<!-- <DetailRow label="Alamat">{{ relative.address || '-' }}</DetailRow> -->
|
||||||
|
<!-- <DetailRow label="Nomor HP">{{ relative.phoneNumber || '-' }}</DetailRow> -->
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<DetailRow label="Orang Tua">-</DetailRow>
|
||||||
|
</template>
|
||||||
|
</DetailSection>
|
||||||
|
<DetailSection title="Penanggung Jawab">
|
||||||
|
<template v-if="patient.person.relatives && patient.person.relatives.filter((rel) => rel.responsible).length > 0">
|
||||||
|
<template
|
||||||
|
v-for="(relative, index) in patient.person.relatives.filter((rel) => rel.responsible)"
|
||||||
:key="relative.id"
|
:key="relative.id"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { withBase } from '~/models/_base'
|
import { withBase } from '~/models/_base'
|
||||||
import type { HeaderPrep } from '~/components/pub/my-ui/data/types'
|
import type { HeaderPrep } from '~/components/pub/my-ui/data/types'
|
||||||
import type { PatientEntity } from '~/models/patient'
|
import type { Patient } from '~/models/patient'
|
||||||
import type { Person } from '~/models/person'
|
import type { Person } from '~/models/person'
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
@@ -18,7 +18,7 @@ const props = defineProps<{
|
|||||||
|
|
||||||
// #region State & Computed
|
// #region State & Computed
|
||||||
const patient = ref(
|
const patient = ref(
|
||||||
withBase<PatientEntity>({
|
withBase<Patient>({
|
||||||
person: {} as Person,
|
person: {} as Person,
|
||||||
personAddresses: [],
|
personAddresses: [],
|
||||||
personContacts: [],
|
personContacts: [],
|
||||||
@@ -74,7 +74,7 @@ function handleAction(type: string) {
|
|||||||
class="mb-4 border-b-2 border-b-slate-300 pb-2 xl:mb-5"
|
class="mb-4 border-b-2 border-b-slate-300 pb-2 xl:mb-5"
|
||||||
/>
|
/>
|
||||||
<AppPatientPreview
|
<AppPatientPreview
|
||||||
:person="patient.person"
|
:patient="patient"
|
||||||
@click="handleAction"
|
@click="handleAction"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { PatientEntity, genPatientProps } from '~/models/patient'
|
import type { Patient, genPatientProps } from '~/models/patient'
|
||||||
import type { ExposedForm } from '~/types/form'
|
import type { ExposedForm } from '~/types/form'
|
||||||
import type { PatientBase } from '~/models/patient'
|
import type { PatientBase } from '~/models/patient'
|
||||||
import Action from '~/components/pub/my-ui/nav-footer/ba-dr-su.vue'
|
import Action from '~/components/pub/my-ui/nav-footer/ba-dr-su.vue'
|
||||||
@@ -16,7 +16,7 @@ import { postPatient } from '~/services/patient.service'
|
|||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
callbackUrl?: string
|
callbackUrl?: string
|
||||||
}>()
|
}>()
|
||||||
const payload = ref<PatientEntity>()
|
const payload = ref<Patient>()
|
||||||
|
|
||||||
// form related state
|
// form related state
|
||||||
const personAddressForm = ref<ExposedForm<any> | null>(null)
|
const personAddressForm = ref<ExposedForm<any> | null>(null)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export interface PatientBase extends Base {
|
|||||||
number?: string
|
number?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PatientEntity extends PatientBase {
|
export interface Patient extends PatientBase {
|
||||||
person: Person
|
person: Person
|
||||||
personAddresses: PersonAddress[]
|
personAddresses: PersonAddress[]
|
||||||
personContacts: PersonContact[]
|
personContacts: PersonContact[]
|
||||||
@@ -37,16 +37,16 @@ export interface genPatientProps {
|
|||||||
responsible: PersonRelativeFormData
|
responsible: PersonRelativeFormData
|
||||||
}
|
}
|
||||||
|
|
||||||
export function genPatient(props: genPatientProps): PatientEntity {
|
export function genPatient(props: genPatientProps): Patient {
|
||||||
const { patient, residentAddress, cardAddress, familyData, contacts, responsible } = props
|
const { patient, residentAddress, cardAddress, familyData, contacts, responsible } = props
|
||||||
|
|
||||||
const addresses: PersonAddress[] = [{ ...genBase(), person_id: 0, locationType: '', ...residentAddress }]
|
const addresses: PersonAddress[] = [{ ...genBase(), person_id: 0, ...residentAddress }]
|
||||||
const familiesContact: PersonRelative[] = []
|
const familiesContact: PersonRelative[] = []
|
||||||
const personContacts: PersonContact[] = []
|
const personContacts: PersonContact[] = []
|
||||||
|
|
||||||
// jika alamat ktp sama dengan domisili saat ini
|
// jika alamat ktp sama dengan domisili saat ini
|
||||||
if (cardAddress.isSameAddress) {
|
if (cardAddress.isSameAddress) {
|
||||||
addresses.push({ ...genBase(), person_id: 0, locationType: '', ...residentAddress })
|
addresses.push({ ...genBase(), ...residentAddress, person_id: 0, locationType: 'identity' })
|
||||||
}
|
}
|
||||||
|
|
||||||
// add data orang tua
|
// add data orang tua
|
||||||
|
|||||||
@@ -12,3 +12,4 @@ export interface PersonRelative {
|
|||||||
occupation_code?: string
|
occupation_code?: string
|
||||||
responsible?: boolean
|
responsible?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user