Merge branch 'dev' into feat/consultation-82

This commit is contained in:
2025-10-19 06:27:59 +07:00
147 changed files with 5581 additions and 1460 deletions
+16
View File
@@ -0,0 +1,16 @@
import { type Base, genBase } from './_base'
export interface DiagnoseSrc extends Base {
code: string
name: string
indName: string
}
export function genDiagnoseSrc(): DiagnoseSrc {
return {
...genBase(),
code: '',
name: '',
indName: '',
}
}
+20
View File
@@ -0,0 +1,20 @@
import { type Base, genBase } from './_base'
import type { Regency } from './regency'
export interface District extends Base {
regency_code: string
code: string
name: string
// preload
regency?: Regency | null
}
export function genDistrict(): District {
return {
...genBase(),
regency_code: '',
name: '',
code: '',
}
}
+16
View File
@@ -0,0 +1,16 @@
import { type Base, genBase } from './_base'
export interface MedicalActionSrcItem extends Base {
medicalActionSrc_id: number
procedureSrc_id: number
item_id: number
}
export function genMedicalActionSrcItem(): MedicalActionSrcItem {
return {
...genBase(),
medicalActionSrc_id: 0,
procedureSrc_id: 0,
item_id: 0,
}
}
+19
View File
@@ -0,0 +1,19 @@
import { type Base, genBase } from './_base'
import type { medicalActionTypeCodeKey } from '~/lib/constants'
export interface MedicalActionSrc extends Base {
code: string
name: string
type_code: medicalActionTypeCodeKey
item_id: number
}
export function genMedicalActionSrc(): MedicalActionSrc {
return {
...genBase(),
code: '',
name: '',
type_code: '',
item_id: 0,
}
}
+32 -9
View File
@@ -21,7 +21,7 @@ export interface PatientBase extends Base {
number?: string
}
export interface PatientEntity extends PatientBase {
export interface Patient extends PatientBase {
person: Person
personAddresses: PersonAddress[]
personContacts: PersonContact[]
@@ -37,16 +37,39 @@ export interface genPatientProps {
responsible: PersonRelativeFormData
}
export function genPatient(props: genPatientProps): PatientEntity {
export function genPatient(props: genPatientProps): Patient {
console.log(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 personContacts: PersonContact[] = []
// jika alamat ktp sama dengan domisili saat ini
if (cardAddress.isSameAddress === '1') {
addresses.push({ ...genBase(), person_id: 0, locationType: '', ...residentAddress })
if (cardAddress.isSameAddress) {
addresses.push({
...genBase(),
...residentAddress,
person_id: 0,
locationType_code: cardAddress.locationType_code || 'identity'
})
} else {
// jika alamat berbeda, tambahkan alamat relatif
// Pastikan semua field yang diperlukan ada
const relativeAddress = {
...genBase(),
person_id: 0,
locationType_code: cardAddress.locationType_code || 'identity',
address: cardAddress.address || '',
province_code: cardAddress.province_code || '',
regency_code: cardAddress.regency_code || '',
district_code: cardAddress.district_code || '',
village_code: cardAddress.village_code || '',
postalRegion_code: cardAddress.postalRegion_code || '',
rt: cardAddress.rt,
rw: cardAddress.rw,
}
addresses.push(relativeAddress)
}
// add data orang tua
@@ -97,7 +120,7 @@ export function genPatient(props: genPatientProps): PatientEntity {
person: {
id: 0,
name: patient.fullName,
alias: patient.alias,
// alias: patient.alias,
birthDate: patient.birthDate,
birthRegency_code: patient.birthPlace,
gender_code: patient.gender,
@@ -111,7 +134,7 @@ export function genPatient(props: genPatientProps): PatientEntity {
ethnic_code: patient.ethnicity,
language_code: patient.language,
communicationIssueStatus: patient.communicationBarrier,
disability: patient.disability,
disability: patient.disabilityType || '',
nationality: patient.nationality,
// residentIdentityFileUrl: patient.residentIdentityFileUrl,
// passportFileUrl: patient.passportFileUrl,
@@ -126,10 +149,10 @@ export function genPatient(props: genPatientProps): PatientEntity {
personRelatives: familiesContact,
registeredAt: new Date(),
status_code: 'active',
newBornStatus: false,
newBornStatus: patient.isNewBorn,
person_id: 0,
id: 0,
number: '0x000000000000000000000000000000',
number: '',
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
deletedAt: null,
+31 -5
View File
@@ -1,21 +1,47 @@
import { type Base, genBase } from "./_base"
import { type Base, genBase } from './_base'
import type { AddressLocationTypeCode } from '~/lib/constants'
import type { PostalRegion } from './postal-region'
import { toTitleCase } from '~/lib/utils'
export interface PersonAddress extends Base {
person_id: number
locationType: string
locationType_code: AddressLocationTypeCode
address: string
rt?: string
rw?: string
postalCode?: string
postalRegion_code?: string
village_code: string
// preload
postalRegion?: PostalRegion | null
locationType?: AddressLocationTypeCode
}
export function genPersonAddress(): PersonAddress {
return {
...genBase(),
person_id: 0,
locationType: '',
locationType_code: '',
address: '',
village_code: '',
}
}
export function formatAddress(builder?: PersonAddress) {
if (!builder) return ''
const village = builder?.postalRegion?.village
const district = village?.district
const regency = district?.regency
const province = regency?.province
const parts = [
builder?.address,
village?.name,
district?.name,
toTitleCase(regency?.name || ''),
toTitleCase(province?.name || ''),
builder?.postalRegion_code,
].filter(Boolean)
return parts.join(', ')
}
+1
View File
@@ -12,3 +12,4 @@ export interface PersonRelative {
occupation_code?: string
responsible?: boolean
}
+16 -4
View File
@@ -1,10 +1,14 @@
import { type Base, genBase } from "./_base"
import { type Base, genBase } from './_base'
import type { Ethnic } from './ethnic'
import type { Language } from './language'
import type { PersonAddress } from './person-address'
import type { PersonContact } from './person-contact'
import type { PersonRelative } from './person-relative'
import type { Regency } from './regency'
export interface Person extends Base {
// todo: awaiting approve from stake holder: buat field sapaan
// todo: adjust field ketika person Balita
name: string
alias?: string
// alias?: string
frontTitle?: string
endTitle?: string
birthDate?: Date | string
@@ -26,6 +30,14 @@ export interface Person extends Base {
passportFileUrl?: string
drivingLicenseFileUrl?: string
familyIdentityFileUrl?: string
// preload data for detail patient
birthRegency?: Regency | null
addresses?: PersonAddress[] | null
contacts?: PersonContact[] | null
relatives?: PersonRelative[] | null
ethnic?: Ethnic | null
language?: Language | null
}
export function genPerson(): Person {
+18
View File
@@ -0,0 +1,18 @@
import { type Base, genBase } from './_base'
import type { Village } from './village'
export interface PostalRegion extends Base {
code: string
village_code: string
// preload
village?: Village | null
}
export function genPostalRegion(): PostalRegion {
return {
...genBase(),
code: '',
village_code: '',
}
}
+16
View File
@@ -0,0 +1,16 @@
import { type Base, genBase } from './_base'
export interface ProcedureSrc extends Base {
code: string
name: string
indName: string
}
export function genProcedureSrc(): ProcedureSrc {
return {
...genBase(),
code: '',
name: '',
indName: '',
}
}
+4 -1
View File
@@ -1,9 +1,12 @@
import { type Base, genBase } from "./_base"
import { type Base, genBase } from './_base'
import type { Province } from './province'
export interface Regency extends Base {
code: string
name: string
province_code: string
province?: Province | null
}
export function genRegency(): Regency {
+20
View File
@@ -0,0 +1,20 @@
import { type Base, genBase } from './_base'
import type { District } from './district'
export interface Village extends Base {
district_code: string
code: string
name: string
// preload
district?: District | null
}
export function genVillage(): Village {
return {
...genBase(),
district_code: '',
code: '',
name: '',
}
}