|
@@ -10,6 +10,8 @@ import com.lantone.qc.pub.model.InputInfo;
|
|
|
import com.lantone.qc.pub.model.doc.DifficultCaseDiscussDoc;
|
|
|
import com.lantone.qc.pub.model.doc.RescueDoc;
|
|
|
import com.lantone.qc.pub.model.doc.ThreeLevelWardDoc;
|
|
|
+import com.lantone.qc.pub.model.doc.ward.AttendingDoctorWardDoc;
|
|
|
+import com.lantone.qc.pub.model.doc.ward.DirectorDoctorWardDoc;
|
|
|
import com.lantone.qc.pub.model.label.ThreeLevelWardLabel;
|
|
|
import com.lantone.qc.pub.util.ListUtil;
|
|
|
import com.lantone.qc.pub.util.StringUtil;
|
|
@@ -43,52 +45,56 @@ public class ThreeLevelWardAI extends ModelAI {
|
|
|
if (threeLevelWardDocs.size() == 0) {
|
|
|
return;
|
|
|
}
|
|
|
- //主治/主任首次查房记录
|
|
|
- Map<String, Map<String, String>> firstWardRecord = CatalogueUtil.extractWardRecord(threeLevelWardDocs);
|
|
|
- //主治医师首次查房记录
|
|
|
- if (firstWardRecord.get(Content.indications) != null) {
|
|
|
- putContent(crfContent, medicalTextType.get(0), firstWardRecord.get(Content.indications).get("病情记录"), Content.indications);
|
|
|
+ ThreeLevelWardDoc threeLevelWardDoc = threeLevelWardDocs.get(0);
|
|
|
+ List<AttendingDoctorWardDoc> attendingDocs = threeLevelWardDoc.getAttendingDoctorWardDocs();//主治医师查房记录
|
|
|
+ if (attendingDocs.size() > 0) {
|
|
|
+ //主治医师首次查房记录
|
|
|
+ Map<String, String> fitstAttStructureMap = attendingDocs.get(0).getStructureMap();
|
|
|
+ putContent(crfContent, medicalTextType.get(0), fitstAttStructureMap.get("病情记录"), Content.attend);
|
|
|
}
|
|
|
- //主任医师首次查房记录
|
|
|
- if (firstWardRecord.get(Content.director) != null) {
|
|
|
- putContent(crfContent, medicalTextType.get(0), firstWardRecord.get(Content.director).get("病情记录"), Content.director);
|
|
|
- }
|
|
|
- Map<String, String> lastCourseRecord = getLastCourseRecord(threeLevelWardDocs);
|
|
|
- if (lastCourseRecord != null && lastCourseRecord.containsKey("病情记录")) {
|
|
|
+
|
|
|
+ List<DirectorDoctorWardDoc> directorDocs = threeLevelWardDoc.getDirectorDoctorWardDocs();//主任医师查房记录
|
|
|
+ if (directorDocs.size() > 0) {
|
|
|
+ //主任医师首次查房记录
|
|
|
+ Map<String, String> fitstDirStructureMap = directorDocs.get(0).getStructureMap();
|
|
|
+ putContent(crfContent, medicalTextType.get(0), fitstDirStructureMap.get("病情记录"), Content.director);
|
|
|
+
|
|
|
//主任医师最后一次查房记录
|
|
|
- putContent(crfContent, medicalTextType.get(1), lastCourseRecord.get("病情记录"), Content.director + "最后一次");
|
|
|
+ Map<String, String> lastDirStructureMap = directorDocs.get(directorDocs.size() - 1).getStructureMap();
|
|
|
+ putContent(crfContent, medicalTextType.get(0), lastDirStructureMap.get("病情记录"), Content.director + "最后一次");
|
|
|
}
|
|
|
|
|
|
+ List<ThreeLevelWardDoc> allDoctorWradDocs = threeLevelWardDoc.getAllDoctorWradDocs();//所有查房记录
|
|
|
List<Map<String, String>> directorDifficultRecord = new ArrayList<>();
|
|
|
//疑难患者副高及以上查房记录
|
|
|
if (inputInfo.getDifficultCaseDiscussDocs().size() > 0) {
|
|
|
- directorDifficultRecord = putDirectorDifficultRecord(inputInfo, threeLevelWardDocs);
|
|
|
+ directorDifficultRecord = putDirectorDifficultRecord(inputInfo, allDoctorWradDocs);
|
|
|
for (int i = 0; i < directorDifficultRecord.size(); i++) {
|
|
|
- putContent(crfContent, medicalTextType.get(0), directorDifficultRecord.get(i).get("病情记录"), Content.difficultPatients + i);
|
|
|
+ putContent(crfContent, medicalTextType.get(0), directorDifficultRecord.get(i).get("病情记录"), Content.difficultPatients + i, directorDifficultRecord.get(i).get("查房日期"));
|
|
|
}
|
|
|
}
|
|
|
List<Map<String, String>> directorRescueRecord = new ArrayList<>();
|
|
|
//抢救患者副高及以上查房记录
|
|
|
if (inputInfo.getRescueDocs().size() > 0) {
|
|
|
- directorRescueRecord = putDirectorRescueRecord(inputInfo, threeLevelWardDocs);
|
|
|
+ directorRescueRecord = putDirectorRescueRecord(inputInfo, allDoctorWradDocs);
|
|
|
for (int i = 0; i < directorRescueRecord.size(); i++) {
|
|
|
- putContent(crfContent, medicalTextType.get(0), directorRescueRecord.get(i).get("病情记录"), Content.rescuingPatients + i);
|
|
|
+ putContent(crfContent, medicalTextType.get(0), directorRescueRecord.get(i).get("病情记录"), Content.rescuingPatients + i, directorRescueRecord.get(i).get("查房日期"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
JSONObject midData = loadAI(crfContent, crfServiceClient);//crf返回数据
|
|
|
|
|
|
//主治医师首次查房记录模型输出
|
|
|
- if (midData.get(Content.indications) != null) {
|
|
|
- putWardRoundCrfData(midData.getJSONObject(Content.indications), inputInfo, Content.indications, 0);//查房记录
|
|
|
+ if (midData.get(Content.attend) != null) {
|
|
|
+ putWardRoundCrfData(midData.getJSONObject(Content.attend), inputInfo, 0);//查房记录
|
|
|
}
|
|
|
//主任医师首次查房记录模型输出
|
|
|
if (midData.get(Content.director) != null) {
|
|
|
- putWardRoundCrfData(midData.getJSONObject(Content.director), inputInfo, Content.director, 0);//查房记录
|
|
|
+ putWardRoundCrfData(midData.getJSONObject(Content.director), inputInfo, 0);//查房记录
|
|
|
}
|
|
|
//主任医师最后一次查房记录模型输出
|
|
|
if (midData.get(Content.director + "最后一次") != null) {
|
|
|
- putWardRoundCrfData(midData.getJSONObject(Content.director + "最后一次"), inputInfo, Content.director + "最后一次", 0);//最后一次查房记录
|
|
|
+ putWardRoundCrfData(midData.getJSONObject(Content.director + "最后一次"), inputInfo, 0);//最后一次查房记录
|
|
|
}
|
|
|
//疑难患者副高及以上查房记录模型输出
|
|
|
if (inputInfo.getDifficultCaseDiscussDocs().size() > 0 && ListUtil.isNotEmpty(directorDifficultRecord)) {
|
|
@@ -96,7 +102,7 @@ public class ThreeLevelWardAI extends ModelAI {
|
|
|
if (midData.get(Content.difficultPatients + i) == null) {
|
|
|
continue;
|
|
|
}
|
|
|
- putWardRoundCrfData(midData.getJSONObject(Content.difficultPatients + i), inputInfo, Content.director, 2);//查房记录
|
|
|
+ putWardRoundCrfData(midData.getJSONObject(Content.difficultPatients + i), inputInfo, 2);//查房记录
|
|
|
}
|
|
|
}
|
|
|
//抢救患者副高及以上查房记录模型输出
|
|
@@ -105,22 +111,22 @@ public class ThreeLevelWardAI extends ModelAI {
|
|
|
if (midData.get(Content.rescuingPatients + i) == null) {
|
|
|
continue;
|
|
|
}
|
|
|
- putWardRoundCrfData(midData.getJSONObject(Content.difficultPatients + i), inputInfo, Content.director, 3);//查房记录
|
|
|
+ putWardRoundCrfData(midData.getJSONObject(Content.difficultPatients + i), inputInfo, 3);//查房记录
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- protected void putContent(JSONArray crfContent, String medicalTextType, String text, String sign) {
|
|
|
- String move_text = CatalogueUtil.removeSpecialChar(text);
|
|
|
- if (StringUtil.isEmpty(move_text)) {
|
|
|
+ protected void putContent(JSONArray crfContent, String medicalTextType, String text, String sign, String wardDate) {
|
|
|
+ String moveText = CatalogueUtil.removeSpecialChar(text);
|
|
|
+ if (StringUtil.isEmpty(moveText)) {
|
|
|
return;
|
|
|
}
|
|
|
JSONObject detailContent = new JSONObject();
|
|
|
detailContent.put("medical_text_type", medicalTextType);
|
|
|
- detailContent.put("content", move_text);
|
|
|
+ detailContent.put("content", moveText);
|
|
|
detailContent.put("detail_title", sign);
|
|
|
- detailContent.put("originalText", text);
|
|
|
+ detailContent.put("wardDate", wardDate);
|
|
|
crfContent.add(detailContent);
|
|
|
}
|
|
|
|
|
@@ -130,20 +136,33 @@ public class ThreeLevelWardAI extends ModelAI {
|
|
|
* @param jsonObject
|
|
|
* @param inputInfo
|
|
|
*/
|
|
|
- public void putWardRoundCrfData(JSONObject jsonObject, InputInfo inputInfo, String detailTitle, int serious) {
|
|
|
+ public void putWardRoundCrfData(JSONObject jsonObject, InputInfo inputInfo, int serious) {
|
|
|
JSONObject aiOut = loadEntity(jsonObject, entityRelationObject, outputs, content);
|
|
|
- String originalText = jsonObject.getString("originalText");
|
|
|
+ String wardDate = jsonObject.getString("wardDate");
|
|
|
+ String detailTitle = jsonObject.getString("detail_title");
|
|
|
//使用现病史结构来处理病历特点
|
|
|
EntityProcessThreeLevelWard entityProcessThreeLevelWard = new EntityProcessThreeLevelWard();
|
|
|
ThreeLevelWardLabel threeLevelWardLabel = entityProcessThreeLevelWard.extractEntity(aiOut);
|
|
|
threeLevelWardLabel.setTitle(detailTitle);
|
|
|
threeLevelWardLabel.setSerious(serious);
|
|
|
- List<ThreeLevelWardDoc> threeLevelWardDocs = inputInfo.getThreeLevelWardDocs();
|
|
|
- for (ThreeLevelWardDoc threeLevelWardDoc : threeLevelWardDocs) {
|
|
|
- String text = threeLevelWardDoc.getText();
|
|
|
- if (StringUtil.isNotBlank(text) && StringUtil.isNotBlank(originalText) && text.equals(originalText)) {
|
|
|
- threeLevelWardDoc.getThreeLevelWardLabel().add(threeLevelWardLabel);
|
|
|
- break;
|
|
|
+ ThreeLevelWardDoc threeLevelWardDoc = inputInfo.getThreeLevelWardDocs().get(0);
|
|
|
+ if (serious == 0) {//处理主治/主任查房记录
|
|
|
+ if (Content.attend.equals(detailTitle)) {
|
|
|
+ threeLevelWardDoc.getAttendingDoctorWardDocs().get(0).setThreeLevelWardLabel(threeLevelWardLabel);
|
|
|
+ } else if (Content.director.equals(detailTitle)) {
|
|
|
+ threeLevelWardDoc.getDirectorDoctorWardDocs().get(0).setThreeLevelWardLabel(threeLevelWardLabel);
|
|
|
+ } else if ((Content.director + "最后一次").equals(detailTitle)) {
|
|
|
+ List<DirectorDoctorWardDoc> director = threeLevelWardDoc.getDirectorDoctorWardDocs();
|
|
|
+ director.get(director.size() - 1).setThreeLevelWardLabel(threeLevelWardLabel);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ List<ThreeLevelWardDoc> allDoctorWradDocs = threeLevelWardDoc.getAllDoctorWradDocs();
|
|
|
+ for (ThreeLevelWardDoc wardDoc : allDoctorWradDocs) {
|
|
|
+ String date = wardDoc.getStructureMap().get("查房日期");
|
|
|
+ if (StringUtil.isNotBlank(date) && StringUtil.isNotBlank(wardDate) && date.equals(wardDate)) {
|
|
|
+ wardDoc.getThreeLevelWardLabel().add(threeLevelWardLabel);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -152,10 +171,10 @@ public class ThreeLevelWardAI extends ModelAI {
|
|
|
* 存放每条疑难病例讨论记录后第一条查房记录
|
|
|
*
|
|
|
* @param inputInfo
|
|
|
- * @param threeLevelWardDocs
|
|
|
+ * @param allDoctorWradDocs
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<Map<String, String>> putDirectorDifficultRecord(InputInfo inputInfo, List<ThreeLevelWardDoc> threeLevelWardDocs) {
|
|
|
+ public List<Map<String, String>> putDirectorDifficultRecord(InputInfo inputInfo, List<ThreeLevelWardDoc> allDoctorWradDocs) {
|
|
|
List<Map<String, String>> record = new ArrayList<>();
|
|
|
List<DifficultCaseDiscussDoc> difficultCaseDiscussDocs = inputInfo.getDifficultCaseDiscussDocs(); //疑难病例讨论记录
|
|
|
Map<Date, Map<String, String>> dateRecord = new TreeMap<>(new Comparator<Date>() {
|
|
@@ -170,7 +189,7 @@ public class ThreeLevelWardAI extends ModelAI {
|
|
|
Map<String, String> difficultCaseDiscussStructureMap = difficultCaseDiscussDoc.getStructureMap();
|
|
|
recordTime = difficultCaseDiscussStructureMap.get("讨论时间");
|
|
|
Date recordDate = null;
|
|
|
- if(StringUtil.isNotEmpty(recordTime)){
|
|
|
+ if (StringUtil.isNotEmpty(recordTime)) {
|
|
|
recordDate = StringUtil.parseDateTime(recordTime);
|
|
|
}
|
|
|
if (recordDate == null) {
|
|
@@ -179,7 +198,7 @@ public class ThreeLevelWardAI extends ModelAI {
|
|
|
dateRecord.put(recordDate, difficultCaseDiscussStructureMap);
|
|
|
}
|
|
|
dateRecord = extractUnique(dateRecord);
|
|
|
- for (ThreeLevelWardDoc threeLevelWardDoc : threeLevelWardDocs) {
|
|
|
+ for (ThreeLevelWardDoc threeLevelWardDoc : allDoctorWradDocs) {
|
|
|
Map<String, String> rescueStructureMap = threeLevelWardDoc.getStructureMap();
|
|
|
recordTime = rescueStructureMap.get("查房日期");
|
|
|
title = CatalogueUtil.subTitle(rescueStructureMap.get("查房标题"));
|
|
@@ -198,7 +217,7 @@ public class ThreeLevelWardAI extends ModelAI {
|
|
|
for (int i = 0; i < dateRecordList.size(); i++) {
|
|
|
if (i != dateRecordList.size() - 1) {
|
|
|
//当前为疑难病例讨论记录
|
|
|
- if (!dateRecordList.get(i).containsKey("抢救时间")) {
|
|
|
+ if (!dateRecordList.get(i).containsKey("讨论时间")) {
|
|
|
continue;
|
|
|
}
|
|
|
//疑难病例讨论记录下一条不是查房记录则清空list
|
|
@@ -218,10 +237,10 @@ public class ThreeLevelWardAI extends ModelAI {
|
|
|
* 存放每条抢救记录后第一条
|
|
|
*
|
|
|
* @param inputInfo
|
|
|
- * @param threeLevelWardDocs
|
|
|
+ * @param allDoctorWradDocs
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<Map<String, String>> putDirectorRescueRecord(InputInfo inputInfo, List<ThreeLevelWardDoc> threeLevelWardDocs) {
|
|
|
+ public List<Map<String, String>> putDirectorRescueRecord(InputInfo inputInfo, List<ThreeLevelWardDoc> allDoctorWradDocs) {
|
|
|
List<Map<String, String>> record = new ArrayList<>();
|
|
|
List<RescueDoc> rescueDocs = inputInfo.getRescueDocs(); //抢救记录
|
|
|
Map<Date, Map<String, String>> dateRecord = new TreeMap<>(new Comparator<Date>() {
|
|
@@ -242,7 +261,7 @@ public class ThreeLevelWardAI extends ModelAI {
|
|
|
dateRecord.put(recordDate, rescueStructureMap);
|
|
|
}
|
|
|
dateRecord = extractUnique(dateRecord);
|
|
|
- for (ThreeLevelWardDoc threeLevelWardDoc : threeLevelWardDocs) {
|
|
|
+ for (ThreeLevelWardDoc threeLevelWardDoc : allDoctorWradDocs) {
|
|
|
Map<String, String> rescueStructureMap = threeLevelWardDoc.getStructureMap();
|
|
|
recordTime = rescueStructureMap.get("查房日期");
|
|
|
title = CatalogueUtil.subTitle(rescueStructureMap.get("查房标题"));
|
|
@@ -300,39 +319,4 @@ public class ThreeLevelWardAI extends ModelAI {
|
|
|
}
|
|
|
return record;
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取查房记录最后一条记录
|
|
|
- *
|
|
|
- * @param threeLevelWardDocs
|
|
|
- * @return
|
|
|
- */
|
|
|
- public Map<String, String> getLastCourseRecord(List<ThreeLevelWardDoc> threeLevelWardDocs) {
|
|
|
- Map<Date, Map<String, String>> dateRecord = new TreeMap<>(new Comparator<Date>() {
|
|
|
- @Override
|
|
|
- public int compare(Date o1, Date o2) {
|
|
|
- // 降序排列
|
|
|
- return o2.compareTo(o1);
|
|
|
- }
|
|
|
- });//按时间key排序,存放抢救记录、查房记录
|
|
|
- String recordTime = "", title = "";
|
|
|
- for (ThreeLevelWardDoc threeLevelWardDoc : threeLevelWardDocs) {
|
|
|
- Map<String, String> rescueStructureMap = threeLevelWardDoc.getStructureMap();
|
|
|
- recordTime = rescueStructureMap.get("查房日期");
|
|
|
- title = CatalogueUtil.subTitle(rescueStructureMap.get("查房标题"));
|
|
|
- Date recordDate = null;
|
|
|
- if(StringUtil.isNotEmpty(recordTime)){
|
|
|
- recordDate = StringUtil.parseDateTime(recordTime);
|
|
|
- }
|
|
|
- if (recordDate == null || StringUtil.isBlank(title) || !title.contains(Content.director)) {//只存副高以上查房记录) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- dateRecord.put(recordDate, rescueStructureMap);
|
|
|
- }
|
|
|
- List<Map<String, String>> dateRecordList = new ArrayList<>(dateRecord.values());
|
|
|
- if (ListUtil.isEmpty(dateRecordList)) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- return dateRecordList.get(0);
|
|
|
- }
|
|
|
}
|