diff --git a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/dataflow/event/PathologySpecimenSubmittedEvent.java b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/dataflow/event/PathologySpecimenSubmittedEvent.java new file mode 100644 index 000000000..26c18d421 --- /dev/null +++ b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/dataflow/event/PathologySpecimenSubmittedEvent.java @@ -0,0 +1,22 @@ +package com.healthlink.his.web.dataflow.event; + +import org.springframework.context.ApplicationEvent; +import lombok.Getter; + +@Getter +public class PathologySpecimenSubmittedEvent extends ApplicationEvent { + private final Long encounterId; + private final Long patientId; + private final Long surgeryId; + private final String specimenType; + private final String specimenSource; + + public PathologySpecimenSubmittedEvent(Object source, Long encounterId, Long patientId, Long surgeryId, String specimenType, String specimenSource) { + super(source); + this.encounterId = encounterId; + this.patientId = patientId; + this.surgeryId = surgeryId; + this.specimenType = specimenType; + this.specimenSource = specimenSource; + } +} diff --git a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/dataflow/handler/PathologySubmissionHandler.java b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/dataflow/handler/PathologySubmissionHandler.java new file mode 100644 index 000000000..8966a62ea --- /dev/null +++ b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/dataflow/handler/PathologySubmissionHandler.java @@ -0,0 +1,40 @@ +package com.healthlink.his.web.dataflow.handler; + +import com.healthlink.his.web.dataflow.event.PathologySpecimenSubmittedEvent; +import com.healthlink.his.web.dataflow.util.EventRetryUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.event.EventListener; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.Map; + +@Slf4j +@Component +public class PathologySubmissionHandler { + + @Async + @EventListener + public void onSpecimenSubmitted(PathologySpecimenSubmittedEvent event) { + log.info("Chain11 Pathology: encounterId={}, surgeryId={}, specimenType={}", + event.getEncounterId(), event.getSurgeryId(), event.getSpecimenType()); + EventRetryUtil.executeVoidWithRetry("11-Pathology", () -> { + Map pathologyOrder = new HashMap<>(); + pathologyOrder.put("encounterId", event.getEncounterId()); + pathologyOrder.put("patientId", event.getPatientId()); + pathologyOrder.put("surgeryId", event.getSurgeryId()); + pathologyOrder.put("specimenType", event.getSpecimenType()); + pathologyOrder.put("specimenSource", event.getSpecimenSource()); + pathologyOrder.put("status", "PENDING_COLLECTION"); + + // TODO: 保存病理申请到数据库 + + // TODO: 调用条码服务生成唯一标识 + + // TODO: WebSocket推送通知病理科接收标本 + + log.info("Chain11 Pathology: order created for surgeryId={}", event.getSurgeryId()); + }, 3); + } +}