Jelajahi Sumber

Merge branch 'dev' of trick9191/patient-co-management into dev

trick9191 7 tahun lalu
induk
melakukan
e35fa1e7ac

+ 234 - 217
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/adapter/PresModeAdapter.java

@ -8,6 +8,8 @@ import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import com.yihu.wlyy.service.system.Icd10DictServcie;
import com.yihu.wlyy.service.system.Icd10DictServcie;
import com.yihu.wlyy.service.third.jw.ZyDictService;
import com.yihu.wlyy.service.third.jw.ZyDictService;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Component;
@ -21,6 +23,7 @@ import java.util.List;
@Component
@Component
public class PresModeAdapter {
public class PresModeAdapter {
    private static Logger logger = LoggerFactory.getLogger(PresModeAdapter.class);
    @Autowired
    @Autowired
    private Icd10DictServcie icd10DictServcie;
    private Icd10DictServcie icd10DictServcie;
    @Autowired
    @Autowired
@ -33,64 +36,69 @@ public class PresModeAdapter {
     * @throws Exception
     * @throws Exception
     */
     */
    public JSONArray modeTopresInfo(String json) throws Exception{
    public JSONArray modeTopresInfo(String json) throws Exception{
        JSONObject oldJson = JSONObject.parseObject(json);
        String dataStr = oldJson.getString("data");
        JSONObject data = JSONObject.parseObject(dataStr);
        JSONArray returnData = data.getJSONArray("returnData");
        String code = data.getString("CODE");
        if(StringUtils.isNotBlank(code)&&"1".equals(code)){
            JSONArray rs = new JSONArray();
            Iterator iterator = returnData.iterator();
            while (iterator.hasNext()){
                JSONArray modeArray = (JSONArray) iterator.next();
                for(int i=0;i<modeArray.size();i++){
                    JSONObject mode = (JSONObject) modeArray.get(i);
                    JSONObject m = new JSONObject();
                    m.put("templateNo",mode.getInteger("TEMPLATE_NO"));
                    m.put("templateName",mode.getString("TEMPLATE_NAME"));
                    //m.put("templateExplain",mode.getInt("TEMPLATE_EXPLAIN"));
                    JSONArray infos = mode.getJSONArray("TEMPLATE_DETAIL");
                    Iterator infoIt = infos.iterator();
                    JSONArray is = new JSONArray();
                    while (infoIt.hasNext()){
                        JSONObject info = (JSONObject) infoIt.next();
                        PrescriptionInfo prescriptionInfo = new PrescriptionInfo();
                        prescriptionInfo.setRemark(info.getString("REMARK"));
                        prescriptionInfo.setBindFlag(info.getString("BIND_FLAG"));
                        prescriptionInfo.setDirection(info.getString("USAGE_NAME"));//药品用法
                        prescriptionInfo.setDrugCode(info.getString("ITEM_CODE"));//药品code
                        prescriptionInfo.setDrugName(info.getString("ITEM_NAME"));//药品名称
                        prescriptionInfo.setDrugRate(info.getString("FREQUENCY"));//吃药频率 FREQUENCY
                        prescriptionInfo.setDrugRateName(info.getString("FREQUENCY_NAME"));
                        prescriptionInfo.setDrugFormat(info.getString("ITEM_SPEC"));//药品规格
                        prescriptionInfo.setPrice(info.getInteger("ITEM_PRICE"));//药品单价
                        prescriptionInfo.setNum(info.getInteger("ITEM_QUANTITY"));//药品数目
                        prescriptionInfo.setJwSubCode("");//智业子处方号
                        prescriptionInfo.setDrugNumUnit(info.getString("ITEM_UNIT"));//数量单位编码
                        prescriptionInfo.setDrugNumUnitName(info.getString("ITEM_UNIT_NAME"));//数量单位名称
                        prescriptionInfo.setCost(1);//金额
                        prescriptionInfo.setCharge(0);//自付
                        prescriptionInfo.setBindFlag("0");//成组标志, 0.非成组,1.成组
                        prescriptionInfo.setDayCount(info.getInteger("DAY_COUNT"));//用药天数
                        prescriptionInfo.setDrugUsage(info.getString("USAGE"));//用药方法编码
                        prescriptionInfo.setUsageName(info.getString("USAGE_NAME"));//用药方法名称
                        prescriptionInfo.setPhysicDose(info.getString("PHYSIC_DOSE"));//用药剂量
                        prescriptionInfo.setPhysicDoseUnit(info.getString("PHYSIC_DOSE_UNIT"));//剂量单位编码
                        prescriptionInfo.setPhysicDoseUnitName(info.getString("PHYSIC_DOSE_UNIT_NAME"));//剂量单位名称
                        prescriptionInfo.setPhysicAmount(info.getString("PHYSIC_AMOUNT"));//用药总量
                        prescriptionInfo.setPhysicAmountUnit(info.getString("PHYSIC_AMOUNT_UNIT"));//总量单位编码
                        prescriptionInfo.setPhysicAmountUnitName(info.getString("PHYSIC_AMOUNT_UNIT_NAME"));//总量单位名称
                        prescriptionInfo.setPhysicInjectPlace("");//注射地点编码
                        prescriptionInfo.setPhysicInjectPlaceName("");//注射地点名称
                        prescriptionInfo.setPhysicSkinTest(info.getString("PHYSIC_SKIN_TEST"));//皮试类型名称
                        prescriptionInfo.setPhysicSkinTestName(info.getString("PHYSIC_SKIN_TEST_NAME"));//皮试类型名称
                        is.add(prescriptionInfo);
        try{
            JSONObject oldJson = JSONObject.parseObject(json);
            String dataStr = oldJson.getString("data");
            JSONObject data = JSONObject.parseObject(dataStr);
            JSONArray returnData = data.getJSONArray("returnData");
            String code = data.getString("CODE");
            if(StringUtils.isNotBlank(code)&&"1".equals(code)){
                JSONArray rs = new JSONArray();
                Iterator iterator = returnData.iterator();
                while (iterator.hasNext()){
                    JSONArray modeArray = (JSONArray) iterator.next();
                    for(int i=0;i<modeArray.size();i++){
                        JSONObject mode = (JSONObject) modeArray.get(i);
                        JSONObject m = new JSONObject();
                        m.put("templateNo",mode.getInteger("TEMPLATE_NO"));
                        m.put("templateName",mode.getString("TEMPLATE_NAME"));
                        //m.put("templateExplain",mode.getInt("TEMPLATE_EXPLAIN"));
                        JSONArray infos = mode.getJSONArray("TEMPLATE_DETAIL");
                        Iterator infoIt = infos.iterator();
                        JSONArray is = new JSONArray();
                        while (infoIt.hasNext()){
                            JSONObject info = (JSONObject) infoIt.next();
                            PrescriptionInfo prescriptionInfo = new PrescriptionInfo();
                            prescriptionInfo.setRemark(info.getString("REMARK"));
                            prescriptionInfo.setBindFlag(info.getString("BIND_FLAG"));
                            prescriptionInfo.setDirection(info.getString("USAGE_NAME"));//药品用法
                            prescriptionInfo.setDrugCode(info.getString("ITEM_CODE"));//药品code
                            prescriptionInfo.setDrugName(info.getString("ITEM_NAME"));//药品名称
                            prescriptionInfo.setDrugRate(info.getString("FREQUENCY"));//吃药频率 FREQUENCY
                            prescriptionInfo.setDrugRateName(info.getString("FREQUENCY_NAME"));
                            prescriptionInfo.setDrugFormat(info.getString("ITEM_SPEC"));//药品规格
                            prescriptionInfo.setPrice(info.getInteger("ITEM_PRICE"));//药品单价
                            prescriptionInfo.setNum(info.getInteger("ITEM_QUANTITY"));//药品数目
                            prescriptionInfo.setJwSubCode("");//智业子处方号
                            prescriptionInfo.setDrugNumUnit(info.getString("ITEM_UNIT"));//数量单位编码
                            prescriptionInfo.setDrugNumUnitName(info.getString("ITEM_UNIT_NAME"));//数量单位名称
                            prescriptionInfo.setCost(1);//金额
                            prescriptionInfo.setCharge(0);//自付
                            prescriptionInfo.setBindFlag("0");//成组标志, 0.非成组,1.成组
                            prescriptionInfo.setDayCount(info.getInteger("DAY_COUNT"));//用药天数
                            prescriptionInfo.setDrugUsage(info.getString("USAGE"));//用药方法编码
                            prescriptionInfo.setUsageName(info.getString("USAGE_NAME"));//用药方法名称
                            prescriptionInfo.setPhysicDose(info.getString("PHYSIC_DOSE"));//用药剂量
                            prescriptionInfo.setPhysicDoseUnit(info.getString("PHYSIC_DOSE_UNIT"));//剂量单位编码
                            prescriptionInfo.setPhysicDoseUnitName(info.getString("PHYSIC_DOSE_UNIT_NAME"));//剂量单位名称
                            prescriptionInfo.setPhysicAmount(info.getString("PHYSIC_AMOUNT"));//用药总量
                            prescriptionInfo.setPhysicAmountUnit(info.getString("PHYSIC_AMOUNT_UNIT"));//总量单位编码
                            prescriptionInfo.setPhysicAmountUnitName(info.getString("PHYSIC_AMOUNT_UNIT_NAME"));//总量单位名称
                            prescriptionInfo.setPhysicInjectPlace("");//注射地点编码
                            prescriptionInfo.setPhysicInjectPlaceName("");//注射地点名称
                            prescriptionInfo.setPhysicSkinTest(info.getString("PHYSIC_SKIN_TEST"));//皮试类型名称
                            prescriptionInfo.setPhysicSkinTestName(info.getString("PHYSIC_SKIN_TEST_NAME"));//皮试类型名称
                            is.add(prescriptionInfo);
                        }
                        m.put("prescriptionInfo",is);
                        rs.add(m);
                    }
                    }
                    m.put("prescriptionInfo",is);
                    rs.add(m);
                }
                }
                return rs;
            }
            }
            return rs;
        }catch (Exception e){
            logger.info("PresModeAdapter:modeTopresInfo:Json:"+json);
            throw e;
        }
        }
        return null;
        return null;
    }
    }
@ -102,98 +110,103 @@ public class PresModeAdapter {
     * @throws Exception
     * @throws Exception
     */
     */
    public JSONArray modeToPrescription(String json)throws Exception{
    public JSONArray modeToPrescription(String json)throws Exception{
        JSONObject oldJson = JSONObject.parseObject(json);
        JSONObject data = oldJson.getJSONObject("data");
        JSONArray returnData = data.getJSONArray("returnData");
        String code = data.getString("CODE");
        if(StringUtils.isNotBlank(code)&&"1".equals(code)){
            JSONArray rs = new JSONArray();
            Iterator iterator = returnData.iterator();
            while (iterator.hasNext()){
                JSONArray modeArray = (JSONArray) iterator.next();
                for(int i=0;i<modeArray.size();i++){
                    JSONObject mode = (JSONObject) modeArray.get(i);
                    JSONObject p  = new JSONObject();
                    p.put("code",mode.getInteger("RECIPE_NO")+"");
                    p.put("createTime",mode.getString("APPLY_TIME"));
        try{
            JSONObject oldJson = JSONObject.parseObject(json);
            JSONObject data = oldJson.getJSONObject("data");
            JSONArray returnData = data.getJSONArray("returnData");
            String code = data.getString("CODE");
            if(StringUtils.isNotBlank(code)&&"1".equals(code)){
                JSONArray rs = new JSONArray();
                Iterator iterator = returnData.iterator();
                while (iterator.hasNext()){
                    JSONArray modeArray = (JSONArray) iterator.next();
                    for(int i=0;i<modeArray.size();i++){
                        JSONObject mode = (JSONObject) modeArray.get(i);
                        JSONObject p  = new JSONObject();
                        p.put("code",mode.getInteger("RECIPE_NO")+"");
                        p.put("createTime",mode.getString("APPLY_TIME"));
                    Doctor doctor =  zyDictService.getDoctByJw(mode.getString("APPLY_OPERATOR"),mode.getString("HEALTH_ORG_CODE"));
                    // "APPLY_OPERATOR_NAME": 开单医生姓名","HEALTH_ORG_CODE": "开单机构编码",
                    if(doctor!=null){
                        p.put("doctor",doctor.getCode());
                        p.put("doctorName",doctor.getName());
                        p.put("hospitalName",doctor.getHospitalName());
                        p.put("hospital",doctor.getHospital());
                    }else{
                        p.put("doctor",mode.getString("APPLY_OPERATOR"));
                        p.put("doctorName",mode.getString("APPLY_OPERATOR_NAME"));
                        p.put("hospitalName",mode.getString("HEALTH_ORG_CODE"));
                        p.put("hospital",mode.getString("HEALTH_ORG_CODE"));
                    }
                        Doctor doctor =  zyDictService.getDoctByJw(mode.getString("APPLY_OPERATOR"),mode.getString("HEALTH_ORG_CODE"));
                        // "APPLY_OPERATOR_NAME": 开单医生姓名","HEALTH_ORG_CODE": "开单机构编码",
                        if(doctor!=null){
                            p.put("doctor",doctor.getCode());
                            p.put("doctorName",doctor.getName());
                            p.put("hospitalName",doctor.getHospitalName());
                            p.put("hospital",doctor.getHospital());
                        }else{
                            p.put("doctor",mode.getString("APPLY_OPERATOR"));
                            p.put("doctorName",mode.getString("APPLY_OPERATOR_NAME"));
                            p.put("hospitalName",mode.getString("HEALTH_ORG_CODE"));
                            p.put("hospital",mode.getString("HEALTH_ORG_CODE"));
                        }
                    PrescriptionDiagnosis diagnosis = new PrescriptionDiagnosis();
                    String diagnoseCode = mode.getString("DIAGNOSE_CODE");
                    String diagnoseName = mode.getString("DIAGNOSE_NAME");
                        PrescriptionDiagnosis diagnosis = new PrescriptionDiagnosis();
                        String diagnoseCode = mode.getString("DIAGNOSE_CODE");
                        String diagnoseName = mode.getString("DIAGNOSE_NAME");
//                    String diagnoseCode = "E10.100";
//                    String diagnoseCode = "E10.100";
//                    String diagnoseName = "1型糖尿病性酮症";
//                    String diagnoseName = "1型糖尿病性酮症";
                    diagnosis.setCode(diagnoseCode);//诊断代码
                    diagnosis.setName(diagnoseName);//诊断名称
                    String icd10 = icd10DictServcie.getHealthProblemsByIcd10Code(diagnoseCode);
                    if(!StringUtils.isEmpty(icd10)){
                        JSONObject icd = JSONObject.parseObject(icd10);
                        diagnosis.setHealthProblemName(icd.getString("value"));//诊断名称
                        diagnosis.setHealthProblem(icd.getString("key"));//诊断代码
                    }else{
                        diagnosis.setHealthProblemName(diagnoseName);//诊断名称
                        diagnosis.setHealthProblem(diagnoseCode);//诊断代码
                    }
                    JSONArray jsonArrayDt = new JSONArray();
                    jsonArrayDt.add(diagnosis);
                    p.put("prescriptionDt",jsonArrayDt);
                        diagnosis.setCode(diagnoseCode);//诊断代码
                        diagnosis.setName(diagnoseName);//诊断名称
                        String icd10 = icd10DictServcie.getHealthProblemsByIcd10Code(diagnoseCode);
                        if(!StringUtils.isEmpty(icd10)){
                            JSONObject icd = JSONObject.parseObject(icd10);
                            diagnosis.setHealthProblemName(icd.getString("value"));//诊断名称
                            diagnosis.setHealthProblem(icd.getString("key"));//诊断代码
                        }else{
                            diagnosis.setHealthProblemName(diagnoseName);//诊断名称
                            diagnosis.setHealthProblem(diagnoseCode);//诊断代码
                        }
                        JSONArray jsonArrayDt = new JSONArray();
                        jsonArrayDt.add(diagnosis);
                        p.put("prescriptionDt",jsonArrayDt);
                    JSONArray infos = mode.getJSONArray("RECIPE_DETAIL");
                    Iterator infoIt = infos.iterator();
                    List<PrescriptionInfo> prescriptionInfos = new ArrayList<>();
                    while (infoIt.hasNext()){
                        JSONObject info = (JSONObject) infoIt.next();
                        PrescriptionInfo prescriptionInfo = new PrescriptionInfo();
                        prescriptionInfo.setRemark(info.getString("REMARK"));
                        prescriptionInfo.setBindFlag(info.getString("BIND_FLAG"));
                        prescriptionInfo.setDirection(info.getString("USAGE_NAME"));//药品用法
                        prescriptionInfo.setDrugCode(info.getString("ITEM_CODE"));//药品code
                        prescriptionInfo.setDrugName(info.getString("ITEM_NAME"));//药品名称
                        prescriptionInfo.setDrugRate(info.getString("FREQUENCY"));//吃药频率 FREQUENCY
                        prescriptionInfo.setDrugRateName(info.getString("FREQUENCY_NAME"));
                        prescriptionInfo.setDrugFormat(info.getString("ITEM_SPEC"));//药品规格
                        prescriptionInfo.setPrice(info.getInteger("ITEM_PRICE"));//药品单价
                        prescriptionInfo.setNum(info.getInteger("ITEM_QUANTITY"));//药品数目
                        prescriptionInfo.setJwSubCode("");//智业子处方号
                        prescriptionInfo.setDrugNumUnit(info.getString("ITEM_UNIT"));//数量单位编码
                        prescriptionInfo.setDrugNumUnitName(info.getString("ITEM_UNIT_NAME"));//数量单位名称
                        prescriptionInfo.setCost(1);//金额
                        prescriptionInfo.setCharge(0);//自付
                        prescriptionInfo.setBindFlag("0");//成组标志, 0.非成组,1.成组
                        prescriptionInfo.setDayCount(info.getInteger("DAY_COUNT"));//用药天数
                        prescriptionInfo.setDrugUsage(info.getString("USAGE"));//用药方法编码
                        prescriptionInfo.setUsageName(info.getString("USAGE_NAME"));//用药方法名称
                        prescriptionInfo.setPhysicDose(info.getString("PHYSIC_DOSE"));//用药剂量
                        prescriptionInfo.setPhysicDoseUnit(info.getString("PHYSIC_DOSE_UNIT"));//剂量单位编码
                        prescriptionInfo.setPhysicDoseUnitName(info.getString("PHYSIC_DOSE_UNIT_NAME"));//剂量单位名称
                        prescriptionInfo.setPhysicAmount(info.getString("PHYSIC_AMOUNT"));//用药总量
                        prescriptionInfo.setPhysicAmountUnit(info.getString("PHYSIC_AMOUNT_UNIT"));//总量单位编码
                        prescriptionInfo.setPhysicAmountUnitName(info.getString("PHYSIC_AMOUNT_UNIT_NAME"));//总量单位名称
                        prescriptionInfo.setPhysicInjectPlace("");//注射地点编码
                        prescriptionInfo.setPhysicInjectPlaceName("");//注射地点名称
                        prescriptionInfo.setPhysicSkinTest(info.getString("PHYSIC_SKIN_TEST"));//皮试类型名称
                        prescriptionInfo.setPhysicSkinTestName(info.getString("PHYSIC_SKIN_TEST_NAME"));//皮试类型名称
                        prescriptionInfos.add(prescriptionInfo);
                        JSONArray infos = mode.getJSONArray("RECIPE_DETAIL");
                        Iterator infoIt = infos.iterator();
                        List<PrescriptionInfo> prescriptionInfos = new ArrayList<>();
                        while (infoIt.hasNext()){
                            JSONObject info = (JSONObject) infoIt.next();
                            PrescriptionInfo prescriptionInfo = new PrescriptionInfo();
                            prescriptionInfo.setRemark(info.getString("REMARK"));
                            prescriptionInfo.setBindFlag(info.getString("BIND_FLAG"));
                            prescriptionInfo.setDirection(info.getString("USAGE_NAME"));//药品用法
                            prescriptionInfo.setDrugCode(info.getString("ITEM_CODE"));//药品code
                            prescriptionInfo.setDrugName(info.getString("ITEM_NAME"));//药品名称
                            prescriptionInfo.setDrugRate(info.getString("FREQUENCY"));//吃药频率 FREQUENCY
                            prescriptionInfo.setDrugRateName(info.getString("FREQUENCY_NAME"));
                            prescriptionInfo.setDrugFormat(info.getString("ITEM_SPEC"));//药品规格
                            prescriptionInfo.setPrice(info.getInteger("ITEM_PRICE"));//药品单价
                            prescriptionInfo.setNum(info.getInteger("ITEM_QUANTITY"));//药品数目
                            prescriptionInfo.setJwSubCode("");//智业子处方号
                            prescriptionInfo.setDrugNumUnit(info.getString("ITEM_UNIT"));//数量单位编码
                            prescriptionInfo.setDrugNumUnitName(info.getString("ITEM_UNIT_NAME"));//数量单位名称
                            prescriptionInfo.setCost(1);//金额
                            prescriptionInfo.setCharge(0);//自付
                            prescriptionInfo.setBindFlag("0");//成组标志, 0.非成组,1.成组
                            prescriptionInfo.setDayCount(info.getInteger("DAY_COUNT"));//用药天数
                            prescriptionInfo.setDrugUsage(info.getString("USAGE"));//用药方法编码
                            prescriptionInfo.setUsageName(info.getString("USAGE_NAME"));//用药方法名称
                            prescriptionInfo.setPhysicDose(info.getString("PHYSIC_DOSE"));//用药剂量
                            prescriptionInfo.setPhysicDoseUnit(info.getString("PHYSIC_DOSE_UNIT"));//剂量单位编码
                            prescriptionInfo.setPhysicDoseUnitName(info.getString("PHYSIC_DOSE_UNIT_NAME"));//剂量单位名称
                            prescriptionInfo.setPhysicAmount(info.getString("PHYSIC_AMOUNT"));//用药总量
                            prescriptionInfo.setPhysicAmountUnit(info.getString("PHYSIC_AMOUNT_UNIT"));//总量单位编码
                            prescriptionInfo.setPhysicAmountUnitName(info.getString("PHYSIC_AMOUNT_UNIT_NAME"));//总量单位名称
                            prescriptionInfo.setPhysicInjectPlace("");//注射地点编码
                            prescriptionInfo.setPhysicInjectPlaceName("");//注射地点名称
                            prescriptionInfo.setPhysicSkinTest(info.getString("PHYSIC_SKIN_TEST"));//皮试类型名称
                            prescriptionInfo.setPhysicSkinTestName(info.getString("PHYSIC_SKIN_TEST_NAME"));//皮试类型名称
                            prescriptionInfos.add(prescriptionInfo);
                        }
                        p.put("prescriptionInfo",prescriptionInfos);
                        rs.add(p);
                    }
                    }
                    p.put("prescriptionInfo",prescriptionInfos);
                    rs.add(p);
                }
                }
                return rs;
            }
            }
            return rs;
        }catch (Exception e){
            logger.info("PresModeAdapter:modeToPrescription:Json:"+json);
            throw e;
        }
        }
        return null;
        return null;
    }
    }
@ -204,90 +217,94 @@ public class PresModeAdapter {
     * @return
     * @return
     */
     */
    public JSONObject modelToSinglePrescription(String json){
    public JSONObject modelToSinglePrescription(String json){
        JSONObject oldJson = JSONObject.parseObject(json);
        JSONObject data = oldJson.getJSONObject("data");
        JSONArray returnData = data.getJSONArray("returnData");
        String code = data.getString("CODE");
        if(StringUtils.isNotBlank(code)&&"1".equals(code)){
            JSONArray modeArray = returnData.getJSONArray(0);
            JSONObject mode = (JSONObject) modeArray.get(0);
            JSONObject p  = new JSONObject();
            p.put("code",mode.getInteger("RECIPE_NO")+"");
            p.put("createTime",mode.getString("APPLY_TIME"));
            Doctor doctor =  zyDictService.getDoctByJw(mode.getString("APPLY_OPERATOR"),mode.getString("HEALTH_ORG_CODE"));
            // "APPLY_OPERATOR_NAME": 开单医生姓名","HEALTH_ORG_CODE": "开单机构编码",
            if(doctor!=null){
                p.put("doctor",doctor.getCode());
                p.put("doctorName",doctor.getName());
                p.put("hospitalName",doctor.getHospitalName());
                p.put("hospital",doctor.getHospital());
            }else{
                p.put("doctor",mode.getString("APPLY_OPERATOR"));
                p.put("doctorName",mode.getString("APPLY_OPERATOR_NAME"));
                p.put("hospitalName",mode.getString("HEALTH_ORG_CODE"));
                p.put("hospital",mode.getString("HEALTH_ORG_CODE"));
            }
        try{
            JSONObject oldJson = JSONObject.parseObject(json);
            JSONObject data = oldJson.getJSONObject("data");
            JSONArray returnData = data.getJSONArray("returnData");
            String code = data.getString("CODE");
            if(StringUtils.isNotBlank(code)&&"1".equals(code)){
                JSONArray modeArray = returnData.getJSONArray(0);
                JSONObject mode = (JSONObject) modeArray.get(0);
                JSONObject p  = new JSONObject();
                p.put("code",mode.getInteger("RECIPE_NO")+"");
                p.put("createTime",mode.getString("APPLY_TIME"));
            JSONObject diagnosis = new JSONObject();
                Doctor doctor =  zyDictService.getDoctByJw(mode.getString("APPLY_OPERATOR"),mode.getString("HEALTH_ORG_CODE"));
                // "APPLY_OPERATOR_NAME": 开单医生姓名","HEALTH_ORG_CODE": "开单机构编码",
                if(doctor!=null){
                    p.put("doctor",doctor.getCode());
                    p.put("doctorName",doctor.getName());
                    p.put("hospitalName",doctor.getHospitalName());
                    p.put("hospital",doctor.getHospital());
                }else{
                    p.put("doctor",mode.getString("APPLY_OPERATOR"));
                    p.put("doctorName",mode.getString("APPLY_OPERATOR_NAME"));
                    p.put("hospitalName",mode.getString("HEALTH_ORG_CODE"));
                    p.put("hospital",mode.getString("HEALTH_ORG_CODE"));
                }
                JSONObject diagnosis = new JSONObject();
//                String diagnoseCode = mode.getString("DIAGNOSE_CODE");
//                String diagnoseCode = mode.getString("DIAGNOSE_CODE");
//                String diagnoseName = mode.getString("DIAGNOSE_NAME");
//                String diagnoseName = mode.getString("DIAGNOSE_NAME");
            String diagnoseCode = "E10.100";
            String diagnoseName = "1型糖尿病性酮症";
            diagnosis.put("code",diagnoseCode);//诊断代码
            diagnosis.put("name",diagnoseName);//诊断名称
            String icd10 = icd10DictServcie.getHealthProblemsByIcd10Code(diagnoseCode);
            if(!StringUtils.isEmpty(icd10)){
                JSONObject icd = JSONObject.parseObject(icd10);
                diagnosis.put("healthProblemName",icd.getString("value"));//诊断名称
                diagnosis.put("healthProblem",icd.getString("key"));//诊断代码
            }else{
                diagnosis.put("healthProblemName",diagnoseName);//诊断名称
                diagnosis.put("healthProblem",diagnoseCode);//诊断代码
            }
            JSONArray jsonArrayDt = new JSONArray();
            jsonArrayDt.add(diagnosis);
            p.put("prescriptionDt",jsonArrayDt);
                String diagnoseCode = "E10.100";
                String diagnoseName = "1型糖尿病性酮症";
                diagnosis.put("code",diagnoseCode);//诊断代码
                diagnosis.put("name",diagnoseName);//诊断名称
                String icd10 = icd10DictServcie.getHealthProblemsByIcd10Code(diagnoseCode);
                if(!StringUtils.isEmpty(icd10)){
                    JSONObject icd = JSONObject.parseObject(icd10);
                    diagnosis.put("healthProblemName",icd.getString("value"));//诊断名称
                    diagnosis.put("healthProblem",icd.getString("key"));//诊断代码
                }else{
                    diagnosis.put("healthProblemName",diagnoseName);//诊断名称
                    diagnosis.put("healthProblem",diagnoseCode);//诊断代码
                }
                JSONArray jsonArrayDt = new JSONArray();
                jsonArrayDt.add(diagnosis);
                p.put("prescriptionDt",jsonArrayDt);
            JSONArray infos = mode.getJSONArray("RECIPE_DETAIL");
            Iterator infoIt = infos.iterator();
            JSONArray prescriptionInfos = new JSONArray();
            while (infoIt.hasNext()){
                JSONObject info = (JSONObject) infoIt.next();
                JSONObject prescriptionInfo = new JSONObject();
                prescriptionInfo.put("Remark",info.getString("REMARK"));
                prescriptionInfo.put("BindFlag",info.getString("BIND_FLAG"));
                prescriptionInfo.put("direction",info.getString("USAGE_NAME"));//药品用法
                prescriptionInfo.put("drugCode",info.getString("ITEM_CODE"));//药品code
                prescriptionInfo.put("drugName",info.getString("ITEM_NAME"));//药品名称
                prescriptionInfo.put("drugRate",info.getString("FREQUENCY"));//吃药频率 FREQUENCY
                prescriptionInfo.put("drugRateName",info.getString("FREQUENCY_NAME"));
                prescriptionInfo.put("drugFormat",info.getString("ITEM_SPEC"));//药品规格
                prescriptionInfo.put("price",info.getInteger("ITEM_PRICE"));//药品单价
                prescriptionInfo.put("num",info.getInteger("ITEM_QUANTITY"));//药品数目
                prescriptionInfo.put("jwSubCode","");//智业子处方号
                prescriptionInfo.put("drugNumUnit",info.getString("ITEM_UNIT"));//数量单位编码
                prescriptionInfo.put("drugNumUnitName",info.getString("ITEM_UNIT_NAME"));//数量单位名称
                prescriptionInfo.put("cost",1);//金额
                prescriptionInfo.put("charge",0);//自付
                prescriptionInfo.put("bindFlag","0");//成组标志, 0.非成组,1.成组
                prescriptionInfo.put("dayCount",info.getInteger("DAY_COUNT"));//用药天数
                prescriptionInfo.put("drugUsage",info.getString("USAGE"));//用药方法编码
                prescriptionInfo.put("usageName",info.getString("USAGE_NAME"));//用药方法名称
                prescriptionInfo.put("physicDose",info.getString("PHYSIC_DOSE"));//用药剂量
                prescriptionInfo.put("physicDoseUnit",info.getString("PHYSIC_DOSE_UNIT"));//剂量单位编码
                prescriptionInfo.put("physicDoseUnitName",info.getString("PHYSIC_DOSE_UNIT_NAME"));//剂量单位名称
                prescriptionInfo.put("physicAmount",info.getString("PHYSIC_AMOUNT"));//用药总量
                prescriptionInfo.put("physicAmountUnit",info.getString("PHYSIC_AMOUNT_UNIT"));//总量单位编码
                prescriptionInfo.put("physicAmountUnitName",info.getString("PHYSIC_AMOUNT_UNIT_NAME"));//总量单位名称
                prescriptionInfo.put("physicInjectPlace","");//注射地点编码
                prescriptionInfo.put("physicInjectPlaceName","");//注射地点名称
                prescriptionInfo.put("physicSkinTest",info.getString("PHYSIC_SKIN_TEST"));//皮试类型名称
                prescriptionInfo.put("physicSkinTestName",info.getString("PHYSIC_SKIN_TEST_NAME"));//皮试类型名称
                prescriptionInfos.add(prescriptionInfo);
                JSONArray infos = mode.getJSONArray("RECIPE_DETAIL");
                Iterator infoIt = infos.iterator();
                JSONArray prescriptionInfos = new JSONArray();
                while (infoIt.hasNext()){
                    JSONObject info = (JSONObject) infoIt.next();
                    JSONObject prescriptionInfo = new JSONObject();
                    prescriptionInfo.put("Remark",info.getString("REMARK"));
                    prescriptionInfo.put("BindFlag",info.getString("BIND_FLAG"));
                    prescriptionInfo.put("direction",info.getString("USAGE_NAME"));//药品用法
                    prescriptionInfo.put("drugCode",info.getString("ITEM_CODE"));//药品code
                    prescriptionInfo.put("drugName",info.getString("ITEM_NAME"));//药品名称
                    prescriptionInfo.put("drugRate",info.getString("FREQUENCY"));//吃药频率 FREQUENCY
                    prescriptionInfo.put("drugRateName",info.getString("FREQUENCY_NAME"));
                    prescriptionInfo.put("drugFormat",info.getString("ITEM_SPEC"));//药品规格
                    prescriptionInfo.put("price",info.getInteger("ITEM_PRICE"));//药品单价
                    prescriptionInfo.put("num",info.getInteger("ITEM_QUANTITY"));//药品数目
                    prescriptionInfo.put("jwSubCode","");//智业子处方号
                    prescriptionInfo.put("drugNumUnit",info.getString("ITEM_UNIT"));//数量单位编码
                    prescriptionInfo.put("drugNumUnitName",info.getString("ITEM_UNIT_NAME"));//数量单位名称
                    prescriptionInfo.put("cost",1);//金额
                    prescriptionInfo.put("charge",0);//自付
                    prescriptionInfo.put("bindFlag","0");//成组标志, 0.非成组,1.成组
                    prescriptionInfo.put("dayCount",info.getInteger("DAY_COUNT"));//用药天数
                    prescriptionInfo.put("drugUsage",info.getString("USAGE"));//用药方法编码
                    prescriptionInfo.put("usageName",info.getString("USAGE_NAME"));//用药方法名称
                    prescriptionInfo.put("physicDose",info.getString("PHYSIC_DOSE"));//用药剂量
                    prescriptionInfo.put("physicDoseUnit",info.getString("PHYSIC_DOSE_UNIT"));//剂量单位编码
                    prescriptionInfo.put("physicDoseUnitName",info.getString("PHYSIC_DOSE_UNIT_NAME"));//剂量单位名称
                    prescriptionInfo.put("physicAmount",info.getString("PHYSIC_AMOUNT"));//用药总量
                    prescriptionInfo.put("physicAmountUnit",info.getString("PHYSIC_AMOUNT_UNIT"));//总量单位编码
                    prescriptionInfo.put("physicAmountUnitName",info.getString("PHYSIC_AMOUNT_UNIT_NAME"));//总量单位名称
                    prescriptionInfo.put("physicInjectPlace","");//注射地点编码
                    prescriptionInfo.put("physicInjectPlaceName","");//注射地点名称
                    prescriptionInfo.put("physicSkinTest",info.getString("PHYSIC_SKIN_TEST"));//皮试类型名称
                    prescriptionInfo.put("physicSkinTestName",info.getString("PHYSIC_SKIN_TEST_NAME"));//皮试类型名称
                    prescriptionInfos.add(prescriptionInfo);
                }
                p.put("prescriptionInfo",prescriptionInfos);
                return p;
            }
            }
            p.put("prescriptionInfo",prescriptionInfos);
            return p;
        }catch (Exception e){
            logger.info("PresModeAdapter:modelToSinglePrescription:Json:"+json);
            throw e;
        }
        }
        return null;
        return null;
    }
    }