|
@ -2,12 +2,19 @@ package com.yihu.wlyy.adapter;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.Prescription;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.PrescriptionDiagnosis;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
|
|
|
import com.yihu.wlyy.service.system.Icd10DictServcie;
|
|
|
import com.yihu.wlyy.service.third.jw.ZyDictService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* Created by Trick on 2017/8/10.
|
|
@ -15,6 +22,11 @@ import java.util.Iterator;
|
|
|
@Component
|
|
|
public class PresModeAdapter {
|
|
|
|
|
|
@Autowired
|
|
|
private Icd10DictServcie icd10DictServcie;
|
|
|
@Autowired
|
|
|
private ZyDictService zyDictService;
|
|
|
|
|
|
/**
|
|
|
* 续方模板适配器
|
|
|
* @param json
|
|
@ -88,15 +100,14 @@ public class PresModeAdapter {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 处方模板解析
|
|
|
* 处方列表解析
|
|
|
* @param json
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONArray modeToPrescription(String json)throws Exception{
|
|
|
JSONObject oldJson = JSONObject.parseObject(json);
|
|
|
String dataStr = oldJson.getString("data");
|
|
|
JSONObject data = JSONObject.parseObject(dataStr);
|
|
|
JSONObject data = oldJson.getJSONObject("data");
|
|
|
JSONArray returnData = data.getJSONArray("returnData");
|
|
|
String code = data.getString("CODE");
|
|
|
if(StringUtils.isNotBlank(code)&&"1".equals(code)){
|
|
@ -108,15 +119,30 @@ public class PresModeAdapter {
|
|
|
Prescription p = new Prescription();
|
|
|
p.setCode(mode.getInteger("RECIPE_NO")+"");
|
|
|
p.setCreateTime(mode.getDate("APPLY_TIME"));
|
|
|
// "APPLY_OPERATOR_NAME": "开单医生姓名",
|
|
|
// "HEALTH_ORG_CODE": "开单机构编码",
|
|
|
// "DIAGNOSE_CODE": "诊断代码",
|
|
|
// "DIAGNOSE_NAME": "诊断名称",
|
|
|
|
|
|
Doctor doctor = zyDictService.getDoctByJw(mode.getString("APPLY_OPERATOR"),mode.getString("HEALTH_ORG_CODE"));
|
|
|
// "APPLY_OPERATOR_NAME": 开单医生姓名","HEALTH_ORG_CODE": "开单机构编码",
|
|
|
p.setDoctor(doctor.getCode());
|
|
|
p.setDoctorName(doctor.getName());
|
|
|
p.setHospitalName(doctor.getHospitalName());
|
|
|
p.setHospital(doctor.getHospital());
|
|
|
|
|
|
JSONArray infos = mode.getJSONArray("TEMPLATE_DETAIL");
|
|
|
PrescriptionDiagnosis diagnosis = new PrescriptionDiagnosis();
|
|
|
diagnosis.setCode(mode.getString("DIAGNOSE_CODE"));//诊断代码
|
|
|
diagnosis.setName(mode.getString("DIAGNOSE_NAME"));//诊断名称
|
|
|
String icd10 = icd10DictServcie.getHealthProblemsByIcd10Code(mode.getString("DIAGNOSE_CODE"));
|
|
|
if(!StringUtils.isEmpty(icd10)){
|
|
|
JSONObject icd = JSONObject.parseObject(icd10);
|
|
|
diagnosis.setHealthProblemName(icd.getString("value"));//诊断名称
|
|
|
diagnosis.setHealthProblem(icd.getString("key"));//诊断代码
|
|
|
}else{
|
|
|
diagnosis.setHealthProblemName(mode.getString("DIAGNOSE_CODE"));//诊断名称
|
|
|
diagnosis.setHealthProblem(mode.getString("DIAGNOSE_NAME"));//诊断代码
|
|
|
}
|
|
|
|
|
|
JSONArray infos = mode.getJSONArray("RECIPE_DETAIL");
|
|
|
Iterator infoIt = infos.iterator();
|
|
|
JSONArray is = new JSONArray();
|
|
|
List<PrescriptionInfo> prescriptionInfos = new ArrayList<>();
|
|
|
while (infoIt.hasNext()){
|
|
|
JSONObject info = (JSONObject) infoIt.next();
|
|
|
PrescriptionInfo prescriptionInfo = new PrescriptionInfo();
|
|
@ -149,10 +175,10 @@ public class PresModeAdapter {
|
|
|
prescriptionInfo.setPhysicInjectPlaceName("");//注射地点名称
|
|
|
prescriptionInfo.setPhysicSkinTest(info.getString("PHYSIC_SKIN_TEST"));//皮试类型名称
|
|
|
prescriptionInfo.setPhysicSkinTestName(info.getString("PHYSIC_SKIN_TEST_NAME"));//皮试类型名称
|
|
|
is.add(prescriptionInfo);
|
|
|
prescriptionInfos.add(prescriptionInfo);
|
|
|
}
|
|
|
// m.put("prescriptionInfo",is);
|
|
|
// rs.add(m);
|
|
|
p.setPrescriptionInfo(prescriptionInfos);
|
|
|
rs.add(p);
|
|
|
}
|
|
|
return rs;
|
|
|
}
|