463 lines
13 KiB
JavaScript
463 lines
13 KiB
JavaScript
import { fetchWrapper } from "@/shared/fetchWrapper";
|
||
import { genderOptions } from "@/pages/newMedicalCard/utils/medicalConfig";
|
||
import { getConfidantObject } from "@/pages/newMedicalCard/utils/gettersObjects";
|
||
import toothFormula from "@/store/modules/toothFormula";
|
||
|
||
const state = () => ({
|
||
medicalCard: {},
|
||
confidantData: [],
|
||
contactsData: {
|
||
phones: [],
|
||
emails: [],
|
||
networks: [],
|
||
},
|
||
basicData: {
|
||
personalData: {
|
||
last_name: null,
|
||
first_name: null,
|
||
patronymic: null,
|
||
gender: null,
|
||
birth_date: null,
|
||
photo: null,
|
||
},
|
||
registrationAddress: {
|
||
region: null,
|
||
city: null,
|
||
street: null,
|
||
house_number: null,
|
||
apartment_number: null,
|
||
},
|
||
residenceAddress: {
|
||
region: null,
|
||
city: null,
|
||
street: null,
|
||
house_number: null,
|
||
apartment_number: null,
|
||
},
|
||
insuranceDMS: {
|
||
series: null,
|
||
number: null,
|
||
photo: null,
|
||
id: null,
|
||
organization: null,
|
||
},
|
||
insuranceOMS: {
|
||
series: null,
|
||
number: null,
|
||
photo: null,
|
||
id: null,
|
||
organization: null,
|
||
},
|
||
benefit: {
|
||
id: null,
|
||
discount: null,
|
||
name: null,
|
||
photo: null,
|
||
},
|
||
},
|
||
documents: {},
|
||
allergies: [],
|
||
avatar: "",
|
||
benefitData: [],
|
||
events: [],
|
||
protocolsList: [
|
||
{
|
||
id: 1,
|
||
employee: {
|
||
last_name: "Захаров",
|
||
first_name: "Алексей",
|
||
patronymic: "Сергеевич",
|
||
job_title: "Хирург",
|
||
photo: "",
|
||
},
|
||
start: "2023-03-23T13:00:00+03:00",
|
||
end: "2023-03-23T13:40:00+03:00",
|
||
status: "filled",
|
||
},
|
||
{
|
||
id: 2,
|
||
employee: {
|
||
last_name: "Лаврентьев",
|
||
first_name: "Сергей",
|
||
patronymic: "Анатольевич",
|
||
job_title: "Терапевт",
|
||
photo: "",
|
||
},
|
||
start: "2023-04-11T18:00:00+03:00",
|
||
end: "2023-04-11T18:30:00+03:00",
|
||
status: "partially filled",
|
||
},
|
||
{
|
||
id: 3,
|
||
employee: {
|
||
last_name: "Захаров",
|
||
first_name: "Алексей",
|
||
patronymic: "Сергеевич",
|
||
job_title: "Хирург",
|
||
photo: "",
|
||
},
|
||
start: "2021-08-23T10:00:00+03:00",
|
||
end: "2021-08-23T13:00:00+03:00",
|
||
status: "filled",
|
||
},
|
||
{
|
||
id: 4,
|
||
employee: {
|
||
last_name: "Щевьева",
|
||
first_name: "Лариса",
|
||
patronymic: "Николаевна",
|
||
job_title: "Ортодонт",
|
||
photo: "",
|
||
},
|
||
start: "2023-05-23T14:10:00+03:00",
|
||
end: "2023-05-23T15:10:00+03:00",
|
||
status: "",
|
||
},
|
||
{
|
||
id: 5,
|
||
employee: {
|
||
last_name: "Захаров",
|
||
first_name: "Алексей",
|
||
patronymic: "Сергеевич",
|
||
job_title: "Хирург",
|
||
photo: "",
|
||
},
|
||
start: "2022-01-23T13:10:00+03:00",
|
||
end: "2022-01-23T13:30:00+03:00",
|
||
status: "filled",
|
||
},
|
||
],
|
||
protocolData: null,
|
||
});
|
||
|
||
const getters = {
|
||
getBasicData(state, rootState) {
|
||
let registrationAddress =
|
||
state.medicalCard?.person?.address?.find((el) => el.registration_flg) ||
|
||
{};
|
||
let residenceAddress =
|
||
state?.medicalCard?.person?.address?.find((el) => el.residence_flg) || {};
|
||
let person = state.medicalCard.person;
|
||
let OMS = person?.insurance_policy?.find((e) => e.title === "OMS");
|
||
let DMS = person?.insurance_policy?.find((e) => e.title === "DMS");
|
||
return {
|
||
personalData: {
|
||
last_name: person?.last_name || "",
|
||
first_name: person?.first_name || "",
|
||
patronymic: person?.patronymic || "",
|
||
gender:
|
||
(person?.gender &&
|
||
genderOptions.find((el) => el.id === person?.gender)) ||
|
||
"",
|
||
birth_date: person?.birth_date ? new Date(person?.birth_date) : "",
|
||
photo: person?.photo
|
||
? {
|
||
photo: rootState.getUrl + person.photo,
|
||
file: null,
|
||
}
|
||
: {},
|
||
id: person?.id,
|
||
},
|
||
registrationAddress: {
|
||
region: registrationAddress?.region || "",
|
||
city: registrationAddress?.city || "",
|
||
street: registrationAddress?.street || "",
|
||
house_number: registrationAddress?.house_number || "",
|
||
apartment_number: registrationAddress?.apartment_number || "",
|
||
id: registrationAddress?.id || "",
|
||
},
|
||
residenceAddress: {
|
||
region: residenceAddress?.region || "",
|
||
city: residenceAddress?.city || "",
|
||
street: residenceAddress?.street || "",
|
||
house_number: residenceAddress?.house_number || "",
|
||
apartment_number: residenceAddress?.apartment_number || "",
|
||
id: residenceAddress?.id || "",
|
||
},
|
||
insuranceDMS: {
|
||
series: DMS?.series,
|
||
number: DMS?.number,
|
||
photo: DMS?.photo
|
||
? {
|
||
photo: rootState.getUrl + DMS?.photo,
|
||
file: null,
|
||
}
|
||
: {},
|
||
id: DMS?.id,
|
||
organization: DMS?.organization,
|
||
},
|
||
insuranceOMS: {
|
||
series: OMS?.series,
|
||
number: OMS?.number,
|
||
photo: OMS?.photo
|
||
? {
|
||
photo: rootState.getUrl + OMS?.photo,
|
||
file: null,
|
||
}
|
||
: {},
|
||
id: OMS?.id,
|
||
organization: OMS?.organization,
|
||
},
|
||
benefit: {
|
||
name: person?.benefit?.name,
|
||
id: person?.benefit?.id,
|
||
discount: person?.benefit?.discount,
|
||
photo: person?.photo_benefit
|
||
? {
|
||
photo: rootState.getUrl + person?.photo_benefit,
|
||
file: null,
|
||
}
|
||
: {},
|
||
},
|
||
};
|
||
},
|
||
getDocumentsData(state, rootState) {
|
||
let person = state.medicalCard?.person;
|
||
const passport = person?.identity_document.find(
|
||
(el) => el.kind === "PASSPORT"
|
||
);
|
||
return {
|
||
passport: {
|
||
id: passport?.id ?? "",
|
||
series: passport?.series ?? "",
|
||
number: passport?.number ?? "",
|
||
issued_by_org: passport?.issued_by_org ?? "",
|
||
issued_by_org_code: passport?.issued_by_org_code ?? "",
|
||
issued_by_date: passport?.issued_by_date
|
||
? new Date(passport?.issued_by_date)
|
||
: null,
|
||
photo: passport?.photo
|
||
? {
|
||
photo: rootState.getUrl + passport.photo,
|
||
file: null,
|
||
}
|
||
: {},
|
||
},
|
||
insurance_number: {
|
||
insurance_number: person?.insurance_number ?? "",
|
||
photo_insurance_number: person?.photo_insurance_number
|
||
? {
|
||
photo: rootState.getUrl + person.photo_insurance_number,
|
||
file: null,
|
||
}
|
||
: {},
|
||
},
|
||
tax_identification_number: {
|
||
tax_identification_number: person?.tax_identification_number ?? "",
|
||
photo_tax_identification_number: person?.photo_tax_identification_number
|
||
? {
|
||
photo: rootState.getUrl + person?.photo_tax_identification_number,
|
||
file: null,
|
||
}
|
||
: {},
|
||
},
|
||
};
|
||
},
|
||
getContactsData(state) {
|
||
let phones = state.medicalCard.person.contacts
|
||
.filter((el) => el.kind === "PHONE")
|
||
.map((el) => ({ ...el }));
|
||
let emails = state.medicalCard.person.contacts
|
||
.filter((el) => el.kind === "EMAIL")
|
||
.map((el) => ({ ...el }));
|
||
let networks = state.medicalCard.person.contacts
|
||
.filter((el) => el.kind !== "PHONE" && el.kind !== "EMAIL")
|
||
.map((el) => ({ ...el }));
|
||
return {
|
||
phones: [...phones],
|
||
emails: [...emails],
|
||
networks: [...networks],
|
||
};
|
||
},
|
||
getAllergiesData(state) {
|
||
return [...state.medicalCard.person.allergic.map((el) => ({ ...el }))];
|
||
},
|
||
getConfidantData(state) {
|
||
return [...state.medicalCard.confidant.map((el) => getConfidantObject(el))];
|
||
},
|
||
getAvatar(state) {
|
||
let lastName = state?.medicalCard?.person?.last_name;
|
||
let firstName = state?.medicalCard?.person?.first_name;
|
||
return lastName?.[0] + firstName?.[0];
|
||
},
|
||
getProtocolData() {
|
||
return {
|
||
bite: "distal bite",
|
||
hygieneIndex: 2,
|
||
KPUIndex: 6.1,
|
||
disease:
|
||
"Пациенту 20 лет. Неделю назад металлокерамический мостовидный протез с опорами на зубы 4.3 и 4.6 зафиксирован на временный цемент. Во время ортопедического лечения интактные зубы 4.3 и 4.6 были препарированы под местной анестезией, после препарирования зубы были защищены временным пластмассовым мостовидным протезом, боли в это время пациент не ощущал. Ноющая боль появилась на второй день после фиксации металлокерамического зубного протеза на временный цемент, интенсивность боли постепенно нарастает, усиливается от холодного. Пациент точно указывает, что боль локализуется в области зуба 4.3",
|
||
thermometry: {
|
||
cold: {
|
||
value: 22,
|
||
result: "Реакция нормальная",
|
||
},
|
||
heat: {
|
||
value: 50,
|
||
result: "Повышенная чувствительность",
|
||
},
|
||
},
|
||
tonometry: {
|
||
pulse: {
|
||
value: 84,
|
||
},
|
||
pressure: {
|
||
value: 120,
|
||
},
|
||
},
|
||
toothFormula: {
|
||
lacticBite: toothFormula.state.lacticBite,
|
||
formula: toothFormula.state.formula,
|
||
},
|
||
};
|
||
},
|
||
getInitProtocol() {
|
||
return {
|
||
bite: null,
|
||
hygieneIndex: null,
|
||
KPUIndex: null,
|
||
thermometry: {
|
||
cold: {
|
||
value: null,
|
||
result: null,
|
||
},
|
||
heat: {
|
||
value: null,
|
||
result: null,
|
||
},
|
||
},
|
||
tonometry: {
|
||
pulse: {
|
||
value: null,
|
||
},
|
||
pressure: {
|
||
value: null,
|
||
},
|
||
},
|
||
disease: null,
|
||
toothFormula: {
|
||
lacticBite: toothFormula.stateInit.lacticBite,
|
||
formula: toothFormula.stateInit.formula,
|
||
},
|
||
};
|
||
},
|
||
};
|
||
|
||
const actions = {
|
||
getBenefitData({ commit }) {
|
||
fetchWrapper.get("general/benefit/").then((res) => {
|
||
commit("setBenefitData", res.results);
|
||
});
|
||
},
|
||
getBenefitDataSearch({ commit }) {
|
||
fetchWrapper
|
||
.get(`general/benefit/?name=${localStorage.getItem("searchBenefit")}`)
|
||
.then((res) => {
|
||
commit("setBenefitData", res.results);
|
||
});
|
||
},
|
||
getMedicalCardData({ commit }) {
|
||
fetchWrapper
|
||
.get(
|
||
`medical_card/medical_history/${localStorage.getItem(
|
||
"medicalId"
|
||
)}/detail/`
|
||
)
|
||
.then((res) => {
|
||
commit("setMedicalCard", res);
|
||
commit("setBasicData");
|
||
commit("setContactsData");
|
||
commit("setDocumentsData");
|
||
commit("setAllergiesData");
|
||
commit("setConfidantData");
|
||
commit("setEventsPersonData", res.person.id);
|
||
});
|
||
},
|
||
getPersonsFiltredList() {
|
||
return fetchWrapper
|
||
.get(
|
||
`general/person/?last_name=${localStorage.getItem("searchConfidant")}`
|
||
)
|
||
.then((res) => res.results);
|
||
},
|
||
returnInitData({ commit }) {
|
||
commit("setBasicData");
|
||
commit("setContactsData");
|
||
commit("setAllergiesData");
|
||
commit("setConfidantData");
|
||
},
|
||
removeMedicalCardData({ commit, rootState }) {
|
||
fetchWrapper
|
||
.del(
|
||
`medical_card/medical_history/${localStorage.getItem(
|
||
"medicalId"
|
||
)}/delete/`
|
||
)
|
||
.then(() => {
|
||
rootState.routingHistory.back();
|
||
commit("setMedicalCard", {});
|
||
localStorage.removeItem("medicalId");
|
||
});
|
||
},
|
||
createProtocol({ commit, rootGetters, state }, data) {
|
||
data.employee = rootGetters.getUserData;
|
||
data.id = state.protocolsList.length + 1;
|
||
commit("setProtocolsList", data);
|
||
},
|
||
getProtocolData({ commit }, props) {
|
||
commit("setProtocolData", props);
|
||
},
|
||
};
|
||
|
||
const mutations = {
|
||
setBenefitData(state, data) {
|
||
state.benefitData = data;
|
||
},
|
||
setMedicalCard(state, card) {
|
||
state.medicalCard = card;
|
||
},
|
||
setBasicData(state) {
|
||
state.basicData = { ...this.getters.getBasicData };
|
||
},
|
||
setContactsData(state) {
|
||
state.contactsData = { ...this.getters.getContactsData };
|
||
},
|
||
setDocumentsData(state) {
|
||
state.documents = { ...this.getters.getDocumentsData };
|
||
},
|
||
setAllergiesData(state) {
|
||
state.allergies = this.getters.getAllergiesData;
|
||
},
|
||
setConfidantData(state) {
|
||
state.confidantData = this.getters.getConfidantData;
|
||
},
|
||
setEventsPersonData(state, id) {
|
||
fetchWrapper.get(`general/person/${id}/detail/`).then((res) => {
|
||
state.events = res.events;
|
||
});
|
||
},
|
||
setProtocolsList(state, data) {
|
||
state.protocolsList = [...state.protocolsList, data];
|
||
},
|
||
setProtocolData(state, props) {
|
||
if (props?.key) {
|
||
state.protocolData[props.key] = {
|
||
...JSON.parse(JSON.stringify(this.getters.getProtocolData[props.key])),
|
||
};
|
||
} else {
|
||
if (props.fillInspection) {
|
||
state.protocolData = this.getters.getInitProtocol;
|
||
} else {
|
||
state.protocolData = this.getters.getProtocolData;
|
||
}
|
||
}
|
||
},
|
||
};
|
||
|
||
export default {
|
||
state,
|
||
getters,
|
||
actions,
|
||
mutations,
|
||
};
|