fix edit form state
fix: id list for contacts and address list fix warning fix duplicate contacts responsible: true fix edit family fix nik required
This commit is contained in:
@@ -15,7 +15,7 @@ import { contactTypeMapping } from '~/lib/constants'
|
||||
|
||||
export interface PatientBase extends Base {
|
||||
person_id?: number | null
|
||||
newBornStatus?: boolean
|
||||
newBornStatus?: boolean | string
|
||||
registeredAt?: Date | string | null
|
||||
status_code?: string | null
|
||||
number?: string | null
|
||||
@@ -40,6 +40,7 @@ export interface genPatientProps {
|
||||
export function genPatientEntity(props: genPatientProps, patientData: PatientEntity | null): PatientEntity {
|
||||
const { patient, residentAddress, cardAddress, familyData, contacts, responsible } = props
|
||||
|
||||
// const val = toRaw(patientData)
|
||||
const addresses: PersonAddress[] = [{ ...genBase(), person_id: patientData?.person?.id || 0, ...residentAddress }]
|
||||
const familiesContact: PersonRelative[] = []
|
||||
const personContacts: PersonContact[] = []
|
||||
@@ -49,6 +50,7 @@ export function genPatientEntity(props: genPatientProps, patientData: PatientEnt
|
||||
addresses.push({
|
||||
...genBase(),
|
||||
...residentAddress,
|
||||
id: cardAddress.id || 0,
|
||||
person_id: 0,
|
||||
locationType_code: cardAddress.locationType_code || 'identity',
|
||||
})
|
||||
@@ -57,6 +59,7 @@ export function genPatientEntity(props: genPatientProps, patientData: PatientEnt
|
||||
// Pastikan semua field yang diperlukan ada
|
||||
const relativeAddress = {
|
||||
...genBase(),
|
||||
id: cardAddress.id || 0,
|
||||
person_id: patientData?.person?.id || 0,
|
||||
locationType_code: cardAddress.locationType_code || 'identity',
|
||||
address: cardAddress.address || '',
|
||||
@@ -75,7 +78,7 @@ export function genPatientEntity(props: genPatientProps, patientData: PatientEnt
|
||||
if (familyData.shareFamilyData === '1') {
|
||||
for (const family of familyData.families) {
|
||||
familiesContact.push({
|
||||
id: 0,
|
||||
id: family.id || 0,
|
||||
relationship_code: family.relation,
|
||||
name: family.name,
|
||||
education_code: family.education,
|
||||
@@ -94,6 +97,7 @@ export function genPatientEntity(props: genPatientProps, patientData: PatientEnt
|
||||
|
||||
personContacts.push({
|
||||
...genBase(),
|
||||
id: contact.id || 0,
|
||||
person_id: patientData?.person?.id || 0,
|
||||
type_code: mappedContactType || '',
|
||||
value: contact.contactNumber,
|
||||
@@ -105,7 +109,7 @@ export function genPatientEntity(props: genPatientProps, patientData: PatientEnt
|
||||
if (responsible) {
|
||||
for (const contact of responsible.contacts) {
|
||||
familiesContact.push({
|
||||
id: 0,
|
||||
id: contact.id || 0,
|
||||
relationship_code: contact.relation,
|
||||
name: contact.name,
|
||||
address: contact.address,
|
||||
@@ -164,7 +168,7 @@ export function genPatientEntity(props: genPatientProps, patientData: PatientEnt
|
||||
export interface Patient extends Base {
|
||||
person_id?: number | null
|
||||
person: Person
|
||||
newBornStatus?: boolean
|
||||
newBornStatus?: boolean | string
|
||||
registeredAt?: Date | string | null
|
||||
status_code?: string | null
|
||||
number?: string | null
|
||||
|
||||
@@ -26,7 +26,7 @@ export interface Person extends Base {
|
||||
ethnic_code?: string | null
|
||||
language_code?: string | null
|
||||
nationality?: string | null
|
||||
communicationIssueStatus?: boolean
|
||||
communicationIssueStatus?: boolean | string
|
||||
disability?: string | null
|
||||
residentIdentityFileUrl?: string | null
|
||||
passportFileUrl?: string | null
|
||||
|
||||
Reference in New Issue
Block a user