Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12cf373a49 | ||
|
|
0434999603 | ||
|
|
f40d33b07a | ||
|
|
e5f84b4693 | ||
|
|
71424ff576 | ||
|
|
fbe62c7a9b |
No files matched your search
@@ -1394,6 +1394,7 @@ def list_collection_protocols(
|
||||
"sampleTypeName": type_name,
|
||||
"sampleCode": code,
|
||||
"sampleStatus": (s.sample_status or "").strip(),
|
||||
"voidDesc": (getattr(s, "void_desc", None) or "").strip(),
|
||||
"labStorageCode": lab_code_map.get(code, "") if code else "",
|
||||
"transport": transport_dict,
|
||||
"freight": freight_by_sample.get(s.id),
|
||||
|
||||
@@ -410,7 +410,8 @@ def list_protocol_sample_collections(
|
||||
item["newbornDeliveryTime"] = _fmt_dt(party.newborn_delivery_time) if party else ""
|
||||
item["protocolRemark"] = (proto.remark or "") if proto else ""
|
||||
item["voidType"] = (proto.void_type or "") if proto else ""
|
||||
item["voidDesc"] = (proto.void_desc or "") if proto else ""
|
||||
# 样本状态问号展示样本作废原因,不用协议作废描述
|
||||
item["voidDesc"] = (getattr(psample, "void_desc", None) or "").strip()
|
||||
item["protocolAttachments"] = (proto.protocol_attachments or "") if proto else ""
|
||||
item["consentFormUrls"] = (proto.consent_form_urls or "") if proto else ""
|
||||
item["healthSurveyFormUrls"] = (proto.health_survey_form_urls or "") if proto else ""
|
||||
|
||||
@@ -976,6 +976,7 @@ def list_donations(
|
||||
"sampleTypeName": type_name,
|
||||
"sampleCode": code,
|
||||
"sampleStatus": (s.sample_status or "").strip(),
|
||||
"voidDesc": (getattr(s, "void_desc", None) or "").strip(),
|
||||
"labStorageCode": lab_code_map.get(code, "") if code else "",
|
||||
"transport": transport_dict,
|
||||
"freight": freight_by_sample.get(s.id),
|
||||
|
||||
@@ -444,6 +444,7 @@ def _rows_to_sample_list_items(
|
||||
"sampleTypeName": type_map.get(sample.sample_type_id or "", ""),
|
||||
"collectAmount": _dec(sample.collect_amount),
|
||||
"sampleStatus": sample.sample_status or "",
|
||||
"voidDesc": (getattr(sample, "void_desc", None) or "").strip(),
|
||||
"motherName": (party.mother_name if party else "") or "",
|
||||
"newbornName": (party.newborn_name if party else "") or "",
|
||||
"sampleCollectTime": (
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
"""市场协议无效态 ↔ 样本接收废弃 / 样本状态作废联动。
|
||||
|
||||
规则(细胞存储 / 科研捐赠):
|
||||
1. 单条样本接收结论为废弃(bj)时:仅该样本 `sample_status` 置为已作废(yzf)并写 `void_date`;
|
||||
协议状态保持不变。接收结论改回接收(js)且协议仍有效时:若该样本为 yzf,则清空状态与 void_date。
|
||||
1. 单条样本接收结论为废弃(bj)时:仅该样本 `sample_status` 置为已作废(yzf),
|
||||
写 `void_date`,并将接收备注写入 `void_desc`(备注为空则作废原因为空);
|
||||
协议状态保持不变。接收结论改回接收(js)且协议仍有效时:若该样本为 yzf,则清空状态、void_date 与 void_desc。
|
||||
2. 协议变为已作废(yzf)或属地废弃(sdfq)时:
|
||||
- 协议下全部样本接收结论自动为废弃(bj);
|
||||
- 协议下全部有效样本 `sample_status` 置为已作废(yzf),并写入 `void_date`。
|
||||
@@ -585,13 +586,17 @@ def void_sample_for_discarded_reception(
|
||||
tenant_no: str,
|
||||
user_id: Optional[str] = None,
|
||||
) -> bool:
|
||||
"""单条接收废弃:仅将该样本置为已作废。"""
|
||||
"""单条接收废弃:将该样本置为已作废,作废原因取接收备注。"""
|
||||
_source, sample = _find_sample_for_reception(db, reception=reception, tenant_no=tenant_no)
|
||||
if not sample:
|
||||
return False
|
||||
now = datetime.now()
|
||||
reason = (reception.remark or "").strip()
|
||||
if len(reason) > 512:
|
||||
reason = reason[:512]
|
||||
sample.sample_status = SAMPLE_VOID_STATUS
|
||||
sample.void_date = _void_date_yyyymmdd(void_time=reception.reception_time or now)
|
||||
sample.void_desc = reason or None
|
||||
sample.update_by = user_id
|
||||
sample.update_time = now
|
||||
db.add(sample)
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
"""协议/捐赠列表 sampleItems 须返回样本 voidDesc,供审核列表问号展示。"""
|
||||
from __future__ import annotations
|
||||
|
||||
import inspect
|
||||
import re
|
||||
import unittest
|
||||
|
||||
|
||||
_SAMPLE_ITEM_VOID_DESC = re.compile(
|
||||
r'"sampleStatus"\s*:\s*\(s\.sample_status[^)]*\)\.strip\(\),\s*'
|
||||
r'"voidDesc"\s*:\s*\(getattr\(s,\s*"void_desc"',
|
||||
re.S,
|
||||
)
|
||||
|
||||
|
||||
class TestProtocolListSampleVoidDesc(unittest.TestCase):
|
||||
def test_collection_protocol_list_includes_sample_void_desc(self):
|
||||
from app.crud import collection_protocol as cp
|
||||
|
||||
src = inspect.getsource(cp.list_collection_protocols)
|
||||
self.assertRegex(src, _SAMPLE_ITEM_VOID_DESC)
|
||||
|
||||
def test_research_donation_list_includes_sample_void_desc(self):
|
||||
from app.crud import research_donation as rd
|
||||
|
||||
# 捐赠列表函数名
|
||||
fn = None
|
||||
for name, obj in inspect.getmembers(rd, inspect.isfunction):
|
||||
if "list" in name and "donation" in name:
|
||||
src = inspect.getsource(obj)
|
||||
if "sample_items.append" in src and '"sampleStatus"' in src:
|
||||
fn = obj
|
||||
break
|
||||
self.assertIsNotNone(fn, "未找到组装 sampleItems 的捐赠列表函数")
|
||||
self.assertRegex(inspect.getsource(fn), _SAMPLE_ITEM_VOID_DESC)
|
||||
|
||||
def test_sample_collection_list_uses_sample_void_desc(self):
|
||||
from app.crud import protocol_sample_collection as psc
|
||||
|
||||
src = inspect.getsource(psc)
|
||||
self.assertIn('getattr(psample, "void_desc"', src)
|
||||
self.assertNotIn('item["voidDesc"] = (proto.void_desc or "") if proto else ""', src)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -440,6 +440,7 @@ class TestProtocolReceptionDiscardSync(unittest.TestCase):
|
||||
accept_conclusion="bj",
|
||||
reception_source="cell_storage",
|
||||
sample_code="ZKA",
|
||||
remark="母血乙肝阳性",
|
||||
tenant_no="tenant-a",
|
||||
create_dept_id="",
|
||||
create_time=now,
|
||||
@@ -471,6 +472,7 @@ class TestProtocolReceptionDiscardSync(unittest.TestCase):
|
||||
}
|
||||
self.assertEqual(by_id["sa"].sample_status, SAMPLE_VOID_STATUS)
|
||||
self.assertEqual(by_id["sa"].void_date, "20261105")
|
||||
self.assertEqual(by_id["sa"].void_desc, "母血乙肝阳性")
|
||||
self.assertEqual(by_id["sb"].sample_status, "ycj")
|
||||
self.assertEqual(by_id["sc"].sample_status, "ycj")
|
||||
|
||||
@@ -496,6 +498,7 @@ class TestProtocolReceptionDiscardSync(unittest.TestCase):
|
||||
sample_code="ZKCLR",
|
||||
sample_status=SAMPLE_VOID_STATUS,
|
||||
void_date="20261101",
|
||||
void_desc="旧作废原因",
|
||||
tenant_no="tenant-a",
|
||||
create_dept_id="",
|
||||
create_time=now,
|
||||
@@ -535,6 +538,7 @@ class TestProtocolReceptionDiscardSync(unittest.TestCase):
|
||||
sample = db.query(BizProtocolSample).filter(BizProtocolSample.id == "s-clear").one()
|
||||
self.assertFalse((sample.sample_status or "").strip())
|
||||
self.assertFalse((sample.void_date or "").strip())
|
||||
self.assertFalse((sample.void_desc or "").strip())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -4,6 +4,8 @@ export type SampleVoidTarget = {
|
||||
receptionSource: 'cell_storage' | 'research_donation'
|
||||
sampleId?: string
|
||||
sampleCode?: string
|
||||
/** 仅弹窗展示,不参与作废请求 */
|
||||
labStorageCode?: string
|
||||
protocolId?: string
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
class="biz-dialog-form"
|
||||
>
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="实验室入库编码" class="form-col-span-2">
|
||||
<span class="sample-void-dialog__code">{{ labStorageCodeDisplay }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="sampleCode" label="样本编码" class="form-col-span-2">
|
||||
<span class="sample-void-dialog__code">{{ sampleCode }}</span>
|
||||
</el-form-item>
|
||||
@@ -84,6 +87,9 @@
|
||||
]
|
||||
}
|
||||
|
||||
const labStorageCodeDisplay = computed(
|
||||
() => String(props.target?.labStorageCode || '').trim() || '—'
|
||||
)
|
||||
const sampleCode = computed(() => String(props.target?.sampleCode || '').trim())
|
||||
|
||||
watch(
|
||||
|
||||
@@ -8,12 +8,14 @@ describe('resolveSampleVoidTarget', () => {
|
||||
receptionSource: 'cell_storage',
|
||||
protocolSampleId: 'ps-1',
|
||||
sampleCode: 'S1',
|
||||
labStorageCode: 'B0000108',
|
||||
collectionProtocolId: 'p-1'
|
||||
})
|
||||
assert.deepEqual(target, {
|
||||
receptionSource: 'cell_storage',
|
||||
sampleId: 'ps-1',
|
||||
sampleCode: 'S1',
|
||||
labStorageCode: 'B0000108',
|
||||
protocolId: 'p-1'
|
||||
})
|
||||
})
|
||||
|
||||
@@ -8,6 +8,7 @@ export function resolveSampleVoidTarget(input: {
|
||||
receptionSource?: string | null
|
||||
protocolSampleId?: string | null
|
||||
sampleCode?: string | null
|
||||
labStorageCode?: string | null
|
||||
collectionProtocolId?: string | null
|
||||
fallbackSource?: string | null
|
||||
}): SampleVoidTarget | null {
|
||||
@@ -18,12 +19,14 @@ export function resolveSampleVoidTarget(input: {
|
||||
if (source !== 'cell_storage' && source !== 'research_donation') return null
|
||||
const sampleId = String(input.protocolSampleId || '').trim()
|
||||
const sampleCode = String(input.sampleCode || '').trim()
|
||||
const labStorageCode = String(input.labStorageCode || '').trim()
|
||||
const protocolId = String(input.collectionProtocolId || '').trim()
|
||||
if (!sampleId && !sampleCode) return null
|
||||
return {
|
||||
receptionSource: source,
|
||||
sampleId: sampleId || undefined,
|
||||
sampleCode: sampleCode || undefined,
|
||||
labStorageCode: labStorageCode || undefined,
|
||||
protocolId: protocolId || undefined
|
||||
}
|
||||
}
|
||||
@@ -499,6 +499,7 @@
|
||||
receptionSource: row.receptionSource,
|
||||
protocolSampleId: row.protocolSampleId,
|
||||
sampleCode: row.sampleCode,
|
||||
labStorageCode: row.labStorageCode,
|
||||
collectionProtocolId: row.collectionProtocolId,
|
||||
fallbackSource: productionVoidFallbackSource(row)
|
||||
})
|
||||
@@ -509,6 +510,7 @@
|
||||
receptionSource: row.receptionSource,
|
||||
protocolSampleId: row.protocolSampleId,
|
||||
sampleCode: row.sampleCode,
|
||||
labStorageCode: row.labStorageCode,
|
||||
collectionProtocolId: row.collectionProtocolId,
|
||||
fallbackSource: productionVoidFallbackSource(row)
|
||||
})
|
||||
|
||||
@@ -419,6 +419,7 @@
|
||||
receptionSource: props.row.receptionSource,
|
||||
protocolSampleId: props.row.protocolSampleId,
|
||||
sampleCode: props.row.sampleCode,
|
||||
labStorageCode: props.row.labStorageCode,
|
||||
collectionProtocolId: props.row.collectionProtocolId,
|
||||
fallbackSource: inboundVoidFallbackSource()
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user