TZDBConnForHis.java 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822
  1. package com.diagbot.util;
  2. import com.diagbot.dto.SentEntryRecordDTO;
  3. import com.diagbot.entity.*;
  4. import com.google.common.collect.Lists;
  5. import org.apache.commons.lang3.StringUtils;
  6. import java.sql.*;
  7. import java.util.List;
  8. import java.util.ResourceBundle;
  9. public class TZDBConnForHis {
  10. private static final String DRIVER = getValue("jdbc.driverClassName1");
  11. private static final String URL = getValue("jdbc.url1");
  12. private static final String USERNAME = getValue("jdbc.username1");
  13. private static final String PASSWORD = getValue("jdbc.password1");
  14. public static final Long HOSPITAL_ID=Long.valueOf("35");//1:长兴,2:邵逸夫,3:台州市立医院
  15. private static Connection connection = null;
  16. private static PreparedStatement sta = null;
  17. private static ResultSet rs = null;
  18. /**
  19. * 读取属性文件中的信息
  20. *
  21. * @param key
  22. * @return
  23. */
  24. private static String getValue(String key) {
  25. // 资源包绑定
  26. ResourceBundle bundle = ResourceBundle.getBundle("jdbc");
  27. return bundle.getString(key);
  28. }
  29. /**
  30. * 加载驱动程序
  31. */
  32. static {
  33. try {
  34. Class.forName(DRIVER);
  35. } catch (ClassNotFoundException e) {
  36. e.printStackTrace();
  37. }
  38. }
  39. /**
  40. * @return 连接对象
  41. */
  42. public Connection getConnection() {
  43. try {
  44. connection = DriverManager.getConnection(URL,USERNAME,PASSWORD);
  45. } catch (SQLException e) {
  46. e.printStackTrace();
  47. }
  48. return connection;
  49. }
  50. /**
  51. * @param sql sql语句
  52. * @param obj 参数
  53. * @return 数据集合
  54. */
  55. public ResultSet Query(String sql,Object...obj){
  56. connection=getConnection();
  57. try {
  58. sta=connection.prepareStatement(sql);
  59. if(obj!=null){
  60. for(int i=0;i<obj.length;i++){
  61. sta.setObject(i+1, obj[i]);
  62. }
  63. }
  64. rs=sta.executeQuery();
  65. } catch (SQLException e) {
  66. e.printStackTrace();
  67. }
  68. return rs;
  69. }
  70. /**
  71. * 关闭资源
  72. */
  73. public void close() {
  74. try {
  75. if (rs != null) {
  76. rs.close();
  77. }
  78. } catch (SQLException e) {
  79. e.printStackTrace();
  80. } finally {
  81. try {
  82. if (sta != null) {
  83. sta.close();
  84. }
  85. } catch (SQLException e2) {
  86. e2.printStackTrace();
  87. } finally {
  88. if (connection != null) {
  89. try {
  90. connection.close();
  91. } catch (SQLException e) {
  92. e.printStackTrace();
  93. }
  94. }
  95. }
  96. }
  97. }
  98. /**
  99. * 从视图中获取医院科室数据,根据修改时间同步数据
  100. * @return
  101. */
  102. public List<BasDeptInfo> getDeptInfo(String sql) {
  103. List<BasDeptInfo> basDeptInfoList=Lists.newLinkedList();
  104. try {
  105. TZDBConnForHis dbconn=new TZDBConnForHis();
  106. ResultSet rs =dbconn.Query(sql, null);
  107. while(rs.next()){
  108. BasDeptInfo basDeptInfo=new BasDeptInfo();
  109. basDeptInfo.setDeptId(rs.getString("deptId"));//科室编码
  110. basDeptInfo.setHospitalId(HOSPITAL_ID);//医院ID
  111. basDeptInfo.setDeptName(rs.getString("deptName"));//科室名称
  112. basDeptInfo.setParentDeptId(rs.getString("partentDeptId"));//父类科室名称
  113. basDeptInfo.setDeptType(rs.getString("deptType"));//科室类别
  114. basDeptInfo.setStation(rs.getString("station"));//区域类别
  115. basDeptInfo.setSpell(rs.getString("spell"));//首字母拼音
  116. basDeptInfoList.add(basDeptInfo);
  117. }
  118. } catch (Exception e) {
  119. e.printStackTrace();
  120. }finally {
  121. close();
  122. }
  123. return basDeptInfoList;
  124. }
  125. /**
  126. * 从视图中获取医院医生信息
  127. * @return
  128. */
  129. public List<BasDoctorInfo> getDoctorInfo(String sql) {
  130. List<BasDoctorInfo> basDoctorInfos=Lists.newLinkedList();
  131. try {
  132. TZDBConnForHis dbconn=new TZDBConnForHis();
  133. ResultSet rs =dbconn.Query(sql, null);
  134. while(rs.next()){
  135. BasDoctorInfo basDoctorInfo =new BasDoctorInfo();
  136. basDoctorInfo.setDoctorId(rs.getString("user_id"));//医生id
  137. basDoctorInfo.setHospitalId(Long.valueOf("35"));
  138. basDoctorInfo.setDeptId(rs.getString("dept_code"));//医生所在科室
  139. basDoctorInfo.setName(rs.getString("name"));//医师姓名
  140. basDoctorInfo.setProfessor(rs.getString("title"));//医师职称
  141. basDoctorInfo.setOccup(rs.getString("certificate"));//是否有职业医师资格
  142. basDoctorInfos.add(basDoctorInfo);
  143. }
  144. } catch (Exception e) {
  145. e.printStackTrace();
  146. }finally {
  147. close();
  148. }
  149. return basDoctorInfos;
  150. }
  151. /**
  152. * 查询文书数量
  153. * @return
  154. */
  155. public Integer getCount(String sql) {
  156. Integer count =0;
  157. try {
  158. TZDBConnForHis dbconn=new TZDBConnForHis();
  159. ResultSet rs =dbconn.Query(sql, null);
  160. while(rs.next()){
  161. count=rs.getInt("count");
  162. }
  163. } catch (Exception e) {
  164. e.printStackTrace();
  165. }finally {
  166. close();
  167. }
  168. return count;
  169. }
  170. /**
  171. * 病案诊断
  172. * @return
  173. */
  174. public List<HomeDiagnoseInfo> getHomeDiagnose(String sql){
  175. List<HomeDiagnoseInfo> homeDiagnoseVOList=Lists.newLinkedList();
  176. try {
  177. TZDBConnForHis dbconn=new TZDBConnForHis();
  178. ResultSet rs =dbconn.Query(sql, null);
  179. while(rs.next()){
  180. HomeDiagnoseInfo homeDiagnose=new HomeDiagnoseInfo();
  181. homeDiagnose.setHomePageId(rs.getString("homePageId"));//病案首页ID
  182. homeDiagnose.setHospitalId(HOSPITAL_ID);//医院ID
  183. homeDiagnose.setDiagnoseOrderNo(rs.getString("diagnoseOrderNo"));//诊断序号
  184. homeDiagnose.setDiagnoseName(rs.getString("diagnoseName"));//诊断名称
  185. homeDiagnose.setDiagnoseType(rs.getString("diagnoseType"));//诊断类别
  186. homeDiagnose.setDiagnoseTypeShort(rs.getString("diagnoseTypeShort"));//诊断判别
  187. homeDiagnose.setBehospitalType(rs.getString("behospitalType"));//入院情况
  188. homeDiagnose.setLeaveHospitalType(rs.getString("leaveHospitalType"));//出院情况
  189. homeDiagnose.setPathologyDiagnose(rs.getString("pathologyDiagnose"));//病理号
  190. homeDiagnose.setIcdCode(rs.getString("icdCode"));//诊断编码
  191. homeDiagnoseVOList.add(homeDiagnose);
  192. }
  193. } catch (Exception e) {
  194. e.printStackTrace();
  195. }finally {
  196. close();
  197. }
  198. return homeDiagnoseVOList;
  199. }
  200. /**
  201. * 病案手术
  202. * @return
  203. */
  204. public List<HomeOperationInfo> getHomeOperation(String sql) {
  205. List<HomeOperationInfo> homeOperationVOList=Lists.newLinkedList();
  206. try {
  207. TZDBConnForHis dbconn=new TZDBConnForHis();
  208. ResultSet rs =dbconn.Query(sql, null);
  209. while(rs.next()){
  210. HomeOperationInfo homeOperationVO=new HomeOperationInfo();
  211. homeOperationVO.setHomePageId(rs.getString("homePageId"));//病案首页ID
  212. homeOperationVO.setHospitalId(HOSPITAL_ID);//医院ID
  213. homeOperationVO.setOperationOrderNo(rs.getString("operationOrderNo"));//手术序号
  214. homeOperationVO.setOperationDate(StringUtils.isNotBlank(rs.getString("operationDate"))?DateUtil.parseDateTime(rs.getString("operationDate")):null);//手术日期
  215. homeOperationVO.setOperationCode(rs.getString("operationCode"));//手术编码
  216. homeOperationVO.setOperationDoctorId(rs.getString("operationDoctorId"));//手术医生
  217. homeOperationVO.setFirstAssistantId(rs.getString("firstAssistantId"));//一助医生
  218. homeOperationVO.setSecondAssistantId(rs.getString("secondAssistantId"));//二助医生
  219. homeOperationVO.setCutLevel(rs.getString("cutLevel"));//切口等级
  220. homeOperationVO.setHealingLevel(rs.getString("healingLevel"));//愈合等级
  221. homeOperationVO.setOperationName(rs.getString("operationName"));//手术名称
  222. homeOperationVO.setOperationLevel(rs.getString("operationLevel"));//手术级别
  223. homeOperationVO.setAnaesthesiaName(rs.getString("anaesthesiaName"));//麻醉方式
  224. homeOperationVO.setShamOperationName(rs.getString("shamOperationName"));//拟手术名称
  225. homeOperationVO.setAnaesthesiaDoctor(rs.getString("anaesthesiaDoctor"));//麻醉医师
  226. homeOperationVOList.add(homeOperationVO);
  227. }
  228. } catch (Exception e) {
  229. e.printStackTrace();
  230. }finally {
  231. close();
  232. }
  233. List<HomeOperationInfo> homeOperationList=BeanUtil.listCopyTo(homeOperationVOList, HomeOperationInfo.class);
  234. return homeOperationList;
  235. }
  236. /**
  237. * 从视图获取病案首页信息
  238. *
  239. */
  240. public List<HomePage> getHomePage(String sql) {
  241. List<HomePage> homePageList=Lists.newLinkedList();
  242. try {
  243. TZDBConnForHis dbconn=new TZDBConnForHis();
  244. ResultSet rs =dbconn.Query(sql, null);
  245. // if (!rs.next()){
  246. // System.out.println("返回查询结果为空");
  247. // }else {
  248. while(rs.next()){
  249. HomePage homePageVO=new HomePage();
  250. homePageVO.setHomePageId(rs.getString("homePageId"));//病案首页编号
  251. homePageVO.setHospitalId(HOSPITAL_ID);//医院ID
  252. homePageVO.setBehospitalCode(rs.getString("behospitalCode")+"_"+rs.getString("behospitalNum"));//病人住院序号
  253. homePageVO.setHospitalCode(rs.getString("hospitalCode"));//组织机构id
  254. homePageVO.setHospitalName(rs.getString("hospitalName"));//医疗机构名称
  255. homePageVO.setOrgCode(rs.getString("orgCode"));//医疗机构代码
  256. homePageVO.setPayType(rs.getString("payType"));//医疗付费方式
  257. homePageVO.setHealthCard(rs.getString("healthCard"));//健康卡号
  258. homePageVO.setBehospitalNum(rs.getString("behospitalNum"));//住院次数
  259. homePageVO.setFileCode(rs.getString("fileCode"));//病案号
  260. homePageVO.setName(rs.getString("name"));//姓名
  261. homePageVO.setSex(rs.getString("sex"));//性别
  262. homePageVO.setBirthday(rs.getDate("birthday"));//出生日期
  263. homePageVO.setAge(rs.getString("age").equals("-")?null:rs.getString("age"));//病人年龄
  264. homePageVO.setAgeUnit(rs.getString("ageUnit"));//年龄单位
  265. homePageVO.setNationality(rs.getString("nationality"));//国籍
  266. homePageVO.setNewbornMonth(rs.getString("newbornMonth"));//新生儿出生月数
  267. homePageVO.setNewbornDay(rs.getString("newbornDay"));//新生儿出生天数
  268. homePageVO.setNewbornWeight(rs.getString("newbornWeight"));//新生儿出生体重
  269. homePageVO.setNewbornBehospitalWeight(rs.getString("newbornBehospitalWeight"));//新生儿入院体重
  270. homePageVO.setBornAddress(rs.getString("bornAddress"));//出生地
  271. homePageVO.setBornPlace(rs.getString("bornPlace"));//籍贯
  272. homePageVO.setNation(rs.getString("nation"));//民族
  273. homePageVO.setIdentityCardNo(rs.getString("identityCardNo"));//身份证号
  274. homePageVO.setJobType(rs.getString("jobType"));//职业
  275. homePageVO.setMarriage(rs.getString("marriage"));//婚姻
  276. homePageVO.setCurAddress(rs.getString("curAddress"));//现住址
  277. homePageVO.setCurPhone(rs.getString("curPhone"));//现住址电话
  278. homePageVO.setCurPostCode(rs.getString("curPostCode"));//现住址邮编
  279. homePageVO.setResidenceAddress(rs.getString("residenceAddress"));//户口地址
  280. homePageVO.setResidencePostCode(rs.getString("residencePostCode"));//户口地址邮编
  281. homePageVO.setWorkAddress(rs.getString("workAddress"));//工作单位
  282. homePageVO.setWorkPhone(rs.getString("workPhone"));//工作单位电话
  283. homePageVO.setWorkPostCode(rs.getString("workPostCode"));//工作单位邮编
  284. homePageVO.setContactName(rs.getString("contactName"));//联系人姓名
  285. homePageVO.setContactRelation(rs.getString("contactRelation"));//联系人关系
  286. homePageVO.setContactAddress(rs.getString("contactAddress"));//联系人地址
  287. homePageVO.setContactPhone(rs.getString("contactPhone"));//联系人电话
  288. homePageVO.setBehospitalWay(rs.getString("behospitalWay"));//入院途径
  289. homePageVO.setBehospitalDate(StringUtils.isNotBlank(rs.getString("behospitalDate"))?DateUtil.parseDateTime(rs.getString("behospitalDate")):null);//入院时间
  290. homePageVO.setBehospitalDept(rs.getString("behospitalDept"));//入院科室
  291. homePageVO.setBehospitalWard(rs.getString("behospitalWard"));//入院病房
  292. homePageVO.setBehospitalBedId(rs.getString("behospitalBedId"));//入院床位序号
  293. homePageVO.setBehospitalBedCode(rs.getString("behospitalBedCode"));//入院床位号码
  294. homePageVO.setChangeDept(rs.getString("changeDept"));//转科科别
  295. homePageVO.setLeaveHospitalDate(StringUtils.isNotBlank(rs.getString("leaveHospitalDate"))?DateUtil.parseDateTime(rs.getString("leaveHospitalDate")):null);//出院时间
  296. homePageVO.setLeaveHospitalDept(rs.getString("leaveHospitalDept"));//出院科别
  297. homePageVO.setLeaveHospitalWard(rs.getString("leaveHospitalWard"));//出院病房
  298. homePageVO.setLeaveHospitalBedId(rs.getString("leaveHospitalBedId"));//出院床位序号
  299. homePageVO.setLeaveHospitalBedCode(rs.getString("leaveHospitalBedCode"));//出院床位号码
  300. homePageVO.setBehospitalDayNum(rs.getString("behospitalDayNum"));//实际住院天数
  301. homePageVO.setOutpatientEmrDiagnose(rs.getString("outpatientEmrDiagnose"));//门急诊诊断
  302. homePageVO.setOutpatientEmrDiagnoseCode(rs.getString("outpatientEmrDiagnoseCode"));//门急诊诊断编码
  303. homePageVO.setPoisonFactor(rs.getString("poisonFactor"));//损伤中毒因素
  304. homePageVO.setPoisonFactorCode(rs.getString("poisonFactorCode"));//损伤中毒因素编码
  305. homePageVO.setPathologyDiagnose(rs.getString("pathologyDiagnose"));//病理诊断
  306. homePageVO.setPathologyDiagnoseCode(rs.getString("pathologyDiagnoseCode"));//病理诊断编码
  307. homePageVO.setPathologyDiagnoseId(rs.getString("pathologyDiagnoseId"));//病理诊断编号
  308. homePageVO.setIsMedAllergy(rs.getString("isMedAllergy"));//药物过敏
  309. homePageVO.setMedAllergyName(rs.getString("medAllergyName"));//过敏药物
  310. homePageVO.setAutopsy(rs.getString("autopsy"));//死亡患者尸检
  311. homePageVO.setBloodType(rs.getString("bloodType"));//血型
  312. homePageVO.setRh(rs.getString("rh"));//Rh
  313. homePageVO.setDeptDirector(rs.getString("deptDirector"));//科主任
  314. homePageVO.setDirectorDoctor(rs.getString("directorDoctor"));//主任医师
  315. homePageVO.setAttendingDoctor(rs.getString("attendingDoctor"));//主治医师
  316. homePageVO.setBehospitalDoctor(rs.getString("behospitalDoctor"));//住院医师
  317. homePageVO.setResponseNurse(rs.getString("responseNurse"));//责任护士
  318. homePageVO.setStudyDoctor(rs.getString("studyDoctor"));//进修医师
  319. homePageVO.setPracticeDoctor(rs.getString("practiceDoctor"));//实习医师
  320. homePageVO.setEncodeMan(rs.getString("encodeMan"));//编码员
  321. homePageVO.setHomePageQuality(rs.getString("homePageQuality"));//病案质量
  322. homePageVO.setQcDoctor(rs.getString("qcDoctor"));//质控医师
  323. homePageVO.setQcNurse(rs.getString("qcNurse"));//质控护士
  324. if(!"".equals(rs.getString("qcDate"))){
  325. homePageVO.setQcDate(DateUtil.parseDate(rs.getString("qcDate"),DateUtil.DATE_TIME_FORMAT));//质控日期
  326. }
  327. homePageVO.setLeaveHospitalType(rs.getString("leaveHospitalType"));//离院方式
  328. homePageVO.setAcceptOrgCode(rs.getString("acceptOrgCode"));//接收机构名称
  329. homePageVO.setAgainBehospitalPlan(rs.getString("againBehospitalPlan"));//31天内再住院计划
  330. homePageVO.setAgainBehospitalGoal(rs.getString("againBehospitalGoal"));//再住院目的
  331. homePageVO.setTbiBeforeDay(rs.getString("tbiBeforeDay"));//颅脑损伤患者昏迷前天数
  332. homePageVO.setTbiBeforeHour(rs.getString("tbiBeforeHour"));//颅脑损伤患者昏迷前小时
  333. homePageVO.setTbiBeforeMinute(rs.getString("tbiBeforeMinute"));//颅脑损伤患者昏迷前分钟
  334. homePageVO.setTbiAfterDay(rs.getString("tbiAfterDay"));//颅脑损伤患者昏迷后天数
  335. homePageVO.setTbiAfterHour(rs.getString("tbiAfterHour"));//颅脑损伤患者昏迷后小时
  336. homePageVO.setTbiAfterMinute(rs.getString("tbiAfterMinute"));//颅脑损伤患者昏迷后分钟
  337. homePageVO.setTotalFee(rs.getString("totalFee"));//总费用
  338. homePageVO.setOwnFee(rs.getString("ownFee"));//自付金额
  339. homePageVO.setGeneralFee(rs.getString("generalFee"));//一般医疗服务费
  340. homePageVO.setServiceFee(rs.getString("serviceFee"));//一般治疗服务费
  341. homePageVO.setNurseFee(rs.getString("nurseFee"));//护理费
  342. homePageVO.setOtherFee(rs.getString("otherFee"));//其他费用
  343. homePageVO.setPathologyFee(rs.getString("pathologyFee"));//病理诊断费
  344. homePageVO.setLabFee(rs.getString("labFee"));//实验室诊断费
  345. homePageVO.setPacsFee(rs.getString("pacsFee"));//影像学诊断费
  346. homePageVO.setClinicDiagnoseFee(rs.getString("clinicDiagnoseFee"));//临床诊断项目费
  347. homePageVO.setNotOperationFee(rs.getString("notOperationFee"));//非手术治疗项目费
  348. homePageVO.setClinicPhysicFee(rs.getString("clinicPhysicFee"));//临床物理治疗费
  349. homePageVO.setOperationTreatFee(rs.getString("operationTreatFee"));//手术治疗费
  350. homePageVO.setAnaesthesiaFee(rs.getString("anaesthesiaFee"));//麻醉费
  351. homePageVO.setOperationFee(rs.getString("operationFee"));//手术费
  352. homePageVO.setHealthTypeFee(rs.getString("healthTypeFee"));//康复类
  353. homePageVO.setChnTreatFee(rs.getString("chnTreatFee"));//中医治疗费
  354. homePageVO.setWesternMedFee(rs.getString("westernMedFee"));//西药费
  355. homePageVO.setAntibiosisFee(rs.getString("antibiosisFee"));//抗菌药物费用
  356. homePageVO.setChnMedFee(rs.getString("chnMedFee"));//中成药费
  357. homePageVO.setChnHerbFee(rs.getString("chnHerbFee"));//中草药费
  358. homePageVO.setBloodFee(rs.getString("bloodFee"));//血费
  359. homePageVO.setAlbumenFee(rs.getString("albumenFee"));//白蛋白类制品费
  360. homePageVO.setGlobulinFee(rs.getString("globulinFee"));//球蛋白类制品费
  361. homePageVO.setBloodFactorFee(rs.getString("bloodFactorFee"));//凝血因子类制品费
  362. homePageVO.setCellFactorFee(rs.getString("cellFactorFee"));//细胞因子类制品费
  363. homePageVO.setCheckMaterialFee(rs.getString("checkMaterialFee"));//检查用一次性医用材料费
  364. homePageVO.setTreatMaterialFee(rs.getString("treatMaterialFee"));//治疗用一次性医用材料费
  365. homePageVO.setOperationMaterialFee(rs.getString("operationMaterialFee"));//手术用一次性医用材料费
  366. homePageVO.setOtherTypeFee(rs.getString("otherTypeFee"));//其他类其他费
  367. homePageVO.setSingleDiagManage(rs.getString("singleDiagManage"));//单病种管理
  368. homePageVO.setClinicPathwayManage(rs.getString("clinicPathwayManage"));//临床路径管理
  369. homePageVO.setIsOutpatientBehospital(rs.getString("isOutpatientBehospital"));//门诊与住院
  370. homePageVO.setIsLeaveBehospital(rs.getString("isLeaveBehospital"));//入院与出院
  371. homePageVO.setIsOperationBeforeAfter(rs.getString("isOperationBeforeAfter"));//术前与术后
  372. homePageVO.setIsClinicPathology(rs.getString("isClinicPathology"));//临床与病理
  373. homePageVO.setIsRadiatePathology(rs.getString("isRadiatePathology"));//放射与病理
  374. homePageVO.setRescueSuccessNum(rs.getString("rescueNum"));//病人抢救次数
  375. homePageVO.setRescueSuccessNum(rs.getString("rescueSuccessNum"));//病人抢救成功次数
  376. homePageVO.setIsAutoLeavehospital(rs.getString("isAutoLeavehospital"));//是否为自动出院
  377. homePageVO.setReturnToType(rs.getString("returnToType"));//转归情况HomePage homePageVO=new HomePage();
  378. homePageVO.setIsPhysicalRestraint(rs.getString("isPhysicalRestraint"));//住院期间身体约束
  379. homePageVO.setTbiBehospitalBeforeTime(rs.getString("tbiBehospitalBeforeTime"));//颅脑损伤患者昏迷时间(入院前)
  380. homePageVO.setIsPhysicalRestraint(rs.getString("isPhysicalRestraint"));//颅脑损伤患者昏迷时间(入院后)
  381. homePageVO.setIsFallBed(rs.getString("isFallBed"));//住院期间是否发生跌倒或坠床
  382. homePageVO.setIsNosocomialInfection(rs.getString("isNosocomialInfection"));//医院感染
  383. homePageVO.setIsIntoIcu(rs.getString("isIntoIcu"));//入住ICU情况
  384. homePageVO.setIsComplications(rs.getString("isComplications"));//并发症情况
  385. homePageVO.setIsPressureSore(rs.getString("isPressureSore"));//是否发生压疮
  386. homePageVO.setIsBehospitalPressureSore(rs.getString("isBehospitalPressureSore"));//是否住院期间发生压疮
  387. homePageVO.setIsUnplannedReoperation(rs.getString("isUnplannedReoperation"));//非计划再次手术
  388. homePageVO.setTreatmentResults(rs.getString("treatmentResults"));//治疗结果
  389. homePageVO.setComplicationsResults(rs.getString("complicationsResults"));//并发症
  390. homePageVO.setInfectionSite(rs.getString("infectionSite"));//感染部位
  391. homePageVO.setIsBeInDanger(rs.getString("isBeInDanger"));//住院期间有无告病危
  392. homePageList.add(homePageVO);
  393. }
  394. // }
  395. } catch (Exception e) {
  396. e.printStackTrace();
  397. }finally {
  398. close();
  399. }
  400. return homePageList;
  401. }
  402. /**
  403. * 从视图中获取医嘱信息
  404. * @return
  405. */
  406. public List<DoctorAdvice> getDoctorAdvice(String sql){
  407. List<DoctorAdvice> doctorAdviceList=Lists.newLinkedList();
  408. try {
  409. TZDBConnForHis dbconn=new TZDBConnForHis();
  410. ResultSet rs =dbconn.Query(sql, null);
  411. while(rs.next()){
  412. DoctorAdvice doctorAdviceVO=new DoctorAdvice();
  413. doctorAdviceVO.setDoctorAdviceId(rs.getString("doctorAdviceId"));//病人医嘱ID
  414. doctorAdviceVO.setHospitalId(HOSPITAL_ID);//医院ID
  415. doctorAdviceVO.setBehospitalCode(rs.getString("behospitalCode")+"_"+rs.getString("behospitalNum"));//病人ID
  416. doctorAdviceVO.setOrderDoctorName(rs.getString("orderDoctorName"));//医生开单判别
  417. doctorAdviceVO.setFrequency(rs.getString("frequency"));//医嘱频率判别
  418. doctorAdviceVO.setParentTypeId(rs.getString("parentTypeId"));//父类医嘱ID
  419. doctorAdviceVO.setDoctorAdviceType(rs.getString("doctorAdviceType"));//医嘱类型判别
  420. doctorAdviceVO.setUsageNum(rs.getString("usageNum"));//一次使用数量
  421. doctorAdviceVO.setUsageUnit(rs.getString("usageUnit"));//一次用量单位
  422. doctorAdviceVO.setDose(rs.getString("dose"));//医嘱单次剂量
  423. doctorAdviceVO.setDoseUnit(rs.getString("doseUnit"));//单次剂量单位
  424. doctorAdviceVO.setMedModeType(rs.getString("medModeType"));//给药方式
  425. doctorAdviceVO.setMedicineType(rs.getString("medicineType"));//药品类型
  426. doctorAdviceVO.setDaFrequency(rs.getString("daFrequency"));//医嘱频率
  427. doctorAdviceVO.setDaDealType(rs.getString("daDealType"));//医嘱处理类型
  428. doctorAdviceVO.setDaStartDate(StringUtils.isNotBlank(rs.getString("daStartDate"))?DateUtil.parseDateTime(rs.getString("daStartDate")):null);//医嘱开始时间
  429. doctorAdviceVO.setDaItemName(rs.getString("daItemName"));//医嘱项目名称
  430. doctorAdviceVO.setDaStatus(rs.getString("daStatus"));//医嘱状态判别
  431. doctorAdviceVO.setDaStopDate(StringUtils.isNotBlank(rs.getString("daStopDate"))?DateUtil.parseDateTime(rs.getString("daStopDate")):null);//医嘱结束时间
  432. doctorAdviceVO.setDaGroupNo(rs.getString("daGroupCode"));//医嘱同组序号
  433. doctorAdviceVO.setDaPrescriptionType(rs.getString("daPrescriptionType"));//医嘱处方类型
  434. doctorAdviceVO.setDaMedType(rs.getString("daMedType"));//医嘱领药类型
  435. doctorAdviceVO.setDoctorNotice(rs.getString("doctoryNotice"));//医生嘱托
  436. // doctorAdviceVO.setDoctorId(rs.getString("KDYSID"));//开单医生ID
  437. doctorAdviceVO.setDoctorName(rs.getString("doctorName"));//开单医生姓名
  438. doctorAdviceList.add(doctorAdviceVO);
  439. }
  440. } catch (Exception e) {
  441. e.printStackTrace();
  442. }finally {
  443. close();
  444. }
  445. return doctorAdviceList;
  446. }
  447. /**
  448. * 从视图中获取化验信息
  449. * @return
  450. */
  451. public List<MedLisInfo> getLisInfo(String sql){
  452. List<MedLisInfo> medLisInfos=Lists.newLinkedList();
  453. try {
  454. TZDBConnForHis dbconn=new TZDBConnForHis();
  455. ResultSet rs =dbconn.Query(sql, null);
  456. while(rs.next()){
  457. MedLisInfo medLisInfo=new MedLisInfo();
  458. medLisInfo.setRepNo(rs.getString("repNo"));//报告单号
  459. medLisInfo.setHospitalId(HOSPITAL_ID+"");//医院ID
  460. medLisInfo.setBehospitalCode(rs.getString("behospitalCode")+"_"+rs.getString("behospitalNum"));//住院病人ID
  461. medLisInfo.setRepName(rs.getString("repName"));//报告名称
  462. medLisInfo.setRepType(rs.getString("repType"));//报告类型代码
  463. medLisInfo.setRepTypeName(rs.getString("repTypeName"));//检查类型名称
  464. medLisInfo.setSlideType(rs.getString("slideType"));//标本名称
  465. medLisInfo.setRepDate(rs.getString("repDate"));//发布时间
  466. medLisInfo.setCheckDate(rs.getString("checkDate"));//报告检查时间
  467. medLisInfo.setApplyDoctor(rs.getString("applyDoctor"));//申请医生
  468. medLisInfo.setDeptName(rs.getString("deptName"));//开单科室名称
  469. medLisInfo.setDeptId(rs.getString("deptId"));//开单科室代码
  470. medLisInfo.setRegisterFlag(rs.getString("registerFlag"));//报告单状态
  471. medLisInfos.add(medLisInfo);
  472. }
  473. } catch (Exception e) {
  474. e.printStackTrace();
  475. }finally {
  476. close();
  477. }
  478. return medLisInfos;
  479. }
  480. /**
  481. * 从视图中获取化验结果
  482. * @return
  483. */
  484. public List<MedLisResult> getLisResult(String sql){
  485. List<MedLisResult> medLisResultList=Lists.newLinkedList();
  486. try {
  487. TZDBConnForHis dbconn=new TZDBConnForHis();
  488. ResultSet rs =dbconn.Query(sql, null);
  489. while(rs.next()){
  490. MedLisResult medLisResult=new MedLisResult();
  491. medLisResult.setRepNo(rs.getString("repNo"));//报告单号
  492. medLisResult.setHospitalId(HOSPITAL_ID);//医院ID
  493. medLisResult.setBehospitalCode(rs.getString("behospitalCode")+"_"+rs.getString("behospitalNum"));//住院病人ID
  494. medLisResult.setItemCode(rs.getString("itemCode"));//报告代码
  495. medLisResult.setItemName(rs.getString("itemName"));//报告名称
  496. medLisResult.setResult(rs.getString("result"));//检验结果
  497. medLisResult.setReferenceMin(rs.getString("referenceMin"));//最小参考值
  498. medLisResult.setReferenceMax(rs.getString("referenceMax"));//最大参考值
  499. medLisResult.setUnit(rs.getString("unit"));//单位
  500. medLisResult.setAbnormal(rs.getString("abnormal"));//异常标志
  501. medLisResult.setColor(rs.getString("color"));//异常颜色
  502. medLisResultList.add(medLisResult);
  503. }
  504. } catch (Exception e) {
  505. e.printStackTrace();
  506. }finally {
  507. close();
  508. }
  509. return medLisResultList;
  510. }
  511. /**
  512. * 获取检查信息
  513. * @param sql
  514. * @return
  515. */
  516. public List<MedPacsInfo> getPacsInfo(String sql){
  517. List<MedPacsInfo> medPacsInfos=Lists.newLinkedList();
  518. try {
  519. TZDBConnForHis dbconn=new TZDBConnForHis();
  520. ResultSet rs =dbconn.Query(sql, null);
  521. while(rs.next()){
  522. MedPacsInfo medPacsInfo=new MedPacsInfo();
  523. medPacsInfo.setRepNo(rs.getString("repNo"));//报告单号
  524. medPacsInfo.setHospitalId(HOSPITAL_ID+"");//医院ID
  525. medPacsInfo.setBehospitalCode(rs.getString("behospitalCode")+"_"+rs.getString("behospitalNum"));//住院病人ID
  526. medPacsInfo.setRepName(rs.getString("repName"));//报告名称
  527. medPacsInfo.setRepType(rs.getString("repType"));//报告类型代码
  528. medPacsInfo.setRepTypeName(rs.getString("repTypeName"));//检查类型名称
  529. medPacsInfo.setPart(rs.getString("part"));//检查部位
  530. medPacsInfo.setRepDate(rs.getString("repDate"));//发布时间
  531. medPacsInfo.setCheckDate(rs.getString("checkDate"));//报告检查时间
  532. medPacsInfo.setApplyDoctor(rs.getString("applyDoctor"));//申请医生
  533. medPacsInfo.setChecker(rs.getString("checker"));//报告审核医生
  534. medPacsInfo.setReportDoctor(rs.getString("reportDoctor"));//报告医生
  535. medPacsInfo.setDeptName(rs.getString("deptName"));//开单科室名称
  536. medPacsInfo.setDeptId(rs.getString("deptId"));//开单科室代码
  537. medPacsInfos.add(medPacsInfo);
  538. }
  539. } catch (Exception e) {
  540. e.printStackTrace();
  541. }finally {
  542. close();
  543. }
  544. return medPacsInfos;
  545. }
  546. /**
  547. * 从视图中获取检查结果
  548. * @return
  549. */
  550. public List<MedPacsResult> getPacsResult(String sql){
  551. List<MedPacsResult> medPacsResultList=Lists.newLinkedList();
  552. try {
  553. TZDBConnForHis dbconn=new TZDBConnForHis();
  554. ResultSet rs =dbconn.Query(sql, null);
  555. while(rs.next()){
  556. MedPacsResult medPacsResult=new MedPacsResult();
  557. medPacsResult.setRepNo(rs.getString("repNo"));//报告单号
  558. medPacsResult.setHospitalId(HOSPITAL_ID);
  559. medPacsResult.setBehospitalCode(rs.getString("behospitalCode")+"_"+rs.getString("behospitalNum"));//住院病人ID
  560. medPacsResult.setReptName(rs.getString("repName"));//报告名称
  561. medPacsResult.setPart(rs.getString("part"));//检查部位
  562. medPacsResult.setClinicSight(rs.getString("clinicSight"));//检查所见
  563. medPacsResult.setReptDiag(rs.getString("reptDiag"));//检查结果(诊断)
  564. medPacsResult.setClinicDiag(rs.getString("clinicDiag"));//临床诊断
  565. medPacsResult.setApplyDoctor(rs.getString("applyDoctor"));//申请医生
  566. medPacsResult.setCheckerDoctor(rs.getString("checker"));//审核医生
  567. medPacsResult.setReportDoctor(rs.getString("reportDoctor"));//报告医生
  568. medPacsResult.setDeptName(rs.getString("deptName"));//科室名称
  569. medPacsResultList.add(medPacsResult);
  570. }
  571. } catch (Exception e) {
  572. e.printStackTrace();
  573. }finally {
  574. close();
  575. }
  576. return medPacsResultList;
  577. }
  578. /**
  579. * 从视图中获取入院登记
  580. * @return
  581. */
  582. public List<BehospitalInfo> getBehospitalInfo(String sql){
  583. List<BehospitalInfo> behospitalInfoList=Lists.newLinkedList();
  584. try {
  585. TZDBConnForHis dbconn=new TZDBConnForHis();
  586. ResultSet rs =dbconn.Query(sql, null);
  587. while(rs.next()){
  588. BehospitalInfo behospitalInfo=new BehospitalInfo();
  589. behospitalInfo.setBehospitalCode(rs.getString("behospitalCode")+"_"+rs.getString("behospitalNum"));//病人住院ID
  590. behospitalInfo.setHospitalId(HOSPITAL_ID);
  591. behospitalInfo.setName(rs.getString("Name"));//姓名
  592. behospitalInfo.setSex(rs.getString("Sex"));//性别
  593. behospitalInfo.setBirthday(StringUtils.isNotBlank(rs.getString("Birthday"))?DateUtil.parseDate(rs.getString("Birthday")):null);//出生日期
  594. behospitalInfo.setFileCode(rs.getString("fileCode"));//住院号
  595. behospitalInfo.setWardCode(rs.getString("wardCode"));//病区编码
  596. behospitalInfo.setWardName(rs.getString("wardName"));//病区名称
  597. behospitalInfo.setBehDeptId(rs.getString("behDeptId"));//住院科室ID
  598. behospitalInfo.setBehDeptName(rs.getString("behDeptName"));//住院科室名称
  599. behospitalInfo.setBedCode(rs.getString("bedCode"));//床位号
  600. behospitalInfo.setBedName(rs.getString("bedName"));//床位名称
  601. behospitalInfo.setInsuranceName(rs.getString("charge_type"));//医保类别
  602. behospitalInfo.setJobType(rs.getString("jobType"));//职业
  603. behospitalInfo.setBehospitalDate(StringUtils.isNotBlank(rs.getString("behospitalDate"))?DateUtil.parseDateTime(rs.getString("behospitalDate")):null);//入院时间
  604. behospitalInfo.setLeaveHospitalDate(StringUtils.isNotBlank(rs.getString("leaveHospitalDate"))?DateUtil.parseDateTime(rs.getString("leaveHospitalDate")):null);//出院时间
  605. behospitalInfo.setDiagnoseIcd(rs.getString("diagnoseIcd"));//疾病ICD编码
  606. behospitalInfo.setDiagnose(rs.getString("Diagnose"));//疾病名称
  607. behospitalInfo.setBehDoctorId(rs.getString("behDoctorId"));//住院医生ID
  608. behospitalInfo.setBehDoctorName(rs.getString("behDoctorName"));//住院医生姓名
  609. behospitalInfo.setDirectorDoctorId(rs.getString("directorDoctorId"));//主任医生ID
  610. behospitalInfo.setDirectorDoctorName(rs.getString("directorDoctorName"));//主任医生姓名
  611. behospitalInfo.setDoctorId(rs.getString("doctorId"));//主治医生ID
  612. behospitalInfo.setDoctorName(rs.getString("doctorName"));//主治医生姓名
  613. behospitalInfo.setIsPlacefile(rs.getString("isPlacefile"));//是否归档
  614. behospitalInfo.setPlacefileDate(StringUtils.isNotBlank(rs.getString("placefileDate"))?DateUtil.parseDateTime(rs.getString("placefileDate")):null);//归档时间
  615. // behospitalInfo.setInstate(rs.getString("Instate"));//病人状态
  616. behospitalInfoList.add(behospitalInfo);
  617. }
  618. } catch (Exception e) {
  619. e.printStackTrace();
  620. }finally {
  621. close();
  622. }
  623. return behospitalInfoList;
  624. }
  625. /**
  626. * 从视图中获取文书信息
  627. * @return
  628. */
  629. public List<MedicalRecord> getMedicalRecord(String sql){
  630. List<MedicalRecord> medicalRecordList=Lists.newLinkedList();
  631. try {
  632. TZDBConnForHis dbconn=new TZDBConnForHis();
  633. ResultSet rs =dbconn.Query(sql, null);
  634. while(rs.next()){
  635. MedicalRecord medicalRecord=new MedicalRecord();
  636. medicalRecord.setRecId(rs.getString("recId"));//文书序号
  637. medicalRecord.setHospitalId(HOSPITAL_ID);//医院ID
  638. medicalRecord.setBehospitalCode(rs.getString("behospitalCode")+"_"+rs.getString("behospitalNum"));//病人住院ID
  639. medicalRecord.setOrgCode(rs.getString("orgCode"));//组织机构代码
  640. medicalRecord.setRecTypeId(rs.getString("recTypeId"));//病历类别编号
  641. medicalRecord.setRecDate(StringUtils.isNotBlank(rs.getString("recDate"))?DateUtil.parseDateTime(rs.getString("recDate")):null);//病历生成日期
  642. medicalRecord.setRecTitle(rs.getString("recTitle"));//病历模板名称
  643. medicalRecordList.add(medicalRecord);
  644. }
  645. } catch (Exception e) {
  646. e.printStackTrace();
  647. }finally {
  648. close();
  649. }
  650. return medicalRecordList;
  651. }
  652. /**
  653. * 关闭数据库
  654. * @param conn
  655. */
  656. public void closeConnection(Connection conn){
  657. try{
  658. if(conn != null){
  659. conn.close();
  660. }
  661. }
  662. catch(Exception e){
  663. System.out.println("数据库关闭失败");
  664. e.printStackTrace();
  665. }
  666. }
  667. /**
  668. * 新赠评分插入表中
  669. * @return
  670. */
  671. public Integer setQcMessAge(SentEntryRecordDTO sentEntryRecordDTO) throws SQLException {
  672. try {
  673. String patientId=sentEntryRecordDTO.getBehospitalCode().split("_")[0];
  674. String visitId=sentEntryRecordDTO.getBehospitalCode().split("_")[1];
  675. int re=0;
  676. connection = getConnection();
  677. connection.setAutoCommit(false);//事物开始
  678. PreparedStatement state=connection.prepareStatement("insert into MEDICAL_QC_MSG " +
  679. "(PATIENT_ID,VISIT_ID,DOCTOR_IN_CHARGE,QA_EVENT_TYPE,QC_MSG_CODE,MESSAGE,ISSUED_BY,ISSUED_DATE_TIME,TOPIC_ID,DEPT_STAYED,MSG_STATUS)"+
  680. "values(?,?,?,?,?,?,?,to_date(?,'yyyy-mm-dd hh24:mi:ss'),?,?,?)");
  681. state.setString(1, patientId);
  682. state.setString(2, visitId);
  683. state.setString(3,StringUtils.isNotEmpty(sentEntryRecordDTO.getDoctorName())?sentEntryRecordDTO.getDoctorName():sentEntryRecordDTO.getCheckName());
  684. state.setString(4,StringUtils.isNotEmpty(sentEntryRecordDTO.getModeName())?sentEntryRecordDTO.getModeName():"其他");
  685. state.setInt(5,1511);
  686. state.setString(6,sentEntryRecordDTO.getMsg());
  687. state.setString(7,"评价质控");
  688. state.setString(8, DateUtil.formatDateTime(DateUtil.now()));
  689. state.setString(9,StringUtils.isNotEmpty(sentEntryRecordDTO.getModeName())?sentEntryRecordDTO.getModeName():"其他");
  690. state.setString(10,sentEntryRecordDTO.getDeptId());
  691. state.setInt(11,0);
  692. re = state.executeUpdate();
  693. if(re < 0){ //插入失败
  694. connection.rollback(); //回滚
  695. state.close();
  696. closeConnection(connection);
  697. return re;
  698. }
  699. connection.commit(); //插入正常
  700. state.close();
  701. closeConnection(connection);
  702. return re;
  703. } catch (Exception e) {
  704. e.printStackTrace();
  705. throw e;
  706. }finally {
  707. close();
  708. }
  709. }
  710. /**
  711. * 删除评分表中的对应数据
  712. * @return
  713. */
  714. public Integer DeleteQcMessAge(SentEntryRecordDTO sentEntryRecordDTO) throws SQLException {
  715. try {
  716. String patientId=sentEntryRecordDTO.getBehospitalCode().split("_")[0];
  717. String visitId=sentEntryRecordDTO.getBehospitalCode().split("_")[1];
  718. int re=0;
  719. connection = getConnection();
  720. connection.setAutoCommit(false);//事物开始
  721. String sql ="delete MEDICAL_QC_MSG where PATIENT_ID = '"+patientId+"' and VISIT_ID = '"
  722. +visitId+"' and MESSAGE = '"+sentEntryRecordDTO.getMsg()+"'";
  723. PreparedStatement state=connection.prepareStatement(sql);
  724. re = state.executeUpdate();
  725. if(re < 0){ //删除失败
  726. connection.rollback(); //回滚
  727. state.close();
  728. closeConnection(connection);
  729. return re;
  730. }
  731. connection.commit(); //删除正常
  732. state.close();
  733. closeConnection(connection);
  734. return re;
  735. } catch (Exception e) {
  736. e.printStackTrace();
  737. throw e;
  738. }finally {
  739. close();
  740. }
  741. }
  742. /**
  743. * 修改评分表中对应数据
  744. * @return
  745. */
  746. public Integer UpdateQcMessAge(SentEntryRecordDTO sentEntryRecordDTO,String OldMsg) throws SQLException {
  747. try {
  748. String patientId=sentEntryRecordDTO.getBehospitalCode().split("_")[0];
  749. String visitId=sentEntryRecordDTO.getBehospitalCode().split("_")[1];
  750. int re=0;
  751. connection = getConnection();
  752. connection.setAutoCommit(false);//事物开始
  753. String sql =" update MEDICAL_QC_MSG set MESSAGE = '"+sentEntryRecordDTO.getMsg()+"' where PATIENT_ID = '"+patientId+"' and VISIT_ID = '"
  754. +visitId+"' and MESSAGE = '"+OldMsg+"'" ;
  755. PreparedStatement state=connection.prepareStatement(sql);
  756. re = state.executeUpdate();
  757. if(re < 0){ //修改失败
  758. connection.rollback(); //回滚
  759. state.close();
  760. closeConnection(connection);
  761. return re;
  762. }
  763. connection.commit(); //修改正常
  764. state.close();
  765. closeConnection(connection);
  766. return re;
  767. } catch (Exception e) {
  768. e.printStackTrace();
  769. throw e;
  770. }finally {
  771. close();
  772. }
  773. }
  774. }