123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- package com.lemon.lifecenter.service;
- import java.util.List;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import com.lemon.lifecenter.dto.ClinicConfigurationDTO;
- import com.lemon.lifecenter.dto.PatientPHRHistoryDTO;
- import com.lemon.lifecenter.dto.PatientPHRLatestDTO;
- import com.lemon.lifecenter.dto.PatientSymptomSimDTO;
- import com.lemon.lifecenter.mapper.ClinicConfigurationMapper;
- import com.lemon.lifecenter.mapper.PatientPHRHistoryMapper;
- import com.lemon.lifecenter.mapper.PatientPHRLatestMapper;
- import com.lemon.lifecenter.mapper.PatientSymptomSimMapper;
- @Service
- public class PHRService {
- @Autowired
- private PatientPHRHistoryMapper mapperHistory;
-
- @Autowired
- private PatientPHRLatestMapper mapperPHRLatest;
-
- @Autowired
- private PatientSymptomSimMapper mapperSymptom;
-
- @Autowired
- private ClinicConfigurationMapper mapperClinicConfiguration;
-
- public void insertPHR(PatientPHRHistoryDTO dto) {
- mapperHistory.insertPHRHistory(dto);
-
- // 해당 환자가 속해 있는 센터의 설정 정보 가져오기
- ClinicConfigurationDTO configurationDTO = new ClinicConfigurationDTO();
- configurationDTO.setPatientIdx(dto.getPatientIdx());
- configurationDTO = mapperClinicConfiguration.selectConfigurationWithPatient(configurationDTO);
-
- PatientPHRLatestDTO phrLatestDTO = new PatientPHRLatestDTO();
- phrLatestDTO.setPatientIdx(dto.getPatientIdx());
-
- switch (dto.getPhrType()) {
- case "temperature":
- String temperatureAlarmYN = "N";
- if (dto.getPhrValue() >= configurationDTO.getTemparatureThreshold()) {
- temperatureAlarmYN = "Y";
- }
- phrLatestDTO.setTemperature(dto.getPhrValue());
- phrLatestDTO.setTemperatureAlarmYN(temperatureAlarmYN);
- break;
- case "oxygenSaturation":
- String oxygenSaturationAlarmYN = "N";
- if (dto.getPhrValue().intValue() <= configurationDTO.getOxygenSaturationThreshold()) {
- oxygenSaturationAlarmYN = "Y";
- }
- phrLatestDTO.setOxygenSaturation(dto.getPhrValue().intValue());
- phrLatestDTO.setOxygenSaturationAlarmYN(oxygenSaturationAlarmYN);
- break;
- case "pulseRate":
- String pulseRateAlarmYN = "N";
- if (dto.getPhrValue().intValue() <= configurationDTO.getPulseRateThresholdMin() || dto.getPhrValue().intValue() >= configurationDTO.getPulseRateThresholdMax()) {
- pulseRateAlarmYN = "Y";
- }
- phrLatestDTO.setPulseRate(dto.getPhrValue().intValue());
- phrLatestDTO.setPulseRateAlarmYN(pulseRateAlarmYN);
- break;
- case "bloodPressure":
- String systolicBloodPressureAlarmYN = "N";
- if (dto.getPhrValue().intValue() <= configurationDTO.getSystolicBloodPressureThresholdMin() || dto.getPhrValue().intValue() >= configurationDTO.getSystolicBloodPressureThresholdMax()) {
- systolicBloodPressureAlarmYN = "Y";
- }
- phrLatestDTO.setSystolicBloodPressure(dto.getPhrValue().intValue());
- phrLatestDTO.setSystolicBloodPressureAlarmYN(systolicBloodPressureAlarmYN);
-
- String diastolicBloodPressureAlarmY = "N";
- if (dto.getPhrValue().intValue() <= configurationDTO.getDiastolicBloodPressureThresholdMin() || dto.getPhrValue().intValue() >= configurationDTO.getDiastolicBloodPressureThresholdMax()) {
- diastolicBloodPressureAlarmY = "Y";
- }
- phrLatestDTO.setDiastolicBloodPressure(dto.getPhrValue2().intValue());
- phrLatestDTO.setDiastolicBloodPressureAlarmYN(diastolicBloodPressureAlarmY);
- break;
- case "bloodSugar":
- String bloodSugarAlarmYN = "N";
- if (dto.getPhrValue().intValue() <= configurationDTO.getBloodSugarThresholdMin() || dto.getPhrValue().intValue() >= configurationDTO.getBloodSugerThresholdMax()) {
- bloodSugarAlarmYN = "Y";
- }
- phrLatestDTO.setBloodSugar(dto.getPhrValue().intValue());
- phrLatestDTO.setBloodSugarAlarmYN(bloodSugarAlarmYN);
- break;
- }
-
- mapperPHRLatest.insertPHRLatest(phrLatestDTO);
- }
-
- public int selectPHRHistoryCount(PatientPHRHistoryDTO dto) {
- return mapperHistory.selectPHRHistoryCount(dto);
- }
-
- public List<PatientPHRHistoryDTO> selectPHRHistoryList(PatientPHRHistoryDTO dto) {
- return mapperHistory.selectPHRHistoryList(dto);
- }
-
- public void insertSymptom(PatientSymptomSimDTO dto) {
- mapperSymptom.insertSymptom(dto);
- PatientPHRLatestDTO phrLatestDTO = new PatientPHRLatestDTO();
- phrLatestDTO.setPatientIdx(dto.getPatientIdx());
- phrLatestDTO.setSymptomYN("Y");
- mapperPHRLatest.insertPHRLatest(phrLatestDTO);
- }
-
- public int selectSymptomCount(PatientSymptomSimDTO dto) {
- return mapperSymptom.selectSymptomCount(dto);
- }
-
- public List<PatientSymptomSimDTO> selectSymptomList(PatientSymptomSimDTO dto) {
- return mapperSymptom.selectSymptomList(dto);
- }
- }
|