Compare commits
No commits in common. "1541aba89f716dfd33b7ec7b18a2322231423562" and "79e352037b68269a38207d8092d13283b2d836ba" have entirely different histories.
1541aba89f
...
79e352037b
@ -1,22 +1,10 @@
|
|||||||
FROM python:3.10-slim
|
FROM python:3.10-slim
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y \
|
|
||||||
lsb-release \
|
|
||||||
wget \
|
|
||||||
gnupg \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
RUN echo "deb http://apt.postgresql.org/pub/repos/apt bookworm-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
|
|
||||||
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
|
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
libpq-dev \
|
libpq-dev \
|
||||||
libmagic1 \
|
libmagic1 \
|
||||||
postgresql-client-17 \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
RUN mkdir -p /app/backups && chmod 777 /app/backups
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY req.txt .
|
COPY req.txt .
|
||||||
|
|||||||
@ -76,15 +76,6 @@ class LensIssuesRepository:
|
|||||||
|
|
||||||
return issues, total_count
|
return issues, total_count
|
||||||
|
|
||||||
async def get_by_patient_id(self, patient_id: int) -> Sequence[LensIssue]:
|
|
||||||
stmt = (
|
|
||||||
select(LensIssue)
|
|
||||||
.filter_by(patient_id=patient_id)
|
|
||||||
.options(joinedload(LensIssue.lens))
|
|
||||||
)
|
|
||||||
result = await self.db.execute(stmt)
|
|
||||||
return result.scalars().all()
|
|
||||||
|
|
||||||
async def get_by_id(self, lens_issue_id: int) -> Optional[LensIssue]:
|
async def get_by_id(self, lens_issue_id: int) -> Optional[LensIssue]:
|
||||||
stmt = select(LensIssue).filter_by(id=lens_issue_id)
|
stmt = select(LensIssue).filter_by(id=lens_issue_id)
|
||||||
result = await self.db.execute(stmt)
|
result = await self.db.execute(stmt)
|
||||||
|
|||||||
@ -44,22 +44,6 @@ async def get_all_lens_issues(
|
|||||||
total_count=total_count
|
total_count=total_count
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.get(
|
|
||||||
'/by-patient/{patient_id}/',
|
|
||||||
response_model=list[LensIssueEntity],
|
|
||||||
summary="Get lens issues by patients id",
|
|
||||||
description="Returns a paginated list of lens issues by patients id",
|
|
||||||
)
|
|
||||||
async def get_lens_issues_by_patient(
|
|
||||||
patient_id: int,
|
|
||||||
db: AsyncSession = Depends(get_db),
|
|
||||||
user=Depends(get_current_user),
|
|
||||||
):
|
|
||||||
lens_issues_service = LensIssuesService(db)
|
|
||||||
return await lens_issues_service.get_lens_issues_by_patient_id(patient_id)
|
|
||||||
|
|
||||||
|
|
||||||
@router.post(
|
@router.post(
|
||||||
"/",
|
"/",
|
||||||
response_model=LensIssueEntity,
|
response_model=LensIssueEntity,
|
||||||
|
|||||||
@ -11,5 +11,5 @@ class AppointmentType(BaseModel):
|
|||||||
|
|
||||||
title = Column(VARCHAR(150), nullable=False, unique=True)
|
title = Column(VARCHAR(150), nullable=False, unique=True)
|
||||||
|
|
||||||
appointments = relationship('Appointment', back_populates='type', cascade="all, delete")
|
appointments = relationship('Appointment', back_populates='type')
|
||||||
scheduled_appointments = relationship('ScheduledAppointment', back_populates='type', cascade="all, delete")
|
scheduled_appointments = relationship('ScheduledAppointment', back_populates='type')
|
||||||
|
|||||||
@ -22,4 +22,4 @@ class Appointment(BaseModel):
|
|||||||
doctor = relationship('User', back_populates='appointments')
|
doctor = relationship('User', back_populates='appointments')
|
||||||
type = relationship('AppointmentType', back_populates='appointments')
|
type = relationship('AppointmentType', back_populates='appointments')
|
||||||
|
|
||||||
files = relationship('AppointmentFile', back_populates='appointment', cascade="all, delete")
|
files = relationship('AppointmentFile', back_populates='appointment')
|
||||||
|
|||||||
@ -30,4 +30,4 @@ class Lens(BaseModel):
|
|||||||
|
|
||||||
type = relationship('LensType', back_populates='lenses')
|
type = relationship('LensType', back_populates='lenses')
|
||||||
|
|
||||||
lens_issues = relationship('LensIssue', back_populates='lens', cascade="all, delete")
|
lens_issues = relationship('LensIssue', back_populates='lens')
|
||||||
|
|||||||
@ -11,5 +11,5 @@ class LensType(BaseModel):
|
|||||||
|
|
||||||
title = Column(VARCHAR(150), nullable=False, unique=True)
|
title = Column(VARCHAR(150), nullable=False, unique=True)
|
||||||
|
|
||||||
lenses = relationship('Lens', back_populates='type', cascade="all, delete")
|
lenses = relationship('Lens', back_populates='type')
|
||||||
contents = relationship('SetContent', back_populates='type', cascade="all, delete")
|
contents = relationship('SetContent', back_populates='type')
|
||||||
|
|||||||
@ -18,5 +18,5 @@ class Mailing(BaseModel):
|
|||||||
|
|
||||||
user = relationship('User', back_populates='mailing')
|
user = relationship('User', back_populates='mailing')
|
||||||
|
|
||||||
recipients = relationship('Recipient', back_populates='mailing', cascade="all, delete")
|
recipients = relationship('Recipient', back_populates='mailing')
|
||||||
mailing_options = relationship('MailingOption', back_populates='mailing', cascade="all, delete")
|
mailing_options = relationship('MailingOption', back_populates='mailing')
|
||||||
|
|||||||
@ -11,4 +11,4 @@ class MailingDeliveryMethod(BaseModel):
|
|||||||
|
|
||||||
title = Column(VARCHAR(200), nullable=False)
|
title = Column(VARCHAR(200), nullable=False)
|
||||||
|
|
||||||
mailing = relationship('MailingOption', back_populates='method', cascade="all, delete")
|
mailing = relationship('MailingOption', back_populates='method')
|
||||||
|
|||||||
@ -13,5 +13,5 @@ class MailingOption(BaseModel):
|
|||||||
nullable=False)
|
nullable=False)
|
||||||
mailing_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.mailing.id', ondelete='CASCADE'), nullable=False)
|
mailing_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.mailing.id', ondelete='CASCADE'), nullable=False)
|
||||||
|
|
||||||
method = relationship('MailingDeliveryMethod', back_populates='mailing', cascade="all, delete")
|
method = relationship('MailingDeliveryMethod', back_populates='mailing')
|
||||||
mailing = relationship('Mailing', back_populates='mailing_options', cascade="all, delete")
|
mailing = relationship('Mailing', back_populates='mailing_options')
|
||||||
|
|||||||
@ -19,7 +19,7 @@ class Patient(BaseModel):
|
|||||||
diagnosis = Column(String)
|
diagnosis = Column(String)
|
||||||
correction = Column(String)
|
correction = Column(String)
|
||||||
|
|
||||||
lens_issues = relationship('LensIssue', back_populates='patient', cascade="all, delete")
|
lens_issues = relationship('LensIssue', back_populates='patient')
|
||||||
appointments = relationship('Appointment', back_populates='patient', cascade="all, delete")
|
appointments = relationship('Appointment', back_populates='patient')
|
||||||
mailing = relationship('Recipient', back_populates='patient', cascade="all, delete")
|
mailing = relationship('Recipient', back_populates='patient')
|
||||||
scheduled_appointments = relationship('ScheduledAppointment', back_populates='patient', cascade="all, delete")
|
scheduled_appointments = relationship('ScheduledAppointment', back_populates='patient')
|
||||||
|
|||||||
@ -12,5 +12,5 @@ class Recipient(BaseModel):
|
|||||||
patient_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.patients.id', ondelete='CASCADE'), nullable=False)
|
patient_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.patients.id', ondelete='CASCADE'), nullable=False)
|
||||||
mailing_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.mailing.id', ondelete='CASCADE'), nullable=False)
|
mailing_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.mailing.id', ondelete='CASCADE'), nullable=False)
|
||||||
|
|
||||||
patient = relationship('Patient', back_populates='mailing', cascade="all, delete")
|
patient = relationship('Patient', back_populates='mailing')
|
||||||
mailing = relationship('Mailing', back_populates='recipients', cascade="all, delete")
|
mailing = relationship('Mailing', back_populates='recipients')
|
||||||
|
|||||||
@ -11,4 +11,4 @@ class Set(BaseModel):
|
|||||||
|
|
||||||
title = Column(VARCHAR(150), nullable=False, unique=True)
|
title = Column(VARCHAR(150), nullable=False, unique=True)
|
||||||
|
|
||||||
contents = relationship('SetContent', back_populates='set', cascade="all, delete")
|
contents = relationship('SetContent', back_populates='set')
|
||||||
|
|||||||
@ -1,14 +1,16 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import tarfile
|
import tarfile
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
from fastapi_maintenance import maintenance_mode_on
|
||||||
|
|
||||||
import aiofiles
|
import aiofiles
|
||||||
import magic
|
|
||||||
from fastapi import HTTPException, UploadFile
|
from fastapi import HTTPException, UploadFile
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from magic import magic
|
||||||
|
from sqlalchemy.ext.asyncio import AsyncSession, AsyncEngine
|
||||||
from starlette.responses import FileResponse
|
from starlette.responses import FileResponse
|
||||||
from werkzeug.utils import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
|
|
||||||
|
|||||||
@ -45,24 +45,6 @@ class LensIssuesService:
|
|||||||
total_count
|
total_count
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get_lens_issues_by_patient_id(self, patient_id: int) -> list[LensIssueEntity]:
|
|
||||||
patient = await self.patient_repository.get_by_id(patient_id)
|
|
||||||
|
|
||||||
if not patient:
|
|
||||||
raise HTTPException(
|
|
||||||
status_code=status.HTTP_400_BAD_REQUEST,
|
|
||||||
detail='Пациент с таким ID не найден',
|
|
||||||
)
|
|
||||||
|
|
||||||
lens_issues = await self.lens_issues_repository.get_by_patient_id(patient.id)
|
|
||||||
|
|
||||||
print(lens_issues)
|
|
||||||
|
|
||||||
return [
|
|
||||||
self.model_to_entity(lens_issue)
|
|
||||||
for lens_issue in lens_issues
|
|
||||||
]
|
|
||||||
|
|
||||||
async def create_lens_issue(self, lens_issue: LensIssueEntity, user_id: int) -> Optional[LensIssueEntity]:
|
async def create_lens_issue(self, lens_issue: LensIssueEntity, user_id: int) -> Optional[LensIssueEntity]:
|
||||||
patient = await self.patient_repository.get_by_id(lens_issue.patient_id)
|
patient = await self.patient_repository.get_by_id(lens_issue.patient_id)
|
||||||
|
|
||||||
|
|||||||
@ -19,13 +19,6 @@ spec:
|
|||||||
ports:
|
ports:
|
||||||
- containerPort: {{ .Values.service.port }}
|
- containerPort: {{ .Values.service.port }}
|
||||||
env:
|
env:
|
||||||
- name: PG_DUMP_PATH
|
|
||||||
value: "{{ .Values.env.PG_DUMP_PATH }}"
|
|
||||||
- name: BACKUP_DB_URL
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: visus-api-secret
|
|
||||||
key: BACKUP_DB_URL
|
|
||||||
- name: SECRET_KEY
|
- name: SECRET_KEY
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
|
|||||||
@ -33,4 +33,3 @@ env:
|
|||||||
LOG_LEVEL: info
|
LOG_LEVEL: info
|
||||||
LOG_FILE: logs/app.log
|
LOG_FILE: logs/app.log
|
||||||
ALGORITHM: HS256
|
ALGORITHM: HS256
|
||||||
PG_DUMP_PATH: pg_dump
|
|
||||||
@ -13,5 +13,3 @@ python-magic==0.4.27
|
|||||||
aiofiles==24.1.0
|
aiofiles==24.1.0
|
||||||
python-multipart==0.0.20
|
python-multipart==0.0.20
|
||||||
fastapi-maintenance==0.0.4
|
fastapi-maintenance==0.0.4
|
||||||
python-magic==0.4.27
|
|
||||||
libmagic==1.0
|
|
||||||
@ -46,15 +46,10 @@ export const lensIssuesApi = createApi({
|
|||||||
}),
|
}),
|
||||||
invalidatesTags: ['LensIssues'],
|
invalidatesTags: ['LensIssues'],
|
||||||
}),
|
}),
|
||||||
getLensIssuesByPatient: builder.query({
|
|
||||||
query: (patientId) => `/lens_issues/by-patient/${patientId}/`,
|
|
||||||
providesTags: ['LensIssues'],
|
|
||||||
}),
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const {
|
export const {
|
||||||
useGetLensIssuesQuery,
|
useGetLensIssuesQuery,
|
||||||
useAddLensIssuesMutation,
|
useAddLensIssuesMutation,
|
||||||
useGetLensIssuesByPatientQuery,
|
|
||||||
} = lensIssuesApi;
|
} = lensIssuesApi;
|
||||||
@ -1,21 +0,0 @@
|
|||||||
import { useGetLensIssuesByPatientQuery } from "../../../../../Api/lensIssuesApi.js";
|
|
||||||
|
|
||||||
const usePatientsViewModal = (patient, visible) => {
|
|
||||||
const {
|
|
||||||
data: lensIssues = [],
|
|
||||||
isLoading: isLensIssuesLoading,
|
|
||||||
isError: isLensIssuesError,
|
|
||||||
} = useGetLensIssuesByPatientQuery(patient?.id, {
|
|
||||||
skip: !visible || !patient?.id,
|
|
||||||
pollingInterval: 60000,
|
|
||||||
refetchOnMountOrArgChange: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
lensIssues,
|
|
||||||
isLensIssuesLoading,
|
|
||||||
isLensIssuesError,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export default usePatientsViewModal;
|
|
||||||
Loading…
x
Reference in New Issue
Block a user