|
@ -12,8 +12,7 @@ import com.yihu.wlyy.entity.patient.Patient;
|
|
|
import com.yihu.wlyy.entity.patient.PatientSchemeList;
|
|
|
import com.yihu.wlyy.health.repository.DevicePatientHealthIndexDao;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctoreSchemeBloodPressureDao;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctoreSchemeBloodSuggerDao;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctroSchemeBloodSuggerDao;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctrorSchemeBloodSuggerDao;
|
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
|
import com.yihu.wlyy.repository.patient.scheme.PatientSchemeListDao;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
@ -26,6 +25,7 @@ import org.springframework.orm.jpa.JpaTransactionManager;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.TransactionDefinition;
|
|
|
import org.springframework.transaction.TransactionStatus;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
|
|
|
|
|
import java.util.*;
|
|
@ -43,7 +43,7 @@ public class DoctorSchemeService {
|
|
|
JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
@Autowired
|
|
|
private DoctroSchemeBloodSuggerDao doctroSchemeBloodSuggerDao;
|
|
|
private DoctrorSchemeBloodSuggerDao doctroSchemeBloodSuggerDao;
|
|
|
|
|
|
@Autowired
|
|
|
private DoctoreSchemeBloodPressureDao doctoreSchemeBloodPressureDao;
|
|
@ -54,9 +54,6 @@ public class DoctorSchemeService {
|
|
|
@Autowired
|
|
|
private PatientSchemeListDao patientSchemeListDao;
|
|
|
|
|
|
@Autowired
|
|
|
private DoctoreSchemeBloodSuggerDao doctoreSchemeBloodSuggerDao;
|
|
|
|
|
|
@Autowired
|
|
|
private PatientDao patientDao;
|
|
|
|
|
@ -124,24 +121,24 @@ public class DoctorSchemeService {
|
|
|
|
|
|
HashMap<String,List<DoctorSchemeBloodSugger>> mapresult = new HashMap<>();
|
|
|
|
|
|
List<DoctorSchemeBloodSugger> schemelist = doctroSchemeBloodSuggerDao.getListByDoctorcode(doctorcode);
|
|
|
|
|
|
List<DoctorSchemeBloodSugger> defaultSchemeBloodSugger = doctroSchemeBloodSuggerDao.findByCode("default");
|
|
|
LinkedList<String> keys = new LinkedList<>();
|
|
|
|
|
|
schemelist.addAll(defaultSchemeBloodSugger);
|
|
|
List<DoctorSchemeBloodSugger> schemelist = doctroSchemeBloodSuggerDao.getListByDoctorcode(doctorcode);
|
|
|
|
|
|
if(!schemelist.isEmpty()){
|
|
|
|
|
|
for (DoctorSchemeBloodSugger doctorSchemeBloodSugger : schemelist) {
|
|
|
if(mapresult.keySet().contains(doctorSchemeBloodSugger.getCode())){
|
|
|
if(keys.contains(doctorSchemeBloodSugger.getCode())){
|
|
|
mapresult.get(doctorSchemeBloodSugger.getCode()).add(doctorSchemeBloodSugger);
|
|
|
}else{
|
|
|
List<DoctorSchemeBloodSugger> list = new ArrayList<>();
|
|
|
list.add(doctorSchemeBloodSugger);
|
|
|
mapresult.put(doctorSchemeBloodSugger.getCode(),list);
|
|
|
keys.add(doctorSchemeBloodSugger.getCode());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for (String key :mapresult.keySet()) {
|
|
|
for (String key :keys) {
|
|
|
DoctorSchemeBloodSuggerVO doctorSchemeBloodSuggerVO = new DoctorSchemeBloodSuggerVO();
|
|
|
doctorSchemeBloodSuggerVO.setCode(key);
|
|
|
doctorSchemeBloodSuggerVO.setName(mapresult.get(key).get(0).getName());
|
|
@ -167,22 +164,21 @@ public class DoctorSchemeService {
|
|
|
|
|
|
List<DoctorSchemeBloodPressure> schemelist = doctoreSchemeBloodPressureDao.getListByDoctorcode(doctorcode);
|
|
|
|
|
|
List<DoctorSchemeBloodPressure> defaultSchemeBloodPressure = doctoreSchemeBloodPressureDao.findByCode("default");
|
|
|
|
|
|
schemelist.addAll(defaultSchemeBloodPressure);
|
|
|
LinkedList<String> keys = new LinkedList<>();
|
|
|
|
|
|
if(!schemelist.isEmpty()){
|
|
|
for (DoctorSchemeBloodPressure doctorSchemeBloodPressure : schemelist) {
|
|
|
if(mapresult.keySet().contains(doctorSchemeBloodPressure.getCode())){
|
|
|
if(keys.contains(doctorSchemeBloodPressure.getCode())){
|
|
|
mapresult.get(doctorSchemeBloodPressure.getCode()).add(doctorSchemeBloodPressure);
|
|
|
}else{
|
|
|
List<DoctorSchemeBloodPressure> list = new ArrayList<>();
|
|
|
list.add(doctorSchemeBloodPressure);
|
|
|
mapresult.put(doctorSchemeBloodPressure.getCode(),list);
|
|
|
keys.add(doctorSchemeBloodPressure.getCode());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for (String key :mapresult.keySet()) {
|
|
|
for (String key :keys) {
|
|
|
DoctorSchemeBloodPressureVO doctorSchemeBloodPressureVO = new DoctorSchemeBloodPressureVO();
|
|
|
doctorSchemeBloodPressureVO.setCode(key);
|
|
|
doctorSchemeBloodPressureVO.setName(mapresult.get(key).get(0).getName());
|
|
@ -202,7 +198,7 @@ public class DoctorSchemeService {
|
|
|
* @param data
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public void saveDoctorSchemeBloodSugger(String data) {
|
|
|
public void saveDoctorSchemeBloodSugger(String data) throws Exception{
|
|
|
|
|
|
JSONObject dataObj = JSON.parseObject(data);
|
|
|
|
|
@ -223,7 +219,10 @@ public class DoctorSchemeService {
|
|
|
for (int i = 0; i < datalist.size(); i++) {
|
|
|
DoctorSchemeBloodSugger doctorSchemeBloodSugger = new DoctorSchemeBloodSugger();
|
|
|
|
|
|
Long id = datalist.getJSONObject(i).getLong("id");
|
|
|
long id = 0;
|
|
|
if(datalist.getJSONObject(i).containsKey("id")){
|
|
|
id=datalist.getJSONObject(i).getLong("id");
|
|
|
}
|
|
|
if(id != 0){
|
|
|
doctorSchemeBloodSugger.setId(datalist.getJSONObject(i).getLong("id"));
|
|
|
}
|
|
@ -251,11 +250,12 @@ public class DoctorSchemeService {
|
|
|
doctorSchemeBloodSugger.setAlertTag(datalist.getJSONObject(i).getShort("alertTag"));
|
|
|
doctorSchemeBloodSugger.setContent(content);
|
|
|
doctorSchemeBloodSugger.setCreateTime(DateUtil.getNowTimestamp());
|
|
|
doctorSchemeBloodSugger.setDel(0);
|
|
|
results.add(doctorSchemeBloodSugger);
|
|
|
}
|
|
|
|
|
|
if(!results.isEmpty()) {
|
|
|
doctoreSchemeBloodSuggerDao.save(results);
|
|
|
doctroSchemeBloodSuggerDao.save(results);
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
@ -284,7 +284,10 @@ public class DoctorSchemeService {
|
|
|
for (int i = 0; i < datalist.size(); i++) {
|
|
|
DoctorSchemeBloodPressure doctorSchemeBloodPressure = new DoctorSchemeBloodPressure();
|
|
|
|
|
|
Long id = datalist.getJSONObject(i).getLong("id");
|
|
|
long id = 0;
|
|
|
if(datalist.getJSONObject(i).containsKey("id")){
|
|
|
id=datalist.getJSONObject(i).getLong("id");
|
|
|
}
|
|
|
if(id != 0){
|
|
|
doctorSchemeBloodPressure.setId(datalist.getJSONObject(i).getLong("id"));
|
|
|
}
|
|
@ -306,6 +309,7 @@ public class DoctorSchemeService {
|
|
|
doctorSchemeBloodPressure.setAlertTag(datalist.getJSONObject(i).getShort("alertTag"));
|
|
|
doctorSchemeBloodPressure.setContent(content);
|
|
|
doctorSchemeBloodPressure.setCreateTime(DateUtil.getNowTimestamp());
|
|
|
doctorSchemeBloodPressure.setDel(0);
|
|
|
results.add(doctorSchemeBloodPressure);
|
|
|
}
|
|
|
|
|
@ -323,20 +327,23 @@ public class DoctorSchemeService {
|
|
|
* @param type
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@Transactional
|
|
|
public void savePatientScheme(String doctorcode, String schemecode, String type,String patientcodes) throws Exception {
|
|
|
List<String> patientcodeList = new ArrayList<>();
|
|
|
|
|
|
JSONObject dataObj = JSON.parseObject(patientcodes);
|
|
|
JSONArray codes = dataObj.getJSONArray("patientcodes");
|
|
|
|
|
|
if (codes == null || codes.size() == 0) {
|
|
|
throw new Exception("居民列表不能为空");
|
|
|
}
|
|
|
String[] codes = patientcodes.split(",");
|
|
|
|
|
|
for (int i = 0; i < codes.size(); i++) {
|
|
|
patientcodeList.add(codes.getJSONObject(i).toString());
|
|
|
if(patientcodes.contains(",")){
|
|
|
for (String code : codes) {
|
|
|
patientcodeList.add(code);
|
|
|
}
|
|
|
}else{
|
|
|
patientcodeList.add(patientcodes);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!patientcodeList.isEmpty()) {
|
|
|
|
|
|
//使用事务控制批量更新
|
|
@ -345,21 +352,21 @@ public class DoctorSchemeService {
|
|
|
TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
|
|
|
try {
|
|
|
|
|
|
PatientSchemeList patientSchemeListObj = new PatientSchemeList();
|
|
|
for (String patientcode : patientcodeList) {
|
|
|
patientSchemeListDao.delByPatientCodeAndSchemeCode(patientcode, Integer.parseInt(type), schemecode);
|
|
|
PatientSchemeList patientSchemeListObj = new PatientSchemeList();
|
|
|
patientSchemeListObj.setCode(UUID.randomUUID().toString());
|
|
|
patientSchemeListObj.setPatientcode(patientcode);
|
|
|
patientSchemeListObj.setSchemecode(schemecode);
|
|
|
patientSchemeListObj.setDoctorcode(doctorcode);
|
|
|
Short _type = new Short(type);
|
|
|
patientSchemeListObj.setType(_type);
|
|
|
patientSchemeListObj.setType(Integer.parseInt(type));
|
|
|
patientSchemeListObj.setCreateTime(DateUtil.getNowTimestamp());
|
|
|
patientSchemeListDao.save(patientSchemeListObj);
|
|
|
}
|
|
|
//事务提交
|
|
|
transactionManager.commit(status);
|
|
|
} catch (Exception ex) {
|
|
|
System.out.println(ex.getMessage());
|
|
|
//报错事务回滚
|
|
|
transactionManager.rollback(status);
|
|
|
}
|
|
@ -376,11 +383,11 @@ public class DoctorSchemeService {
|
|
|
* @param enddate
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONArray getSlowDiseaseTeaminfos(String teamCode, int getcolor, int getstands, int gethealthindex, String startdate, String enddate) throws Exception{
|
|
|
public JSONObject getSlowDiseaseTeaminfos(String teamCode, int getcolor, int getstands, int gethealthindex, String startdate, String enddate) throws Exception{
|
|
|
|
|
|
List<Patient> patients = patientDao.findAllSignPatientTeamcode(teamCode);
|
|
|
|
|
|
JSONArray result = new JSONArray();
|
|
|
JSONObject result = new JSONObject();
|
|
|
JSONObject green = new JSONObject();//绿标
|
|
|
JSONObject yellow = new JSONObject();//黄标
|
|
|
JSONObject red = new JSONObject();//红标
|
|
@ -410,10 +417,10 @@ public class DoctorSchemeService {
|
|
|
List<String> bloodsugar_patientcodes = new ArrayList<>();
|
|
|
|
|
|
if(!patients.isEmpty()){
|
|
|
for (Patient patient : red_patients) {
|
|
|
for (Patient patient : patients) {
|
|
|
|
|
|
//获取居民颜色标签
|
|
|
if(1 == getcolor){
|
|
|
if(1 == getcolor && patient.getDiseaseCondition() != null){
|
|
|
switch (patient.getDiseaseCondition()){
|
|
|
case 0:
|
|
|
green_patients.add(patient);
|
|
@ -430,15 +437,18 @@ public class DoctorSchemeService {
|
|
|
}
|
|
|
|
|
|
//获取预警居民CODES
|
|
|
if(1 == getstands && 1 == patient.getStandardStatus()){
|
|
|
if(1 == getstands && (patient.getStandardStatus() !=null && patient.getStandardStatus() ==1)){
|
|
|
|
|
|
if( 1 == patient.getDisease() || 3 == patient.getDisease()){
|
|
|
bloodpressure_patientcodes.add(patient.getCode());
|
|
|
}
|
|
|
if(patient.getDisease() != null){
|
|
|
if( 1 == patient.getDisease() || 3 == patient.getDisease()){
|
|
|
bloodpressure_patientcodes.add(patient.getCode());
|
|
|
}
|
|
|
|
|
|
if( 2 == patient.getDisease() || 3 == patient.getDisease()){
|
|
|
bloodsugar_patientcodes.add(patient.getCode());
|
|
|
if( 2 == patient.getDisease() || 3 == patient.getDisease()){
|
|
|
bloodsugar_patientcodes.add(patient.getCode());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@ -446,19 +456,19 @@ public class DoctorSchemeService {
|
|
|
|
|
|
|
|
|
if(1 == getcolor){
|
|
|
green.put("greencount",green_patients.size());
|
|
|
yellow.put("yellowcount",yellow_patients.size());
|
|
|
red.put("redcount",red_patients.size());
|
|
|
result.add(green);
|
|
|
result.add(yellow);
|
|
|
result.add(red);
|
|
|
result.put("greencount",green_patients.size());
|
|
|
result.put("yellowcount",yellow_patients.size());
|
|
|
result.put("redcount",red_patients.size());
|
|
|
// result.add(green);
|
|
|
// result.add(yellow);
|
|
|
// result.add(red);
|
|
|
}
|
|
|
|
|
|
if(1 == getstands){
|
|
|
pressure_standard.put("pressure_standard",bloodpressure_patientcodes);
|
|
|
sugar_standard.put("sugar_standard",bloodsugar_patientcodes);
|
|
|
result.add(pressure_standard);
|
|
|
result.add(sugar_standard);
|
|
|
result.put("pressure_standard",bloodpressure_patientcodes);
|
|
|
result.put("sugar_standard",bloodsugar_patientcodes);
|
|
|
// result.add(pressure_standard);
|
|
|
// result.add(sugar_standard);
|
|
|
}
|
|
|
|
|
|
|
|
@ -494,18 +504,37 @@ public class DoctorSchemeService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
pressure_count.put("pressure_count",pressure);
|
|
|
pressure_unusual_ount.put("pressure_unusual_count",pressure_unusual);
|
|
|
sugar_count.put("sugar_count",sugar);
|
|
|
sugar_unusual_count.put("sugar_unusual_count",sugar_unusual);
|
|
|
result.put("pressure_count",pressure);
|
|
|
result.put("pressure_unusual_count",pressure_unusual);
|
|
|
result.put("sugar_count",sugar);
|
|
|
result.put("sugar_unusual_count",sugar_unusual);
|
|
|
|
|
|
result.add(pressure_count);
|
|
|
result.add(pressure_unusual_ount);
|
|
|
result.add(sugar_count);
|
|
|
result.add(sugar_unusual_count);
|
|
|
// result.add(pressure_count);
|
|
|
// result.add(pressure_unusual_ount);
|
|
|
// result.add(sugar_count);
|
|
|
// result.add(sugar_unusual_count);
|
|
|
}
|
|
|
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除医生监测方案
|
|
|
* @param doctorcode
|
|
|
* @param schemecode
|
|
|
* @param type
|
|
|
*/
|
|
|
@Transactional
|
|
|
public void delDoctorScheme(String doctorcode, String schemecode, String type) throws Exception{
|
|
|
|
|
|
if("1".equals(type)){
|
|
|
|
|
|
doctroSchemeBloodSuggerDao.updateDelStatus(1,doctorcode,schemecode);
|
|
|
}
|
|
|
|
|
|
if("2".equals(type)){
|
|
|
doctoreSchemeBloodPressureDao.updateDelStatus(1,doctorcode,schemecode);
|
|
|
}
|
|
|
}
|
|
|
}
|