|
@@ -1,25 +1,217 @@
|
|
|
package com.dbs.mplus.knuh.consent;
|
|
|
|
|
|
import android.content.Context;
|
|
|
+import android.os.Build;
|
|
|
+import android.util.Log;
|
|
|
+
|
|
|
+import com.dbs.mplus.knuh.BuildConfig;
|
|
|
+import com.dbs.mplus.knuh.R;
|
|
|
+import com.dbs.mplus.knuh.activity.ConsentActivity;
|
|
|
+import com.dbs.mplus.knuh.httpTask.CallBack;
|
|
|
+import com.dbs.mplus.knuh.httpTask.HttpSoapConnection;
|
|
|
+import com.dbs.mplus.knuh.util.ConsentConfig;
|
|
|
+import com.dbs.mplus.knuh.util.Util;
|
|
|
+
|
|
|
+import org.ksoap2.serialization.SoapObject;
|
|
|
+
|
|
|
+import java.io.BufferedReader;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileReader;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.concurrent.ExecutionException;
|
|
|
|
|
|
import kr.co.clipsoft.eform.EFormToolkit;
|
|
|
import kr.co.clipsoft.eform.event.IEventHandler;
|
|
|
import kr.co.clipsoft.eform.event.ResultEventArgs;
|
|
|
+import kr.co.clipsoft.eform.type.enumtype.ResultCode;
|
|
|
|
|
|
-public class EFormSaveHandler implements IEventHandler<ResultEventArgs> {
|
|
|
+public class EFormSaveHandler implements IEventHandler<ResultEventArgs>, CallBack {
|
|
|
|
|
|
+ private static final String TAG = "EFormSaveHandler";
|
|
|
private Context mContext;
|
|
|
private EFormToolkit eFormToolkit;
|
|
|
+ private HashMap consentData;
|
|
|
+ private ConsentActivity instance = null;
|
|
|
+
|
|
|
+ private CallBack callBack = null;
|
|
|
+
|
|
|
+ private HashMap saveMapData = null;
|
|
|
|
|
|
+ private String buttonType = "";
|
|
|
|
|
|
- public EFormSaveHandler(Context mContext, EFormToolkit eFormToolkit) {
|
|
|
+ public EFormSaveHandler(Context mContext, EFormToolkit eFormToolkit, HashMap consentData) {
|
|
|
this.mContext = mContext;
|
|
|
this.eFormToolkit = eFormToolkit;
|
|
|
+ this.consentData = consentData;
|
|
|
+ this.callBack = this;
|
|
|
+ this.instance = (ConsentActivity) mContext;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void eventReceived(Object o, ResultEventArgs resultEventArgs) {
|
|
|
- eFormToolkit.sendEFormViewerOkEvent();
|
|
|
+
|
|
|
+// eFormToolkit.sendEFormViewerOkEvent();
|
|
|
+ saveMapData = createSaveData(resultEventArgs, consentData);
|
|
|
+ saveProcess(saveMapData, resultEventArgs);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private HashMap createSaveData(ResultEventArgs eventArgs, HashMap consentData) {
|
|
|
+ HashMap resultMap = new HashMap();
|
|
|
+ int index = eventArgs.getFormOpenSequence() - 1;
|
|
|
+ Log.e(TAG, "index -- > " + index);
|
|
|
+ HashMap<String, String> globalParam = (HashMap<String, String>) consentData.get("globalParam");
|
|
|
+ ArrayList<HashMap<String, String>> formListParam = (ArrayList<HashMap<String, String>>) consentData.get("formListParam");
|
|
|
+ HashMap<String, String> formParam = (HashMap<String, String>) formListParam.get(index);
|
|
|
+
|
|
|
+ String userId = Util.getStringPreference(mContext, "userInfo", "userId");
|
|
|
+ String userDeptCd = Util.getStringPreference(mContext, "userInfo", "deptCd");
|
|
|
+ String patientCode = globalParam.get("parCMDCHD_1PatientNo");
|
|
|
+ String clnDeptCode = globalParam.get("parCMDCHD_1DepartmentCd");
|
|
|
+ int formRid = Integer.parseInt(formParam.get("formRid"));
|
|
|
+ String formCd = formParam.get("formCd");
|
|
|
+ int consentMstRid = Integer.parseInt(formParam.get("rid"));
|
|
|
+ int rewriteConsentMstRid = 0;
|
|
|
+ String dataXml = eventArgs.getDataXml();
|
|
|
+ String deviceType = "AND";
|
|
|
+ String deviceIdentNo = Util.getMACAddress();
|
|
|
+ String vistType = globalParam.get("ordType");
|
|
|
+ String hosType = BuildConfig.INST_CD;
|
|
|
+ String clnDate = globalParam.get("parCMDCHD_1VisitDt"); //입원은 inDd, 외래는 ordDd;
|
|
|
+ String ward = globalParam.get("ward");
|
|
|
+ String roomCd = globalParam.get("parNUR_Fast_HospitalroomNo");
|
|
|
+ int orderNo = 0;
|
|
|
+ String orderName = "";
|
|
|
+ String orderCd = "";
|
|
|
+ String ocrCode = formParam.get("parCMSGBD_ocr_cd");
|
|
|
+ int cretNo = Integer.parseInt(globalParam.get("parCMSGBD_Cretno"));
|
|
|
+ String createUserName = userId;
|
|
|
+ String modifyUserName = userId;
|
|
|
+ String mainDrId = globalParam.get("mainDrId");
|
|
|
+ String pageCnt = String.valueOf(eventArgs.getTotalPagesCount());
|
|
|
+ String actKind = ""; // (임시 확인 : P), 인증 C, 삭제 CP
|
|
|
+ String clientType = "M";
|
|
|
+ String opRsrvNo = globalParam.get("parCMDCBD_OpRsrvNo");
|
|
|
+
|
|
|
+// Util.LOG(EFormSaveHandler.class, "globalParam -- > " + consentData.get("globalParam"));
|
|
|
+// Util.LOG(EFormSaveHandler.class, "formListParam -- > " + consentData.get("formListParam"));
|
|
|
+
|
|
|
+
|
|
|
+ String eptFilePath = eventArgs.getTempFilePath();
|
|
|
+ StringBuffer formXml = new StringBuffer();
|
|
|
+ if (eptFilePath != null && "".equals(eptFilePath) == false) {
|
|
|
+ try {
|
|
|
+ BufferedReader br = new BufferedReader(new FileReader(eptFilePath));
|
|
|
+ while (br.ready()) {
|
|
|
+ formXml.append(br.readLine());
|
|
|
+ }
|
|
|
+ } catch (Exception e1) {
|
|
|
+ e1.printStackTrace();
|
|
|
+ this.eFormToolkit.sendEFormViewerCancelEvent(mContext.getString(R.string.notReadEptFile));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ File eptFile = new File(eptFilePath);
|
|
|
+ eptFile.delete();
|
|
|
+
|
|
|
+ resultMap.put("userId", userId);
|
|
|
+ resultMap.put("userDeptCd", userDeptCd);
|
|
|
+ resultMap.put("patientCode", patientCode);
|
|
|
+ resultMap.put("clnDeptCode", clnDeptCode);
|
|
|
+ resultMap.put("formRid", formRid);
|
|
|
+ resultMap.put("formCd", formCd);
|
|
|
+ resultMap.put("consentMstRid", consentMstRid);
|
|
|
+ resultMap.put("rewriteConsentMstRid", rewriteConsentMstRid);
|
|
|
+ resultMap.put("formXml", formXml.toString());
|
|
|
+ resultMap.put("dataXml", dataXml);
|
|
|
+ resultMap.put("deviceType", deviceType);
|
|
|
+ resultMap.put("deviceIdentNo", deviceIdentNo);
|
|
|
+ resultMap.put("vistType", vistType);
|
|
|
+ resultMap.put("hosType", hosType);
|
|
|
+ resultMap.put("clnDate", clnDate);
|
|
|
+ resultMap.put("ward", ward);
|
|
|
+ resultMap.put("roomCd", roomCd);
|
|
|
+ resultMap.put("orderNo", orderNo);
|
|
|
+ resultMap.put("orderName", orderName);
|
|
|
+ resultMap.put("orderCd", orderCd);
|
|
|
+ resultMap.put("ocrCode", ocrCode);
|
|
|
+ resultMap.put("cretNo", cretNo);
|
|
|
+ resultMap.put("createUserName", createUserName);
|
|
|
+ resultMap.put("modifyUserName", modifyUserName);
|
|
|
+ resultMap.put("mainDrId", mainDrId);
|
|
|
+ resultMap.put("pageCnt", pageCnt);
|
|
|
+ resultMap.put("clientType", clientType);
|
|
|
+ resultMap.put("opRsrvNo", opRsrvNo);
|
|
|
+
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void saveProcess(HashMap saveData, ResultEventArgs eventArgs) {
|
|
|
+ buttonType = eventArgs.getResultCode().toString();
|
|
|
+ Log.e(TAG, "buttonType -- > " + buttonType);
|
|
|
+ switch (eventArgs.getResultCode()) {
|
|
|
+ case SAVE: // 인증저장
|
|
|
+ saveData.put("actKind", "C");
|
|
|
+ saveData.put("consentState", "CERTIFY_CMP");
|
|
|
+// eFormToolkit.sendEFormViewerOkEvent();
|
|
|
+ break;
|
|
|
+ case TEMP_SAVE: // 임시저장
|
|
|
+ saveData.put("actKind", "P");
|
|
|
+ saveData.put("consentState", "TEMP");
|
|
|
+ Util.callHttp(mContext, ConsentConfig.HOST_CONSENT, ConsentConfig.SAVE_TEMP, saveData, callBack);
|
|
|
+// eFormToolkit.sendEFormViewerOkEvent();
|
|
|
+ break;
|
|
|
+ case TEMP_SAVE2: // 확인저장
|
|
|
+ saveData.put("actKind", "P");
|
|
|
+ saveData.put("consentState", "ELECTR_CMP");
|
|
|
+// eFormToolkit.sendEFormViewerOkEvent();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void result(SoapObject result) {
|
|
|
+ Log.e(TAG, "result !! -- > " + result);
|
|
|
+ if (result == null) {
|
|
|
+ stop();
|
|
|
+ } else {
|
|
|
+ String res = result.getProperty("responseData").toString().trim();
|
|
|
+ int intRes = Integer.parseInt(res);
|
|
|
+
|
|
|
+ if (intRes == -1) {
|
|
|
+ stop();
|
|
|
+ } else {
|
|
|
+ String pid = saveMapData.get("patientCode").toString();
|
|
|
+ String inDd = saveMapData.get("clnDate").toString();
|
|
|
+ instance.centerMenu.getConsentList(pid, inDd);
|
|
|
+
|
|
|
+ eFormToolkit.sendEFormViewerOkEvent();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void stop() {
|
|
|
+ String msg = "";
|
|
|
+ if (buttonType.equals(ResultCode.SAVE.toString())) {
|
|
|
+ msg = mContext.getString(R.string.cert);
|
|
|
+ } else if (buttonType.equals(ResultCode.TEMP_SAVE.toString())) {
|
|
|
+ msg = mContext.getString(R.string.temp);
|
|
|
+ } else if (buttonType.equals(ResultCode.TEMP_SAVE2.toString())) {
|
|
|
+ msg = mContext.getString(R.string.confirm);
|
|
|
+ }
|
|
|
+
|
|
|
+ eFormToolkit.sendEFormViewerCancelEvent(String.format(mContext.getString(R.string.saveFailed), msg));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void error() {
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|