delete useless pages
This commit is contained in:
@@ -1,101 +0,0 @@
|
||||
import { ref } from "vue";
|
||||
import type { OdontogramData } from "~/types/apps/medical/odontogram";
|
||||
|
||||
const STORAGE_KEY = "odontogramData";
|
||||
|
||||
const savedData = ref<OdontogramData | null>(null);
|
||||
|
||||
function saveData(data: OdontogramData) {
|
||||
try {
|
||||
// Convert reactive data to plain JS object before saving
|
||||
const plainData = JSON.parse(JSON.stringify(data));
|
||||
console.log("Saving odontogram data to localStorage (plain):", plainData);
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(plainData));
|
||||
savedData.value = plainData;
|
||||
} catch (error) {
|
||||
console.error("Failed to save odontogram data:", error);
|
||||
}
|
||||
}
|
||||
|
||||
function loadData(): OdontogramData | null {
|
||||
try {
|
||||
const data = localStorage.getItem(STORAGE_KEY);
|
||||
console.log("Loading odontogram data from localStorage:", data);
|
||||
if (data) {
|
||||
const parsed = JSON.parse(data);
|
||||
if (isOdontogramData(parsed)) {
|
||||
savedData.value = parsed;
|
||||
return parsed;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to load odontogram data:", error);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
const clearData = () => {
|
||||
try {
|
||||
localStorage.removeItem(STORAGE_KEY);
|
||||
savedData.value = null;
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error("Error clearing odontogram data:", error);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const exportData = (data: OdontogramData) => {
|
||||
const blob = new Blob([JSON.stringify(data, null, 2)], {
|
||||
type: "application/json"
|
||||
});
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = `odontogram_${new Date().toISOString().split("T")[0]}.json`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
};
|
||||
|
||||
const importData = (file: File): Promise<OdontogramData | null> => {
|
||||
return new Promise((resolve) => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = (e) => {
|
||||
try {
|
||||
const data = JSON.parse(e.target?.result as string);
|
||||
if (isOdontogramData(data)) {
|
||||
resolve(data);
|
||||
} else {
|
||||
console.error("Imported data is not valid OdontogramData");
|
||||
resolve(null);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error parsing imported data:", error);
|
||||
resolve(null);
|
||||
}
|
||||
};
|
||||
reader.readAsText(file);
|
||||
});
|
||||
};
|
||||
|
||||
function isOdontogramData(data: any): data is OdontogramData {
|
||||
return (
|
||||
data &&
|
||||
typeof data === "object" &&
|
||||
Array.isArray(data.conditions) &&
|
||||
typeof data.metadata === "object" &&
|
||||
data.metadata !== null &&
|
||||
(data.currentMode === undefined || typeof data.currentMode === "number")
|
||||
);
|
||||
}
|
||||
|
||||
export function useDataStorage() {
|
||||
return {
|
||||
saveData,
|
||||
loadData,
|
||||
clearData,
|
||||
exportData,
|
||||
importData,
|
||||
savedData
|
||||
};
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,131 +0,0 @@
|
||||
// composables/usePatientForm.ts
|
||||
import type { FhirPatient, FhirHumanName } from "~/types/fhir/humanName";
|
||||
|
||||
interface PatientFormData {
|
||||
dataDiri: {
|
||||
namaLengkap: string;
|
||||
jenisKelamin: string;
|
||||
tanggalLahir: string;
|
||||
nomorIdentitas: string;
|
||||
jenisIdentitas: string;
|
||||
fhirName?: FhirHumanName | null;
|
||||
};
|
||||
// ... other interfaces
|
||||
}
|
||||
|
||||
export const usePatientForm = () => {
|
||||
const convertToFhirPatient = (formData: PatientFormData): FhirPatient => {
|
||||
const fhirPatient: FhirPatient = {
|
||||
resourceType: "Patient",
|
||||
identifier: [],
|
||||
active: true,
|
||||
name: [],
|
||||
telecom: [],
|
||||
gender: undefined,
|
||||
birthDate: undefined,
|
||||
address: []
|
||||
};
|
||||
|
||||
// Add parsed FHIR name
|
||||
if (formData.dataDiri.fhirName) {
|
||||
fhirPatient.name!.push(formData.dataDiri.fhirName);
|
||||
}
|
||||
|
||||
// Gender mapping
|
||||
if (formData.dataDiri.jenisKelamin) {
|
||||
fhirPatient.gender =
|
||||
formData.dataDiri.jenisKelamin === "L" ? "male" : "female";
|
||||
}
|
||||
|
||||
// Birth date
|
||||
if (formData.dataDiri.tanggalLahir) {
|
||||
fhirPatient.birthDate = formData.dataDiri.tanggalLahir;
|
||||
}
|
||||
|
||||
// Identifiers
|
||||
if (formData.dataDiri.nomorIdentitas) {
|
||||
fhirPatient.identifier!.push({
|
||||
use: "official",
|
||||
type: {
|
||||
coding: [
|
||||
{
|
||||
system: "http://terminology.hl7.org/CodeSystem/v2-0203",
|
||||
code:
|
||||
formData.dataDiri.jenisIdentitas === "KTP" ? "NNESP" : "PPN",
|
||||
display: formData.dataDiri.jenisIdentitas
|
||||
}
|
||||
]
|
||||
},
|
||||
value: formData.dataDiri.nomorIdentitas
|
||||
});
|
||||
}
|
||||
|
||||
return fhirPatient;
|
||||
};
|
||||
|
||||
return {
|
||||
convertToFhirPatient
|
||||
};
|
||||
};
|
||||
interface PersonalInfo {
|
||||
nik?: string;
|
||||
fullName?: string;
|
||||
birthPlace?: string;
|
||||
birthDate?: string;
|
||||
gender?: string;
|
||||
}
|
||||
|
||||
interface ContactInfo {
|
||||
phone?: string;
|
||||
address?: string;
|
||||
province?: string;
|
||||
city?: string;
|
||||
}
|
||||
|
||||
// export const usePatientForm = () => {
|
||||
// const validatePersonalInfo = (data: PersonalInfo) => {
|
||||
// const errors: Record<string, string> = {};
|
||||
|
||||
// if (!data.nik) errors.nik = "NIK wajib diisi";
|
||||
// if (!data.fullName) errors.fullName = "Nama lengkap wajib diisi";
|
||||
// if (!data.birthPlace) errors.birthPlace = "Tempat lahir wajib diisi";
|
||||
// if (!data.birthDate) errors.birthDate = "Tanggal lahir wajib diisi";
|
||||
// if (!data.gender) errors.gender = "Jenis kelamin wajib diisi";
|
||||
|
||||
// return {
|
||||
// valid: Object.keys(errors).length === 0,
|
||||
// errors
|
||||
// };
|
||||
// };
|
||||
|
||||
// const validateContactInfo = (data: ContactInfo) => {
|
||||
// const errors: Record<string, string> = {};
|
||||
|
||||
// if (!data.phone) errors.phone = "Nomor telepon wajib diisi";
|
||||
// if (!data.address) errors.address = "Alamat wajib diisi";
|
||||
// if (!data.province) errors.province = "Provinsi wajib diisi";
|
||||
// if (!data.city) errors.city = "Kota wajib diisi";
|
||||
|
||||
// return {
|
||||
// valid: Object.keys(errors).length === 0,
|
||||
// errors
|
||||
// };
|
||||
// };
|
||||
|
||||
// const generateMRNumber = () => {
|
||||
// const date = new Date();
|
||||
// const year = date.getFullYear().toString().substr(-2);
|
||||
// const month = (date.getMonth() + 1).toString().padStart(2, "0");
|
||||
// const random = Math.floor(Math.random() * 10000)
|
||||
// .toString()
|
||||
// .padStart(4, "0");
|
||||
|
||||
// return `MR${year}${month}${random}`;
|
||||
// };
|
||||
|
||||
// return {
|
||||
// validatePersonalInfo,
|
||||
// validateContactInfo,
|
||||
// generateMRNumber
|
||||
// };
|
||||
// };
|
||||
Reference in New Issue
Block a user