|
@ -9,6 +9,7 @@ import com.yihu.jw.hospital.family.dao.BasePatientMemberDictDao;
|
|
|
import com.yihu.jw.hospital.family.dao.WlyyPatientFamilyMemberDao;
|
|
|
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
|
|
|
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
|
|
|
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.restmodel.web.Envelop;
|
|
|
import com.yihu.jw.restmodel.web.MixEnvelop;
|
|
@ -20,6 +21,7 @@ import net.sf.json.JSONArray;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.checkerframework.checker.units.qual.A;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@ -42,6 +44,11 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem
|
|
|
private BasePatientDao basePatientDao;
|
|
|
@Autowired
|
|
|
private HibenateUtils hibenateUtils;
|
|
|
@Autowired
|
|
|
private YkyyEntranceService ykyyEntranceService;
|
|
|
@Value("${wechat.id}")
|
|
|
private String wxId;
|
|
|
|
|
|
//添加关联家属
|
|
|
@Transactional
|
|
|
public MixEnvelop addFamily(String id,String patientId, String familyName, String dictId, String cardType, String idCard, String phoneNum,boolean demo) throws Exception {
|
|
@ -64,84 +71,112 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem
|
|
|
if (null!=basePatientMemberDictDO){
|
|
|
dictName = basePatientMemberDictDO.getRelationName();
|
|
|
}
|
|
|
String familyId="";
|
|
|
String birth = "";
|
|
|
int sex=3;
|
|
|
//获取his家属数据
|
|
|
JSONArray jsonArray = entranceService.BS10008(idCard,"","","","","",demo);
|
|
|
if(jsonArray!=null&&jsonArray.size()>0){
|
|
|
net.sf.json.JSONObject jsonObject= net.sf.json.JSONObject.fromObject(jsonArray.get(0).toString());
|
|
|
String familyId="";
|
|
|
//如果病人id为空则没有就诊记录
|
|
|
if (null!=jsonObject.get("Patient_Id")){
|
|
|
familyId = jsonObject.getString("Patient_Id");
|
|
|
String Pat_name = jsonObject.getString("Pat_Name");
|
|
|
if (null!=jsonObject.get("Phone_Number_Business")){
|
|
|
String Next_Of_Kin_Phone = jsonObject.get("Phone_Number_Business").toString();
|
|
|
if(!Next_Of_Kin_Phone.equalsIgnoreCase(phoneNum)){
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
if("xm_ykyy_wx".equalsIgnoreCase(wxId)){
|
|
|
jsonArray = ykyyEntranceService.findHisPatientByIdCard(idCard,false);
|
|
|
if(jsonArray!=null&&jsonArray.size()>0){
|
|
|
net.sf.json.JSONObject jsonObject= net.sf.json.JSONObject.fromObject(jsonArray.get(0).toString());
|
|
|
if (null!=jsonObject.get("brid")){
|
|
|
String Pat_name = jsonObject.getString("brxm");
|
|
|
if (!Pat_name.equalsIgnoreCase(familyName)) {
|
|
|
mixEnvelop.setStatus(408);
|
|
|
mixEnvelop.setMessage("您所添加的家属的电话有误,无法添加");
|
|
|
mixEnvelop.setMessage("您所添加的家属的名称有误,无法添加");
|
|
|
return mixEnvelop;
|
|
|
}
|
|
|
}
|
|
|
if(!Pat_name.equalsIgnoreCase(familyName)){
|
|
|
familyId= jsonObject.getString("brid");
|
|
|
birth= jsonObject.getString("csny");
|
|
|
}else {
|
|
|
mixEnvelop.setStatus(408);
|
|
|
mixEnvelop.setMessage("您所添加的家属的名称有误,无法添加");
|
|
|
mixEnvelop.setMessage("您所添加的家属无就诊记录无法添加");
|
|
|
return mixEnvelop;
|
|
|
}
|
|
|
result.setFamilyRelation(dictId);
|
|
|
result.setFamilyRelationName(dictName);
|
|
|
result.setIsDel(1);
|
|
|
result.setPatient(patientId);
|
|
|
result.setCardNo(idCard);
|
|
|
result.setCardType(cardType);
|
|
|
//保存到base_patient表中
|
|
|
basePatientDO.setMobile(phoneNum);
|
|
|
if(null!=jsonObject.get("Birth_Date")){
|
|
|
String birth = jsonObject.get("Birth_Date").toString();
|
|
|
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
Date saveBirth = sf.parse(birth);
|
|
|
basePatientDO.setBirthday(saveBirth);
|
|
|
}
|
|
|
basePatientDO.setName(familyName);
|
|
|
basePatientDO.setIdcard(idCard);
|
|
|
basePatientDO.setRegister("0");
|
|
|
basePatientDO.setDel("1");
|
|
|
if(null!=jsonObject.get("Sex")){
|
|
|
basePatientDO.setSex(Integer.parseInt(jsonObject.get("Sex").toString()));
|
|
|
}
|
|
|
BasePatientDO sucessPatient= basePatientDao.save(basePatientDO);
|
|
|
String patientNewId= "";
|
|
|
if (sucessPatient!=null){
|
|
|
patientNewId=sucessPatient.getId();
|
|
|
}
|
|
|
result.setFamilyMember(patientNewId);
|
|
|
wlyyPatientFamilyMemberDao.save(result);
|
|
|
patientMappingDO.setIdcard(idCard);
|
|
|
patientMappingDO.setSource("1");
|
|
|
patientMappingDO.setPatientName(familyName);
|
|
|
patientMappingDO.setMappingCode(familyId);
|
|
|
patientMappingDO.setPatient(patientNewId);
|
|
|
patientMappingDO.setCreateTime(new Date());
|
|
|
patientMappingDao.save(patientMappingDO);
|
|
|
resultMap.put("patientId",patientId);
|
|
|
resultMap.put("familyMember",patientNewId);
|
|
|
resultMap.put("idCard",idCard);
|
|
|
resultMap.put("phoneNum",phoneNum);
|
|
|
resultMap.put("relationName",dictName);
|
|
|
resultMap.put("name",familyName);
|
|
|
resultMap.put("cardType",cardType);
|
|
|
List<Map<String,Object>> resultList = new ArrayList();
|
|
|
resultList.add(resultMap);
|
|
|
mixEnvelop.setStatus(200);
|
|
|
mixEnvelop.setMessage("添加成功");
|
|
|
mixEnvelop.setDetailModelList(resultList);
|
|
|
}else {
|
|
|
|
|
|
}
|
|
|
}else if ("xm_zsyy_wx".equalsIgnoreCase(wxId)) {
|
|
|
jsonArray = entranceService.BS10008(idCard, "", "", "", "", "", demo);
|
|
|
if (jsonArray != null && jsonArray.size() > 0) {
|
|
|
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(jsonArray.get(0).toString());
|
|
|
//如果病人id为空则没有就诊记录
|
|
|
if (null != jsonObject.get("Patient_Id")) {
|
|
|
familyId = jsonObject.getString("Patient_Id");
|
|
|
String Pat_name = jsonObject.getString("Pat_Name");
|
|
|
if (null != jsonObject.get("Phone_Number_Business")) {
|
|
|
String Next_Of_Kin_Phone = jsonObject.get("Phone_Number_Business").toString();
|
|
|
if (!Next_Of_Kin_Phone.equalsIgnoreCase(phoneNum)) {
|
|
|
mixEnvelop.setStatus(408);
|
|
|
mixEnvelop.setMessage("您所添加的家属的电话有误,无法添加");
|
|
|
return mixEnvelop;
|
|
|
}
|
|
|
}
|
|
|
if (!Pat_name.equalsIgnoreCase(familyName)) {
|
|
|
mixEnvelop.setStatus(408);
|
|
|
mixEnvelop.setMessage("您所添加的家属的名称有误,无法添加");
|
|
|
return mixEnvelop;
|
|
|
}
|
|
|
if(null!=jsonObject.get("Birth_Date")){
|
|
|
birth = jsonObject.get("Birth_Date").toString();
|
|
|
}
|
|
|
if(null!=jsonObject.get("Sex")){
|
|
|
sex = Integer.parseInt(jsonObject.get("Sex").toString());
|
|
|
}
|
|
|
}else {
|
|
|
mixEnvelop.setStatus(408);
|
|
|
mixEnvelop.setMessage("您所添加的家属无就诊记录,无法添加");
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
}
|
|
|
}else {
|
|
|
mixEnvelop.setStatus(408);
|
|
|
mixEnvelop.setMessage("您所添加的家属无就诊记录,无法添加");
|
|
|
mixEnvelop.setMessage("心脏中心暂未开放");
|
|
|
}
|
|
|
basePatientDO.setSex(sex);
|
|
|
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
Date saveBirth = sf.parse(birth);
|
|
|
basePatientDO.setBirthday(saveBirth);
|
|
|
result.setFamilyRelation(dictId);
|
|
|
result.setFamilyRelationName(dictName);
|
|
|
result.setIsDel(1);
|
|
|
result.setPatient(patientId);
|
|
|
result.setCardNo(idCard);
|
|
|
result.setCardType(cardType);
|
|
|
//保存到base_patient表中
|
|
|
basePatientDO.setMobile(phoneNum);
|
|
|
|
|
|
basePatientDO.setName(familyName);
|
|
|
basePatientDO.setIdcard(idCard);
|
|
|
basePatientDO.setRegister("0");
|
|
|
basePatientDO.setDel("1");
|
|
|
|
|
|
BasePatientDO sucessPatient= basePatientDao.save(basePatientDO);
|
|
|
String patientNewId= "";
|
|
|
if (sucessPatient!=null){
|
|
|
patientNewId=sucessPatient.getId();
|
|
|
}
|
|
|
result.setFamilyMember(patientNewId);
|
|
|
wlyyPatientFamilyMemberDao.save(result);
|
|
|
patientMappingDO.setIdcard(idCard);
|
|
|
patientMappingDO.setSource("1");
|
|
|
patientMappingDO.setPatientName(familyName);
|
|
|
patientMappingDO.setMappingCode(familyId);
|
|
|
patientMappingDO.setPatient(patientNewId);
|
|
|
patientMappingDO.setCreateTime(new Date());
|
|
|
patientMappingDao.save(patientMappingDO);
|
|
|
resultMap.put("patientId",patientId);
|
|
|
resultMap.put("familyMember",patientNewId);
|
|
|
resultMap.put("idCard",idCard);
|
|
|
resultMap.put("phoneNum",phoneNum);
|
|
|
resultMap.put("relationName",dictName);
|
|
|
resultMap.put("name",familyName);
|
|
|
resultMap.put("cardType",cardType);
|
|
|
List<Map<String,Object>> resultList = new ArrayList();
|
|
|
resultList.add(resultMap);
|
|
|
mixEnvelop.setStatus(200);
|
|
|
mixEnvelop.setMessage("添加成功");
|
|
|
mixEnvelop.setDetailModelList(resultList);
|
|
|
|
|
|
return mixEnvelop;
|
|
|
}
|
|
|
|