|
@ -1,6 +1,7 @@
|
|
|
package com.yihu.wlyy.service.third.jw;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.Prescription;
|
|
|
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
|
|
@ -16,7 +17,9 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 基位长处方接口
|
|
@ -87,6 +90,7 @@ public class JwPrescriptionService {
|
|
|
params.add(new BasicNameValuePair("applyTimeEnd", applyTimeEnd));
|
|
|
|
|
|
String response = httpClientUtil.post(url, params, "UTF-8");
|
|
|
|
|
|
// String sql = "SELECT h.response from wlyy_http_log h WHERE h.id = 806287";
|
|
|
// List<Map<String ,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
// String response = list.get(0).get("response").toString();
|
|
@ -97,6 +101,62 @@ public class JwPrescriptionService {
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取处方列表
|
|
|
* @param cardNo
|
|
|
* @param recipeNo
|
|
|
* @param applyTimeFrom
|
|
|
* @param applyTimeEnd
|
|
|
* @return
|
|
|
*/
|
|
|
public String getRecipeList(String cardNo,String recipeNo,String applyTimeFrom,String applyTimeEnd){
|
|
|
JSONObject recipeJson = new JSONObject();
|
|
|
try{
|
|
|
Map<String,String> map = new HashMap<>();
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
for (int i=0;i<20;i++){
|
|
|
if(!map.containsKey(recipeNo)){
|
|
|
map.put(recipeNo,recipeNo);
|
|
|
String response = getLastRecipe(cardNo,recipeNo,applyTimeFrom,applyTimeEnd);
|
|
|
JSONObject json = JSONObject.parseObject(response);
|
|
|
if(json.getInteger("status")==200){
|
|
|
//智业接口每次返回一条数据,需要遍历请求
|
|
|
JSONObject data = json.getJSONObject("data");
|
|
|
String code = data.getString("CODE");
|
|
|
if("1".equals(code)){
|
|
|
JSONArray returnData = data.getJSONArray("returnData");
|
|
|
if(returnData.size()>0){
|
|
|
JSONObject recipe = returnData.getJSONArray(0).getJSONObject(0);//获取最后一条处方
|
|
|
jsonArray.add(recipe);
|
|
|
recipeNo = recipe.getString("RECIPE_NO");
|
|
|
if(recipeJson.isEmpty()){
|
|
|
recipeJson = json;
|
|
|
}else {
|
|
|
recipeJson.getJSONObject("data").getJSONArray("returnData").getJSONArray(0).add(recipe);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if(jsonArray.size()>1){
|
|
|
JSONObject re = new JSONObject();
|
|
|
re.put("status",200);
|
|
|
re.put("msg","调阅历史处方接口!");
|
|
|
JSONObject data = new JSONObject();
|
|
|
data.put("CODE","1");
|
|
|
JSONArray returnData = new JSONArray();
|
|
|
returnData.add(jsonArray);
|
|
|
data.put("returnData",returnData);
|
|
|
re.put("data",data);
|
|
|
return re.toString();
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return recipeJson.toString();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取单条历史处方
|
|
|
* @param recipeNo
|