Explorar o código

电子病历注册代码提交

huangwenjie %!s(int64=5) %!d(string=hai) anos
pai
achega
6a664055be

+ 118 - 1
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -21,6 +21,7 @@ import com.yihu.jw.entity.hospital.doctor.WlyyDoctorWorkTimeDO;
import com.yihu.jw.entity.hospital.doctor.WlyyPatientRegisterTimeDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.entity.ylzinfo.OauthYlzConfigDO;
@ -52,7 +53,9 @@ import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.PinYinUtils;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.WebserviceUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.jw.wlyy.wlyyhttp.WlyyHttpService;
import com.yihu.mysql.query.BaseJpaService;
@ -1216,11 +1219,17 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    public net.sf.json.JSONObject registerOutPatient(String outPatientId,String doctor)throws Exception{
        WlyyOutpatientDO outpatientDO = outpatientDao.findOne(outPatientId);
        
        
        DoctorMappingDO doctorMappingDO = doctorMappingService.findMappingCode(doctor,outpatientDO.getHospital());
        if(doctorMappingDO==null){
            throw new RuntimeException("未找到医生映射信息");
        }
        
        BasePatientDO basePatientDO = basePatientDao.findById(outpatientDO.getPatient());
    
        Integer manageType = 1;//处理类型(1-新增 2-修改 3-删除) 必填
        //查找居民当天挂号记录
        String date = DateUtil.dateToStr(new Date(),"yyyy-MM-dd");
@ -1239,7 +1248,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                outpatientDO.setRegisterNo(registerDO.getRegisterNo());
                outpatientDO.setAdmDate(registerDO.getCreateTime());
                outpatientDao.save(outpatientDO);
                //调用电子病历注册
                manageType =2;
                registDianziBingli(outPatientId,basePatientDO,manageType);
                return res;
            }
        }
@ -1249,6 +1260,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        net.sf.json.JSONObject res = rs.getJSONObject("resquest");
        logger.info("挂号结果 res: " +res.toString());
        String rsCode = res.getString("@RESULT");
        
        if("0".equals(rsCode)){
            //存储挂号号
            // {"resquest":{"@RESULT":"0","@MSG":"完成","@serial_no":"47770476","@times":"28"}}
@ -1276,6 +1288,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            registerDO.setCreateTime(new Date());
            registerDO.setDate(DateUtil.dateToStr(new Date(),"yyyy-MM-dd"));
            patientRegisterDao.save(registerDO);
            
        }else if("-2".equals(rsCode)){
            String serialNo = (String)res.get("@serial_no");
@ -1303,6 +1316,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            patientRegisterDao.save(registerDO);
        }
    
        manageType = 1;//处理类型(1-新增 2-修改 3-删除) 必填
    
        registDianziBingli(outPatientId,basePatientDO,manageType);
        
            //保存日志
        WlyyHttpLogDO log = new WlyyHttpLogDO();
        log.setCode("registerOutPatient");
@ -1316,6 +1335,104 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        wlyyHttpLogDao.save(log);
        return res;
    }
    
    public String registDianziBingli(String outPatientId,BasePatientDO basePatientDO,Integer manageType) throws Exception {
    
        //调用电子病历接口注册居民信息
            String patientMappingCode =  patientMappingService.findHisPatNoByIdCard(basePatientDO.getIdcard());
            Map<String,String> params = new HashedMap();
            params.put("type","PatientInfo");
            String xmlStr = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
                    "<HtRequest >" +
                    "<PatientInfo>" +
                    "<RecordFlow>"+outPatientId+"</RecordFlow >" +
                    "<PID>"+patientMappingCode+"</PID>" +
                    "<InsuranceNo>"+basePatientDO.getIdcard()+"</InsuranceNo>" +
                    "<PatientName>"+basePatientDO.getName()+"</PatientName>" +
                    "<TmpFlag>正式</TmpFlag>" +
                    "<LastName>"+basePatientDO.getName().substring(0,1)+"</LastName>" +
                    "<FirstName>"+basePatientDO.getName().substring(1,basePatientDO.getName().length())+"</FirstName>" +
                    "<PY>"+ PinYinUtils.getUpEname(basePatientDO.getName())+"</PY> \n" +
                    "<WB></WB>" +
                    "<SexCode>"+basePatientDO.getSex()+"</SexCode>";
            if(1 == basePatientDO.getSex()){
                xmlStr = xmlStr + "<Sex>男</Sex>";
            }else{
                xmlStr = xmlStr +  "<Sex>女</Sex>";
            }
        
            xmlStr = xmlStr +    "<DateOfBirth>"+IdCardUtil.getBirthdayForIdcard(basePatientDO.getIdcard())+"</DateOfBirth>" +
                    "<TimeOfBirth></TimeOfBirth>" +
                    "<MarriageStatusCode></MarriageStatusCode>" +
                    "<MarriageStatus></MarriageStatus>" +
                    "<OccupationCode></OccupationCode>" +
                    "<Occupation></Occupation>" +
                    "<NationalityCode></NationalityCode>" +
                    "<Nationality></Nationality>" +
                    "<CountryCode>CN</CountryCode>" +
                    "<Country>中国</Country>" +
                    "<FormalSchoolingCode></FormalSchoolingCode>" +
                    "<FormalSchooling></FormalSchooling>" +
                    "<Religion></Religion>" +
                    "<BirthPlaceCode></BirthPlaceCode>" +
                    "<BirthPlace></BirthPlace>" +
                    "<NativePlaceCode></NativePlaceCode>" +
                    "<NativePlace></NativePlace>" +
                    "<BloodType></BloodType>" +
                    "<CertTypeCode>111</CertTypeCode>" +
                    "<CertType>身份证</CertType>" +
                    "<CertNo>"+basePatientDO.getIdcard()+"</CertNo>" +
                    "<PatientClassCode></PatientClassCode>" +
                    "<PatientClass></PatientClass>" +
                    "<FeeTypeCode></FeeTypeCode>" +
                    "<FeeType></FeeType>" +
                    "<Company></Company>" +
                    "<PublicExpenseNo></PublicExpenseNo>" +
                    "<ContractUnitCode></ContractUnitCode> " +
                    "<ContractUnit></ContractUnit>" +
                    "<BusinessAddressCode></BusinessAddressCode>" +
                    "<BusinessAddress></BusinessAddress>" +
                    "<BusinessPostCode>/BusinessPostCode>" +
                    "<BusinessPhone></BusinessPhone>" +
                    "<HomeAddressCode></HomeAddressCode>" +
                    "<HomeAddress></HomeAddress>" +
                    "<HomePostCode></HomePostCode>" +
                    "<MobilePhone></MobilePhone>n" +
                    "<Contact></Contact>" +
                    "<RelationCode></RelationCode>" +
                    "<Relation></Relation>" +
                    "<ContactEmail></ContactEmail>" +
                    "<ContactMethod></ContactMethod>" +
                    "<VIPType></VIPType>" +
                    "<OperatorID></OperatorID>" +
                    "<Operator></Operator>" +
                    "<OperatorTime>0</OperatorTime>" +
                    "<Available></Available>" +
                    "<ManageType>"+manageType+"</ManageType>" +
                    "<InsuranceTypeCode></InsuranceTypeCode>" +
                    "<InsuranceType></InsuranceType>" +
                    "<RegisteredAddressCode></RegisteredAddressCode>" +
                    "<RegisteredAddress></RegisteredAddress>" +
                    "<ContactAddressCode></ContactAddressCode>" +
                    "<ContactAddress></ContactAddress>" +
                    "<RegisteredPostCode></RegisteredPostCode>" +
                    "<ContactPostcode></ContactPostcode>" +
                    "<BloodType></BloodType>" +
                    "<RhBloodType></RhBloodType>" +
                    "</PatientInfo>" +
                    "</HtRequest>";
            String returnValue = "";
            params.put("xmlStr",xmlStr);
        
            returnValue = WebserviceUtil.post("http://192.10.33.34:9080/HtMzWebService/services/Manage",
                    "http://business.htemr.haitaiinc.com",
                    "manageAdt",
                    params);
        
            logger.info("调用电子病历注册接口请求成功,返回值xmlstr:"+returnValue);
            
            return returnValue;
    }
    /**
     * 获取诊断

+ 62 - 0
business/base-service/src/main/java/com/yihu/jw/utils/PinYinUtils.java

@ -0,0 +1,62 @@
package com.yihu.jw.utils;
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
/**
 * @author huangwenjie
 * @date 2020/3/13 09:32
 */
public class PinYinUtils {
	 //将中文转换为英文
	public static String getEname(String name) throws  Exception
    {
		HanyuPinyinOutputFormat pyFormat = new HanyuPinyinOutputFormat();
		pyFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
		pyFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
		pyFormat.setVCharType(HanyuPinyinVCharType.WITH_V);
		
		return PinyinHelper.toHanyuPinyinString(name, pyFormat, "");
	}
	
	//姓、名的第一个字母需要为大写
	public static String getUpEname(String name) throws  Exception {
		char[] strs = name.toCharArray();
		String newname = null;
		
		//名字的长度
		if (strs.length == 2) {
			newname = toUpCase(getEname("" + strs[0])) + " "
					+ toUpCase(getEname("" + strs[1]));
		} else if (strs.length == 3)
		{
			newname = toUpCase(getEname("" + strs[0])) + " "
					+ toUpCase(getEname("" + strs[1] + strs[2]));
		}
		else if (strs.length == 4)
		{
			newname = toUpCase(getEname("" + strs[0] + strs[1])) + " "
					+ toUpCase(getEname("" + strs[2] + strs[3]));
		} else
		{
			newname = toUpCase(getEname(name));
		}
		return newname;
	}
	
	//首字母大写
	private static String toUpCase(String str) {
		StringBuffer newstr = new StringBuffer();
		newstr.append((str.substring(0, 1)).toUpperCase()).append(
				str.substring(1, str.length()));
		
		return newstr.toString();
	}
	public static void main(String[] args)  throws  Exception{
		System.out.println(getUpEname("李宇春"));
		
	}
}