Data.java
4.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package com.xkl.upsoft;
import com.xkl.Constants;
import org.json.JSONObject;
import org.junit.Test;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
/**
* Created by zhao yue on 2017/1/14.
*/
public class Data {
public static final String USR_ACCOUNT = "15211112222";
public static String AMP_REPORT = "";
static {
Data data = new Data();
data.generateJsonFormatReport();
}
public static String readTxtFile(String filePath) {
String line = "";
try {
String encoding = "UTF-8";
File file = new File(filePath);
if (file.isFile() && file.exists()) { //判断文件是否存在
InputStreamReader read = new InputStreamReader(
new FileInputStream(file), encoding);//考虑到编码格式
BufferedReader bufferedReader = new BufferedReader(read);
String lineTxt = null;
while ((lineTxt = bufferedReader.readLine()) != null && !lineTxt.equals("")) {
line = lineTxt;
break;
}
read.close();
} else {
System.out.println("找不到指定的文件");
}
} catch (Exception e) {
System.out.println("读取文件内容出错");
e.printStackTrace();
}
return line;
}
@Test
public void generateJsonFormatReport() {
JSONObject report = new JSONObject();
report.put("ABD", 35.66);
report.put("LAC", 36.23);
report.put("LCA", 32.94);
report.put("RAC", 35.84);
report.put("RCA", 33.05);
report.put("total", 173.62); // sum of the above 5 temperature
report.put("age", 24);
report.put("atmospheric_pressure", 756.58);
// The conclusion string of the report.
report.put("basic_result", "初步检测结果(仅供参考):\\n\\n低渗性血管张力异常 \\n\\n有必要排除血凝异常 血凝升高 \\n\\n建议向胃肠病专家(精于胃十二指肠炎)进一步咨询 \\n\\n血管张力异常,静脉循环障碍 酒精性高血压 \\n\\n第三脑室宽度=6.42 \\n\\n建议向妇科医生进一步咨询 其它器官血流量占=4.1 \\n\\nTiffeneau指数持续减少83.6 (Tiffeneau测试) \\n\\n----------------------------------------------------------------------------------------------------------\\n\\n\\n");
JSONObject details = new JSONObject();
DecimalFormat df = new java.text.DecimalFormat("######.00");
for (int i = 1; i <= 125; i++) {
details.put(String.valueOf(i), df.format(Math.random() * 100)); // 125 items of the report.
}
report.put("detail", details);
report.put("name", "user name"); // user name
report.put("number", "report number"); //report number. Leave it empty if not exist. Such as : report.put("number", "");
report.put("pulse", 79);
report.put("report_date", System.currentTimeMillis()); // physical examination time of this report
report.put("respiratory_rate", 18);
report.put("sex", 0); // 0 is male; 1 is female
report.put("stable", "99999");
report.put("weight", 45);
report.put("title", "AMP无创健康评估报告"); // report title
report.put("account", Constants.USR_ACC); // user account
report.put("machine_num", "10311212");//machine serial
// /*
// * Some other temperature serial which not display on the report.
// */
// report.put("T0", "{{{{{{{{{{{{{{{{{{{{{{");
// report.put("T1", "............");
// report.put("T2", "+++++++++++");
// report.put("T3", "@@@@@@@@@@@");
// report.put("T4", "!!!!!!!!!!!!");
//
// /*
// * The ID of the conclusion.
// */
// JSONArray basicResIds = new JSONArray();
// basicResIds.put(1);
// basicResIds.put(2);
// basicResIds.put(3);
// basicResIds.put(4);
// report.put("basic_result_ids", basicResIds);
AMP_REPORT = report.toString();
// use http://www.jsoneditoronline.org/ to view the json easily
System.out.println(AMP_REPORT);
}
}