ConsentParameter.java 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. package com.dbs.mplus.fatima.consent;
  2. import android.content.Context;
  3. import android.util.Log;
  4. import com.dbs.mplus.fatima.httpTask.HttpCon;
  5. import com.dbs.mplus.fatima.model.ConsentListVO;
  6. import com.dbs.mplus.fatima.model.ConsentSetListVO;
  7. import com.dbs.mplus.fatima.model.ConsentWriteListVO;
  8. import com.dbs.mplus.fatima.model.PatientInfoVO;
  9. import com.dbs.mplus.fatima.util.ConsentConfig;
  10. import com.dbs.mplus.fatima.util.Util;
  11. import org.json.JSONObject;
  12. import java.util.ArrayList;
  13. import java.util.HashMap;
  14. import java.util.concurrent.ExecutionException;
  15. public class ConsentParameter {
  16. private static final String TAG = "ConsentParameter";
  17. public ConsentParameter() {
  18. }
  19. public static HashMap<String, String> makeGlobalParam(PatientInfoVO patientInfoVO, String signDoctorId, Context mContext) {
  20. HashMap<String, String> result = new HashMap<String, String>();
  21. if (patientInfoVO == null) {
  22. } else {
  23. String nowDate = Util.logTime();
  24. String signImage = "";
  25. HashMap<String, String> mData = new HashMap<String, String>();
  26. mData.put("userid", signDoctorId);
  27. HttpCon httpCon = new HttpCon(ConsentConfig.HOST_HOSPITAL, mData, ConsentConfig.GET_SIGN_IMAGE);
  28. try {
  29. String rts = httpCon.execute().get();
  30. JSONObject object = Util.xmltoJsonObject(rts);
  31. String res = Util.xmlToJsonString(object);
  32. ArrayList<HashMap<String, String>> mapArrayList = Util.parseJSON(mContext, res);
  33. if (mapArrayList.size() > 0) {
  34. signImage = mapArrayList.get(0).get("SignImage");
  35. }
  36. } catch (ExecutionException e) {
  37. e.printStackTrace();
  38. } catch (InterruptedException e) {
  39. e.printStackTrace();
  40. }
  41. result.put("userid", signDoctorId);
  42. result.put("IO_device", "M");
  43. result.put("visitType", patientInfoVO.getVisitType());
  44. result.put("IO_signdate", nowDate);
  45. result.put("IO_signtime", nowDate);
  46. result.put("IO_printtime", nowDate);
  47. result.put("IO_maindr", patientInfoVO.getMainDrNm().equals("") ? "" : patientInfoVO.getMainDrNm());
  48. result.put("IO_SIGNIMG", signImage);
  49. // 2017.8.22 이전 작업)) 응급일 경우 ioerdrNm에 실제 주치의가 들어오기때문에 이걸로 변경해줌.
  50. // 2017.8.22 - 응급인 경우 조건 추가 (기존에 visitType 체크가 없어서 응급통해서 입원한경우(?) 문제됨)
  51. // 병원 담당자 확인 받고 작업한 내용임
  52. if (patientInfoVO.getVisitType().equals("E") && !patientInfoVO.getErDrNm().equals("")) {
  53. result.put("IO_maindr", patientInfoVO.getErDrNm());
  54. }
  55. }
  56. return result;
  57. }
  58. public static ArrayList<HashMap<String, Object>> makeNewConsentParam(PatientInfoVO patientInfoVO, ArrayList consentList, String userName, Context mContext) {
  59. ArrayList<HashMap<String, Object>> result = new ArrayList<HashMap<String, Object>>();
  60. for (int i = 0; i < consentList.size(); i++) {
  61. ConsentSetListVO consentSetListVO = (ConsentSetListVO) consentList.get(i);
  62. String ocrTag = getOcrTag(mContext);
  63. HashMap<String, Object> consentItem = new HashMap<String, Object>();
  64. consentItem.put("newConsent", "true");
  65. consentItem.put("hospitalCretno", patientInfoVO.getCretNo());
  66. consentItem.put("ward", patientInfoVO.getWard());
  67. consentItem.put("roomNo", patientInfoVO.getRoomNo());
  68. consentItem.put("IO_ocr_cd", ocrTag);
  69. consentItem.put("outDate", patientInfoVO.getDschDd());
  70. consentItem.put("mainDrId", patientInfoVO.getMainDrId());
  71. consentItem.put("guid", consentSetListVO.getFormGuid());
  72. consentItem.put("IO_formname", consentSetListVO.getFormName());
  73. consentItem.put("IO_INPUTNM", userName);
  74. consentItem.put("formCd", consentSetListVO.getFormCd());
  75. consentItem.put("formRid", consentSetListVO.getFormRid());
  76. consentItem.put("IO_Pt_ID", patientInfoVO.getPid());
  77. consentItem.put("IO_sex_age_y_m", patientInfoVO.getSa());
  78. consentItem.put("IO_Pt_name", patientInfoVO.getPatientNm());
  79. consentItem.put("IO_JuminNo", patientInfoVO.getJuminNo());
  80. consentItem.put("IO_PT_birthday", patientInfoVO.getJuminNo().split("-")[0]);
  81. consentItem.put("IO_roomNo", patientInfoVO.getRoomNo());
  82. consentItem.put("IO_ADdate", Util.addSlashDate(patientInfoVO.getAdDate()));
  83. consentItem.put("IO_Dept", patientInfoVO.getDeptHngNm());
  84. consentItem.put("IO_Dept2", patientInfoVO.getDeptEngNm());
  85. consentItem.put("IO_DeptCd", patientInfoVO.getDeptCd());
  86. // consentItem.put("IO_OPdept", patientInfoVO.getDeptHngNm());
  87. consentItem.put("IO_OPdept", "");
  88. consentItem.put("IO_OPdr", patientInfoVO.getOpDrNm());
  89. consentItem.put("IO_Dx", patientInfoVO.getDxNm());
  90. consentItem.put("IO_bp", patientInfoVO.getBp());
  91. consentItem.put("IO_dm", patientInfoVO.getDm());
  92. consentItem.put("IO_heart", patientInfoVO.getHeart());
  93. consentItem.put("IO_kidney", patientInfoVO.getKidney());
  94. consentItem.put("IO_respiration", patientInfoVO.getRespiration());
  95. consentItem.put("IO_hx", patientInfoVO.getHx());
  96. consentItem.put("IO_allergy", patientInfoVO.getAllergy());
  97. consentItem.put("IO_drug", patientInfoVO.getDrug());
  98. consentItem.put("IO_smoking", patientInfoVO.getSmoking());
  99. consentItem.put("IO_idio", patientInfoVO.getIdio());
  100. consentItem.put("IO_nacrotics", patientInfoVO.getNacrotics());
  101. consentItem.put("IO_airway", patientInfoVO.getAirway());
  102. consentItem.put("IO_hemorrhage", patientInfoVO.getHemorrhage());
  103. consentItem.put("IO_status_etc", patientInfoVO.getStatusEtc());
  104. if (consentItem.get("ward").toString().length() > 0 && consentItem.get("roomNo").toString().length() > 0) {
  105. consentItem.put("IO_roomNo", consentItem.get("ward") + "/" + consentItem.get("roomNo"));
  106. } else {
  107. consentItem.put("IO_roomNo", "");
  108. }
  109. // 외과>소화기내과인 경우 시술의, 수술의 설정. 2017/1/3 고객요구사항
  110. if (patientInfoVO.getVisitType().equals("O") && patientInfoVO.getDeptCd().equals("2010300000")) {
  111. consentItem.put("IO_opdr", patientInfoVO.getMainDrNm());
  112. }
  113. result.add(consentItem);
  114. }
  115. return result;
  116. }
  117. public static ArrayList<HashMap<String, Object>> makeConsent(PatientInfoVO patientInfoVO, ArrayList consentList, String userName, String type, Context mContext) {
  118. ArrayList<HashMap<String, Object>> result = new ArrayList<HashMap<String, Object>>();
  119. for (int i = 0; i < consentList.size(); i ++) {
  120. ConsentListVO consentListVO = null;
  121. ConsentWriteListVO consentWriteListVO = null;
  122. String orderNo = "";
  123. String orderCd = "";
  124. String ocrNumber = "";
  125. String cretNo = "";
  126. String consentState = "";
  127. String consentMstRid = "";
  128. String consentName = "";
  129. String formCd = "";
  130. String formRid = "";
  131. String formGuid = "";
  132. if (type.equals("patient")) {
  133. consentListVO = (ConsentListVO) consentList.get(i);
  134. orderNo = consentListVO.getOrderNo();
  135. orderCd = consentListVO.getOrderCd();
  136. ocrNumber = consentListVO.getOcrNumber();
  137. cretNo = consentListVO.getCretno();
  138. consentState = consentListVO.getConsentState();
  139. consentMstRid = consentListVO.getConsentMstRid();
  140. consentName = consentListVO.getConsentName();
  141. formCd = consentListVO.getFormCd();
  142. formRid = consentListVO.getFormRid();
  143. formGuid = consentListVO.getFormGuid();
  144. } else {
  145. consentWriteListVO = (ConsentWriteListVO) consentList.get(i);
  146. orderNo = consentWriteListVO.getOrderNo();
  147. orderCd = consentWriteListVO.getOrderCd();
  148. ocrNumber = consentWriteListVO.getOcrNumber();
  149. cretNo = consentWriteListVO.getCretNo();
  150. consentState = consentWriteListVO.getConsentState();
  151. consentMstRid = consentWriteListVO.getConsentMstRid();
  152. consentName = consentWriteListVO.getFormNm();
  153. formCd = consentWriteListVO.getFormCd();
  154. formRid = consentWriteListVO.getFormRid();
  155. formGuid = consentWriteListVO.getFormGuid();
  156. }
  157. HashMap<String, Object> consentItem = new HashMap<String, Object>();
  158. // String ocrTag = getOcrTag();
  159. String newConsent = "false";
  160. if (consentState.equals(ConsentConfig.UNFINISHED)) {
  161. newConsent = "true";
  162. }
  163. consentItem.put("newConsent", newConsent);
  164. consentItem.put("hospitalCretno", patientInfoVO.getCretNo());
  165. consentItem.put("ward", patientInfoVO.getWard());
  166. consentItem.put("roomNo", patientInfoVO.getRoomNo());
  167. consentItem.put("orderNo", orderNo);
  168. consentItem.put("orderCd", orderCd);
  169. consentItem.put("IO_ocr_cd", ocrNumber);
  170. consentItem.put("consentCretno", cretNo);
  171. consentItem.put("outDate", patientInfoVO.getDschDd());
  172. consentItem.put("mainDrId", patientInfoVO.getMainDrId());
  173. consentItem.put("consentState", consentState);
  174. consentItem.put("rid", consentMstRid);
  175. consentItem.put("IO_formname", consentName);
  176. consentItem.put("IO_INPUTNM", userName);
  177. consentItem.put("formCd", formCd);
  178. consentItem.put("formRid", formRid);
  179. consentItem.put("IO_Pt_ID", patientInfoVO.getPid());
  180. consentItem.put("IO_sex_age_y_m", patientInfoVO.getSa());
  181. consentItem.put("IO_Pt_name", patientInfoVO.getPatientNm());
  182. consentItem.put("IO_JuminNo", patientInfoVO.getJuminNo());
  183. consentItem.put("IO_PT_birthday", patientInfoVO.getJuminNo().split("-")[0]);
  184. consentItem.put("IO_ADdate", patientInfoVO.getAdDate());
  185. consentItem.put("IO_Dept", patientInfoVO.getDeptHngNm());
  186. consentItem.put("IO_Dept2", patientInfoVO.getDeptEngNm());
  187. consentItem.put("IO_DeptCd", patientInfoVO.getDeptCd());
  188. consentItem.put("IO_OPdept", patientInfoVO.getOpDeptNm());
  189. consentItem.put("IO_OPdr", patientInfoVO.getOpDrNm());
  190. consentItem.put("IO_Dx", patientInfoVO.getDxNm());
  191. consentItem.put("IO_bp", patientInfoVO.getBp());
  192. consentItem.put("IO_dm", patientInfoVO.getDm());
  193. consentItem.put("IO_heart", patientInfoVO.getHeart());
  194. consentItem.put("IO_kidney", patientInfoVO.getKidney());
  195. consentItem.put("IO_respiration", patientInfoVO.getRespiration());
  196. consentItem.put("IO_hx", patientInfoVO.getHx());
  197. consentItem.put("IO_allergy", patientInfoVO.getAllergy());
  198. consentItem.put("IO_drug", patientInfoVO.getDrug());
  199. consentItem.put("IO_smoking", patientInfoVO.getSmoking());
  200. consentItem.put("IO_idio", patientInfoVO.getIdio());
  201. consentItem.put("IO_nacrotics", patientInfoVO.getNacrotics());
  202. consentItem.put("IO_airway", patientInfoVO.getAirway());
  203. consentItem.put("IO_hemorrhage", patientInfoVO.getHemorrhage());
  204. consentItem.put("IO_status_etc", patientInfoVO.getStatusEtc());
  205. if (newConsent.equals("true")) {
  206. consentItem.put("guid", formGuid);
  207. }
  208. if (consentItem.get("ward").toString().length() > 0 && consentItem.get("roomNo").toString().length() > 0) {
  209. consentItem.put("IO_roomNo", consentItem.get("ward") + "/" + consentItem.get("roomNo"));
  210. } else {
  211. consentItem.put("IO_roomNo", "");
  212. }
  213. if (patientInfoVO.getVisitType().equals("O") && patientInfoVO.getDeptCd().equals("2010300000")) {
  214. consentItem.put("IO_OPdr", patientInfoVO.getMainDrNm());
  215. }
  216. result.add(consentItem);
  217. }
  218. return result;
  219. }
  220. private static String getOcrTag(Context mContext) {
  221. String ocrTag = "";
  222. HashMap<String, String> mData = new HashMap<String, String>();
  223. HttpCon httpCon = new HttpCon(ConsentConfig.HOST_HOSPITAL, mData, ConsentConfig.GET_OCR_TAG);
  224. try {
  225. String result = httpCon.execute().get();
  226. JSONObject object = Util.xmltoJsonObject(result);
  227. String res = Util.xmlToJsonString(object);
  228. ArrayList<HashMap<String, String>> mapArrayList = Util.parseJSON(mContext, res);
  229. ocrTag = mapArrayList.get(0).get("GetOcrTagResult");
  230. } catch (ExecutionException e) {
  231. e.printStackTrace();
  232. } catch (InterruptedException e) {
  233. e.printStackTrace();
  234. }
  235. return ocrTag;
  236. }
  237. }