diff --git a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/empi/appservice/IEmpiAppService.java b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/empi/appservice/IEmpiAppService.java index ee340774d..6ffc99cb1 100644 --- a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/empi/appservice/IEmpiAppService.java +++ b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/empi/appservice/IEmpiAppService.java @@ -1,7 +1,10 @@ package com.healthlink.his.web.empi.appservice; + +import com.healthlink.his.administration.domain.Patient; import com.healthlink.his.empi.domain.*; import java.util.List; import java.util.Map; + public interface IEmpiAppService { EmpiPerson registerPerson(EmpiPerson p); void mergePersons(Long primaryId, List secondaryIds); @@ -9,4 +12,7 @@ public interface IEmpiAppService { EmpiPerson findByIdCard(String idCardNo); List getMappings(String globalId); Map getStatistics(); -} + List findLinkedPatients(String globalId); + List findLinkedPatientsByIdCard(String idCardNo); + List listPersons(String name, String idCardNo); +} \ No newline at end of file diff --git a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/empi/appservice/impl/EmpiAppServiceImpl.java b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/empi/appservice/impl/EmpiAppServiceImpl.java index a5f6cd44d..fe7320c4f 100644 --- a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/empi/appservice/impl/EmpiAppServiceImpl.java +++ b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/empi/appservice/impl/EmpiAppServiceImpl.java @@ -1,54 +1,116 @@ package com.healthlink.his.web.empi.appservice.impl; -import com.healthlink.his.empi.domain.*; -import com.healthlink.his.empi.service.*; -import com.healthlink.his.web.empi.appservice.IEmpiAppService; + import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.healthlink.his.administration.domain.Patient; +import com.healthlink.his.administration.service.IPatientService; +import com.healthlink.his.empi.domain.EmpiPerson; +import com.healthlink.his.empi.domain.EmpiPersonIdMapping; +import com.healthlink.his.empi.service.IEmpiPersonIdMappingService; +import com.healthlink.his.empi.service.IEmpiPersonService; +import com.healthlink.his.web.empi.appservice.IEmpiAppService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; + import java.util.*; +import java.util.stream.Collectors; + @Service public class EmpiAppServiceImpl implements IEmpiAppService { @Autowired private IEmpiPersonService personService; @Autowired private IEmpiPersonIdMappingService mappingService; + @Autowired private IPatientService patientService; @Override public EmpiPerson registerPerson(EmpiPerson p) { p.setGlobalId(UUID.randomUUID().toString().replace("-", "").substring(0, 16).toUpperCase()); - p.setMergeStatus("ACTIVE"); personService.save(p); return p; + p.setMergeStatus("ACTIVE"); + personService.save(p); + return p; } + @Override public void mergePersons(Long primaryId, List secondaryIds) { EmpiPerson primary = personService.getById(primaryId); for (Long secId : secondaryIds) { + EmpiPerson sec = personService.getById(secId); + if (sec == null) continue; List mappings = mappingService.list(new LambdaQueryWrapper() - .eq(EmpiPersonIdMapping::getGlobalId, personService.getById(secId).getGlobalId())); + .eq(EmpiPersonIdMapping::getGlobalId, sec.getGlobalId())); for (EmpiPersonIdMapping m : mappings) { m.setGlobalId(primary.getGlobalId()); mappingService.updateById(m); } - EmpiPerson sec = personService.getById(secId); - sec.setMergeStatus("MERGED"); personService.updateById(sec); + sec.setMergeStatus("MERGED"); + personService.updateById(sec); } } + @Override public EmpiPerson findByGlobalId(String globalId) { return personService.getOne(new LambdaQueryWrapper().eq(EmpiPerson::getGlobalId, globalId)); } + @Override public EmpiPerson findByIdCard(String idCardNo) { - return personService.getOne(new LambdaQueryWrapper().eq(EmpiPerson::getIdCardNo, idCardNo)); + return personService.getOne(new LambdaQueryWrapper().eq(EmpiPerson::getIdCardNo, idCardNo).last("LIMIT 1")); } + @Override public List getMappings(String globalId) { return mappingService.list(new LambdaQueryWrapper().eq(EmpiPersonIdMapping::getGlobalId, globalId)); } + @Override public Map getStatistics() { Map r = new HashMap<>(); - r.put("totalPersons", personService.count()); - r.put("activePersons", personService.count(new LambdaQueryWrapper().eq(EmpiPerson::getMergeStatus, "ACTIVE"))); - r.put("mergedPersons", personService.count(new LambdaQueryWrapper().eq(EmpiPerson::getMergeStatus, "MERGED"))); + long total = personService.count(); + long activeCount = personService.count(new LambdaQueryWrapper().eq(EmpiPerson::getMergeStatus, "ACTIVE")); + long mergedCount = personService.count(new LambdaQueryWrapper().eq(EmpiPerson::getMergeStatus, "MERGED")); + r.put("totalPersons", total); + r.put("activePersons", activeCount); + r.put("mergedPersons", mergedCount); r.put("totalMappings", mappingService.count()); + r.put("pendingMerges", total > 0 ? total - activeCount - mergedCount : 0); + r.put("duplicateRate", total > 0 ? Math.round((double) mergedCount / total * 10000) / 100.0 : 0); return r; } -} + + /** + * 通过全局ID查询关联的院内患者记录 + */ + public List findLinkedPatients(String globalId) { + List mappings = mappingService.list( + new LambdaQueryWrapper().eq(EmpiPersonIdMapping::getGlobalId, globalId)); + if (mappings.isEmpty()) return Collections.emptyList(); + + List patientIds = mappings.stream() + .map(EmpiPersonIdMapping::getLocalPatientId) + .collect(Collectors.toList()); + return patientService.listByIds(patientIds); + } + + /** + * 通过身份证号查询关联的院内患者记录 + */ + public List findLinkedPatientsByIdCard(String idCardNo) { + EmpiPerson person = findByIdCard(idCardNo); + if (person == null) return Collections.emptyList(); + return findLinkedPatients(person.getGlobalId()); + } + + /** + * 查询EMPI患者列表 + */ + @Override + public List listPersons(String name, String idCardNo) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + if (name != null && !name.isEmpty()) { + wrapper.like(EmpiPerson::getName, name); + } + if (idCardNo != null && !idCardNo.isEmpty()) { + wrapper.like(EmpiPerson::getIdCardNo, idCardNo); + } + wrapper.orderByDesc(EmpiPerson::getId); + return personService.list(wrapper); + } +} \ No newline at end of file diff --git a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/empi/controller/EmpiController.java b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/empi/controller/EmpiController.java index ad653170e..0011b0a08 100644 --- a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/empi/controller/EmpiController.java +++ b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/empi/controller/EmpiController.java @@ -1,4 +1,5 @@ package com.healthlink.his.web.empi.controller; + import com.core.common.core.domain.AjaxResult; import com.healthlink.his.empi.domain.*; import com.healthlink.his.web.empi.appservice.IEmpiAppService; @@ -7,19 +8,69 @@ import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; -@Tag(name = "患者主索引(EMPI)") @RestController @RequestMapping("/api/v1/empi") + +@Tag(name = "患者主索引(EMPI)") +@RestController +@RequestMapping("/api/v1/empi") public class EmpiController { - @Autowired private IEmpiAppService empiAppService; - @Operation(summary = "注册患者") @PostMapping("/person") - public AjaxResult register(@RequestBody EmpiPerson p) { return AjaxResult.success(empiAppService.registerPerson(p)); } - @Operation(summary = "合并患者") @PostMapping("/merge") - public AjaxResult merge(@RequestParam Long primaryId, @RequestParam List secondaryIds) { empiAppService.mergePersons(primaryId, secondaryIds); return AjaxResult.success(); } - @Operation(summary = "按全局ID查询") @GetMapping("/person/global/{globalId}") - public AjaxResult findByGlobalId(@PathVariable String globalId) { return AjaxResult.success(empiAppService.findByGlobalId(globalId)); } - @Operation(summary = "按身份证查询") @GetMapping("/person/idcard/{idCardNo}") - public AjaxResult findByIdCard(@PathVariable String idCardNo) { return AjaxResult.success(empiAppService.findByIdCard(idCardNo)); } - @Operation(summary = "ID映射") @GetMapping("/mappings/{globalId}") - public AjaxResult mappings(@PathVariable String globalId) { return AjaxResult.success(empiAppService.getMappings(globalId)); } - @Operation(summary = "统计") @GetMapping("/statistics") - public AjaxResult statistics() { return AjaxResult.success(empiAppService.getStatistics()); } -} + + @Autowired + private IEmpiAppService empiAppService; + + @Operation(summary = "注册患者") + @PostMapping("/person") + public AjaxResult register(@RequestBody EmpiPerson p) { + return AjaxResult.success(empiAppService.registerPerson(p)); + } + + @Operation(summary = "合并患者") + @PostMapping("/merge") + public AjaxResult merge(@RequestParam Long primaryId, @RequestParam List secondaryIds) { + empiAppService.mergePersons(primaryId, secondaryIds); + return AjaxResult.success(); + } + + @Operation(summary = "按全局ID查询EMPI") + @GetMapping("/person/global/{globalId}") + public AjaxResult findByGlobalId(@PathVariable String globalId) { + return AjaxResult.success(empiAppService.findByGlobalId(globalId)); + } + + @Operation(summary = "按身份证查询EMPI") + @GetMapping("/person/idcard/{idCardNo}") + public AjaxResult findByIdCard(@PathVariable String idCardNo) { + return AjaxResult.success(empiAppService.findByIdCard(idCardNo)); + } + + @Operation(summary = "ID映射") + @GetMapping("/mappings/{globalId}") + public AjaxResult mappings(@PathVariable String globalId) { + return AjaxResult.success(empiAppService.getMappings(globalId)); + } + + @Operation(summary = "统计") + @GetMapping("/statistics") + public AjaxResult statistics() { + return AjaxResult.success(empiAppService.getStatistics()); + } + + @Operation(summary = "通过全局ID查询关联的院内患者记录") + @GetMapping("/linked-patients/global/{globalId}") + public AjaxResult findLinkedPatientsByGlobalId(@PathVariable String globalId) { + return AjaxResult.success(empiAppService.findLinkedPatients(globalId)); + } + + @Operation(summary = "通过身份证号查询关联的院内患者记录") + @GetMapping("/linked-patients/idcard/{idCardNo}") + public AjaxResult findLinkedPatientsByIdCard(@PathVariable String idCardNo) { + return AjaxResult.success(empiAppService.findLinkedPatientsByIdCard(idCardNo)); + } + + @Operation(summary = "查询EMPI患者列表") + @GetMapping("/persons") + public AjaxResult listPersons( + @RequestParam(required = false) String name, + @RequestParam(required = false) String idCardNo) { + return AjaxResult.success(empiAppService.listPersons(name, idCardNo)); + } +} \ No newline at end of file diff --git a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/inhospitalnursestation/appservice/impl/AdviceProcessAppServiceImpl.java b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/inhospitalnursestation/appservice/impl/AdviceProcessAppServiceImpl.java index 2646713e8..e34baee4d 100755 --- a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/inhospitalnursestation/appservice/impl/AdviceProcessAppServiceImpl.java +++ b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/inhospitalnursestation/appservice/impl/AdviceProcessAppServiceImpl.java @@ -366,7 +366,15 @@ public class AdviceProcessAppServiceImpl implements IAdviceProcessAppService { // 根据执行状态过滤医嘱列表 List filteredList = new ArrayList<>(); - if (EventStatus.COMPLETED.getValue().equals(exeStatus)) { + if (EventStatus.PREPARATION.getValue().equals(exeStatus)) { + // 待执行 - 过滤出没有已执行记录的医嘱(Bug #663修复) + filteredList = inpatientAdviceList.stream().filter( + advice -> advice.getExePerformRecordList() == null || advice.getExePerformRecordList().isEmpty()) + .collect(Collectors.toList()); + // 更新分页数据 + inpatientAdvicePage.setRecords(filteredList); + inpatientAdvicePage.setTotal(filteredList.size()); + } else if (EventStatus.COMPLETED.getValue().equals(exeStatus)) { // 已执行 - 过滤出有执行记录的医嘱 filteredList = inpatientAdviceList.stream().filter( advice -> advice.getExePerformRecordList() != null && !advice.getExePerformRecordList().isEmpty()) diff --git a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/patientmanage/appservice/impl/PatientInformationServiceImpl.java b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/patientmanage/appservice/impl/PatientInformationServiceImpl.java index 62cd36967..611a4cb56 100755 --- a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/patientmanage/appservice/impl/PatientInformationServiceImpl.java +++ b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/patientmanage/appservice/impl/PatientInformationServiceImpl.java @@ -29,7 +29,9 @@ import com.healthlink.his.web.patientmanage.dto.PatientBaseInfoDto; import com.healthlink.his.web.patientmanage.dto.PatientIdInfoDto; import com.healthlink.his.web.patientmanage.dto.PatientInfoInitDto; import com.healthlink.his.web.patientmanage.mapper.PatientManageMapper; +import com.healthlink.his.empi.event.PatientSavedEvent; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Service; import jakarta.servlet.http.HttpServletRequest; @@ -54,6 +56,9 @@ public class PatientInformationServiceImpl implements IPatientInformationService @Autowired PatientManageMapper patientManageMapper; + @Autowired + private ApplicationEventPublisher eventPublisher; + @Autowired private IPatientService patientService; @@ -379,9 +384,13 @@ public class PatientInformationServiceImpl implements IPatientInformationService .set(Patient::getEducationLevel, patient.getEducationLevel()) .set(Patient::getCompanyAddress, patient.getCompanyAddress()); patientService.update(updateWrapper); + // 发布患者保存事件,触发EMPI同步 + eventPublisher.publishEvent(new PatientSavedEvent(this, patient, false)); } else { // 新增操作 patientService.save(patient); + // 发布患者保存事件,触发EMPI同步 + eventPublisher.publishEvent(new PatientSavedEvent(this, patient, true)); } return patient; diff --git a/healthlink-his-server/healthlink-his-application/src/main/resources/db/migration/V2026_0616_1__empi_core_tables.sql b/healthlink-his-server/healthlink-his-application/src/main/resources/db/migration/V2026_0616_1__empi_core_tables.sql new file mode 100644 index 000000000..4ae48bae9 --- /dev/null +++ b/healthlink-his-server/healthlink-his-application/src/main/resources/db/migration/V2026_0616_1__empi_core_tables.sql @@ -0,0 +1,53 @@ +-- V2026_0616_1: EMPI核心表 — empi_person + empi_person_id_mapping +-- 补充 V20 中遗漏的两张EMPI核心表 + +-- 1. EMPI主索引表(全局患者主记录) +CREATE TABLE IF NOT EXISTS empi_person ( + id BIGSERIAL PRIMARY KEY, + global_id VARCHAR(32) NOT NULL, + id_card_no VARCHAR(20), + patient_name VARCHAR(50), + gender VARCHAR(10), + birth_date DATE, + phone VARCHAR(20), + address TEXT, + merge_status VARCHAR(20) NOT NULL DEFAULT 'ACTIVE', + source_system VARCHAR(50), + create_by VARCHAR(64), + create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + update_by VARCHAR(64), + update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + tenant_id INT DEFAULT 0, + delete_flag VARCHAR(1) NOT NULL DEFAULT '0' +); +COMMENT ON TABLE empi_person IS 'EMPI患者主索引'; +COMMENT ON COLUMN empi_person.global_id IS '全局唯一患者ID'; +COMMENT ON COLUMN empi_person.merge_status IS '合并状态(ACTIVE/MERGED)'; +CREATE UNIQUE INDEX IF NOT EXISTS idx_ep_global ON empi_person(global_id); +CREATE INDEX IF NOT EXISTS idx_ep_idcard ON empi_person(id_card_no); +CREATE INDEX IF NOT EXISTS idx_ep_name ON empi_person(patient_name); + +-- 2. EMPI ID映射表(全局ID与院内系统患者ID的映射关系) +CREATE TABLE IF NOT EXISTS empi_person_id_mapping ( + id BIGSERIAL PRIMARY KEY, + global_id VARCHAR(32) NOT NULL, + local_patient_id BIGINT NOT NULL, + source_system VARCHAR(50) NOT NULL, + id_type VARCHAR(20) NOT NULL, + id_value VARCHAR(100) NOT NULL, + create_by VARCHAR(64), + create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + update_by VARCHAR(64), + update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + tenant_id INT DEFAULT 0, + delete_flag VARCHAR(1) NOT NULL DEFAULT '0' +); +COMMENT ON TABLE empi_person_id_mapping IS 'EMPI患者ID映射表'; +COMMENT ON COLUMN empi_person_id_mapping.global_id IS 'EMPI全局患者ID'; +COMMENT ON COLUMN empi_person_id_mapping.local_patient_id IS '院内患者ID'; +COMMENT ON COLUMN empi_person_id_mapping.source_system IS '来源系统编码'; +COMMENT ON COLUMN empi_person_id_mapping.id_type IS '标识类型(MRN/INSURANCE/CARD等)'; +COMMENT ON COLUMN empi_person_id_mapping.id_value IS '标识值'; +CREATE INDEX IF NOT EXISTS idx_epim_global ON empi_person_id_mapping(global_id); +CREATE INDEX IF NOT EXISTS idx_epim_local ON empi_person_id_mapping(local_patient_id); +CREATE INDEX IF NOT EXISTS idx_epim_source ON empi_person_id_mapping(source_system); \ No newline at end of file diff --git a/healthlink-his-server/healthlink-his-domain/src/main/java/com/healthlink/his/empi/event/PatientSavedEvent.java b/healthlink-his-server/healthlink-his-domain/src/main/java/com/healthlink/his/empi/event/PatientSavedEvent.java new file mode 100644 index 000000000..6b0804aac --- /dev/null +++ b/healthlink-his-server/healthlink-his-domain/src/main/java/com/healthlink/his/empi/event/PatientSavedEvent.java @@ -0,0 +1,18 @@ +package com.healthlink.his.empi.event; + +import com.healthlink.his.administration.domain.Patient; +import org.springframework.context.ApplicationEvent; + +public class PatientSavedEvent extends ApplicationEvent { + private final Patient patient; + private final boolean isNew; + + public PatientSavedEvent(Object source, Patient patient, boolean isNew) { + super(source); + this.patient = patient; + this.isNew = isNew; + } + + public Patient getPatient() { return patient; } + public boolean isNew() { return isNew; } +} \ No newline at end of file diff --git a/healthlink-his-server/healthlink-his-domain/src/main/java/com/healthlink/his/empi/listener/EmpiSyncListener.java b/healthlink-his-server/healthlink-his-domain/src/main/java/com/healthlink/his/empi/listener/EmpiSyncListener.java new file mode 100644 index 000000000..d1c640310 --- /dev/null +++ b/healthlink-his-server/healthlink-his-domain/src/main/java/com/healthlink/his/empi/listener/EmpiSyncListener.java @@ -0,0 +1,109 @@ +package com.healthlink.his.empi.listener; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.healthlink.his.administration.domain.Patient; +import com.healthlink.his.empi.domain.EmpiPerson; +import com.healthlink.his.empi.domain.EmpiPersonIdMapping; +import com.healthlink.his.empi.event.PatientSavedEvent; +import com.healthlink.his.empi.service.IEmpiPersonIdMappingService; +import com.healthlink.his.empi.service.IEmpiPersonService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.event.EventListener; +import org.springframework.stereotype.Component; + +import java.util.UUID; + +@Slf4j +@Component +public class EmpiSyncListener { + + @Autowired + private IEmpiPersonService empiPersonService; + + @Autowired + private IEmpiPersonIdMappingService empiPersonIdMappingService; + + @EventListener + public void onPatientSaved(PatientSavedEvent event) { + Patient patient = event.getPatient(); + try { + if (event.isNew()) { + syncNewPatient(patient); + } else { + syncUpdatedPatient(patient); + } + } catch (Exception e) { + log.error("EMPI同步失败, patientId={}, error={}", patient.getId(), e.getMessage(), e); + } + } + + private void syncNewPatient(Patient patient) { + String idCard = patient.getIdCard(); + EmpiPerson existingPerson = null; + if (idCard != null && !idCard.isEmpty()) { + existingPerson = empiPersonService.getOne( + new LambdaQueryWrapper() + .eq(EmpiPerson::getIdCardNo, idCard) + .eq(EmpiPerson::getMergeStatus, "ACTIVE")); + } + + if (existingPerson == null) { + EmpiPerson person = new EmpiPerson(); + person.setGlobalId(UUID.randomUUID().toString().replace("-", "").substring(0, 16).toUpperCase()); + person.setIdCardNo(idCard); + person.setName(patient.getName()); + person.setGender(patient.getGenderEnum() != null && patient.getGenderEnum() == 1 ? "M" : "F"); + person.setBirthDate(patient.getBirthDate()); + person.setPhone(patient.getPhone()); + person.setAddress(patient.getAddress()); + person.setMergeStatus("ACTIVE"); + person.setSourceSystem("HIS"); + empiPersonService.save(person); + existingPerson = person; + log.info("EMPI主索引创建: globalId={}, patientId={}", existingPerson.getGlobalId(), patient.getId()); + } + + createMappingIfNeeded(existingPerson.getGlobalId(), patient); + } + + private void syncUpdatedPatient(Patient patient) { + EmpiPersonIdMapping mapping = empiPersonIdMappingService.getOne( + new LambdaQueryWrapper() + .eq(EmpiPersonIdMapping::getLocalPatientId, patient.getId())); + + if (mapping != null) { + EmpiPerson person = empiPersonService.getOne( + new LambdaQueryWrapper() + .eq(EmpiPerson::getGlobalId, mapping.getGlobalId())); + if (person != null) { + person.setName(patient.getName()); + person.setGender(patient.getGenderEnum() != null && patient.getGenderEnum() == 1 ? "M" : "F"); + person.setBirthDate(patient.getBirthDate()); + person.setPhone(patient.getPhone()); + person.setAddress(patient.getAddress()); + empiPersonService.updateById(person); + } + } else { + syncNewPatient(patient); + } + } + + private void createMappingIfNeeded(String globalId, Patient patient) { + EmpiPersonIdMapping existing = empiPersonIdMappingService.getOne( + new LambdaQueryWrapper() + .eq(EmpiPersonIdMapping::getGlobalId, globalId) + .eq(EmpiPersonIdMapping::getLocalPatientId, patient.getId())); + + if (existing == null) { + EmpiPersonIdMapping mapping = new EmpiPersonIdMapping(); + mapping.setGlobalId(globalId); + mapping.setLocalPatientId(patient.getId()); + mapping.setSourceSystem("HIS"); + mapping.setIdType("MRN"); + mapping.setIdValue(patient.getBusNo() != null ? patient.getBusNo() : String.valueOf(patient.getId())); + empiPersonIdMappingService.save(mapping); + log.info("EMPI映射创建: globalId={}, patientId={}", globalId, patient.getId()); + } + } +} \ No newline at end of file diff --git a/healthlink-his-ui/src/views/empienhanced/api.js b/healthlink-his-ui/src/views/empienhanced/api.js index 993755991..633b17181 100644 --- a/healthlink-his-ui/src/views/empienhanced/api.js +++ b/healthlink-his-ui/src/views/empienhanced/api.js @@ -1,12 +1,19 @@ import request from '@/utils/request' +// EMPI基础操作 export function registerPerson(data) { return request({ url: '/api/v1/empi/person', method: 'post', data }) } export function mergePersons(primaryId, secondaryIds) { return request({ url: '/api/v1/empi/merge', method: 'post', params: { primaryId, secondaryIds: secondaryIds.join(',') } }) } export function findByGlobalId(globalId) { return request({ url: '/api/v1/empi/person/global/' + globalId, method: 'get' }) } export function findByIdCard(idCardNo) { return request({ url: '/api/v1/empi/person/idcard/' + idCardNo, method: 'get' }) } export function getMappings(globalId) { return request({ url: '/api/v1/empi/mappings/' + globalId, method: 'get' }) } export function getStatistics() { return request({ url: '/api/v1/empi/statistics', method: 'get' }) } +export function listPersons(params) { return request({ url: '/api/v1/empi/persons', method: 'get', params }) } +// 关联院内患者查询 +export function findLinkedPatientsByGlobalId(globalId) { return request({ url: '/api/v1/empi/linked-patients/global/' + globalId, method: 'get' }) } +export function findLinkedPatientsByIdCard(idCardNo) { return request({ url: '/api/v1/empi/linked-patients/idcard/' + idCardNo, method: 'get' }) } + +// EMPI增强功能 export function getPhotos(patientId) { return request({ url: '/empi-enhanced/photo/list', method: 'get', params: { patientId } }) } export function addPhoto(data) { return request({ url: '/empi-enhanced/photo/add', method: 'post', data }) } export function getFamilyMembers(patientId) { return request({ url: '/empi-enhanced/family/list', method: 'get', params: { patientId } }) } @@ -14,4 +21,4 @@ export function addFamilyMember(data) { return request({ url: '/empi-enhanced/fa export function deleteFamilyMember(id) { return request({ url: '/empi-enhanced/family/delete', method: 'delete', params: { id } }) } export function getMergeLogPage(params) { return request({ url: '/empi-enhanced/merge-log/page', method: 'get', params }) } export function addMergeLog(data) { return request({ url: '/empi-enhanced/merge-log/add', method: 'post', data }) } -export function undoMergeLog(data) { return request({ url: '/empi-enhanced/merge-log/undo', method: 'post', data }) } +export function undoMergeLog(data) { return request({ url: '/empi-enhanced/merge-log/undo', method: 'post', data }) } \ No newline at end of file diff --git a/healthlink-his-ui/src/views/empienhanced/merge/index.vue b/healthlink-his-ui/src/views/empienhanced/merge/index.vue index 543f5f045..2cf7e8615 100644 --- a/healthlink-his-ui/src/views/empienhanced/merge/index.vue +++ b/healthlink-his-ui/src/views/empienhanced/merge/index.vue @@ -1,29 +1,105 @@