WXL (wul)
17 小时以前 a9d2b856e0f6be6475319c2dc36bf405c2f908fc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
// 妇保/儿保 5 种特殊患者专案注册表(单一数据源)
// category: maternal=妇保科 / child=儿保科
// entryLabel: 入口(门诊记录页选专案)按钮名
// label:      列表页/详情页标题
// columns:    列表页列定义 { label, prop, type }
//   type 取值:text(默认) | sex | date | closeStatus
export const ARCHIVE_TYPES = [
  {
    key: "pregnancy",
    category: "maternal",
    entryLabel: "早孕关爱",
    label: "孕妇随访",
    subTypeLabel: "孕妇随访",
    route: "/filing/pregnancy",
    detailRoute: "/filing/maternalDetail",
    columns: [
      { label: "姓名", prop: "patname" },
      { label: "出生日期", prop: "birthday", type: "date" },
      { label: "身份证号", prop: "idcardno" },
      { label: "联系电话", prop: "telcode" },
      { label: "诊断日期", prop: "diagnosisDate", type: "date" },
      { label: "建档日期", prop: "createTime", type: "date" },
      { label: "诊断", prop: "diagname" },
      { label: "妊娠情况", prop: "pregnancyStatus" },
      { label: "主治医生", prop: "attendingDoctor" },
      { label: "经管医生", prop: "managingDoctor" },
      { label: "结案状态", prop: "closeStatus", type: "closeStatus" },
      { label: "登记人员", prop: "registrant" },
    ],
  },
  {
    key: "menopause",
    category: "maternal",
    entryLabel: "围绝经期MHI",
    label: "围绝经期MHI",
    subTypeLabel: "围绝经期MHI",
    route: "/filing/menopause",
    detailRoute: "/filing/maternalDetail",
    columns: [
      { label: "姓名", prop: "patname" },
      { label: "出生日期", prop: "birthday", type: "date" },
      { label: "身份证号", prop: "idcardno" },
      { label: "联系电话", prop: "telcode" },
      { label: "诊断日期", prop: "diagnosisDate", type: "date" },
      { label: "建档日期", prop: "createTime", type: "date" },
      { label: "诊断", prop: "diagname" },
      { label: "随访周期(次数)", prop: "followupCycles" },
      { label: "主治医生", prop: "attendingDoctor" },
      { label: "经管医生", prop: "managingDoctor" },
      { label: "结案状态", prop: "closeStatus", type: "closeStatus" },
      { label: "登记人员", prop: "registrant" },
    ],
  },
  {
    key: "highRisk",
    category: "child",
    entryLabel: "高危儿专案",
    label: "高危儿专案",
    subTypeLabel: "高危儿专案管理",
    route: "/filing/highRisk",
    detailRoute: "/filing/childDetail",
    columns: [
      { label: "儿童姓名", prop: "patname" },
      { label: "家长姓名", prop: "parentInfo.parentName" },
      { label: "拟随访日期", prop: "followupDate", type: "date" },
      { label: "联系电话", prop: "telcode" },
      { label: "诊断日期", prop: "diagnosisDate", type: "date" },
      { label: "建档日期", prop: "createTime", type: "date" },
      { label: "出生孕周", prop: "gestationalWeek" },
      { label: "性别", prop: "sex", type: "sex" },
      { label: "出生日期", prop: "birthday", type: "date" },
      { label: "出生体重", prop: "birthWeight" },
      { label: "高危儿分类", prop: "highRiskCategory" },
      { label: "高危儿名称", prop: "highRiskName" },
      { label: "登记人员", prop: "registrant" },
    ],
  },
  {
    key: "nutrition",
    category: "child",
    entryLabel: "营养性疾病",
    label: "营养性疾病",
    subTypeLabel: "营养性疾病专案管理",
    route: "/filing/nutrition",
    detailRoute: "/filing/childDetail",
    columns: [
      { label: "儿童姓名", prop: "patname" },
      { label: "家长姓名", prop: "parentInfo.parentName" },
      { label: "出生日期", prop: "birthday", type: "date" },
      { label: "联系电话", prop: "telcode" },
      { label: "诊断日期", prop: "diagnosisDate", type: "date" },
      { label: "建档日期", prop: "createTime", type: "date" },
      { label: "出生孕周", prop: "gestationalWeek" },
      { label: "性别", prop: "sex", type: "sex" },
      { label: "出生体重", prop: "birthWeight" },
      { label: "营养性疾病名称", prop: "nutritionName" },
      { label: "登记人员", prop: "registrant" },
    ],
  },
  {
    key: "learning",
    category: "child",
    entryLabel: "学习困难",
    label: "学习困难",
    subTypeLabel: "学习困难专案管理",
    route: "/filing/learning",
    detailRoute: "/filing/childDetail",
    columns: [
      { label: "儿童姓名", prop: "patname" },
      { label: "家长姓名", prop: "parentInfo.parentName" },
      { label: "出生日期", prop: "birthday", type: "date" },
      { label: "联系电话", prop: "telcode" },
      { label: "诊断日期", prop: "diagnosisDate", type: "date" },
      { label: "建档日期", prop: "createTime", type: "date" },
      { label: "性别", prop: "sex", type: "sex" },
      { label: "预约情况", prop: "appointmentStatus" },
    ],
  },
];
 
export function getTypeByKey(key) {
  return ARCHIVE_TYPES.find((t) => t.key === key);
}
 
// 读取 localStorage 档案列表
export function loadArchives() {
  try {
    return JSON.parse(localStorage.getItem("patientArchives") || "[]");
  } catch (e) {
    return [];
  }
}
 
export function saveArchives(list) {
  localStorage.setItem("patientArchives", JSON.stringify(list));
}
 
// 由一条患者记录(门诊/住院/独立录入)生成某专案的档案草稿
export function buildArchiveRecord(patient, typeKey, sourcePage) {
  const type = getTypeByKey(typeKey);
  const now = new Date().toISOString().replace("T", " ").substring(0, 19);
  const patid = patient.patid || patient.id || "sa_" + Date.now();
  return {
    id: "arc_" + Date.now() + "_" + Math.random().toString(36).substr(2, 6),
    patientId: patid,
    patid: patid,
    patname: patient.patname || patient.name || "",
    sex: patient.sex,
    age: patient.age,
    telcode: patient.telcode || patient.phone || "",
    deptname: patient.deptname || "",
    diagname: patient.diagname || "",
    outhospno: patient.outhospno || "",
    inhospno: patient.inhospno || "",
    bedNo: patient.bedNo || "",
    drname: patient.drname || "",
    nurseName: patient.nurseName || "",
    starttime: patient.starttime || patient.admitdate || "",
    mainCategory: type.category,
    mainCategoryLabel: type.category === "child" ? "儿保科建档" : "妇保科建档",
    subType: type.key,
    subTypeLabel: type.subTypeLabel,
    archiveForm: { doctorName: "" },
    parentInfo: {},
    sourcePage: sourcePage || "outpatient",
    status: "active",
    closeStatus: 0,
    // 列表页新增字段
    idcardno: patient.idcardno || "",
    birthday: patient.birthday || patient.goday || "",
    birthWeight: "",
    gestationalWeek: "",
    diagnosisDate: patient.diagnosisDate || patient.admitdate || "",
    attendingDoctor: patient.drname || "",
    managingDoctor: "",
    registrant: localStorage.getItem("YongHuXM") || "",
    pregnancyStatus: "",
    followupCycles: "",
    highRiskCategory: "",
    highRiskName: "",
    nutritionName: "",
    appointmentStatus: "",
    followupDate: "",
    createTime: now,
    updateTime: now,
  };
}