|
|
@@ -25,6 +25,7 @@ import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
|
+import java.util.List;
|
|
|
|
|
|
import static beans.customers.Customers.getRepeatCustomers;
|
|
|
|
|
|
@@ -452,4 +453,126 @@ public class Hospital extends Controller {
|
|
|
}
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
|
+
|
|
|
+ @API(title = "关联医生查询", apiversion = R.ID2025102310134602.v1.class)
|
|
|
+ public String queryDoctors() throws YosException {
|
|
|
+ StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
+ if (content.containsKey("where")) {
|
|
|
+ JSONObject whereObject = content.getJSONObject("where");
|
|
|
+
|
|
|
+ if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
|
|
|
+ where.append(" and(");
|
|
|
+ where.append("t1.doctorname like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.phonenumber like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.professional like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t2.hospitaldepname like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t4.enterprisename like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Long sa_customersid = content.getLong("sa_customersid");
|
|
|
+
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_doctor", "*").setTableAlias("t1");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_hospitaldep", "t2", "t2.sa_hospitaldepid=t1.sa_hospitaldepid and t2.siteid=t1.siteid", "hospitaldepname");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_customers", "t3", "t3.sa_customersid=t1.sa_customersid");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t4", "t4.sys_enterpriseid=t3.sys_enterpriseid",
|
|
|
+ "enterprisename");
|
|
|
+ querySQL.setWhere(where);
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere("t3.sa_customersid",sa_customersid);
|
|
|
+ querySQL.setPage(pageSize, pageNumber).setOrderBy(pageSorting);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+
|
|
|
+ ArrayList<Long> ids = rows.toArrayList("sa_doctorid", new ArrayList<>());
|
|
|
+ RowsMap leaderRows = DataTeam.getLeader(this, "sa_doctor", rows.toArrayList("sa_doctorid")).toRowsMap("ownerid");
|
|
|
+ //标签
|
|
|
+ HashMap<Long, ArrayList<String>> tagList = DataTag.queryTag(this, "sa_doctor", ids, false);
|
|
|
+ //系统标签
|
|
|
+ HashMap<Long, ArrayList<String>> sysTagList = DataTag.queryTag(this, "sa_doctor", ids, true);
|
|
|
+ for (Row row : rows) {
|
|
|
+ Long id = row.getLong("sa_doctorid");
|
|
|
+ row.put("leader", leaderRows.get(row.getString("sa_doctorid")));
|
|
|
+ if (leaderRows.get(String.valueOf(id)).isNotEmpty()) {
|
|
|
+ row.put("depname", leaderRows.get(String.valueOf(id)).get(0).getString("depname"));
|
|
|
+ }
|
|
|
+ ArrayList<String> tag = tagList.get(id) != null ? tagList.get(id) : new ArrayList<>();
|
|
|
+ ArrayList<String> sys_tag = sysTagList.get(id) != null ? sysTagList.get(id) : new ArrayList<>();
|
|
|
+ //非系统标签
|
|
|
+ row.put("tag", tag);
|
|
|
+ //系统标签
|
|
|
+ row.put("tag_sys", sys_tag);
|
|
|
+ }
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "关联科室查询", apiversion = R.ID2025102310143002.v1.class)
|
|
|
+ public String queryHospitalDeps() throws YosException {
|
|
|
+ StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
+ if (content.containsKey("where")) {
|
|
|
+ JSONObject whereObject = content.getJSONObject("where");
|
|
|
+
|
|
|
+ if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
|
|
|
+ where.append(" and(");
|
|
|
+ where.append("t1.hospitaldepname like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.remarks like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ Long sa_customersid = content.getLong("sa_customersid");
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_hospitaldep", "*").setTableAlias("t1");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_customers", "t2", "t2.sa_customersid=t1.sa_customersid and t2.siteid=t1.siteid");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t3", "t3.sys_enterpriseid=t2.sys_enterpriseid and t3.siteid=t2.siteid", "enterprisename");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere(where);
|
|
|
+ querySQL.setWhere("t2.sa_customersid",sa_customersid);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+
|
|
|
+ ArrayList<Long> ids = rows.toArrayList("sa_hospitaldepid", new ArrayList<>());
|
|
|
+ RowsMap leaderRows = DataTeam.getLeader(this, "sa_hospitaldep", rows.toArrayList("sa_hospitaldepid")).toRowsMap("ownerid");
|
|
|
+ //标签
|
|
|
+ HashMap<Long, ArrayList<String>> tagList = DataTag.queryTag(this, "sa_hospitaldep", ids, false);
|
|
|
+ //系统标签
|
|
|
+ HashMap<Long, ArrayList<String>> sysTagList = DataTag.queryTag(this, "sa_hospitaldep", ids, true);
|
|
|
+ Rows stageRows = dbConnect.runSqlQuery("SELECT stagename,sequence from sa_devstage WHERE siteid='" + siteid + "' order by sequence");
|
|
|
+ RowsMap doctorRowsMap = getDoctorRowsMap(ids);
|
|
|
+ for (Row row : rows) {
|
|
|
+ Long id = row.getLong("sa_hospitaldepid");
|
|
|
+ row.put("leader", leaderRows.get(row.getString("sa_hospitaldepid")));
|
|
|
+ if (leaderRows.get(String.valueOf(id)).isNotEmpty()) {
|
|
|
+ row.put("depname", leaderRows.get(String.valueOf(id)).get(0).getString("depname"));
|
|
|
+ }
|
|
|
+ ArrayList<String> tag = tagList.get(id) != null ? tagList.get(id) : new ArrayList<>();
|
|
|
+ ArrayList<String> sys_tag = sysTagList.get(id) != null ? sysTagList.get(id) : new ArrayList<>();
|
|
|
+ //非系统标签
|
|
|
+ row.put("tag", tag);
|
|
|
+ //系统标签
|
|
|
+ row.put("tag_sys", sys_tag);
|
|
|
+ //科室负责人
|
|
|
+ Rows doctorRows = doctorRowsMap.getOrDefault(id.toString(), new Rows());
|
|
|
+ row.putIfAbsent("doctors", StringUtils.join(doctorRows.toArray("doctorname"), ","));
|
|
|
+ String stagename = row.getString("stagename");
|
|
|
+ for (Row stageRow : stageRows) {
|
|
|
+ if (stagename.equals(stageRow.getString("stagename"))) {
|
|
|
+ stageRow.put("active", 1);
|
|
|
+ }
|
|
|
+ stageRow.putIfAbsent("active", 0);
|
|
|
+ }
|
|
|
+ row.put("stages", stageRows);
|
|
|
+ }
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ public RowsMap getDoctorRowsMap(List<Long> sa_hospitaldepids) throws YosException {
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_doctor", "*").setTableAlias("t1");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere("t1.isleader=1");
|
|
|
+ querySQL.setWhere("t1.sa_hospitaldepid ", sa_hospitaldepids);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+ return rows.toRowsMap("sa_hospitaldepid");
|
|
|
+ }
|
|
|
+
|
|
|
}
|