药品流向管理内容优化-初步

This commit is contained in:
Cheng Zhou
2026-01-13 19:42:28 +08:00
parent 1db36f40b0
commit ef1e67218c
21 changed files with 344 additions and 480 deletions
+11 -4
View File
@@ -17,13 +17,14 @@ async def create_shipment(
shipment = DrugShipment(
study_id=study_id,
direction=shipment_in.direction,
site_name=shipment_in.site_name,
drug_desc=shipment_in.drug_desc,
center_id=shipment_in.center_id,
site_name=shipment_in.site_name or "",
ship_date=shipment_in.ship_date,
receive_date=shipment_in.receive_date,
quantity=shipment_in.quantity,
batch_no=shipment_in.batch_no,
carrier=shipment_in.carrier,
tracking_no=shipment_in.tracking_no,
from_party=shipment_in.from_party,
to_party=shipment_in.to_party,
status=shipment_in.status,
remark=shipment_in.remark,
created_by=created_by,
@@ -42,17 +43,23 @@ async def get_shipment(db: AsyncSession, shipment_id: uuid.UUID) -> DrugShipment
async def list_shipments(
db: AsyncSession,
study_id: uuid.UUID,
center_id: uuid.UUID | None = None,
site_name: str | None = None,
tracking_no: str | None = None,
direction: str | None = None,
status: str | None = None,
skip: int = 0,
limit: int = 100,
) -> Sequence[DrugShipment]:
stmt = select(DrugShipment).where(DrugShipment.study_id == study_id)
if center_id:
stmt = stmt.where(DrugShipment.center_id == center_id)
if site_name:
stmt = stmt.where(DrugShipment.site_name.ilike(f"%{site_name}%"))
if tracking_no:
stmt = stmt.where(DrugShipment.tracking_no.ilike(f"%{tracking_no}%"))
if direction:
stmt = stmt.where(DrugShipment.direction == direction)
if status:
stmt = stmt.where(DrugShipment.status == status)
stmt = stmt.order_by(DrugShipment.created_at.desc()).offset(skip).limit(limit)