优化更新患者信息接口,简化文件上传逻辑;修正身份证号码解析函数的区域代码提取

This commit is contained in:
yuchenglong
2025-12-09 14:07:43 +08:00
parent 58aa8bbdf0
commit 0daeb03e62
2 changed files with 17 additions and 32 deletions

View File

@@ -4,11 +4,11 @@ export function parseRegionCodesFromId(idNo: string | null | undefined) {
const s = String(idNo).trim();
// 身份证号码前6位为行政区划代码
if (!/^[0-9]{6,}/.test(s)) return result;
const first6 = s.slice(4, 6);
const first4 = s.slice(2, 4);
const first6 = s.slice(0, 6);
const first4 = s.slice(0, 4);
const first2 = s.slice(0, 2);
result.county = first6;
result.city = `${first4}`;
result.province = `${first2}`;
result.county = first6; // 6位县级代码
result.city = `${first4}`; // 市级代码前4位+00
result.province = `${first2}`; // 省级代码前2位+0000
return result;
}