-
模板名称:
+
+
+
+ 模板名称:
{
- // 复诊优先展示初诊日期
if (props.visitType === 'FOLLOW_UP' && props.firstVisitDate) {
return props.firstVisitDate;
}
- // 初诊或未获取初诊日期时,展示挂号时间或当前时间
- return formatDate(props.patientInfo?.registerTime || new Date());
+ return formatDateUtil(props.patientInfo?.registerTime || new Date());
});
-const form = ref({});
+// 表单数据
+const form = ref({
+ height: '',
+ weight: '',
+ temperature: '',
+ pulse: '',
+ chiefComplaint: '',
+ onsetDate: '',
+ currentIllnessHistory: '',
+ pastMedicalHistory: '',
+ menstrualHistory: '',
+ allergyHistory: '',
+ physicalExamination: '',
+ treatment: '',
+ auxiliaryExamination: '',
+});
+
+// 文本字段配置(用于循环渲染)
+const textFieldList = [
+ { key: 'currentIllnessHistory', label: '现病史' },
+ { key: 'pastMedicalHistory', label: '既往史' },
+ { key: 'menstrualHistory', label: '个人史' },
+ { key: 'allergyHistory', label: '过敏史' },
+ { key: 'physicalExamination', label: '查体' },
+ { key: 'treatment', label: '处理' },
+ { key: 'auxiliaryExamination', label: '辅助检查' },
+];
+
+// 弹窗控制
const emrTitle = ref('');
const radio = ref(1);
-const rules = ref({
- chiefComplaint: [{ required: true, message: '请输入主诉', trigger: 'blur' }],
-});
-const emits = defineEmits(['save']);
-const { proxy } = getCurrentInstance();
const showDialog = ref('');
const openEmrTemplate = ref(false);
const templateName = ref('');
+// 事件
+const emits = defineEmits(['save']);
+const { proxy } = getCurrentInstance();
+
+// 监听表单变化
watch(
() => form.value,
() => {
- // 如果表单数据有变化,通知父组件保存
emits('save', false);
},
{ deep: true }
);
-/**
- * 保存病历
- */
+// 格式化日期(用于 onsetDate)
+function formatDate(date) {
+ if (!date) return '';
+ return formatDateUtil(date);
+}
+
+// 保存病历
function addEmr() {
- proxy.$refs['emrRef'].validate((valid) => {
- if (valid) {
- saveEmr({
- patientId: props.patientInfo.patientId,
- encounterId: props.patientInfo.encounterId,
- contextJson: form.value,
- }).then((res) => {
- if (res.code == 200) {
- proxy.$modal.msgSuccess('病历已保存');
- emits('save', true);
- }
- });
+ // 简单校验主诉
+ if (!form.value.chiefComplaint) {
+ proxy.$message.warning('请输入主诉');
+ return;
+ }
+ saveEmr({
+ patientId: props.patientInfo.patientId,
+ encounterId: props.patientInfo.encounterId,
+ contextJson: form.value,
+ }).then((res) => {
+ if (res.code === 200) {
+ proxy.$modal.msgSuccess('病历已保存');
+ emits('save', true);
}
});
}
-/**
- * 病历模板
- */
+
+// 打开模板
function handleEmrTemplate() {
emrTitle.value = '病历模板';
showDialog.value = 'emrTemplate';
openEmrTemplate.value = true;
}
-/**
- * 选择病历模板
- */
-function templateSelect(row) {
- form.value = row;
-}
-function emrHistorySelect(row) {
- form.value = row;
- openEmrTemplate.value = false;
-}
-/**
- * 历史病历
- */
+
+// 打开历史
function handleEmrHistory() {
emrTitle.value = '历史病历';
showDialog.value = 'emrHistory';
@@ -299,55 +239,93 @@ function handleEmrHistory() {
sessionStorage.setItem('patientId', props.patientInfo.patientId);
}
-function getDetail(encounterId) {
- getEmrDetail(encounterId).then((res) => {
- if (res.data) {
- form.value = JSON.parse(res.data.contextJson);
- // 提交父组件刷新保存装填
- emits('save', true);
- } else {
- form.value = {};
- }
- });
-}
-
-/**
- * 保存病历模板
- */
+// 保存为模板
function handleSaveTemplate() {
emrTitle.value = '保存模板';
showDialog.value = 'saveTemplate';
openEmrTemplate.value = true;
}
-/**
- * 弹窗确认操作,包括保存病历模板/选择病历模板/选择历史病历
- */
-function submit() {
- switch (showDialog.value) {
- case 'saveTemplate':
- saveEmrTemplate({
- templateName: templateName.value,
- useScopeCode: radio.value,
- contextJson: form.value,
- }).then((res) => {
- if (res.code == 200) {
- openEmrTemplate.value = false;
- proxy.$modal.msgSuccess('保存成功');
- }
- });
- break;
- case 'emrTemplate':
- openEmrTemplate.value = false;
- break;
- case 'emrHistory':
- break;
- }
-}
-function cancel() {
+// 选择模板/历史
+function templateSelect(row) {
+ form.value = { ...row };
+ openEmrTemplate.value = false;
+}
+function emrHistorySelect(row) {
+ form.value = { ...row };
openEmrTemplate.value = false;
- // openDiagnosis.value = false;
}
-defineExpose({ getDetail, addEmr });
-
\ No newline at end of file
+// 弹窗确认
+function submit() {
+ if (showDialog.value === 'saveTemplate') {
+ if (!templateName.value.trim()) {
+ proxy.$message.warning('请输入模板名称');
+ return;
+ }
+ saveEmrTemplate({
+ templateName: templateName.value,
+ useScopeCode: radio.value,
+ contextJson: form.value,
+ }).then((res) => {
+ if (res.code === 200) {
+ openEmrTemplate.value = false;
+ proxy.$modal.msgSuccess('保存成功');
+ }
+ });
+ } else {
+ openEmrTemplate.value = false;
+ }
+}
+
+function cancel() {
+ openEmrTemplate.value = false;
+}
+
+// 可选:打印功能
+// function printEmr() {
+// const printContent = proxy.$refs.printArea.innerHTML;
+// const originalContent = document.body.innerHTML;
+// document.body.innerHTML = printContent;
+// window.print();
+// document.body.innerHTML = originalContent;
+// window.location.reload(); // 恢复组件状态
+// }
+
+// 暴露方法给父组件
+defineExpose({
+ getDetail(encounterId) {
+ getEmrDetail(encounterId).then((res) => {
+ if (res.data) {
+ try {
+ form.value = JSON.parse(res.data.contextJson) || {};
+ } catch (e) {
+ form.value = {};
+ }
+ emits('save', true);
+ } else {
+ form.value = {};
+ }
+ });
+ },
+ addEmr
+});
+
+
+
\ No newline at end of file