PHRService.java 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. package com.lemon.lifecenter.service;
  2. import java.util.List;
  3. import org.springframework.beans.factory.annotation.Autowired;
  4. import org.springframework.stereotype.Service;
  5. import com.lemon.lifecenter.dto.ClinicConfigurationDTO;
  6. import com.lemon.lifecenter.dto.PatientPHRHistoryDTO;
  7. import com.lemon.lifecenter.dto.PatientPHRLatestDTO;
  8. import com.lemon.lifecenter.dto.PatientSymptomSimDTO;
  9. import com.lemon.lifecenter.mapper.ClinicConfigurationMapper;
  10. import com.lemon.lifecenter.mapper.PatientPHRHistoryMapper;
  11. import com.lemon.lifecenter.mapper.PatientPHRLatestMapper;
  12. import com.lemon.lifecenter.mapper.PatientSymptomSimMapper;
  13. @Service
  14. public class PHRService {
  15. @Autowired
  16. private PatientPHRHistoryMapper mapperHistory;
  17. @Autowired
  18. private PatientPHRLatestMapper mapperPHRLatest;
  19. @Autowired
  20. private PatientSymptomSimMapper mapperSymptom;
  21. @Autowired
  22. private ClinicConfigurationMapper mapperClinicConfiguration;
  23. public void insertPHR(PatientPHRHistoryDTO dto) {
  24. mapperHistory.insertPHRHistory(dto);
  25. // 해당 환자가 속해 있는 센터의 설정 정보 가져오기
  26. ClinicConfigurationDTO configurationDTO = new ClinicConfigurationDTO();
  27. configurationDTO.setPatientIdx(dto.getPatientIdx());
  28. configurationDTO = mapperClinicConfiguration.selectConfigurationWithPatient(configurationDTO);
  29. PatientPHRLatestDTO phrLatestDTO = new PatientPHRLatestDTO();
  30. phrLatestDTO.setPatientIdx(dto.getPatientIdx());
  31. switch (dto.getPhrType()) {
  32. case "temperature":
  33. String temperatureAlarmYN = "N";
  34. if (dto.getPhrValue() >= configurationDTO.getTemparatureThreshold()) {
  35. temperatureAlarmYN = "Y";
  36. }
  37. phrLatestDTO.setTemperature(dto.getPhrValue());
  38. phrLatestDTO.setTemperatureAlarmYN(temperatureAlarmYN);
  39. break;
  40. case "oxygenSaturation":
  41. String oxygenSaturationAlarmYN = "N";
  42. if (dto.getPhrValue().intValue() <= configurationDTO.getOxygenSaturationThreshold()) {
  43. oxygenSaturationAlarmYN = "Y";
  44. }
  45. phrLatestDTO.setOxygenSaturation(dto.getPhrValue().intValue());
  46. phrLatestDTO.setOxygenSaturationAlarmYN(oxygenSaturationAlarmYN);
  47. break;
  48. case "pulseRate":
  49. String pulseRateAlarmYN = "N";
  50. if (dto.getPhrValue().intValue() <= configurationDTO.getPulseRateThresholdMin() || dto.getPhrValue().intValue() >= configurationDTO.getPulseRateThresholdMax()) {
  51. pulseRateAlarmYN = "Y";
  52. }
  53. phrLatestDTO.setPulseRate(dto.getPhrValue().intValue());
  54. phrLatestDTO.setPulseRateAlarmYN(pulseRateAlarmYN);
  55. break;
  56. case "bloodPressure":
  57. String systolicBloodPressureAlarmYN = "N";
  58. if (dto.getPhrValue().intValue() <= configurationDTO.getSystolicBloodPressureThresholdMin() || dto.getPhrValue().intValue() >= configurationDTO.getSystolicBloodPressureThresholdMax()) {
  59. systolicBloodPressureAlarmYN = "Y";
  60. }
  61. phrLatestDTO.setSystolicBloodPressure(dto.getPhrValue().intValue());
  62. phrLatestDTO.setSystolicBloodPressureAlarmYN(systolicBloodPressureAlarmYN);
  63. String diastolicBloodPressureAlarmY = "N";
  64. if (dto.getPhrValue().intValue() <= configurationDTO.getDiastolicBloodPressureThresholdMin() || dto.getPhrValue().intValue() >= configurationDTO.getDiastolicBloodPressureThresholdMax()) {
  65. diastolicBloodPressureAlarmY = "Y";
  66. }
  67. phrLatestDTO.setDiastolicBloodPressure(dto.getPhrValue2().intValue());
  68. phrLatestDTO.setDiastolicBloodPressureAlarmYN(diastolicBloodPressureAlarmY);
  69. break;
  70. case "bloodSugar":
  71. String bloodSugarAlarmYN = "N";
  72. if (dto.getPhrValue().intValue() <= configurationDTO.getBloodSugarThresholdMin() || dto.getPhrValue().intValue() >= configurationDTO.getBloodSugerThresholdMax()) {
  73. bloodSugarAlarmYN = "Y";
  74. }
  75. phrLatestDTO.setBloodSugar(dto.getPhrValue().intValue());
  76. phrLatestDTO.setBloodSugarAlarmYN(bloodSugarAlarmYN);
  77. break;
  78. }
  79. mapperPHRLatest.insertPHRLatest(phrLatestDTO);
  80. }
  81. public int selectPHRHistoryCount(PatientPHRHistoryDTO dto) {
  82. return mapperHistory.selectPHRHistoryCount(dto);
  83. }
  84. public List<PatientPHRHistoryDTO> selectPHRHistoryList(PatientPHRHistoryDTO dto) {
  85. return mapperHistory.selectPHRHistoryList(dto);
  86. }
  87. public void insertSymptom(PatientSymptomSimDTO dto) {
  88. mapperSymptom.insertSymptom(dto);
  89. PatientPHRLatestDTO phrLatestDTO = new PatientPHRLatestDTO();
  90. phrLatestDTO.setPatientIdx(dto.getPatientIdx());
  91. phrLatestDTO.setSymptomYN("Y");
  92. mapperPHRLatest.insertPHRLatest(phrLatestDTO);
  93. }
  94. public int selectSymptomCount(PatientSymptomSimDTO dto) {
  95. return mapperSymptom.selectSymptomCount(dto);
  96. }
  97. public List<PatientSymptomSimDTO> selectSymptomList(PatientSymptomSimDTO dto) {
  98. return mapperSymptom.selectSymptomList(dto);
  99. }
  100. }