提交
This commit is contained in:
1 parent
575e63e7e8
commit
771f010a39
165 files changed
+67359
-21698
No files matched your search
@@ -18,6 +18,11 @@ from app.api.material import router as material_router
|
||||
from app.api.storage_release_review import router as storage_release_review_router
|
||||
from app.api.sample_sms_notification import router as sample_sms_notification_router
|
||||
from app.api.storage_entry_sms_notification import router as storage_entry_sms_notification_router
|
||||
from app.api.pilot_application import router as pilot_application_router
|
||||
from app.api.pilot_checkup import router as pilot_checkup_router
|
||||
from app.api.pilot_delivery import router as pilot_delivery_router
|
||||
from app.api.pilot_infusion_confirm import router as pilot_infusion_confirm_router
|
||||
from app.api.outbound_release_review import router as outbound_release_review_router
|
||||
|
||||
__all__ = [
|
||||
"public_router",
|
||||
@@ -39,4 +44,9 @@ __all__ = [
|
||||
"storage_release_review_router",
|
||||
"sample_sms_notification_router",
|
||||
"storage_entry_sms_notification_router",
|
||||
"pilot_application_router",
|
||||
"pilot_checkup_router",
|
||||
"pilot_delivery_router",
|
||||
"pilot_infusion_confirm_router",
|
||||
"outbound_release_review_router",
|
||||
]
|
||||
@@ -69,11 +69,20 @@ class CustomerUpdateBody(BaseModel):
|
||||
remark: Optional[str] = None
|
||||
|
||||
|
||||
def _normalize_date_bound(value: str, *, end_of_day: bool = False) -> str:
|
||||
val = (value or "").strip()
|
||||
if len(val) == 10:
|
||||
return f"{val} 23:59:59" if end_of_day else f"{val} 00:00:00"
|
||||
return val
|
||||
|
||||
|
||||
@router.get("/customers")
|
||||
async def list_customers(
|
||||
page: int = Query(1, ge=1),
|
||||
pageSize: int = Query(10, ge=1, le=100, alias="pageSize"),
|
||||
keyword: Optional[str] = None,
|
||||
createTimeStart: Optional[str] = Query(None, alias="createTimeStart"),
|
||||
createTimeEnd: Optional[str] = Query(None, alias="createTimeEnd"),
|
||||
user: dict = Depends(require_menu_code("biz:customer:list")),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
@@ -94,6 +103,14 @@ async def list_customers(
|
||||
BizCustomer.customer_tags.like(like),
|
||||
)
|
||||
)
|
||||
if createTimeStart:
|
||||
query = query.filter(
|
||||
BizCustomer.create_time >= _normalize_date_bound(createTimeStart)
|
||||
)
|
||||
if createTimeEnd:
|
||||
query = query.filter(
|
||||
BizCustomer.create_time <= _normalize_date_bound(createTimeEnd, end_of_day=True)
|
||||
)
|
||||
query = apply_data_scope(query, BizCustomer, user, db, tenant_no)
|
||||
total = query.count()
|
||||
items = query.order_by(BizCustomer.create_time.desc()).offset((page - 1) * pageSize).limit(pageSize).all()
|
||||
|
||||
@@ -118,6 +118,10 @@ async def list_collection_protocols(
|
||||
pageSize: int = Query(10, ge=1, le=100, alias="pageSize"),
|
||||
keyword: Optional[str] = None,
|
||||
protocolStatus: Optional[str] = Query(None, alias="protocolStatus"),
|
||||
createTimeStart: Optional[str] = Query(None, alias="createTimeStart"),
|
||||
createTimeEnd: Optional[str] = Query(None, alias="createTimeEnd"),
|
||||
sampleCollectTimeStart: Optional[str] = Query(None, alias="sampleCollectTimeStart"),
|
||||
sampleCollectTimeEnd: Optional[str] = Query(None, alias="sampleCollectTimeEnd"),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
@@ -129,6 +133,10 @@ async def list_collection_protocols(
|
||||
page_size=pageSize,
|
||||
keyword=keyword,
|
||||
protocol_status=protocolStatus,
|
||||
create_time_start=createTimeStart,
|
||||
create_time_end=createTimeEnd,
|
||||
sample_collect_time_start=sampleCollectTimeStart,
|
||||
sample_collect_time_end=sampleCollectTimeEnd,
|
||||
tenant_no=tenant_no,
|
||||
scope_collector_user_id=current_user_id,
|
||||
user_info=user,
|
||||
@@ -427,6 +435,8 @@ async def list_payment_details(
|
||||
payStatus: str = Query("dfj", alias="payStatus"),
|
||||
keyword: str = Query("", alias="keyword"),
|
||||
transferType: str = Query("", alias="transferType"),
|
||||
installmentDueDateStart: Optional[str] = Query(None, alias="installmentDueDateStart"),
|
||||
installmentDueDateEnd: Optional[str] = Query(None, alias="installmentDueDateEnd"),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
@@ -438,6 +448,8 @@ async def list_payment_details(
|
||||
pay_status=payStatus,
|
||||
keyword=keyword or None,
|
||||
transfer_type=transferType or None,
|
||||
installment_due_date_start=installmentDueDateStart,
|
||||
installment_due_date_end=installmentDueDateEnd,
|
||||
tenant_no=tenant_no,
|
||||
user_info=user,
|
||||
)
|
||||
@@ -552,11 +564,23 @@ async def post_submit_refund_finance_batch(
|
||||
async def list_receipt_confirm(
|
||||
page: int = Query(1, ge=1),
|
||||
pageSize: int = Query(10, ge=1, le=100, alias="pageSize"),
|
||||
keyword: Optional[str] = None,
|
||||
installmentDueDateStart: Optional[str] = Query(None, alias="installmentDueDateStart"),
|
||||
installmentDueDateEnd: Optional[str] = Query(None, alias="installmentDueDateEnd"),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
items, total = cp_svc.list_receipt_confirm_details(db, page=page, page_size=pageSize, tenant_no=tenant_no, user_info=user)
|
||||
items, total = cp_svc.list_receipt_confirm_details(
|
||||
db,
|
||||
page=page,
|
||||
page_size=pageSize,
|
||||
keyword=keyword or None,
|
||||
installment_due_date_start=installmentDueDateStart,
|
||||
installment_due_date_end=installmentDueDateEnd,
|
||||
tenant_no=tenant_no,
|
||||
user_info=user,
|
||||
)
|
||||
tp = cp_svc.total_pages(total, pageSize)
|
||||
return success_response({"list": items, "total": total, "page": page, "pageSize": pageSize, "totalPages": tp})
|
||||
|
||||
@@ -565,12 +589,22 @@ async def list_receipt_confirm(
|
||||
async def list_receipt_confirmed(
|
||||
page: int = Query(1, ge=1),
|
||||
pageSize: int = Query(10, ge=1, le=100, alias="pageSize"),
|
||||
keyword: Optional[str] = None,
|
||||
installmentDueDateStart: Optional[str] = Query(None, alias="installmentDueDateStart"),
|
||||
installmentDueDateEnd: Optional[str] = Query(None, alias="installmentDueDateEnd"),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
items, total = cp_svc.list_receipt_confirmed_details(
|
||||
db, page=page, page_size=pageSize, tenant_no=tenant_no, user_info=user
|
||||
db,
|
||||
page=page,
|
||||
page_size=pageSize,
|
||||
keyword=keyword or None,
|
||||
installment_due_date_start=installmentDueDateStart,
|
||||
installment_due_date_end=installmentDueDateEnd,
|
||||
tenant_no=tenant_no,
|
||||
user_info=user,
|
||||
)
|
||||
tp = cp_svc.total_pages(total, pageSize)
|
||||
return success_response({"list": items, "total": total, "page": page, "pageSize": pageSize, "totalPages": tp})
|
||||
@@ -623,11 +657,23 @@ async def post_receipt_confirm(
|
||||
async def list_refund_confirm(
|
||||
page: int = Query(1, ge=1),
|
||||
pageSize: int = Query(10, ge=1, le=100, alias="pageSize"),
|
||||
keyword: Optional[str] = None,
|
||||
installmentDueDateStart: Optional[str] = Query(None, alias="installmentDueDateStart"),
|
||||
installmentDueDateEnd: Optional[str] = Query(None, alias="installmentDueDateEnd"),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
items, total = cp_svc.list_refund_confirm_details(db, page=page, page_size=pageSize, tenant_no=tenant_no, user_info=user)
|
||||
items, total = cp_svc.list_refund_confirm_details(
|
||||
db,
|
||||
page=page,
|
||||
page_size=pageSize,
|
||||
keyword=keyword or None,
|
||||
installment_due_date_start=installmentDueDateStart,
|
||||
installment_due_date_end=installmentDueDateEnd,
|
||||
tenant_no=tenant_no,
|
||||
user_info=user,
|
||||
)
|
||||
tp = cp_svc.total_pages(total, pageSize)
|
||||
return success_response({"list": items, "total": total, "page": page, "pageSize": pageSize, "totalPages": tp})
|
||||
|
||||
@@ -636,12 +682,22 @@ async def list_refund_confirm(
|
||||
async def list_refund_confirmed(
|
||||
page: int = Query(1, ge=1),
|
||||
pageSize: int = Query(10, ge=1, le=100, alias="pageSize"),
|
||||
keyword: Optional[str] = None,
|
||||
installmentDueDateStart: Optional[str] = Query(None, alias="installmentDueDateStart"),
|
||||
installmentDueDateEnd: Optional[str] = Query(None, alias="installmentDueDateEnd"),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
items, total = cp_svc.list_refund_confirmed_details(
|
||||
db, page=page, page_size=pageSize, tenant_no=tenant_no, user_info=user
|
||||
db,
|
||||
page=page,
|
||||
page_size=pageSize,
|
||||
keyword=keyword or None,
|
||||
installment_due_date_start=installmentDueDateStart,
|
||||
installment_due_date_end=installmentDueDateEnd,
|
||||
tenant_no=tenant_no,
|
||||
user_info=user,
|
||||
)
|
||||
tp = cp_svc.total_pages(total, pageSize)
|
||||
return success_response({"list": items, "total": total, "page": page, "pageSize": pageSize, "totalPages": tp})
|
||||
@@ -680,6 +736,8 @@ async def list_storage_certs(
|
||||
pageSize: int = Query(10, ge=1, le=100, alias="pageSize"),
|
||||
keyword: Optional[str] = None,
|
||||
makeStatus: Optional[str] = Query(None, alias="makeStatus"),
|
||||
storageInDateStart: Optional[str] = Query(None, alias="storageInDateStart"),
|
||||
storageInDateEnd: Optional[str] = Query(None, alias="storageInDateEnd"),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
@@ -689,6 +747,8 @@ async def list_storage_certs(
|
||||
tenant_no=tenant_no,
|
||||
keyword=keyword,
|
||||
make_status=makeStatus,
|
||||
storage_in_date_start=storageInDateStart,
|
||||
storage_in_date_end=storageInDateEnd,
|
||||
page=page,
|
||||
page_size=pageSize,
|
||||
user_info=user,
|
||||
@@ -707,6 +767,8 @@ async def list_fullmoon_todos(
|
||||
pageSize: int = Query(10, ge=1, le=100, alias="pageSize"),
|
||||
keyword: Optional[str] = None,
|
||||
todoStatus: Optional[str] = Query(None, alias="todoStatus"),
|
||||
fullmoonDateStart: Optional[str] = Query(None, alias="fullmoonDateStart"),
|
||||
fullmoonDateEnd: Optional[str] = Query(None, alias="fullmoonDateEnd"),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
@@ -784,6 +846,15 @@ async def list_fullmoon_todos(
|
||||
ts = (ft.todo_status or "0") if ft else "0"
|
||||
if todoStatus and todoStatus.strip() and ts != todoStatus.strip():
|
||||
continue
|
||||
fm_start = (fullmoonDateStart or "").strip()[:10]
|
||||
fm_end = (fullmoonDateEnd or "").strip()[:10]
|
||||
if fm_start or fm_end:
|
||||
if not fullmoon_date_str:
|
||||
continue
|
||||
if fm_start and fullmoon_date_str < fm_start:
|
||||
continue
|
||||
if fm_end and fullmoon_date_str > fm_end:
|
||||
continue
|
||||
ft_dict = cp_svc._fullmoon_todo_to_dict(ft) if ft else dict(_empty_ft)
|
||||
items.append(
|
||||
{
|
||||
|
||||
@@ -731,11 +731,20 @@ class ExhibitionAppointmentUpdateBody(BaseModel):
|
||||
remark: Optional[str] = None
|
||||
|
||||
|
||||
def _normalize_visit_date_bound(value: str, *, end_of_day: bool = False) -> str:
|
||||
val = (value or "").strip()
|
||||
if len(val) == 10:
|
||||
return f"{val} 23:59:59" if end_of_day else f"{val} 00:00:00"
|
||||
return val
|
||||
|
||||
|
||||
@router.get("/exhibition-appointments")
|
||||
async def list_exhibition_appointments(
|
||||
page: int = Query(1, ge=1),
|
||||
pageSize: int = Query(10, ge=1, le=100, alias="pageSize"),
|
||||
keyword: Optional[str] = None,
|
||||
visitDateStart: Optional[str] = Query(None, alias="visitDateStart"),
|
||||
visitDateEnd: Optional[str] = Query(None, alias="visitDateEnd"),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
@@ -754,6 +763,14 @@ async def list_exhibition_appointments(
|
||||
BizExhibitionAppointment.visit_org.like(like),
|
||||
)
|
||||
)
|
||||
if visitDateStart:
|
||||
query = query.filter(
|
||||
BizExhibitionAppointment.visit_date >= _normalize_visit_date_bound(visitDateStart)
|
||||
)
|
||||
if visitDateEnd:
|
||||
query = query.filter(
|
||||
BizExhibitionAppointment.visit_date <= _normalize_visit_date_bound(visitDateEnd, end_of_day=True)
|
||||
)
|
||||
query = apply_data_scope(query, BizExhibitionAppointment, user, db, tenant_no)
|
||||
total = query.count()
|
||||
items = query.order_by(BizExhibitionAppointment.create_time.desc()).offset((page - 1) * pageSize).limit(pageSize).all()
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
"""出库放行审核 API"""
|
||||
from fastapi import APIRouter, Depends, Query
|
||||
from pydantic import BaseModel
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.core.database import get_db
|
||||
from app.core.menu_guard import require_admin_or_super_admin
|
||||
from app.core.response import error_response, success_response
|
||||
from app.crud import outbound_release_review as svc
|
||||
from app.models.models import SysUser
|
||||
|
||||
router = APIRouter(prefix="/web/admin", tags=["出库放行审核"])
|
||||
|
||||
|
||||
def _get_tenant_no(db: Session, user: dict) -> str:
|
||||
user_id = user.get("user_id")
|
||||
if not user_id:
|
||||
raise PermissionError("用户身份信息缺失")
|
||||
sys_user = db.query(SysUser).filter(SysUser.id == user_id).first()
|
||||
if not sys_user or not sys_user.tenant_no:
|
||||
raise PermissionError("用户租户信息缺失")
|
||||
return sys_user.tenant_no
|
||||
|
||||
|
||||
class CreateBody(BaseModel):
|
||||
scheduleId: str
|
||||
|
||||
|
||||
class UpdateBody(BaseModel):
|
||||
id: str
|
||||
reviewConclusion: str
|
||||
reviewRemark: str = ""
|
||||
|
||||
|
||||
class IdBody(BaseModel):
|
||||
id: str
|
||||
|
||||
|
||||
@router.post("/pilot-release-review/create")
|
||||
async def create_review(
|
||||
body: CreateBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
result = svc.create_release_review(
|
||||
db,
|
||||
schedule_id=body.scheduleId,
|
||||
tenant_no=tenant_no,
|
||||
user_id=user.get("user_id"),
|
||||
create_dept_id=user.get("region_id", ""),
|
||||
)
|
||||
db.commit()
|
||||
return success_response(result, message="创建成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.get("/pilot-release-review/list")
|
||||
async def list_reviews(
|
||||
scheduleId: str = Query(...),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
result = svc.list_reviews_by_schedule(
|
||||
db, schedule_id=scheduleId, tenant_no=tenant_no
|
||||
)
|
||||
return success_response(result)
|
||||
|
||||
|
||||
@router.put("/pilot-release-review/update")
|
||||
async def update_review(
|
||||
body: UpdateBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
result = svc.update_review_conclusion(
|
||||
db,
|
||||
review_id=body.id,
|
||||
conclusion=body.reviewConclusion,
|
||||
remark=body.reviewRemark,
|
||||
tenant_no=tenant_no,
|
||||
user_id=user.get("user_id"),
|
||||
)
|
||||
return success_response(result, message="更新成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.delete("/pilot-release-review/delete")
|
||||
async def delete_review(
|
||||
body: IdBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
svc.delete_release_review(
|
||||
db, review_id=body.id, tenant_no=tenant_no, user_id=user.get("user_id")
|
||||
)
|
||||
return success_response(None, message="删除成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
@@ -0,0 +1,560 @@
|
||||
"""中试服务申请单管理 API(申请单、患者信息、输注方案、输注计划、出库联动)"""
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import APIRouter, Depends, Query
|
||||
from pydantic import BaseModel
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.core.database import get_db
|
||||
from app.core.menu_guard import require_admin_or_super_admin
|
||||
from app.core.response import error_response, success_response
|
||||
from app.crud import pilot_application
|
||||
from app.models.models import SysUser
|
||||
|
||||
router = APIRouter(prefix="/web/admin", tags=["中试服务申请单管理"])
|
||||
|
||||
|
||||
def _get_tenant_no(db: Session, user: dict) -> str:
|
||||
user_id = user.get("user_id")
|
||||
if not user_id:
|
||||
raise PermissionError("用户身份信息缺失,无法确定租户")
|
||||
sys_user = db.query(SysUser).filter(SysUser.id == user_id).first()
|
||||
if not sys_user or not sys_user.tenant_no:
|
||||
raise PermissionError("用户租户信息缺失")
|
||||
return sys_user.tenant_no
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Pydantic Schemas
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class IdBody(BaseModel):
|
||||
id: str
|
||||
|
||||
|
||||
class PlanIdBody(BaseModel):
|
||||
plan_id: str
|
||||
|
||||
|
||||
class ApplicationCreateBody(BaseModel):
|
||||
channel_service_order_id: str
|
||||
remark: Optional[str] = None
|
||||
|
||||
|
||||
class ApplicationUpdateBody(BaseModel):
|
||||
id: str
|
||||
remark: Optional[str] = None
|
||||
|
||||
|
||||
class PatientSaveBody(BaseModel):
|
||||
application_id: str
|
||||
customer_id: Optional[str] = None
|
||||
patient_name: str
|
||||
sex: Optional[str] = None
|
||||
age: Optional[int] = None
|
||||
id_card_no: Optional[str] = None
|
||||
phone_no: Optional[str] = None
|
||||
emergency_contact: Optional[str] = None
|
||||
emergency_phone: Optional[str] = None
|
||||
clinical_diagnosis: Optional[str] = None
|
||||
diagnosis_attachments: Optional[str] = None
|
||||
need_checkup: int = 1
|
||||
|
||||
|
||||
class InfusionPlanCreateBody(BaseModel):
|
||||
pilot_application_id: str
|
||||
cell_type: str
|
||||
spec_text: Optional[str] = None
|
||||
total_course_count: int
|
||||
course_interval: Optional[str] = None
|
||||
infusion_route: Optional[str] = None
|
||||
infusion_start_date: Optional[str] = None
|
||||
|
||||
|
||||
class InfusionPlanUpdateBody(BaseModel):
|
||||
id: str
|
||||
cell_type: Optional[str] = None
|
||||
spec_text: Optional[str] = None
|
||||
total_course_count: Optional[int] = None
|
||||
course_interval: Optional[str] = None
|
||||
infusion_route: Optional[str] = None
|
||||
infusion_start_date: Optional[str] = None
|
||||
|
||||
|
||||
class InfusionScheduleUpdateBody(BaseModel):
|
||||
id: str
|
||||
infusion_time: Optional[str] = None
|
||||
remark: Optional[str] = None
|
||||
attachments: Optional[str] = None
|
||||
|
||||
|
||||
class ScheduleCreateBody(BaseModel):
|
||||
plan_id: str
|
||||
infusion_time: Optional[str] = None
|
||||
remark: Optional[str] = None
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 1. 申请单 CRUD + 状态变更
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@router.get("/pilot-application/list")
|
||||
async def api_list_applications(
|
||||
page: int = Query(1, ge=1),
|
||||
pageSize: int = Query(10, ge=1, le=100, alias="pageSize"),
|
||||
channelId: Optional[str] = Query(None, alias="channelId"),
|
||||
applicationStatus: Optional[str] = Query(None, alias="applicationStatus"),
|
||||
channelServiceOrderId: Optional[str] = Query(None, alias="channelServiceOrderId"),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
result = pilot_application.list_applications(
|
||||
db,
|
||||
tenant_no=tenant_no,
|
||||
page=page,
|
||||
page_size=pageSize,
|
||||
channel_id=channelId,
|
||||
application_status=applicationStatus,
|
||||
channel_service_order_id=channelServiceOrderId,
|
||||
)
|
||||
return success_response(result)
|
||||
|
||||
|
||||
@router.get("/pilot-application/detail")
|
||||
async def api_get_application(
|
||||
id: str = Query(...),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
result = pilot_application.get_application(db, app_id=id, tenant_no=tenant_no)
|
||||
if result is None:
|
||||
return error_response(404, "申请单不存在")
|
||||
return success_response(result)
|
||||
|
||||
|
||||
@router.post("/pilot-application/create")
|
||||
async def api_create_application(
|
||||
body: ApplicationCreateBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
data = {
|
||||
"channelServiceOrderId": body.channel_service_order_id,
|
||||
"remark": body.remark,
|
||||
}
|
||||
result = pilot_application.create_application(
|
||||
db,
|
||||
data=data,
|
||||
tenant_no=tenant_no,
|
||||
user_id=user.get("user_id"),
|
||||
dept_id=user.get("region_id", ""),
|
||||
)
|
||||
return success_response(result, message="创建成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.put("/pilot-application/update")
|
||||
async def api_update_application(
|
||||
body: ApplicationUpdateBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
data = {}
|
||||
if body.remark is not None:
|
||||
data["remark"] = body.remark
|
||||
result = pilot_application.update_application(
|
||||
db, app_id=body.id, data=data, tenant_no=tenant_no
|
||||
)
|
||||
return success_response(result, message="更新成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.delete("/pilot-application/delete")
|
||||
async def api_delete_application(
|
||||
body: IdBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
pilot_application.soft_delete_application(db, app_id=body.id, tenant_no=tenant_no)
|
||||
return success_response(None, message="删除成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.post("/pilot-application/start")
|
||||
async def api_start_application(
|
||||
body: IdBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
result = pilot_application.start_application(
|
||||
db, app_id=body.id, tenant_no=tenant_no, user_id=user.get("user_id")
|
||||
)
|
||||
return success_response(result, message="操作成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.post("/pilot-application/complete")
|
||||
async def api_complete_application(
|
||||
body: IdBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
result = pilot_application.complete_application(
|
||||
db, app_id=body.id, tenant_no=tenant_no, user_id=user.get("user_id")
|
||||
)
|
||||
return success_response(result, message="操作成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.post("/pilot-application/void")
|
||||
async def api_void_application(
|
||||
body: IdBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
result = pilot_application.void_application(
|
||||
db, app_id=body.id, tenant_no=tenant_no, user_id=user.get("user_id")
|
||||
)
|
||||
return success_response(result, message="操作成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 2. 患者信息
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@router.get("/pilot-patient/detail")
|
||||
async def api_get_patient(
|
||||
application_id: str = Query(...),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
result = pilot_application.get_patient_by_application(
|
||||
db, app_id=application_id, tenant_no=tenant_no
|
||||
)
|
||||
if result is None:
|
||||
return success_response(None)
|
||||
return success_response(result)
|
||||
|
||||
|
||||
@router.post("/pilot-patient/save")
|
||||
async def api_save_patient(
|
||||
body: PatientSaveBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
data = {
|
||||
"customerId": body.customer_id,
|
||||
"patientName": body.patient_name,
|
||||
"sex": body.sex,
|
||||
"age": body.age,
|
||||
"idCardNo": body.id_card_no,
|
||||
"phoneNo": body.phone_no,
|
||||
"emergencyContact": body.emergency_contact,
|
||||
"emergencyPhone": body.emergency_phone,
|
||||
"clinicalDiagnosis": body.clinical_diagnosis,
|
||||
"diagnosisAttachments": body.diagnosis_attachments,
|
||||
"needCheckup": body.need_checkup,
|
||||
}
|
||||
result = pilot_application.save_patient(
|
||||
db,
|
||||
app_id=body.application_id,
|
||||
data=data,
|
||||
tenant_no=tenant_no,
|
||||
user_id=user.get("user_id"),
|
||||
dept_id=user.get("region_id", ""),
|
||||
)
|
||||
return success_response(result, message="保存成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 3. 输注方案
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@router.get("/pilot-infusion-plan/list")
|
||||
async def api_list_plans(
|
||||
application_id: str = Query(...),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
result = pilot_application.list_infusion_plans(
|
||||
db, app_id=application_id, tenant_no=tenant_no
|
||||
)
|
||||
return success_response(result)
|
||||
|
||||
|
||||
@router.post("/pilot-infusion-plan/create")
|
||||
async def api_create_plan(
|
||||
body: InfusionPlanCreateBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
data = {
|
||||
"cellType": body.cell_type,
|
||||
"specText": body.spec_text,
|
||||
"totalCourseCount": body.total_course_count,
|
||||
"courseInterval": body.course_interval,
|
||||
"infusionRoute": body.infusion_route,
|
||||
"infusionStartDate": body.infusion_start_date,
|
||||
}
|
||||
result = pilot_application.create_infusion_plan(
|
||||
db,
|
||||
app_id=body.pilot_application_id,
|
||||
data=data,
|
||||
tenant_no=tenant_no,
|
||||
user_id=user.get("user_id"),
|
||||
dept_id=user.get("region_id", ""),
|
||||
)
|
||||
return success_response(result, message="创建成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.put("/pilot-infusion-plan/update")
|
||||
async def api_update_plan(
|
||||
body: InfusionPlanUpdateBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
data = {}
|
||||
if body.cell_type is not None:
|
||||
data["cellType"] = body.cell_type
|
||||
if body.spec_text is not None:
|
||||
data["specText"] = body.spec_text
|
||||
if body.total_course_count is not None:
|
||||
data["totalCourseCount"] = body.total_course_count
|
||||
if body.course_interval is not None:
|
||||
data["courseInterval"] = body.course_interval
|
||||
if body.infusion_route is not None:
|
||||
data["infusionRoute"] = body.infusion_route
|
||||
if body.infusion_start_date is not None:
|
||||
data["infusionStartDate"] = body.infusion_start_date
|
||||
result = pilot_application.update_infusion_plan(
|
||||
db, plan_id=body.id, data=data, tenant_no=tenant_no
|
||||
)
|
||||
return success_response(result, message="更新成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.delete("/pilot-infusion-plan/delete")
|
||||
async def api_delete_plan(
|
||||
body: IdBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
pilot_application.soft_delete_infusion_plan(
|
||||
db, plan_id=body.id, tenant_no=tenant_no
|
||||
)
|
||||
return success_response(None, message="删除成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 4. 输注计划
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@router.post("/pilot-infusion-schedule/auto-generate")
|
||||
async def api_auto_generate(
|
||||
body: PlanIdBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
result = pilot_application.auto_generate_schedules(
|
||||
db,
|
||||
plan_id=body.plan_id,
|
||||
tenant_no=tenant_no,
|
||||
user_id=user.get("user_id"),
|
||||
dept_id=user.get("region_id", ""),
|
||||
)
|
||||
return success_response(result, message="生成成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.post("/pilot-infusion-schedule/create")
|
||||
async def api_create_schedule(
|
||||
body: ScheduleCreateBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
data = {
|
||||
"infusionTime": body.infusion_time,
|
||||
"remark": body.remark,
|
||||
}
|
||||
result = pilot_application.create_schedule(
|
||||
db,
|
||||
plan_id=body.plan_id,
|
||||
data=data,
|
||||
tenant_no=tenant_no,
|
||||
user_id=user.get("user_id"),
|
||||
dept_id=user.get("region_id", ""),
|
||||
)
|
||||
return success_response(result, message="创建成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.put("/pilot-infusion-schedule/update")
|
||||
async def api_update_schedule(
|
||||
body: InfusionScheduleUpdateBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
data = {}
|
||||
if body.infusion_time is not None:
|
||||
data["infusionTime"] = body.infusion_time
|
||||
if body.remark is not None:
|
||||
data["remark"] = body.remark
|
||||
if body.attachments is not None:
|
||||
data["attachments"] = body.attachments
|
||||
result = pilot_application.update_schedule(
|
||||
db, schedule_id=body.id, data=data, tenant_no=tenant_no
|
||||
)
|
||||
return success_response(result, message="更新成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.delete("/pilot-infusion-schedule/delete")
|
||||
async def api_delete_schedule(
|
||||
body: IdBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
pilot_application.soft_delete_schedule(
|
||||
db, schedule_id=body.id, tenant_no=tenant_no
|
||||
)
|
||||
return success_response(None, message="删除成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.post("/pilot-infusion-schedule/mark-complete")
|
||||
async def api_mark_complete(
|
||||
body: IdBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
result = pilot_application.mark_schedule_complete(
|
||||
db, schedule_id=body.id, tenant_no=tenant_no, user_id=user.get("user_id")
|
||||
)
|
||||
return success_response(result, message="操作成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 出库生产工单 / 出库质检工单 联动
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class ScheduleIdBody(BaseModel):
|
||||
scheduleId: str
|
||||
|
||||
|
||||
@router.post("/pilot-infusion-schedule/create-production-work-order")
|
||||
async def api_create_outbound_production(
|
||||
body: ScheduleIdBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
from app.crud import production_work_order as pwo_svc
|
||||
|
||||
wo = pwo_svc.create_outbound_production_work_order(
|
||||
db,
|
||||
schedule_id=body.scheduleId,
|
||||
tenant_no=tenant_no,
|
||||
user_id=user.get("user_id"),
|
||||
create_dept_id=user.get("dept_id", ""),
|
||||
)
|
||||
pilot_application.mark_schedule_complete(
|
||||
db, schedule_id=body.scheduleId, tenant_no=tenant_no, user_id=user.get("user_id")
|
||||
)
|
||||
return success_response(pwo_svc._wo_to_dict(wo), message="创建出库生产工单成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
except Exception as e:
|
||||
db.rollback()
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
class OutboundQcBody(BaseModel):
|
||||
scheduleId: str
|
||||
cellProductId: str = ""
|
||||
|
||||
|
||||
@router.post("/pilot-infusion-schedule/create-qc-work-order")
|
||||
async def api_create_outbound_qc(
|
||||
body: OutboundQcBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
from app.crud import qc_work_order as qc_svc
|
||||
|
||||
wo = qc_svc.create_outbound_qc_work_order(
|
||||
db,
|
||||
schedule_id=body.scheduleId,
|
||||
cell_product_id=body.cellProductId,
|
||||
tenant_no=tenant_no,
|
||||
user_id=user.get("user_id"),
|
||||
create_dept_id=user.get("dept_id", ""),
|
||||
)
|
||||
return success_response(qc_svc._wo_to_dict(wo), message="创建出库质检工单成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
except Exception as e:
|
||||
db.rollback()
|
||||
return error_response(400, str(e))
|
||||
@@ -0,0 +1,264 @@
|
||||
"""中试服务体检管理 API(体检信息、预约项目、实际项目)"""
|
||||
from typing import List, Optional
|
||||
|
||||
from fastapi import APIRouter, Depends, Query
|
||||
from pydantic import BaseModel
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.core.database import get_db
|
||||
from app.core.menu_guard import require_admin_or_super_admin
|
||||
from app.core.response import error_response, success_response
|
||||
from app.crud import pilot_checkup
|
||||
from app.models.models import SysUser
|
||||
|
||||
router = APIRouter(prefix="/web/admin", tags=["中试服务体检管理"])
|
||||
|
||||
|
||||
def _get_tenant_no(db: Session, user: dict) -> str:
|
||||
user_id = user.get("user_id")
|
||||
if not user_id:
|
||||
raise PermissionError("用户身份信息缺失,无法确定租户")
|
||||
sys_user = db.query(SysUser).filter(SysUser.id == user_id).first()
|
||||
if not sys_user or not sys_user.tenant_no:
|
||||
raise PermissionError("用户租户信息缺失")
|
||||
return sys_user.tenant_no
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Pydantic Schemas
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class IdBody(BaseModel):
|
||||
id: str
|
||||
|
||||
|
||||
class CheckupSaveBody(BaseModel):
|
||||
application_id: str
|
||||
checkup_institution_id: Optional[str] = None
|
||||
reserve_time: Optional[str] = None
|
||||
reserve_fee: Optional[float] = None
|
||||
actual_checkup_time: Optional[str] = None
|
||||
actual_checkup_fee: Optional[float] = None
|
||||
checkup_remark: Optional[str] = None
|
||||
report_attachments: Optional[str] = None
|
||||
|
||||
|
||||
class CheckupItemBody(BaseModel):
|
||||
project_name: str
|
||||
project_fee: Optional[float] = None
|
||||
|
||||
|
||||
class CheckupItemsSaveBody(BaseModel):
|
||||
pilot_checkup_id: str
|
||||
items: List[CheckupItemBody]
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 1. 体检信息 CRUD + 状态变更
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@router.get("/pilot-checkup/detail")
|
||||
async def api_get_checkup_detail(
|
||||
application_id: str = Query(...),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
result = pilot_checkup.get_checkup_by_application(
|
||||
db, application_id=application_id, tenant_no=tenant_no
|
||||
)
|
||||
if result is None:
|
||||
return success_response(None)
|
||||
return success_response(result)
|
||||
|
||||
|
||||
@router.post("/pilot-checkup/save")
|
||||
async def api_save_checkup(
|
||||
body: CheckupSaveBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
data = {
|
||||
"checkupInstitutionId": body.checkup_institution_id,
|
||||
"reserveTime": body.reserve_time,
|
||||
"reserveFee": body.reserve_fee,
|
||||
"actualCheckupTime": body.actual_checkup_time,
|
||||
"actualCheckupFee": body.actual_checkup_fee,
|
||||
"checkupRemark": body.checkup_remark,
|
||||
"reportAttachments": body.report_attachments,
|
||||
}
|
||||
existing = pilot_checkup.get_checkup_by_application(
|
||||
db, application_id=body.application_id, tenant_no=tenant_no
|
||||
)
|
||||
if existing:
|
||||
result = pilot_checkup.update_checkup(
|
||||
db, checkup_id=existing["id"], data=data, tenant_no=tenant_no
|
||||
)
|
||||
return success_response(result, message="更新成功")
|
||||
else:
|
||||
result = pilot_checkup.create_checkup(
|
||||
db,
|
||||
application_id=body.application_id,
|
||||
data=data,
|
||||
tenant_no=tenant_no,
|
||||
user_id=user.get("user_id"),
|
||||
)
|
||||
return success_response(result, message="创建成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.delete("/pilot-checkup/delete")
|
||||
async def api_delete_checkup(
|
||||
body: IdBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
pilot_checkup.soft_delete_checkup(db, checkup_id=body.id, tenant_no=tenant_no)
|
||||
return success_response(None, message="删除成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.post("/pilot-checkup/mark-checked")
|
||||
async def api_mark_checked(
|
||||
body: IdBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
result = pilot_checkup.mark_checkup_checked(
|
||||
db, checkup_id=body.id, tenant_no=tenant_no, user_id=user.get("user_id")
|
||||
)
|
||||
return success_response(result, message="操作成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.post("/pilot-checkup/settle-fee")
|
||||
async def api_settle_fee(
|
||||
body: IdBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
result = pilot_checkup.settle_checkup_fee(
|
||||
db, checkup_id=body.id, tenant_no=tenant_no, user_id=user.get("user_id")
|
||||
)
|
||||
return success_response(result, message="结算成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 2. 预约项目
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@router.get("/pilot-checkup/reserve-items")
|
||||
async def api_list_reserve_items(
|
||||
pilot_checkup_id: str = Query(...),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
result = pilot_checkup.list_reserve_items(
|
||||
db, checkup_id=pilot_checkup_id, tenant_no=tenant_no
|
||||
)
|
||||
return success_response(result)
|
||||
|
||||
|
||||
@router.post("/pilot-checkup/reserve-items/save")
|
||||
async def api_save_reserve_items(
|
||||
body: CheckupItemsSaveBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
items_json = [item.dict() for item in body.items]
|
||||
result = pilot_checkup.save_reserve_items(
|
||||
db,
|
||||
checkup_id=body.pilot_checkup_id,
|
||||
items_json=items_json,
|
||||
tenant_no=tenant_no,
|
||||
user_id=user.get("user_id"),
|
||||
)
|
||||
return success_response(result, message="保存成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.delete("/pilot-checkup/reserve-item/delete")
|
||||
async def api_delete_reserve_item(
|
||||
body: IdBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
pilot_checkup.delete_reserve_item(db, item_id=body.id, tenant_no=tenant_no)
|
||||
return success_response(None, message="删除成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 3. 实际项目
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@router.get("/pilot-checkup/actual-items")
|
||||
async def api_list_actual_items(
|
||||
pilot_checkup_id: str = Query(...),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
result = pilot_checkup.list_actual_items(
|
||||
db, checkup_id=pilot_checkup_id, tenant_no=tenant_no
|
||||
)
|
||||
return success_response(result)
|
||||
|
||||
|
||||
@router.post("/pilot-checkup/actual-items/save")
|
||||
async def api_save_actual_items(
|
||||
body: CheckupItemsSaveBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
items_json = [item.dict() for item in body.items]
|
||||
result = pilot_checkup.save_actual_items(
|
||||
db,
|
||||
checkup_id=body.pilot_checkup_id,
|
||||
items_json=items_json,
|
||||
tenant_no=tenant_no,
|
||||
user_id=user.get("user_id"),
|
||||
)
|
||||
return success_response(result, message="保存成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.delete("/pilot-checkup/actual-item/delete")
|
||||
async def api_delete_actual_item(
|
||||
body: IdBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
pilot_checkup.delete_actual_item(db, item_id=body.id, tenant_no=tenant_no)
|
||||
return success_response(None, message="删除成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
@@ -0,0 +1,234 @@
|
||||
"""中试服务交付管理 API(交付信息、交付物料、交付方式)"""
|
||||
from typing import List, Optional
|
||||
|
||||
from fastapi import APIRouter, Depends, Query
|
||||
from pydantic import BaseModel
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.core.database import get_db
|
||||
from app.core.menu_guard import require_admin_or_super_admin
|
||||
from app.core.response import error_response, success_response
|
||||
from app.crud import pilot_delivery
|
||||
from app.models.models import SysUser
|
||||
|
||||
router = APIRouter(prefix="/web/admin", tags=["中试服务交付管理"])
|
||||
|
||||
|
||||
def _get_tenant_no(db: Session, user: dict) -> str:
|
||||
user_id = user.get("user_id")
|
||||
if not user_id:
|
||||
raise PermissionError("用户身份信息缺失,无法确定租户")
|
||||
sys_user = db.query(SysUser).filter(SysUser.id == user_id).first()
|
||||
if not sys_user or not sys_user.tenant_no:
|
||||
raise PermissionError("用户租户信息缺失")
|
||||
return sys_user.tenant_no
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Pydantic Schemas
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class IdBody(BaseModel):
|
||||
id: str
|
||||
|
||||
|
||||
class DeliverySaveBody(BaseModel):
|
||||
remark: Optional[str] = None
|
||||
|
||||
|
||||
class DeliveryMaterialItem(BaseModel):
|
||||
material_name: str
|
||||
qty: Optional[float] = None
|
||||
unit_id: Optional[str] = None
|
||||
remark: Optional[str] = None
|
||||
|
||||
|
||||
class DeliveryMaterialSaveBody(BaseModel):
|
||||
delivery_id: str
|
||||
items: List[DeliveryMaterialItem]
|
||||
|
||||
|
||||
class DeliveryMethodSaveBody(BaseModel):
|
||||
delivery_id: str
|
||||
delivery_mode: str
|
||||
delivery_attachments: Optional[str] = None
|
||||
ship_time: Optional[str] = None
|
||||
handover_temp: Optional[str] = None
|
||||
pickup_person: Optional[str] = None
|
||||
pickup_phone: Optional[str] = None
|
||||
sender_name: Optional[str] = None
|
||||
express_company_id: Optional[str] = None
|
||||
waybill_no: Optional[str] = None
|
||||
express_fee: Optional[float] = None
|
||||
eta_time: Optional[str] = None
|
||||
remark: Optional[str] = None
|
||||
|
||||
|
||||
class DeliveryCreateBody(BaseModel):
|
||||
infusion_schedule_id: str
|
||||
remark: Optional[str] = None
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 1. 交付信息 CRUD
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@router.get("/pilot-delivery/detail")
|
||||
async def get_by_schedule(
|
||||
infusion_schedule_id: str = Query(...),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
result = pilot_delivery.get_delivery_by_schedule(
|
||||
db, schedule_id=infusion_schedule_id, tenant_no=tenant_no
|
||||
)
|
||||
if result is None:
|
||||
return success_response(None)
|
||||
return success_response(result)
|
||||
|
||||
|
||||
@router.get("/pilot-delivery/list-by-application")
|
||||
async def list_by_application(
|
||||
application_id: str = Query(...),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
result = pilot_delivery.list_deliveries_by_application(
|
||||
db, application_id=application_id, tenant_no=tenant_no
|
||||
)
|
||||
return success_response(result)
|
||||
|
||||
|
||||
@router.post("/pilot-delivery/create")
|
||||
async def create_delivery(
|
||||
body: DeliveryCreateBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
data = {"remark": body.remark}
|
||||
result = pilot_delivery.create_delivery(
|
||||
db,
|
||||
schedule_id=body.infusion_schedule_id,
|
||||
data=data,
|
||||
tenant_no=tenant_no,
|
||||
user_id=user.get("user_id"),
|
||||
dept_id=user.get("region_id", ""),
|
||||
)
|
||||
return success_response(result, message="创建成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.delete("/pilot-delivery/delete")
|
||||
async def soft_delete(
|
||||
body: IdBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
pilot_delivery.soft_delete_delivery(
|
||||
db, delivery_id=body.id, tenant_no=tenant_no
|
||||
)
|
||||
return success_response(None, message="删除成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 2. 交付物料
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@router.get("/pilot-delivery/materials")
|
||||
async def list_materials(
|
||||
delivery_id: str = Query(...),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
result = pilot_delivery.list_delivery_materials(
|
||||
db, delivery_id=delivery_id, tenant_no=tenant_no
|
||||
)
|
||||
return success_response(result)
|
||||
|
||||
|
||||
@router.post("/pilot-delivery/materials/save")
|
||||
async def save_materials(
|
||||
body: DeliveryMaterialSaveBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
items_json = [item.dict() for item in body.items]
|
||||
result = pilot_delivery.save_delivery_materials(
|
||||
db,
|
||||
delivery_id=body.delivery_id,
|
||||
items_json=items_json,
|
||||
tenant_no=tenant_no,
|
||||
user_id=user.get("user_id"),
|
||||
)
|
||||
return success_response(result, message="保存成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 3. 交付方式
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@router.get("/pilot-delivery/method")
|
||||
async def get_method(
|
||||
delivery_id: str = Query(...),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
result = pilot_delivery.get_delivery_method(
|
||||
db, delivery_id=delivery_id, tenant_no=tenant_no
|
||||
)
|
||||
if result is None:
|
||||
return success_response(None)
|
||||
return success_response(result)
|
||||
|
||||
|
||||
@router.post("/pilot-delivery/method/save")
|
||||
async def save_method(
|
||||
body: DeliveryMethodSaveBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
data = {
|
||||
"delivery_mode": body.delivery_mode,
|
||||
"delivery_attachments": body.delivery_attachments,
|
||||
"ship_time": body.ship_time,
|
||||
"handover_temp": body.handover_temp,
|
||||
"pickup_person": body.pickup_person,
|
||||
"pickup_phone": body.pickup_phone,
|
||||
"sender_name": body.sender_name,
|
||||
"express_company_id": body.express_company_id,
|
||||
"waybill_no": body.waybill_no,
|
||||
"express_fee": body.express_fee,
|
||||
"eta_time": body.eta_time,
|
||||
"remark": body.remark,
|
||||
}
|
||||
result = pilot_delivery.save_delivery_method(
|
||||
db,
|
||||
delivery_id=body.delivery_id,
|
||||
data=data,
|
||||
tenant_no=tenant_no,
|
||||
user_id=user.get("user_id"),
|
||||
)
|
||||
return success_response(result, message="保存成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
@@ -0,0 +1,142 @@
|
||||
"""中试应用确认 API"""
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import APIRouter, Depends, Query
|
||||
from pydantic import BaseModel
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.core.database import get_db
|
||||
from app.core.menu_guard import require_admin_or_super_admin
|
||||
from app.core.response import error_response, success_response
|
||||
from app.crud import pilot_infusion_confirm as svc
|
||||
from app.models.models import SysUser
|
||||
|
||||
router = APIRouter(prefix="/web/admin", tags=["中试应用确认"])
|
||||
|
||||
|
||||
def _get_tenant_no(db: Session, user: dict) -> str:
|
||||
user_id = user.get("user_id")
|
||||
if not user_id:
|
||||
raise PermissionError("用户身份信息缺失")
|
||||
sys_user = db.query(SysUser).filter(SysUser.id == user_id).first()
|
||||
if not sys_user or not sys_user.tenant_no:
|
||||
raise PermissionError("用户租户信息缺失")
|
||||
return sys_user.tenant_no
|
||||
|
||||
|
||||
class IdBody(BaseModel):
|
||||
id: str
|
||||
|
||||
|
||||
class ConfirmCreateBody(BaseModel):
|
||||
infusionScheduleId: str
|
||||
confirmDesc: Optional[str] = None
|
||||
remark: Optional[str] = None
|
||||
|
||||
|
||||
class ConfirmUpdateBody(BaseModel):
|
||||
id: str
|
||||
confirmDesc: Optional[str] = None
|
||||
remark: Optional[str] = None
|
||||
|
||||
|
||||
@router.post("/pilot-infusion-confirm/create")
|
||||
async def api_create(
|
||||
body: ConfirmCreateBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
result = svc.create_infusion_confirm(
|
||||
db,
|
||||
schedule_id=body.infusionScheduleId,
|
||||
tenant_no=tenant_no,
|
||||
user_id=user.get("user_id"),
|
||||
create_dept_id=user.get("region_id", ""),
|
||||
confirm_desc=body.confirmDesc or "",
|
||||
remark=body.remark or "",
|
||||
)
|
||||
db.commit()
|
||||
return success_response(result, message="创建成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.get("/pilot-infusion-confirm/list")
|
||||
async def api_list(
|
||||
applicationId: str = Query(...),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
result = svc.list_confirms_by_application(
|
||||
db, application_id=applicationId, tenant_no=tenant_no
|
||||
)
|
||||
return success_response(result)
|
||||
|
||||
|
||||
@router.get("/pilot-infusion-confirm/detail")
|
||||
async def api_detail(
|
||||
id: str = Query(...),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
result = svc.get_confirm_by_id(db, confirm_id=id, tenant_no=tenant_no)
|
||||
if result is None:
|
||||
return success_response(None)
|
||||
return success_response(result)
|
||||
|
||||
|
||||
@router.post("/pilot-infusion-confirm/confirm")
|
||||
async def api_confirm(
|
||||
body: IdBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
result = svc.confirm_infusion(
|
||||
db, confirm_id=body.id, tenant_no=tenant_no, user_id=user.get("user_id")
|
||||
)
|
||||
return success_response(result, message="确认成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.put("/pilot-infusion-confirm/update")
|
||||
async def api_update(
|
||||
body: ConfirmUpdateBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
result = svc.update_infusion_confirm(
|
||||
db,
|
||||
confirm_id=body.id,
|
||||
tenant_no=tenant_no,
|
||||
user_id=user.get("user_id"),
|
||||
confirmDesc=body.confirmDesc,
|
||||
remark=body.remark,
|
||||
)
|
||||
return success_response(result, message="更新成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
|
||||
|
||||
@router.delete("/pilot-infusion-confirm/delete")
|
||||
async def api_delete(
|
||||
body: IdBody,
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
svc.delete_infusion_confirm(
|
||||
db, confirm_id=body.id, tenant_no=tenant_no, user_id=user.get("user_id")
|
||||
)
|
||||
return success_response(None, message="删除成功")
|
||||
except ValueError as e:
|
||||
return error_response(400, str(e))
|
||||
@@ -1676,6 +1676,8 @@ async def list_channel_service_orders(
|
||||
orderStatus: Optional[str] = Query(None, alias="orderStatus"),
|
||||
channelId: Optional[str] = Query(None, alias="channelId"),
|
||||
keyword: Optional[str] = None,
|
||||
createTimeStart: Optional[str] = Query(None, alias="createTimeStart"),
|
||||
createTimeEnd: Optional[str] = Query(None, alias="createTimeEnd"),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
@@ -1688,6 +1690,8 @@ async def list_channel_service_orders(
|
||||
order_status=orderStatus,
|
||||
channel_id=channelId,
|
||||
keyword=keyword,
|
||||
create_time_start=createTimeStart,
|
||||
create_time_end=createTimeEnd,
|
||||
tenant_no=tenant_no,
|
||||
user_info=user,
|
||||
)
|
||||
@@ -1926,6 +1930,9 @@ async def list_service_order_txns(
|
||||
serviceOrderId: Optional[str] = Query(None, alias="serviceOrderId"),
|
||||
txnStatus: Optional[str] = Query(None, alias="txnStatus"),
|
||||
txnType: Optional[str] = Query(None, alias="txnType"),
|
||||
keyword: Optional[str] = None,
|
||||
createTimeStart: Optional[str] = Query(None, alias="createTimeStart"),
|
||||
createTimeEnd: Optional[str] = Query(None, alias="createTimeEnd"),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
@@ -1935,6 +1942,9 @@ async def list_service_order_txns(
|
||||
service_order_id=serviceOrderId,
|
||||
txn_status=txnStatus,
|
||||
txn_type=txnType,
|
||||
keyword=keyword,
|
||||
create_time_start=createTimeStart,
|
||||
create_time_end=createTimeEnd,
|
||||
page=page,
|
||||
page_size=pageSize,
|
||||
tenant_no=tenant_no,
|
||||
|
||||
@@ -1596,6 +1596,8 @@ async def list_production_work_orders(
|
||||
workOrderType: Optional[str] = None,
|
||||
protocolNo: Optional[str] = None,
|
||||
sampleCode: Optional[str] = None,
|
||||
createTimeStart: Optional[str] = Query(None, alias="createTimeStart"),
|
||||
createTimeEnd: Optional[str] = Query(None, alias="createTimeEnd"),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
@@ -1606,6 +1608,8 @@ async def list_production_work_orders(
|
||||
work_order_no=workOrderNo, work_order_status=workOrderStatus,
|
||||
work_order_type=workOrderType,
|
||||
protocol_no=protocolNo, sample_code=sampleCode,
|
||||
create_time_start=createTimeStart,
|
||||
create_time_end=createTimeEnd,
|
||||
)
|
||||
result = production_work_order_svc.list_production_work_orders(
|
||||
db, tenant_no=tenant_no, query=query, page=page, page_size=pageSize,
|
||||
@@ -1753,6 +1757,8 @@ async def list_production_tasks(
|
||||
workOrderId: Optional[str] = None,
|
||||
taskNo: Optional[str] = None,
|
||||
taskStatus: Optional[str] = None,
|
||||
startedTimeStart: Optional[str] = Query(None, alias="startedTimeStart"),
|
||||
startedTimeEnd: Optional[str] = Query(None, alias="startedTimeEnd"),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
@@ -1761,6 +1767,8 @@ async def list_production_tasks(
|
||||
db, tenant_no=tenant_no, page=page, page_size=pageSize,
|
||||
keyword=keyword,
|
||||
work_order_id=workOrderId, task_no=taskNo, task_status=taskStatus,
|
||||
started_time_start=startedTimeStart,
|
||||
started_time_end=startedTimeEnd,
|
||||
user_info=user,
|
||||
)
|
||||
tp = production_task_svc.total_pages(total, pageSize)
|
||||
|
||||
@@ -596,6 +596,8 @@ async def list_qc_work_orders(
|
||||
keyword: Optional[str] = None,
|
||||
workOrderStatus: Optional[str] = None,
|
||||
workOrderType: Optional[str] = None,
|
||||
createTimeStart: Optional[str] = Query(None, alias="createTimeStart"),
|
||||
createTimeEnd: Optional[str] = Query(None, alias="createTimeEnd"),
|
||||
db: Session = Depends(get_db),
|
||||
user: dict = Depends(require_menu_code("biz:qcWorkOrder:list")),
|
||||
):
|
||||
@@ -608,6 +610,8 @@ async def list_qc_work_orders(
|
||||
keyword=keyword,
|
||||
work_order_status=workOrderStatus,
|
||||
work_order_type=workOrderType,
|
||||
create_time_start=createTimeStart,
|
||||
create_time_end=createTimeEnd,
|
||||
tenant_no=tenant_no,
|
||||
user_info=user,
|
||||
)
|
||||
|
||||
@@ -117,6 +117,10 @@ async def list_research_donations(
|
||||
pageSize: int = Query(20, ge=1, le=200, alias="pageSize"),
|
||||
keyword: Optional[str] = Query(None, alias="keyword"),
|
||||
donationStatus: Optional[str] = Query(None, alias="donationStatus"),
|
||||
createTimeStart: Optional[str] = Query(None, alias="createTimeStart"),
|
||||
createTimeEnd: Optional[str] = Query(None, alias="createTimeEnd"),
|
||||
sampleCollectTimeStart: Optional[str] = Query(None, alias="sampleCollectTimeStart"),
|
||||
sampleCollectTimeEnd: Optional[str] = Query(None, alias="sampleCollectTimeEnd"),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
@@ -129,6 +133,10 @@ async def list_research_donations(
|
||||
page_size=pageSize,
|
||||
keyword=keyword,
|
||||
donation_status=donationStatus,
|
||||
create_time_start=createTimeStart,
|
||||
create_time_end=createTimeEnd,
|
||||
sample_collect_time_start=sampleCollectTimeStart,
|
||||
sample_collect_time_end=sampleCollectTimeEnd,
|
||||
collector_user_id=collector_user_id,
|
||||
user_info=user,
|
||||
)
|
||||
|
||||
@@ -209,6 +209,8 @@ async def list_pending_samples(
|
||||
pageSize: int = Query(10, ge=1, le=100),
|
||||
keyword: Optional[str] = None,
|
||||
sourceType: Optional[str] = None,
|
||||
etaTimeStart: Optional[str] = Query(None, alias="etaTimeStart"),
|
||||
etaTimeEnd: Optional[str] = Query(None, alias="etaTimeEnd"),
|
||||
db: Session = Depends(get_db),
|
||||
user: dict = Depends(require_menu_code("biz:sampleReception:list")),
|
||||
):
|
||||
@@ -216,7 +218,10 @@ async def list_pending_samples(
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
items, total = sr_svc.list_pending_protocol_samples(
|
||||
db, page=page, page_size=pageSize, tenant_no=tenant_no, keyword=keyword,
|
||||
source_type=sourceType, user_info=user,
|
||||
source_type=sourceType,
|
||||
eta_time_start=etaTimeStart,
|
||||
eta_time_end=etaTimeEnd,
|
||||
user_info=user,
|
||||
)
|
||||
return success_response(_page_payload(items, total, page, pageSize))
|
||||
except PermissionError as e:
|
||||
@@ -231,6 +236,8 @@ async def list_received_samples(
|
||||
pageSize: int = Query(10, ge=1, le=100),
|
||||
keyword: Optional[str] = None,
|
||||
sourceType: Optional[str] = None,
|
||||
receptionTimeStart: Optional[str] = Query(None, alias="receptionTimeStart"),
|
||||
receptionTimeEnd: Optional[str] = Query(None, alias="receptionTimeEnd"),
|
||||
db: Session = Depends(get_db),
|
||||
user: dict = Depends(require_menu_code("biz:sampleReception:list")),
|
||||
):
|
||||
@@ -238,7 +245,10 @@ async def list_received_samples(
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
items, total = sr_svc.list_received_protocol_samples(
|
||||
db, page=page, page_size=pageSize, tenant_no=tenant_no, keyword=keyword,
|
||||
source_type=sourceType, user_info=user,
|
||||
source_type=sourceType,
|
||||
reception_time_start=receptionTimeStart,
|
||||
reception_time_end=receptionTimeEnd,
|
||||
user_info=user,
|
||||
)
|
||||
return success_response(_page_payload(items, total, page, pageSize))
|
||||
except PermissionError as e:
|
||||
|
||||
@@ -56,6 +56,8 @@ async def list_notifications(
|
||||
keyword: Optional[str] = None,
|
||||
acceptConclusion: Optional[str] = None,
|
||||
smsNotified: Optional[int] = None,
|
||||
receptionTimeStart: Optional[str] = Query(None, alias="receptionTimeStart"),
|
||||
receptionTimeEnd: Optional[str] = Query(None, alias="receptionTimeEnd"),
|
||||
db: Session = Depends(get_db),
|
||||
user: dict = Depends(require_menu_code("cell-storage:sample-reception-info:list")),
|
||||
):
|
||||
@@ -69,6 +71,8 @@ async def list_notifications(
|
||||
keyword=keyword,
|
||||
accept_conclusion=acceptConclusion,
|
||||
sms_notified=smsNotified,
|
||||
reception_time_start=receptionTimeStart,
|
||||
reception_time_end=receptionTimeEnd,
|
||||
user_info=user,
|
||||
)
|
||||
return success_response(_page_payload(items, total, page, pageSize))
|
||||
|
||||
@@ -56,6 +56,8 @@ async def list_notifications(
|
||||
keyword: Optional[str] = None,
|
||||
storageStatus: Optional[str] = None,
|
||||
smsNotified: Optional[int] = None,
|
||||
storageTimeStart: Optional[str] = Query(None, alias="storageTimeStart"),
|
||||
storageTimeEnd: Optional[str] = Query(None, alias="storageTimeEnd"),
|
||||
db: Session = Depends(get_db),
|
||||
user: dict = Depends(require_menu_code("cell-storage:storage-entry-info:list")),
|
||||
):
|
||||
@@ -69,6 +71,8 @@ async def list_notifications(
|
||||
keyword=keyword,
|
||||
storage_status=storageStatus,
|
||||
sms_notified=smsNotified,
|
||||
storage_time_start=storageTimeStart,
|
||||
storage_time_end=storageTimeEnd,
|
||||
user_info=user,
|
||||
)
|
||||
return success_response(_page_payload(items, total, page, pageSize))
|
||||
|
||||
Reference in new issue
Block a user