|
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.wdkl.infoboardclassic.BaseApp;
|
|
import com.wdkl.infoboardclassic.BaseApp;
|
|
|
|
+import com.wdkl.infoboardclassic.MainActivity;
|
|
import com.wdkl.infoboardclassic.R;
|
|
import com.wdkl.infoboardclassic.R;
|
|
import com.wdkl.infoboardclassic.constant.Constants;
|
|
import com.wdkl.infoboardclassic.constant.Constants;
|
|
import com.wdkl.infoboardclassic.data.AllPatientInfoItem;
|
|
import com.wdkl.infoboardclassic.data.AllPatientInfoItem;
|
|
@@ -14,10 +15,10 @@ import com.wdkl.infoboardclassic.data.PatientInfoBean;
|
|
import com.wdkl.infoboardclassic.utils.ToastUtil;
|
|
import com.wdkl.infoboardclassic.utils.ToastUtil;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
-import java.util.HashMap;
|
|
|
|
|
|
+import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
-import java.util.Map;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
import okhttp3.Call;
|
|
import okhttp3.Call;
|
|
@@ -34,8 +35,9 @@ public class PatientInfoManager {
|
|
private List<String> nurseConfigTitleList = new ArrayList<>();
|
|
private List<String> nurseConfigTitleList = new ArrayList<>();
|
|
private List<NurseConfigItem> nurseConfigItemList = new ArrayList<>();
|
|
private List<NurseConfigItem> nurseConfigItemList = new ArrayList<>();
|
|
|
|
|
|
|
|
+ private List<PatientInfoBean> patientInfoBeanList;
|
|
|
|
+
|
|
private int[] titleId = new int[] {R.string.patient_count_title, R.string.discharged_today_title, R.string.discharged_tomorrow_title, R.string.admission_today};
|
|
private int[] titleId = new int[] {R.string.patient_count_title, R.string.discharged_today_title, R.string.discharged_tomorrow_title, R.string.admission_today};
|
|
- private int[] contents = new int[]{0, 0, 0, 0};
|
|
|
|
|
|
|
|
private PatientInfoManager(){
|
|
private PatientInfoManager(){
|
|
}
|
|
}
|
|
@@ -58,9 +60,10 @@ public class PatientInfoManager {
|
|
.writeTimeout(60, TimeUnit.SECONDS)
|
|
.writeTimeout(60, TimeUnit.SECONDS)
|
|
.readTimeout(60, TimeUnit.SECONDS);
|
|
.readTimeout(60, TimeUnit.SECONDS);
|
|
|
|
|
|
|
|
+ String hostUrl = Constants.HOST_ADDR_PRE + Constants.HOST_IP + Constants.PORT + "/" + Constants.PATH;
|
|
OkHttpClient httpClient = builder.build();
|
|
OkHttpClient httpClient = builder.build();
|
|
Request request = new Request.Builder()
|
|
Request request = new Request.Builder()
|
|
- .url(Constants.HOST_ADDR + "/" + Constants.PATH)
|
|
|
|
|
|
+ .url(hostUrl)
|
|
.get()
|
|
.get()
|
|
.build();
|
|
.build();
|
|
|
|
|
|
@@ -74,14 +77,8 @@ public class PatientInfoManager {
|
|
public void onResponse(Call call, Response response) throws IOException {
|
|
public void onResponse(Call call, Response response) throws IOException {
|
|
if (response.isSuccessful()) {
|
|
if (response.isSuccessful()) {
|
|
String responseStr = response.body().string();
|
|
String responseStr = response.body().string();
|
|
- Log.d(TAG, "get response:" + responseStr);
|
|
|
|
-
|
|
|
|
- List<PatientInfoBean> patientList = JSONObject.parseArray(responseStr, PatientInfoBean.class);
|
|
|
|
- parsePatientInfo(patientList);
|
|
|
|
-
|
|
|
|
- for (PatientInfoBean model : patientList) {
|
|
|
|
- Log.d(TAG, model.getName());
|
|
|
|
- }
|
|
|
|
|
|
+ //Log.d(TAG, "get response:" + responseStr);
|
|
|
|
+ patientInfoBeanList = JSONObject.parseArray(responseStr, PatientInfoBean.class);
|
|
} else {
|
|
} else {
|
|
Log.e(TAG, response.body().string());
|
|
Log.e(TAG, response.body().string());
|
|
ToastUtil.showShortToast("获取数据错误");
|
|
ToastUtil.showShortToast("获取数据错误");
|
|
@@ -90,12 +87,38 @@ public class PatientInfoManager {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- private void parsePatientInfo(List<PatientInfoBean> patients) {
|
|
|
|
- allPatientInfoItemList.clear();
|
|
|
|
- if (patients != null) {
|
|
|
|
- contents[0] = patients.size();
|
|
|
|
|
|
+ public void setPatientInfoBeanList(List<PatientInfoBean> patients) {
|
|
|
|
+ patientInfoBeanList = patients;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void parsePatientInfo() {
|
|
|
|
+ int[] contents = new int[] {0, 0, 0, 0};
|
|
|
|
+ if (patientInfoBeanList != null) {
|
|
|
|
+ contents[0] = patientInfoBeanList.size(); //现有住院总人数
|
|
|
|
+ for (PatientInfoBean bean: patientInfoBeanList) {
|
|
|
|
+ Long outTime = bean.getOutDate();
|
|
|
|
+ if (outTime != null && outTime > 0) {
|
|
|
|
+ Date outDate = new Date(outTime);
|
|
|
|
+ String outDay = new SimpleDateFormat(MainActivity.DATE_FORMAT).format(outDate);
|
|
|
|
+ if (MainActivity.curDate.equals(outDay)) {
|
|
|
|
+ contents[1]++; //今日出院
|
|
|
|
+ } else if (MainActivity.nextDate.equals(outDay)) {
|
|
|
|
+ contents[2]++; //明日出院
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Long inTime = bean.getInDate();
|
|
|
|
+ if (inTime != null && inTime > 0) {
|
|
|
|
+ Date inDate = new Date(inTime);
|
|
|
|
+ String inDay = new SimpleDateFormat(MainActivity.DATE_FORMAT).format(inDate);
|
|
|
|
+ if (MainActivity.curDate.equals(inDay)) {
|
|
|
|
+ contents[3]++; //今日入院
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
for (int i = 0; i < titleId.length; i++) {
|
|
for (int i = 0; i < titleId.length; i++) {
|
|
- //住院信息
|
|
|
|
|
|
+ //住院人数信息
|
|
AllPatientInfoItem allPatientInfoItem = new AllPatientInfoItem();
|
|
AllPatientInfoItem allPatientInfoItem = new AllPatientInfoItem();
|
|
allPatientInfoItem.setInfoTitle(getString(titleId[i]));
|
|
allPatientInfoItem.setInfoTitle(getString(titleId[i]));
|
|
allPatientInfoItem.setInfoContent(Integer.toString(contents[i]));
|
|
allPatientInfoItem.setInfoContent(Integer.toString(contents[i]));
|
|
@@ -105,12 +128,13 @@ public class PatientInfoManager {
|
|
}
|
|
}
|
|
|
|
|
|
public List<AllPatientInfoItem> getAllPatientInfoItemList() {
|
|
public List<AllPatientInfoItem> getAllPatientInfoItemList() {
|
|
|
|
+ parsePatientInfo();
|
|
if (allPatientInfoItemList.size() == 0) {
|
|
if (allPatientInfoItemList.size() == 0) {
|
|
//默认值
|
|
//默认值
|
|
for (int i = 0; i < titleId.length; i++) {
|
|
for (int i = 0; i < titleId.length; i++) {
|
|
AllPatientInfoItem allPatientInfoItem = new AllPatientInfoItem();
|
|
AllPatientInfoItem allPatientInfoItem = new AllPatientInfoItem();
|
|
allPatientInfoItem.setInfoTitle(getString(titleId[i]));
|
|
allPatientInfoItem.setInfoTitle(getString(titleId[i]));
|
|
- allPatientInfoItem.setInfoContent(Integer.toString(contents[i]));
|
|
|
|
|
|
+ allPatientInfoItem.setInfoContent("0");
|
|
allPatientInfoItemList.add(allPatientInfoItem);
|
|
allPatientInfoItemList.add(allPatientInfoItem);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -142,5 +166,8 @@ public class PatientInfoManager {
|
|
allPatientInfoItemList.clear();
|
|
allPatientInfoItemList.clear();
|
|
nurseConfigTitleList.clear();
|
|
nurseConfigTitleList.clear();
|
|
nurseConfigItemList.clear();
|
|
nurseConfigItemList.clear();
|
|
|
|
+ if (patientInfoBeanList != null) {
|
|
|
|
+ patientInfoBeanList.clear();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|