|
@@ -2,25 +2,44 @@
|
|
|
<el-container>
|
|
|
|
|
|
<el-header>
|
|
|
- <el-button type="primary" @click="clickSaveData">testSave</el-button>
|
|
|
- <el-button type="primary" @click="testPrint">testPrint</el-button>
|
|
|
- <el-button type="primary" @click="testDelete">testDelete</el-button>
|
|
|
+ <el-button icon="ArrowLeft" style="font-size: 14px" text @click="clickBack">返回</el-button>
|
|
|
+ 住院次数:
|
|
|
+ <el-input-number :min="1" :max="huanZheXinXi.admissTimes" v-model="times"/>
|
|
|
+ <el-button @click="queryHistoricalInformation">历史记录</el-button>
|
|
|
+
|
|
|
+ <div v-if="times === huanZheXinXi.admissTimes">
|
|
|
+ <el-button type="success" icon="CircleCheck" @click="clickSaveData">保存数据</el-button>
|
|
|
+ <el-button type="primary" icon="Printer" @click="testPrint">打印电子病历</el-button>
|
|
|
+ <el-button icon="Delete" type="danger" @click="clickDelete">删除电子病历</el-button>
|
|
|
+ </div>
|
|
|
+ <el-button icon="RefreshLeft" @click="refreshPage">刷新页面</el-button>
|
|
|
</el-header>
|
|
|
|
|
|
<el-container>
|
|
|
|
|
|
- <el-aside>
|
|
|
- <emr-sidebar></emr-sidebar>
|
|
|
+ <el-aside style="background-color: white">
|
|
|
+ <emr-sidebar @nodeClick="nodeClick" ref="emrSidebarRef"/>
|
|
|
</el-aside>
|
|
|
|
|
|
- <el-main>
|
|
|
+ <el-main v-loading="loaded">
|
|
|
|
|
|
- <div class="emr-iframe" name="emr">
|
|
|
+ <el-row>
|
|
|
|
|
|
- <iframe id="emrIframe"
|
|
|
- :src="caseHistoryUrl"/>
|
|
|
+ <el-col :span="20">
|
|
|
+ <div class="emr-iframe" name="emr">
|
|
|
|
|
|
- </div>
|
|
|
+ <iframe id="emrIframe"
|
|
|
+ ref="emrRef"
|
|
|
+ :src="caseHistoryUrl"/>
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <el-col :span="4" style="background-color: white">
|
|
|
+ <emr-snippet @node-click="clickSnippet"/>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ </el-row>
|
|
|
|
|
|
</el-main>
|
|
|
|
|
@@ -29,147 +48,208 @@
|
|
|
</el-container>
|
|
|
</template>
|
|
|
|
|
|
-<script>
|
|
|
+<script setup name="emr">
|
|
|
|
|
|
import {huanZheXinXi} from "@/views/hospitalization/zhu-yuan-yi-sheng/public-js/zhu-yuan-yi-sheng";
|
|
|
-import store from "@/store";
|
|
|
-import {uuid} from "@/utils/getUuid";
|
|
|
import {getEmrInpatientData} from "@/api/dictionary/emr-data-maintenance-api";
|
|
|
import EmrSidebar from "@/components/zhu-yuan-yi-sheng/emr/EmrSidebar.vue";
|
|
|
-import {ElMessage} from "element-plus";
|
|
|
-import {getPatientsEmr} from "@/api/zhu-yuan-yi-sheng/emr-api";
|
|
|
+import {EMRInteractive} from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-init";
|
|
|
+import {ElMessageBox} from "element-plus";
|
|
|
+import {uuid} from "@/utils/getUuid";
|
|
|
+import {BizException, ExceptionEnum} from "@/utils/BizException";
|
|
|
+import router from '@/router'
|
|
|
+import EmrSnippet from "@/components/zhu-yuan-yi-sheng/emr/EmrSnippet.vue";
|
|
|
+
|
|
|
+const emit = defineEmits(['refreshPage'])
|
|
|
+
|
|
|
+const currentEmr = ref(null)
|
|
|
+const emrRef = ref(null)
|
|
|
+
|
|
|
+let categoryCode = $ref('')
|
|
|
+let documentId = $ref('')
|
|
|
+let patientId = $ref('')
|
|
|
+let categroyId = $ref('')
|
|
|
+let templateName = $ref('')
|
|
|
+let caseHistoryUrl = $ref('')
|
|
|
+// 患者历史记录
|
|
|
+let times = $ref(huanZheXinXi.value.admissTimes)
|
|
|
+// 侧边栏
|
|
|
+let emrSidebarRef = $ref(null)
|
|
|
+// 是否加载完成了
|
|
|
+let loaded = $ref(false)
|
|
|
+// 是否 改变了数据
|
|
|
+let isEditorChange = $ref(false)
|
|
|
+// 患者数据
|
|
|
+let patientData = $ref({})
|
|
|
+
|
|
|
+const updateCaseHistoryUrl = (val) => {
|
|
|
+ let valCode = val.code ? val.code : val.emrCategoryCode;
|
|
|
+ if (documentId === val.emrDocumentId && categoryCode === valCode) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ loaded = true
|
|
|
+ isEditorChange = false
|
|
|
+ documentId = val.emrDocumentId;
|
|
|
+ categoryCode = valCode
|
|
|
+ templateName = val.emrName ? val.emrName : val.name
|
|
|
+ caseHistoryUrl = `/emr/runtime/?documentId=${documentId}&categoryCode=${categoryCode}&categroyId=${categroyId}&patientId=${patientId}#/`
|
|
|
+}
|
|
|
|
|
|
-export default {
|
|
|
- components: {EmrSidebar},
|
|
|
- setup() {
|
|
|
|
|
|
- const currentEmr = ref(null)
|
|
|
+const refreshPage = () => {
|
|
|
+ emit('refreshPage', '电子病历')
|
|
|
+}
|
|
|
|
|
|
- const caseHistoryUrl = ref('')
|
|
|
|
|
|
- let categoryCode = $ref('7e25f0c0070511edbc820dada413ba28')
|
|
|
- let documentId = $ref('')
|
|
|
+const clickSaveData = () => {
|
|
|
|
|
|
- const clickSaveData = () => {
|
|
|
- currentEmr.value.saveDocument(categoryCode);
|
|
|
- }
|
|
|
+ let data = {
|
|
|
+ emrDocumentId: documentId ? documentId : uuid(31, 62),
|
|
|
+ emrCategoryCode: categoryCode,
|
|
|
+ patNo: huanZheXinXi.value.inpatientNo,
|
|
|
+ times: huanZheXinXi.value.admissTimes,
|
|
|
+ emrName: templateName
|
|
|
+ }
|
|
|
|
|
|
- const testPrint = () => {
|
|
|
- currentEmr.value.printDocument(true, null);
|
|
|
- }
|
|
|
+ objectValuesCannotBeNull(data)
|
|
|
|
|
|
- const testDelete = () => {
|
|
|
- currentEmr.value.deleteDocument(documentId);
|
|
|
- }
|
|
|
+ ElMessageBox.prompt('请输入保存的名称,自动带上日期', '提示', {
|
|
|
+ inputErrorMessage: '长度为2 - 20 个,汉字',
|
|
|
+ inputPattern: /^\S{2,20}$/,
|
|
|
+ inputValue: templateName
|
|
|
+ }).then(async ({value}) => {
|
|
|
+ data.name = value
|
|
|
+ await currentEmr.value.saveDocument(data)
|
|
|
+ isEditorChange = false
|
|
|
+ }).catch(() => {
|
|
|
|
|
|
- const getCaseHistoryUrl = (documentId, categoryCode, categroyId, patientId) => {
|
|
|
- caseHistoryUrl.value = `/emr/runtime/?documentId=${documentId}&categoryCode=${categoryCode}&categroyId=${categroyId}&patientId=${patientId}#/`;
|
|
|
- }
|
|
|
+ })
|
|
|
+}
|
|
|
|
|
|
- onMounted(() => {
|
|
|
+const objectValuesCannotBeNull = (object) => {
|
|
|
+ if (!object.emrCategoryCode) {
|
|
|
+ BizException(ExceptionEnum.LOGICAL_ERROR, "请先选择模板")
|
|
|
+ }
|
|
|
+ if (!object.patNo) {
|
|
|
+ BizException(ExceptionEnum.LOGICAL_ERROR, "请先选择患者")
|
|
|
+ }
|
|
|
+ if (object.times == null || object.times === 0) {
|
|
|
+ BizException(ExceptionEnum.LOGICAL_ERROR, "住院次数为空")
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
- nextTick(async () => {
|
|
|
+const testPrint = () => {
|
|
|
+ currentEmr.value.printDocument(true, null);
|
|
|
+}
|
|
|
|
|
|
- getCaseHistoryUrl(documentId, categoryCode, '', huanZheXinXi.value.inpatientNo)
|
|
|
+const clickDelete = () => {
|
|
|
+ whetherThereIsAMedicalRecordId()
|
|
|
+ ElMessageBox.alert('是否要删除该模板。', '提示', {
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ currentEmr.value.deleteDocument(documentId, function () {
|
|
|
+ refreshPage()
|
|
|
+ });
|
|
|
+ }).catch(() => {
|
|
|
|
|
|
- let data = await getEmrInpatientData({
|
|
|
- patNo: huanZheXinXi.value.inpatientNo,
|
|
|
- times: huanZheXinXi.value.admissTimes
|
|
|
- })
|
|
|
+ })
|
|
|
|
|
|
- data['_id'] = uuid(31, 62)
|
|
|
- currentEmr.value = new EMRInteractive(data);
|
|
|
- const iframe = document.getElementById('emrIframe')
|
|
|
- iframe.parentElement.emr = currentEmr.value
|
|
|
+}
|
|
|
|
|
|
- // 获取患者已经存在的
|
|
|
- getPatientsEmr(huanZheXinXi.value.inpatientNo).then((res) => {
|
|
|
- console.log(res)
|
|
|
- })
|
|
|
+const whetherThereIsAMedicalRecordId = () => {
|
|
|
+ if (!documentId) {
|
|
|
+ BizException(ExceptionEnum.MESSAGE_ERROR, "请先选择电子病历的模板。")
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
- })
|
|
|
+const queryHistoricalInformation = () => {
|
|
|
+ checkEmrChange(() => {
|
|
|
+ nodeClick({}, 0)
|
|
|
+ emrSidebarRef.queryHistory(times);
|
|
|
+ })
|
|
|
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+const checkEmrChange = (cb) => {
|
|
|
+ if (isEditorChange) {
|
|
|
+ ElMessageBox.confirm("您改变了数据是否要保存,不保存可能会丢失数据。", '提示', {
|
|
|
+ type: "warning",
|
|
|
+ cancelButtonText: '放弃修改',
|
|
|
+ confirmButtonText: '保存',
|
|
|
+ distinguishCancelAndClose: true,
|
|
|
+ }).then(() => {
|
|
|
+ clickSaveData()
|
|
|
+ }).catch((action) => {
|
|
|
+ if (action === 'cancel') {
|
|
|
+ isEditorChange = false
|
|
|
+ cb()
|
|
|
+ }
|
|
|
})
|
|
|
+ } else {
|
|
|
+ isEditorChange = false
|
|
|
+ cb()
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
- return {
|
|
|
- clickSaveData,
|
|
|
- testPrint,
|
|
|
- testDelete,
|
|
|
- caseHistoryUrl,
|
|
|
+const nodeClick = (val, templateType) => {
|
|
|
+ checkEmrChange(() => {
|
|
|
+ updateCaseHistoryUrl(val)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+const editorEvents = ({name}) => {
|
|
|
+ if (name === 'loaded') {
|
|
|
+ loaded = false
|
|
|
+ if (times !== huanZheXinXi.value.admissTimes) {
|
|
|
+ currentEmr.value.setEditorMode('readonly');
|
|
|
}
|
|
|
+ } else if (name === 'contentchange') {
|
|
|
+ isEditorChange = true
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+const clickBack = () => {
|
|
|
+ checkEmrChange(() => {
|
|
|
+ router.go(-1)
|
|
|
+ })
|
|
|
+}
|
|
|
|
|
|
-function EMRInteractive(data) {
|
|
|
- this.setEditor = (editor, runtime) => {
|
|
|
- this.editor = editor;
|
|
|
- this.runtime = runtime;
|
|
|
- };
|
|
|
-
|
|
|
- this.getAppContext = () => {
|
|
|
- return {
|
|
|
- endpoints: {
|
|
|
- app: "/bdp/dataservice/api",
|
|
|
- },
|
|
|
- input: {
|
|
|
- user: store.state.user.info.code,
|
|
|
- name: store.state.user.info.name
|
|
|
- },
|
|
|
- login: {
|
|
|
- token: store.state.user.info.token
|
|
|
- },
|
|
|
- data
|
|
|
- };
|
|
|
- };
|
|
|
-
|
|
|
- this.saveDocument = (categoryCode) => {
|
|
|
- let data = this.editor.getDocument();
|
|
|
- data.properties.categoryCode = categoryCode
|
|
|
- data.properties.patientId = huanZheXinXi.value.inpatientNo;
|
|
|
- data.properties.creator = store.state.user.info.code;
|
|
|
- data.properties.createTime = new Date()
|
|
|
- data.properties.modifier = store.state.user.info.code;
|
|
|
- data.properties.modifyTime = new Date()
|
|
|
- this.runtime.saveDocument(
|
|
|
- data,
|
|
|
- (res) => {
|
|
|
- // let validator = this.editor.getValidator();
|
|
|
- console.log(this.editor)
|
|
|
- // let valid = validator.valid();
|
|
|
- // console.log(valid)
|
|
|
- ElMessage.success("保存成功。")
|
|
|
- },
|
|
|
- (err) => {
|
|
|
- ElMessage.success("emr保存失败," + err)
|
|
|
- }
|
|
|
- );
|
|
|
-
|
|
|
- };
|
|
|
-
|
|
|
- this.deleteDocument = (documentId) => {
|
|
|
- this.runtime.delDocument(documentId,
|
|
|
- (res) => {
|
|
|
- ElMessage.success("删除成功")
|
|
|
- },
|
|
|
- (err) => {
|
|
|
- ElMessage.success("删除失败" + err)
|
|
|
- }
|
|
|
- );
|
|
|
- };
|
|
|
-
|
|
|
- this.printDocument = (showPreview, docs = null) => {
|
|
|
-
|
|
|
- this.editor && this.editor.execute("print", {
|
|
|
-
|
|
|
- value: {
|
|
|
- showPreview
|
|
|
- }
|
|
|
+const monitorPageRefresh = (event) => {
|
|
|
+ if (isEditorChange) {
|
|
|
+ event.returnValue = false;
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
- })
|
|
|
- };
|
|
|
+const clickSnippet = ({content, styles}) => {
|
|
|
+ currentEmr.value.insertSnippet(content, styles, patientData)
|
|
|
}
|
|
|
|
|
|
+onMounted(() => {
|
|
|
+
|
|
|
+ nextTick(async () => {
|
|
|
+
|
|
|
+ patientData = await getEmrInpatientData({
|
|
|
+ patNo: huanZheXinXi.value.inpatientNo,
|
|
|
+ times: huanZheXinXi.value.admissTimes
|
|
|
+ })
|
|
|
+ patientId = huanZheXinXi.value.inpatientNo
|
|
|
+ currentEmr.value = new EMRInteractive(patientData, editorEvents);
|
|
|
+ emrRef.value.parentElement.emr = currentEmr.value
|
|
|
+
|
|
|
+ window.addEventListener('beforeunload', monitorPageRefresh)
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+})
|
|
|
+
|
|
|
+onDeactivated(() => {
|
|
|
+ console.log(123)
|
|
|
+ window.removeEventListener('beforeunload', monitorPageRefresh)
|
|
|
+})
|
|
|
+
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|