提交
This commit is contained in:
1 parent
09afdb1d65
commit
afd517ce10
215 files changed
+32936
-23862
No files matched your search
@@ -85,7 +85,19 @@ def list_sample_codes(
|
||||
kw = (keyword or "").strip()
|
||||
if kw:
|
||||
like = f"%{kw}%"
|
||||
q0 = q0.filter(or_(BizSampleCode.sample_code.like(like), BizSampleCode.remark.like(like)))
|
||||
kw_conds = [
|
||||
BizSampleCode.sample_code.like(like),
|
||||
BizSampleCode.remark.like(like),
|
||||
]
|
||||
if tenant_no:
|
||||
from app.crud import sample_reception as reception_svc
|
||||
|
||||
lab_codes = reception_svc.sample_codes_matching_lab_storage_keyword(
|
||||
db, tenant_no, kw
|
||||
)
|
||||
if lab_codes:
|
||||
kw_conds.append(BizSampleCode.sample_code.in_(lab_codes))
|
||||
q0 = q0.filter(or_(*kw_conds))
|
||||
return q0
|
||||
|
||||
total = _filtered().order_by(None).with_entities(func.count(BizSampleCode.id)).scalar() or 0
|
||||
@@ -98,7 +110,16 @@ def list_sample_codes(
|
||||
.limit(page_size)
|
||||
.all()
|
||||
)
|
||||
return [_row_to_dict(x) for x in rows], int(total)
|
||||
items = [_row_to_dict(x) for x in rows]
|
||||
if items and tenant_no:
|
||||
from app.crud import sample_reception as reception_svc
|
||||
|
||||
codes = [i["sampleCode"] for i in items if i.get("sampleCode")]
|
||||
code_map = reception_svc.get_lab_storage_code_map_by_sample_codes(db, tenant_no, codes)
|
||||
for item in items:
|
||||
sc = (item.get("sampleCode") or "").strip()
|
||||
item["labStorageCode"] = code_map.get(sc, "") if sc else ""
|
||||
return items, int(total)
|
||||
|
||||
|
||||
def get_sample_code(db: Session, row_id: str, tenant_no: Optional[str] = None) -> Optional[BizSampleCode]:
|
||||
|
||||
Reference in new issue
Block a user