Merge pull request 'feat(production-reception): 脐带MSC增加选填脐带长度(cm) (#190)' (#191) from feat/production-reception-cord-length into V2.0
Merge pull request #191 from feat/production-reception-cord-length into V2.0
This commit was merged in pull request #191.
This commit is contained in:
commit
2a967e285c
13 files changed
+154
-9
No files matched your search
@@ -67,6 +67,7 @@ class ProductionReceptionBody(BaseModel):
|
||||
available_cell_count_1e7: Optional[float] = Field(None, alias="availableCellCount1e7")
|
||||
original_blood_volume_ml: Optional[float] = Field(None, alias="originalBloodVolumeMl")
|
||||
nucleated_cell_count_1e8: Optional[float] = Field(None, alias="nucleatedCellCount1e8")
|
||||
cord_length_cm: Optional[float] = Field(None, alias="cordLengthCm")
|
||||
remark: Optional[str] = None
|
||||
|
||||
|
||||
@@ -92,6 +93,7 @@ def _body_to_payload(body: ProductionReceptionBody) -> dict:
|
||||
"availableCellCount1e7": body.available_cell_count_1e7,
|
||||
"originalBloodVolumeMl": body.original_blood_volume_ml,
|
||||
"nucleatedCellCount1e8": body.nucleated_cell_count_1e8,
|
||||
"cordLengthCm": body.cord_length_cm,
|
||||
"remark": body.remark,
|
||||
}
|
||||
|
||||
|
||||
@@ -32,10 +32,12 @@ FIELD_PROFILES: Dict[Tuple[str, str], List[str]] = {
|
||||
"cryopreservationTime",
|
||||
"storageTotalTubes",
|
||||
"availableCellCount1e7",
|
||||
"cordLengthCm",
|
||||
],
|
||||
("research_donation", SAMPLE_TYPE_UC_MSC): [
|
||||
"inoculationAmount",
|
||||
"cryopreservationTime",
|
||||
"cordLengthCm",
|
||||
],
|
||||
("research_donation", SAMPLE_TYPE_PERINATAL_HSC): [
|
||||
"originalBloodVolumeMl",
|
||||
@@ -43,6 +45,11 @@ FIELD_PROFILES: Dict[Tuple[str, str], List[str]] = {
|
||||
],
|
||||
}
|
||||
|
||||
# profile 内可选字段:出现在表单/落库,但不参与必填校验
|
||||
OPTIONAL_TYPE_FIELDS = {
|
||||
"cordLengthCm",
|
||||
}
|
||||
|
||||
ALL_TYPE_FIELDS = {
|
||||
"originalBloodWeightG",
|
||||
"hesVolumeMl",
|
||||
@@ -56,6 +63,7 @@ ALL_TYPE_FIELDS = {
|
||||
"availableCellCount1e7",
|
||||
"originalBloodVolumeMl",
|
||||
"nucleatedCellCount1e8",
|
||||
"cordLengthCm",
|
||||
}
|
||||
|
||||
|
||||
@@ -105,6 +113,7 @@ def _row_to_dict(row: BizSampleProductionReception) -> Dict[str, Any]:
|
||||
"availableCellCount1e7": _dec(row.available_cell_count_1e7),
|
||||
"originalBloodVolumeMl": _dec(row.original_blood_volume_ml),
|
||||
"nucleatedCellCount1e8": _dec(row.nucleated_cell_count_1e8),
|
||||
"cordLengthCm": _dec(getattr(row, "cord_length_cm", None)),
|
||||
"remark": row.remark or "",
|
||||
"createTime": _fmt_dt(row.create_time),
|
||||
"updateTime": _fmt_dt(row.update_time),
|
||||
@@ -148,8 +157,8 @@ def _validate_payload(
|
||||
source: str,
|
||||
sample_type_name: str,
|
||||
) -> None:
|
||||
required = {"handlerUserId", "processTime"} | set(
|
||||
resolve_field_profile(source, sample_type_name)
|
||||
required = {"handlerUserId", "processTime"} | (
|
||||
set(resolve_field_profile(source, sample_type_name)) - OPTIONAL_TYPE_FIELDS
|
||||
)
|
||||
for key in required:
|
||||
val = data.get(key)
|
||||
@@ -219,6 +228,7 @@ def _apply_payload_to_row(
|
||||
row.nucleated_cell_count_1e8 = (
|
||||
data.get("nucleatedCellCount1e8") if "nucleatedCellCount1e8" in allowed else None
|
||||
)
|
||||
row.cord_length_cm = data.get("cordLengthCm") if "cordLengthCm" in allowed else None
|
||||
|
||||
|
||||
def get_by_reception_id(
|
||||
|
||||
@@ -2062,6 +2062,7 @@ class BizSampleProductionReception(Base):
|
||||
available_cell_count_1e7 = Column(Numeric(18, 4), nullable=True, comment="可提供细胞数量/*10E7")
|
||||
original_blood_volume_ml = Column(Numeric(18, 4), nullable=True, comment="原血体积/ml")
|
||||
nucleated_cell_count_1e8 = Column(Numeric(18, 4), nullable=True, comment="有核细胞数/10E8")
|
||||
cord_length_cm = Column(Numeric(18, 4), nullable=True, comment="脐带长度(cm)")
|
||||
tenant_no = Column(String(64), nullable=False, default="zkxw", comment="租户编号")
|
||||
order_num = Column(Integer, nullable=True, comment="排序号")
|
||||
remark = Column(String(512), nullable=True, comment="备注")
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
"""生产接收 cordLengthCm:profile 挂载且选填。"""
|
||||
|
||||
from unittest import TestCase
|
||||
|
||||
from app.crud.sample_production_reception import (
|
||||
OPTIONAL_TYPE_FIELDS,
|
||||
_validate_payload,
|
||||
resolve_field_profile,
|
||||
)
|
||||
|
||||
|
||||
class ProductionReceptionCordLengthTest(TestCase):
|
||||
def test_uc_msc_profiles_include_optional_cord_length(self):
|
||||
for source in ("cell_storage", "research_donation"):
|
||||
profile = resolve_field_profile(source, "脐带间充质干细胞")
|
||||
self.assertIn("cordLengthCm", profile)
|
||||
self.assertEqual(profile[-1], "cordLengthCm")
|
||||
self.assertIn("cordLengthCm", OPTIONAL_TYPE_FIELDS)
|
||||
|
||||
def test_perinatal_hsc_profile_excludes_cord_length(self):
|
||||
profile = resolve_field_profile("cell_storage", "围产期造血干细胞")
|
||||
self.assertNotIn("cordLengthCm", profile)
|
||||
|
||||
def test_uc_msc_payload_allows_empty_cord_length(self):
|
||||
# 其他必填齐全时,缺省 cordLengthCm 不应报错
|
||||
_validate_payload(
|
||||
{
|
||||
"handlerUserId": "u1",
|
||||
"processTime": "2026-12-03",
|
||||
"inoculationAmount": "1ml",
|
||||
"cryopreservationTime": "2026-12-03",
|
||||
},
|
||||
source="research_donation",
|
||||
sample_type_name="脐带间充质干细胞",
|
||||
)
|
||||
@@ -0,0 +1,17 @@
|
||||
-- 生产接收:增加脐带长度(cm)。MySQL 5.7,可重复执行。
|
||||
|
||||
SET @col_exists := (
|
||||
SELECT COUNT(*) FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'biz_sample_production_reception'
|
||||
AND COLUMN_NAME = 'cord_length_cm'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@col_exists = 0,
|
||||
'ALTER TABLE biz_sample_production_reception
|
||||
ADD COLUMN cord_length_cm DECIMAL(18,4) NULL COMMENT ''脐带长度(cm)'' AFTER nucleated_cell_count_1e8',
|
||||
'SELECT 1'
|
||||
);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
@@ -0,0 +1,9 @@
|
||||
# 生产接收「脐带长度(cm)」Implementation Plan
|
||||
|
||||
**Goal:** 脐带 MSC 生产接收增加选填脐带长度(cm)。
|
||||
|
||||
**Architecture:** `cord_length_cm` 落库;前后端 profile 挂载;字段 `required:false` 避免被现有“profile 全必填”逻辑卡住。
|
||||
|
||||
**修改端:** backend / web-admin / mobile-oa-h5
|
||||
|
||||
关联 #190
|
||||
@@ -0,0 +1,31 @@
|
||||
# 生产接收增加「脐带长度(cm)」
|
||||
|
||||
关联 Gitea #190。
|
||||
|
||||
## 目标
|
||||
|
||||
在生产接收登记中增加选填字段「脐带长度(cm)」,仅对脐带间充质干细胞(细胞存储 + 科研捐赠)展示与录入;凡展示生产接收信息处一并显示。
|
||||
|
||||
## 约束
|
||||
|
||||
- 选填;空值存 `NULL`
|
||||
- 仅 profile:`cell_storage|脐带间充质干细胞`、`research_donation|脐带间充质干细胞`
|
||||
- 表单位置:对应配置字段列表末尾、备注前
|
||||
- 不改质检接收字段
|
||||
|
||||
## 数据与 API
|
||||
|
||||
- 表 `biz_sample_production_reception` 新增:`cord_length_cm DECIMAL(18,4) NULL COMMENT '脐带长度(cm)'`
|
||||
- 迁移:`docs/sql/migrations/2026-12-03-production-reception-cord-length-cm.sql`
|
||||
- ORM / CRUD / API:`cordLengthCm`
|
||||
|
||||
## 前端
|
||||
|
||||
- `sample-production-reception-fields.ts`:字段定义 + 两处 profile 挂载
|
||||
- 生产填写弹窗、共享只读、详情、mobile-oa-h5 生产接收卡片走现有 `resolveProductionReceptionFields`
|
||||
|
||||
## 验收
|
||||
|
||||
1. 脐带 MSC 生产接收可填脐带长度,空可提交
|
||||
2. 围产期造血干等其他配置不出现该字段
|
||||
3. 只读/详情/移动端生产接收可见该值(空为 —)
|
||||
@@ -12,7 +12,8 @@ const FIELD_DEFS = Object.freeze({
|
||||
storageTotalTubes: { key: 'storageTotalTubes', label: '储存总量(管)' },
|
||||
availableCellCount1e7: { key: 'availableCellCount1e7', label: '可提供细胞数量/*10E7' },
|
||||
originalBloodVolumeMl: { key: 'originalBloodVolumeMl', label: '原血体积/ml' },
|
||||
nucleatedCellCount1e8: { key: 'nucleatedCellCount1e8', label: '有核细胞数/10E8' }
|
||||
nucleatedCellCount1e8: { key: 'nucleatedCellCount1e8', label: '有核细胞数/10E8' },
|
||||
cordLengthCm: { key: 'cordLengthCm', label: '脐带长度(cm)' }
|
||||
})
|
||||
|
||||
const PROFILE_KEYS = Object.freeze({
|
||||
@@ -21,9 +22,12 @@ const PROFILE_KEYS = Object.freeze({
|
||||
'infectiousFourTestResult', 'enrichedBloodWeightG', 'cryopreservationVolumeMl'
|
||||
],
|
||||
'cell_storage|脐带间充质干细胞': [
|
||||
'inoculationAmount', 'cryopreservationTime', 'storageTotalTubes', 'availableCellCount1e7'
|
||||
'inoculationAmount', 'cryopreservationTime', 'storageTotalTubes', 'availableCellCount1e7',
|
||||
'cordLengthCm'
|
||||
],
|
||||
'research_donation|脐带间充质干细胞': [
|
||||
'inoculationAmount', 'cryopreservationTime', 'cordLengthCm'
|
||||
],
|
||||
'research_donation|脐带间充质干细胞': ['inoculationAmount', 'cryopreservationTime'],
|
||||
'research_donation|围产期造血干细胞': ['originalBloodVolumeMl', 'nucleatedCellCount1e8']
|
||||
})
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ test('matches Web production reception profiles by source and sample type', () =
|
||||
)
|
||||
assert.deepEqual(
|
||||
resolveProductionReceptionFields('research_donation', '脐带间充质干细胞').map((field) => field.key),
|
||||
['inoculationAmount', 'cryopreservationTime']
|
||||
['inoculationAmount', 'cryopreservationTime', 'cordLengthCm']
|
||||
)
|
||||
assert.deepEqual(
|
||||
resolveProductionReceptionFields('research_donation', '围产期造血干细胞').map((field) => field.key),
|
||||
@@ -25,7 +25,10 @@ test('matches Web production reception profiles by source and sample type', () =
|
||||
)
|
||||
assert.deepEqual(
|
||||
resolveProductionReceptionFields('cell_storage', '脐带间充质干细胞').map((field) => field.key),
|
||||
['inoculationAmount', 'cryopreservationTime', 'storageTotalTubes', 'availableCellCount1e7']
|
||||
[
|
||||
'inoculationAmount', 'cryopreservationTime', 'storageTotalTubes', 'availableCellCount1e7',
|
||||
'cordLengthCm'
|
||||
]
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ export type ProductionReceptionPayload = {
|
||||
availableCellCount1e7?: number
|
||||
originalBloodVolumeMl?: number
|
||||
nucleatedCellCount1e8?: number
|
||||
cordLengthCm?: number | null
|
||||
remark?: string
|
||||
}
|
||||
|
||||
|
||||
@@ -31,4 +31,20 @@ describe('inoculationAmount / cryopreservationTime field kinds', () => {
|
||||
assert.equal(formatProductionFieldValue(inoc, record), '约 5×10⁶ cells,接种体积 2ml')
|
||||
assert.equal(formatProductionFieldValue(cryo, record), '2026-07-14')
|
||||
})
|
||||
|
||||
it('adds optional cordLengthCm at end of UC-MSC profiles only', () => {
|
||||
for (const source of ['cell_storage', 'research_donation'] as const) {
|
||||
const fields = resolveProductionReceptionFields(source, '脐带间充质干细胞')
|
||||
const cord = fields.find((f) => f.key === 'cordLengthCm')
|
||||
assert.ok(cord)
|
||||
assert.equal(cord.label, '脐带长度(cm)')
|
||||
assert.equal(cord.required, false)
|
||||
assert.equal(fields[fields.length - 1].key, 'cordLengthCm')
|
||||
}
|
||||
const hsc = resolveProductionReceptionFields('cell_storage', '围产期造血干细胞')
|
||||
assert.equal(
|
||||
hsc.some((f) => f.key === 'cordLengthCm'),
|
||||
false
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -18,12 +18,15 @@ export type ProductionReceptionFieldKey =
|
||||
| 'availableCellCount1e7'
|
||||
| 'originalBloodVolumeMl'
|
||||
| 'nucleatedCellCount1e8'
|
||||
| 'cordLengthCm'
|
||||
|
||||
export type ProductionReceptionFieldDef = {
|
||||
key: ProductionReceptionFieldKey
|
||||
label: string
|
||||
kind: 'number' | 'text' | 'datetime' | 'date' | 'select' | 'integer'
|
||||
maxLength?: number
|
||||
/** 默认 true;false 时表单不强制必填 */
|
||||
required?: boolean
|
||||
selectOptions?: Array<{ label: string; value: string }>
|
||||
}
|
||||
|
||||
@@ -66,6 +69,12 @@ const FIELD_DEFS: Record<ProductionReceptionFieldKey, ProductionReceptionFieldDe
|
||||
key: 'nucleatedCellCount1e8',
|
||||
label: '有核细胞数/10E8',
|
||||
kind: 'number'
|
||||
},
|
||||
cordLengthCm: {
|
||||
key: 'cordLengthCm',
|
||||
label: '脐带长度(cm)',
|
||||
kind: 'number',
|
||||
required: false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,9 +91,14 @@ const PROFILE_KEYS: Record<string, ProductionReceptionFieldKey[]> = {
|
||||
'inoculationAmount',
|
||||
'cryopreservationTime',
|
||||
'storageTotalTubes',
|
||||
'availableCellCount1e7'
|
||||
'availableCellCount1e7',
|
||||
'cordLengthCm'
|
||||
],
|
||||
'research_donation|脐带间充质干细胞': [
|
||||
'inoculationAmount',
|
||||
'cryopreservationTime',
|
||||
'cordLengthCm'
|
||||
],
|
||||
'research_donation|脐带间充质干细胞': ['inoculationAmount', 'cryopreservationTime'],
|
||||
'research_donation|围产期造血干细胞': ['originalBloodVolumeMl', 'nucleatedCellCount1e8']
|
||||
}
|
||||
|
||||
@@ -125,6 +139,7 @@ export type ProductionReceptionRecord = {
|
||||
availableCellCount1e7?: number
|
||||
originalBloodVolumeMl?: number
|
||||
nucleatedCellCount1e8?: number
|
||||
cordLengthCm?: number | null
|
||||
remark?: string
|
||||
}
|
||||
|
||||
|
||||
@@ -360,6 +360,7 @@
|
||||
handlerUserId: [{ required: true, message: '请选择处理人', trigger: 'change' }]
|
||||
}
|
||||
for (const field of productionFieldDefs.value) {
|
||||
if (field.required === false) continue
|
||||
rules[field.key] = [{ required: true, message: `请填写${field.label}`, trigger: 'blur' }]
|
||||
}
|
||||
return rules
|
||||
|
||||
Reference in new issue
Block a user