|
@@ -38,7 +38,9 @@
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="4" style="background-color: white">
|
|
|
- <emr-snippet @node-click="clickSnippet" :patientData="patientData"/>
|
|
|
+ <emr-snippet @node-click="clickSnippet"
|
|
|
+ ref="emrSnippetRef"
|
|
|
+ :patientData="patientData"/>
|
|
|
</el-col>
|
|
|
|
|
|
</el-row>
|
|
@@ -51,7 +53,6 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup name="emr">
|
|
|
-
|
|
|
import {huanZheXinXi} from "@/views/hospitalization/zhu-yuan-yi-sheng/public-js/zhu-yuan-yi-sheng";
|
|
|
import {getEmrInpatientData} from "@/api/dictionary/emr-data-maintenance-api";
|
|
|
import EmrSidebar from "@/components/zhu-yuan-yi-sheng/emr/EmrSidebar.vue";
|
|
@@ -65,13 +66,16 @@ import {BizException, ExceptionEnum} from "@/utils/BizException";
|
|
|
import router from '@/router'
|
|
|
import EmrSnippet from "@/components/zhu-yuan-yi-sheng/emr/EmrSnippet.vue";
|
|
|
import store from "@/store";
|
|
|
-import {existCourseRecord} from "@/api/zhu-yuan-yi-sheng/emr-patient";
|
|
|
+import {existCourseRecord, extractDataElement} from "@/api/zhu-yuan-yi-sheng/emr-patient";
|
|
|
+import {onBeforeRouteLeave} from "vue-router";
|
|
|
+import {getUuid} from "@/api/public-api";
|
|
|
|
|
|
const emit = defineEmits(['refreshPage'])
|
|
|
|
|
|
const currentEmr = ref(null)
|
|
|
const emrRef = ref(null)
|
|
|
|
|
|
+
|
|
|
let categoryCode = $ref('')
|
|
|
// 文档 id 唯一值
|
|
|
let documentId = $ref('')
|
|
@@ -79,16 +83,19 @@ let patientId = $ref('')
|
|
|
let categroyId = $ref('')
|
|
|
let templateName = $ref('')
|
|
|
let caseHistoryUrl = $ref('')
|
|
|
+let editor = {}
|
|
|
// 患者历史记录
|
|
|
let times = $ref(huanZheXinXi.value.admissTimes)
|
|
|
// 侧边栏
|
|
|
-let emrSidebarRef = $ref(null)
|
|
|
+const emrSidebarRef = ref(null)
|
|
|
+// 片段预览
|
|
|
+const emrSnippetRef = ref(null)
|
|
|
// 是否加载完成了
|
|
|
let loaded = $ref(false)
|
|
|
// 是否 改变了数据
|
|
|
let isEditorChange = $ref(false)
|
|
|
// 患者数据
|
|
|
-let patientData = $ref({})
|
|
|
+let patientData = {}
|
|
|
// 是否开启审阅模式
|
|
|
let reviewMode = $ref(false)
|
|
|
// 跳转定位
|
|
@@ -98,16 +105,6 @@ let jumpPositioning = {
|
|
|
code: null
|
|
|
}
|
|
|
|
|
|
-const updateCaseHistoryUrl = (val) => {
|
|
|
- let valCode = val.code ? val.code : val.emrCategoryCode;
|
|
|
- loaded = true
|
|
|
- isEditorChange = false
|
|
|
- documentId = val.emrDocumentId;
|
|
|
- categoryCode = valCode
|
|
|
- templateName = val.name
|
|
|
- caseHistoryUrl = `/emr/runtime/?documentId=${documentId}&categoryCode=${categoryCode}&categroyId=${categroyId}&patientId=${patientId}#/`
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
const refreshPage = () => {
|
|
|
checkEmrChange(() => {
|
|
@@ -120,33 +117,46 @@ const clickSaveData = async () => {
|
|
|
if (flag && !documentId && categoryCode === courseOfDisease) {
|
|
|
BizException(ExceptionEnum.MESSAGE_ERROR, '该患者已经存在病程记录,请勿填写.')
|
|
|
}
|
|
|
-
|
|
|
waitForLoadingToComplete()
|
|
|
-
|
|
|
let data = {
|
|
|
// 这个是 唯一 id 我是在本地生成的
|
|
|
- emrDocumentId: documentId ? documentId : uuid(31, 62),
|
|
|
+ emrDocumentId: documentId ? documentId : await getUuid(),
|
|
|
emrCategoryCode: categoryCode,
|
|
|
patNo: huanZheXinXi.value.inpatientNo,
|
|
|
times: huanZheXinXi.value.admissTimes,
|
|
|
emrName: templateName
|
|
|
}
|
|
|
-
|
|
|
objectValuesCannotBeNull(data)
|
|
|
-
|
|
|
ElMessageBox.prompt('请输入保存的名称', '提示', {
|
|
|
inputErrorMessage: '长度为2 - 20 个,汉字',
|
|
|
inputPattern: /^\S{2,20}$/,
|
|
|
inputValue: templateName
|
|
|
- }).then(async ({value}) => {
|
|
|
+ }).then(({value}) => {
|
|
|
data.name = value
|
|
|
- await currentEmr.value.saveDocument(data, () => {
|
|
|
+ let dataElement = JSON.stringify(editor.getDataElements('business'))
|
|
|
+ let tempData = {
|
|
|
+ patNo: huanZheXinXi.value.inpatientNo,
|
|
|
+ times: huanZheXinXi.value.admissTimes,
|
|
|
+ categoryCode: categoryCode,
|
|
|
+ dataElement: dataElement
|
|
|
+ }
|
|
|
+ extractDataElement(tempData)
|
|
|
+ // 记得删除这里才能保存
|
|
|
+ // return
|
|
|
+
|
|
|
+ currentEmr.value.saveDocument(data, () => {
|
|
|
isEditorChange = false
|
|
|
- emrSidebarRef.queryData()
|
|
|
+ emrSidebarRef.value.queryData()
|
|
|
+ updateCaseHistoryUrl({
|
|
|
+ emrDocumentId: '',
|
|
|
+ code: '',
|
|
|
+ emrCategoryCode: '',
|
|
|
+ })
|
|
|
}, (err) => {
|
|
|
documentId = err
|
|
|
isEditorChange = true
|
|
|
})
|
|
|
+
|
|
|
}).catch(() => {
|
|
|
|
|
|
})
|
|
@@ -175,6 +185,9 @@ const testPrint = () => {
|
|
|
currentEmr.value.printDocument(true, null);
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * 点击删除数据
|
|
|
+ */
|
|
|
const clickDelete = () => {
|
|
|
waitForLoadingToComplete()
|
|
|
whetherThereIsAMedicalRecordId()
|
|
@@ -182,8 +195,8 @@ const clickDelete = () => {
|
|
|
type: 'warning'
|
|
|
}).then(() => {
|
|
|
currentEmr.value.deleteDocument(documentId, function () {
|
|
|
- emrSidebarRef.deleteTheSpecifiedNode(documentId)
|
|
|
- nodeClick({}, 2)
|
|
|
+ emrSidebarRef.value.queryData()
|
|
|
+ updateCaseHistoryUrl({})
|
|
|
});
|
|
|
}).catch(() => {
|
|
|
|
|
@@ -197,12 +210,14 @@ const whetherThereIsAMedicalRecordId = () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * 查询历史信息
|
|
|
+ */
|
|
|
const resetData = () => {
|
|
|
checkEmrChange(() => {
|
|
|
- nodeClick({}, 0)
|
|
|
- emrSidebarRef.queryHistory(times);
|
|
|
+ updateCaseHistoryUrl({})
|
|
|
+ emrSidebarRef.value.queryHistory(times);
|
|
|
})
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|
|
@@ -211,7 +226,7 @@ const checkEmrChange = (cb) => {
|
|
|
ElMessageBox.confirm("您改变了数据是否要保存,不保存可能会丢失数据。", '提示', {
|
|
|
type: "warning",
|
|
|
cancelButtonText: '放弃修改',
|
|
|
- confirmButtonText: '保存',
|
|
|
+ confirmButtonText: '保存病历',
|
|
|
distinguishCancelAndClose: true,
|
|
|
}).then(() => {
|
|
|
clickSaveData()
|
|
@@ -227,15 +242,15 @@ const checkEmrChange = (cb) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-const nodeClick = (val, parent, templateType) => {
|
|
|
- if (val.roundTime) {
|
|
|
- if (documentId === parent.emrDocumentId) {
|
|
|
+const nodeClick = (val, jumpOrNot, templateType) => {
|
|
|
+ if (jumpOrNot) {
|
|
|
+ if (val.documentId === documentId) {
|
|
|
positioningTime(val.value, val.code)
|
|
|
} else {
|
|
|
- updateCaseHistoryUrl(parent);
|
|
|
+ updateCaseHistoryUrl(val);
|
|
|
jumpPositioning = {
|
|
|
value: val.value,
|
|
|
- code: val.code
|
|
|
+ code: val.code,
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -245,6 +260,21 @@ const nodeClick = (val, parent, templateType) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+const updateCaseHistoryUrl = (val) => {
|
|
|
+ loaded = true
|
|
|
+ isEditorChange = false
|
|
|
+ documentId = val.documentId;
|
|
|
+ categoryCode = val.categoryCode
|
|
|
+ templateName = val.name
|
|
|
+ categroyId = val.categroyId
|
|
|
+ caseHistoryUrl = `/emr/runtime/?documentId=${documentId}&categoryCode=${categoryCode}&categroyId=${categroyId}&patientId=${patientId}#/`
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 跳转到指定的地方
|
|
|
+ * @param val 值
|
|
|
+ * @param code 业务编码/内部编码/组件编码
|
|
|
+ */
|
|
|
const positioningTime = (val, code) => {
|
|
|
let componentView = currentEmr.value.callMethod('getElementByValue', code, val);
|
|
|
if (componentView) {
|
|
@@ -258,7 +288,7 @@ const positioningTime = (val, code) => {
|
|
|
|
|
|
const clickBack = () => {
|
|
|
checkEmrChange(() => {
|
|
|
- router.go(-1)
|
|
|
+ router.push('/inpatient/zhuYuanYiSheng/yiZhuLuRu')
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -268,81 +298,159 @@ const monitorPageRefresh = (event) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * 点击插入片段
|
|
|
+ * @param content
|
|
|
+ * @param styles
|
|
|
+ */
|
|
|
const clickSnippet = ({content, styles}) => {
|
|
|
+ currentEmr.value.callMethod('setCursor', 'AREA_END')
|
|
|
currentEmr.value.insertSnippet(content, styles, patientData)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+let userData = store.state.user.info
|
|
|
/**
|
|
|
* 获取当前用户的信息
|
|
|
* @param data
|
|
|
*/
|
|
|
const getCurrentPersonnelInformation = (data) => {
|
|
|
- let userData = store.state.user.info
|
|
|
-
|
|
|
- patientData.user_selection = [{code: userData.code, name: userData.name}]
|
|
|
- patientData.user_code = userData.code
|
|
|
- patientData.user_name = userData.name
|
|
|
-
|
|
|
- patientData.user_dept_selection = [{code: userData.deptCode, name: userData.deptName}]
|
|
|
- patientData.user_dept_code = userData.deptCode
|
|
|
- patientData.user_dept_name = userData.deptName
|
|
|
+ patientData['编辑者'] = [{code: userData.code, name: userData.name}]
|
|
|
+ patientData['编辑者编码'] = userData.code
|
|
|
+ patientData['编辑者姓名'] = userData.name
|
|
|
|
|
|
+ patientData['编辑者科室'] = [{code: userData.deptCode, name: userData.deptName}]
|
|
|
+ patientData['编辑者科室编码'] = userData.deptCode
|
|
|
+ patientData['编辑者科室名称'] = userData.deptName
|
|
|
patientData.user_token = userData.token
|
|
|
-
|
|
|
}
|
|
|
|
|
|
const emrEvent = {
|
|
|
+
|
|
|
'loaded': (event) => {
|
|
|
+ editor = currentEmr.value.getEditor()
|
|
|
loaded = false
|
|
|
- if (times !== huanZheXinXi.value.admissTimes) {
|
|
|
- // 如果住院次数不一致 那么就是历史记录 那就只能只读了
|
|
|
- currentEmr.value.callMethod('setEditorMode', 'readonly')
|
|
|
- } else {
|
|
|
- // 设置成编辑模式
|
|
|
- currentEmr.value.callMethod('setEditorMode', 'free')
|
|
|
- }
|
|
|
- if (jumpPositioning.code) {
|
|
|
- positioningTime(jumpPositioning.value, jumpPositioning.code)
|
|
|
- jumpPositioning.code = null
|
|
|
- }
|
|
|
- let whetherToLocate = categoryCode.match(/【锚点-(\S*)】/)
|
|
|
- if (whetherToLocate && whetherToLocate.length > 1) {
|
|
|
- let elName = whetherToLocate[1]
|
|
|
- let emrElData = currentEmr.value.callMethod('getElementsData')
|
|
|
- console.log(emrElData)
|
|
|
- emrSidebarRef.diseaseDurationRecordTime(emrElData[elName], elName, documentId);
|
|
|
- }
|
|
|
-
|
|
|
+ setEditorModeFun()
|
|
|
+ setTheProgressAnchor()
|
|
|
+ courseSegmentLocking()
|
|
|
+ deleteDataElement()
|
|
|
},
|
|
|
+
|
|
|
'contentchange': (event) => {
|
|
|
// 判断内容是否改变
|
|
|
isEditorChange = true
|
|
|
- emrSidebarRef.changeTemplateType(2)
|
|
|
+ emrSidebarRef.value.changeTemplateType(2)
|
|
|
+ },
|
|
|
+
|
|
|
+ 'insertFragment': (evt, view, nodes, fragment, defaultData) => {
|
|
|
+ // 只有是片段才需要 添加这个
|
|
|
+ if (nodes[0] && nodes[0].view.type === 'area') {
|
|
|
+ nodes[0].view.setAttribute('userInfo', {code: userData.code, name: userData.name})
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+const setEditorModeFun = () => {
|
|
|
+ if (times !== huanZheXinXi.value.admissTimes) {
|
|
|
+ // 如果住院次数不一致 那么就是历史记录 那就只能只读了
|
|
|
+ currentEmr.value.callMethod('setEditorMode', 'readonly')
|
|
|
+ } else {
|
|
|
+ // 设置成编辑模式
|
|
|
+ currentEmr.value.callMethod('setEditorMode', 'free')
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * 设置跳转锚点
|
|
|
+ */
|
|
|
+const setTheProgressAnchor = () => {
|
|
|
+ if (jumpPositioning.code) {
|
|
|
+ positioningTime(jumpPositioning.value, jumpPositioning.code)
|
|
|
+ jumpPositioning.code = null
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
-onMounted(() => {
|
|
|
+/**
|
|
|
+ * 病程记录专用,
|
|
|
+ * 设置段落锁定,和设置跳转锚点
|
|
|
+ */
|
|
|
+const courseSegmentLocking = () => {
|
|
|
+ if (!categoryCode.includes('shoucibingchengjilu')) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let root = currentEmr.value.getRoot()
|
|
|
+ if (documentId) {
|
|
|
+ let courseTitles = []
|
|
|
+ let loginUserCode = 'abc'
|
|
|
+ let modelService = editor.ModelService
|
|
|
+ let walker, values
|
|
|
+ for (let node of root.getChildren()) {
|
|
|
+ if (node.view && node.type === 'area') {
|
|
|
+ if (!walker) {
|
|
|
+ walker = modelService.createTreeWalker(node);
|
|
|
+ } else {
|
|
|
+ modelService.setWalkerRoot(walker, node);
|
|
|
+ }
|
|
|
+ values = modelService.getElementsDataFromWalker(walker, '编辑者');
|
|
|
+ // node.view.el.firstElementChild.textContent 如果title不是数据元
|
|
|
+ // values['查房标题'].value 如果title是数据元
|
|
|
+ courseTitles.push({
|
|
|
+ code: '查房时间',
|
|
|
+ name: values['查房标题']?.value,
|
|
|
+ value: values['查房时间'].value,
|
|
|
+ emrDocumentId: documentId,
|
|
|
+ emrCategoryCode: categoryCode,
|
|
|
+ jump: true
|
|
|
+ })
|
|
|
+ // let editorName = modelService.getElementsDataFromWalker(walker, '编辑者姓名');
|
|
|
+ console.log(values)
|
|
|
+
|
|
|
+ if (node.getAttribute('userInfo.code') !== loginUserCode) {
|
|
|
+ node.view.setReadonly(true);
|
|
|
+ node.view.setDeletable(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ emrSidebarRef.value.diseaseDurationRecordTime(documentId, courseTitles)
|
|
|
+ } else {
|
|
|
+ for (let node of root.getChildren()) {
|
|
|
+ if (node.view && node.type === 'area') {
|
|
|
+ node.view.setAttribute('userInfo', {code: userData.code, name: userData.name})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
- nextTick(async () => {
|
|
|
+/**
|
|
|
+ * 删除数据元,
|
|
|
+ * 根据男性女性删除 月经史 数据元
|
|
|
+ */
|
|
|
+const deleteDataElement = () => {
|
|
|
+ if (categoryCode === 'ruyuanjiluzhuanyong') {
|
|
|
+ if (patientData['性别名称'] === '男') {
|
|
|
+ currentEmr.value.deleteElement(['月经史'])
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
+onMounted(() => {
|
|
|
+ nextTick(async () => {
|
|
|
patientData = await getEmrInpatientData({
|
|
|
patNo: huanZheXinXi.value.inpatientNo,
|
|
|
times: huanZheXinXi.value.admissTimes
|
|
|
})
|
|
|
-
|
|
|
getCurrentPersonnelInformation(patientData)
|
|
|
-
|
|
|
-
|
|
|
+ console.log(patientData)
|
|
|
patientId = huanZheXinXi.value.inpatientNo
|
|
|
currentEmr.value = new EMRInteractive(patientData, emrEvent);
|
|
|
- emrRef.value.parentElement.emr = currentEmr.value
|
|
|
|
|
|
+ emrSnippetRef.value.setPatientData(patientData)
|
|
|
+
|
|
|
+ emrRef.value.parentElement.emr = currentEmr.value
|
|
|
window.addEventListener('beforeunload', monitorPageRefresh)
|
|
|
|
|
|
})
|
|
|
-
|
|
|
})
|
|
|
|
|
|
onDeactivated(() => {
|
|
@@ -350,6 +458,13 @@ onDeactivated(() => {
|
|
|
})
|
|
|
|
|
|
|
|
|
+onBeforeRouteLeave((to, from, next) => {
|
|
|
+ checkEmrChange(() => {
|
|
|
+ next();
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|