package com.dbs.mplus.fatima.httpTask;

import android.graphics.HardwareRenderer;
import android.util.Log;

import com.dbs.mplus.fatima.model.CategoryVO;
import com.dbs.mplus.fatima.model.ConsentImageListVO;
import com.dbs.mplus.fatima.model.ConsentListVO;
import com.dbs.mplus.fatima.model.ConsentSetListVO;
import com.dbs.mplus.fatima.model.ConsentWriteListVO;
import com.dbs.mplus.fatima.model.DeptListVO;
import com.dbs.mplus.fatima.model.DoctorListVO;
import com.dbs.mplus.fatima.model.PatientInfoVO;
import com.dbs.mplus.fatima.model.PatientListVO;
import com.dbs.mplus.fatima.util.ConsentConfig;

import org.ksoap2.serialization.SoapObject;

import java.util.ArrayList;

public class SoapParser {
  private static final String TAG = "SoapParser";

  public static ArrayList<DeptListVO> getWardNDeptList(SoapObject object) {
    ArrayList<DeptListVO> arrayList = new ArrayList<DeptListVO>();
    int total = 0;

    if (object != null) {
      total = object.getPropertyCount();
      if (total == 1) {
        if (object.getProperty(0) == null) {
          total = 0;
        }
      }
    }

    if (total == 0) {

    } else {
      for (int i = 0 ; i < total; i++) {
        SoapObject so = (SoapObject) object.getProperty(i);
        String deptCd = so.getProperty("deptcd").toString().trim();
        String deptNm = so.getProperty("deptnm").toString().trim();

        arrayList.add(new DeptListVO(deptCd, deptNm));
      }
    }

    return arrayList;
  }

  public static ArrayList<DoctorListVO> getDoctorList(SoapObject object) {
    ArrayList<DoctorListVO> arrayList = new ArrayList<DoctorListVO>();
    int total = 0;
    if (object != null) {
      total = object.getPropertyCount();
      if (total == 1) {
        if (object.getProperty(0) == null) {
          total = 0;
        }
      }
    }

    if (total == 0) {
    } else {
      for (int i = 0; i < total; i++) {
        SoapObject so = (SoapObject) object.getProperty(i);
        String doctorId = so.getProperty("doctorid").toString().trim();
        String doctorNm = so.getProperty("doctornm").toString().trim();

        arrayList.add(new DoctorListVO(doctorId, doctorNm));
      }
    }

    return arrayList;
  }

  public static ArrayList<PatientListVO> getPatientList(SoapObject object) {
    ArrayList<PatientListVO> arrayList = new ArrayList<PatientListVO>();
    int total = 0;
    if (object != null) {
      total = object.getPropertyCount();
      if (total == 1) {
        if (object.getProperty(0) == null) {
          total = 0;
        }
      }
    }

    if (total == 0) {
    } else {
      for (int i = 0; i < total; i++) {
        SoapObject so = (SoapObject) object.getProperty(i);
        String pid = "";
        String inDd = "";
        String cretNo = "";
        String seqNo = "";
        String instCd = "";
        String hngNm = "";
        String fSexAmFlag = "";
        String ordDeptCd = "";
        String doctorId = "";
        String hd = "";
        String sa = "";
        String deptNm = "";
        String deptEngAbbr = "";
        String doctorNm = "";
        String diagNm = "";
        String dschNoti = "";
        String roomCd = "";
        String cnst = "";
        String ordType = "";
        String boStyle = "";
        String elbulbodStat = "";
        String ordTm = "";
        String ordDrId = "";
        String ordDrNm = "";
        String ordDd = "";
        String opRoomNm = "";
        String astReqFlag = "";
        String anstDrNm = "";
        String erOrdDeptNm = "";
        String erMediSpclNm = "";
        String badCd = "";
        try {
          pid = so.getProperty("pid").toString().trim();
        } catch (Exception e) {
        }
        try {
          inDd = so.getProperty("indd").toString().trim();
        } catch (Exception e) {
        }
        try {
          cretNo = so.getProperty("cretno").toString().trim();
        } catch (Exception e) {
        }
        try {
          seqNo = so.getProperty("seqno").toString().trim();
        } catch (Exception e) {
        }
        try {
          instCd = so.getProperty("instcd").toString().trim();
        } catch (Exception e){
        }
        try {
          hngNm = so.getProperty("hngnm").toString().trim();
        } catch (Exception e) {
        }
        try {
          fSexAmFlag = so.getProperty("fsexamflag").toString().trim();
        } catch (Exception e) {
        }
        try {
          ordDeptCd = so.getProperty("orddeptcd").toString().trim();
        } catch (Exception e) {
        }
        try {
          doctorId = so.getProperty("doctorid").toString().trim();
        } catch (Exception e){
        }
        try {
          hd = so.getProperty("hd").toString().trim();
        } catch (Exception e) {
        }
        try {
          sa = so.getProperty("sa").toString().trim();
        } catch (Exception e) {
        }
        try {
          deptNm = so.getProperty("deptnm").toString().trim();
        } catch (Exception e) {
        }
        try {
          deptEngAbbr = so.getProperty("deptengabbr").toString().trim();
        } catch (Exception e) {
        }
        try {
          doctorNm = so.getProperty("doctornm").toString().trim();
        } catch (Exception e) {
        }
        try {
          diagNm = so.getProperty("diagnm").toString().trim();
        } catch (Exception e) {
        }
        try {
          dschNoti = so.getProperty("dschnoti").toString().trim();
        } catch (Exception e) {
        }
        try {
          roomCd = so.getProperty("roomcd").toString().trim();
        } catch (Exception e) {
        }
        try {
          cnst = so.getProperty("cnst").toString().trim();
        } catch (Exception e) {
        }
        try {
          ordType = so.getProperty("ordtype").toString().trim();
        } catch (Exception e) {
        }
        try {
          boStyle = so.getProperty("bostyle").toString().trim();
        } catch (Exception e) {
        }
        try {
          elbulbodStat = so.getProperty("elbulbodstat").toString().trim();
        } catch (Exception e) {
        }
        try {
          ordTm = so.getProperty("ordtm").toString().trim();
        } catch (Exception e) {
        }
        try {
          ordDrId = so.getProperty("orddrid").toString().trim();
        } catch (Exception e) {
        }
        try {
          ordDrNm = so.getProperty("orddrnm").toString().trim();
        } catch (Exception e) {
        }
        try {
          ordDd = so.getProperty("orddd").toString().trim();
        } catch (Exception e) {
        }
        try {
          opRoomNm = so.getProperty("oproomnm").toString().trim();
        } catch (Exception e) {
        }
        try {
          astReqFlag = so.getProperty("anstreqflag").toString().trim();
        } catch (Exception e) {
        }
        try {
          anstDrNm = so.getProperty("anstdrnm").toString().trim();
        } catch (Exception e) {
        }
        try {
          erOrdDeptNm = so.getProperty("erorddeptnm").toString().trim();
        } catch (Exception e) {
        }
        try {
          erMediSpclNm = so.getProperty("ermedispclnm").toString().trim();
        } catch (Exception e) {
        }
        String opCnfmDd = "";
        try {
          opCnfmDd = so.getProperty("opcnfmdd").toString().trim();
        } catch (Exception e) {
        }
        try {
          badCd = so.getProperty("badcd").toString().trim();
        } catch (Exception e) {
        }

        pid = pid.equals(ConsentConfig.RESULT_NULL) ? "" : pid;
        inDd = pid.equals(ConsentConfig.RESULT_NULL) ? "" : inDd;
        cretNo = pid.equals(ConsentConfig.RESULT_NULL) ? "" : cretNo;
        seqNo = pid.equals(ConsentConfig.RESULT_NULL) ? "" : seqNo;
        instCd = pid.equals(ConsentConfig.RESULT_NULL) ? "" : instCd;
        hngNm = pid.equals(ConsentConfig.RESULT_NULL) ? "" : hngNm;
        fSexAmFlag = pid.equals(ConsentConfig.RESULT_NULL) ? "" : fSexAmFlag;
        ordDeptCd = pid.equals(ConsentConfig.RESULT_NULL) ? "" : ordDeptCd;
        doctorId = pid.equals(ConsentConfig.RESULT_NULL) ? "" : doctorId;
        hd = pid.equals(ConsentConfig.RESULT_NULL) ? "" : hd;
        sa = pid.equals(ConsentConfig.RESULT_NULL) ? "" : sa;
        deptNm = pid.equals(ConsentConfig.RESULT_NULL) ? "" : deptNm;
        deptEngAbbr = pid.equals(ConsentConfig.RESULT_NULL) ? "" : deptEngAbbr;
        doctorNm = pid.equals(ConsentConfig.RESULT_NULL) ? "" : doctorNm;
        diagNm = pid.equals(ConsentConfig.RESULT_NULL) ? "" : diagNm;
        dschNoti = pid.equals(ConsentConfig.RESULT_NULL) ? "" : dschNoti;
        roomCd = pid.equals(ConsentConfig.RESULT_NULL) ? "" : roomCd;
        cnst = pid.equals(ConsentConfig.RESULT_NULL) ? "" : cnst;
        ordType = pid.equals(ConsentConfig.RESULT_NULL) ? "" : ordType;
        boStyle = pid.equals(ConsentConfig.RESULT_NULL) ? "" : boStyle;
        elbulbodStat = pid.equals(ConsentConfig.RESULT_NULL) ? "" : elbulbodStat;
        ordTm = pid.equals(ConsentConfig.RESULT_NULL) ? "" : ordTm;
        ordDrId = pid.equals(ConsentConfig.RESULT_NULL) ? "" : ordDrId;
        ordDrNm = pid.equals(ConsentConfig.RESULT_NULL) ? "" : ordDrNm;
        ordDd = pid.equals(ConsentConfig.RESULT_NULL) ? "" : ordDd;
        opRoomNm = pid.equals(ConsentConfig.RESULT_NULL) ? "" : opRoomNm;
        astReqFlag = pid.equals(ConsentConfig.RESULT_NULL) ? "" : astReqFlag;
        anstDrNm = pid.equals(ConsentConfig.RESULT_NULL) ? "" : anstDrNm;
        erOrdDeptNm = pid.equals(ConsentConfig.RESULT_NULL) ? "" : erOrdDeptNm;
        erMediSpclNm = pid.equals(ConsentConfig.RESULT_NULL) ? "" : erMediSpclNm;
        opCnfmDd = pid.equals(ConsentConfig.RESULT_NULL) ? "" : opCnfmDd;
        badCd = pid.equals(ConsentConfig.RESULT_NULL) ? "" : badCd;

        arrayList.add(new PatientListVO(pid, inDd, cretNo, seqNo, instCd, hngNm, fSexAmFlag, ordDeptCd, doctorId, hd, sa, deptNm, deptEngAbbr, doctorNm, diagNm, dschNoti, roomCd, cnst, ordType, boStyle, elbulbodStat, ordTm, ordDrId, ordDrNm, ordDd, opRoomNm, astReqFlag, anstDrNm, erOrdDeptNm, erMediSpclNm, opCnfmDd, badCd));
      }
    }

    return arrayList;
  }

  public static PatientInfoVO getPatientInfo(SoapObject object) {
    PatientInfoVO patientInfoVO = new PatientInfoVO();
    int total = 0;
    if (object != null) {
      total = object.getPropertyCount();
      if(total == 1) {
        if(object.getProperty(0) == null) {
          total = 0;
        }
      }
    }

    if (total == 0) {
    } else {
      for (int i = 0; i < total; i++) {
        SoapObject so = (SoapObject) object.getProperty(i);
        String pid = "";
        String sa = "";
        String patientNm = "";
        String juminNo = "";
        String hosType = "";
        String ward = "";
        String roomNo = "";
        String adDate = "";
        String dschDd = "";
        String visitType = "";
        String deptCd = "";
        String deptHngNm = "";
        String deptEngNm = "";
        String opDeptCd = "";
        String opDeptNm = "";
        String opDrId = "";
        String opDrNm = "";
        String dxCd = "";
        String dxNm = "";
        String bp = "";
        String dm = "";
        String heart = "";
        String kidney = "";
        String respiration = "";
        String hx = "";
        String allergy = "";
        String drug = "";
        String smoking = "";
        String idio = "";
        String nacrotics = "";
        String airway = "";
        String hemorrhage = "";
        String statusEtc = "";
        String orderNo = "";
        String printTime = "";
        String mainDrId = "";
        String mainDrNm = "";
        String ocrCd = "";
        String inputId = "";
        String inputNm = "";
        String signImg = "";
        String cretNo = "";
        String zipCdAddr = "";
        String telNo = "";
        String insuKind = "";
        String erDrNm = "";

        try {
          pid = so.getProperty("IO_Pt_ID").toString().trim();
        } catch (Exception e) {
        }
        try {
          sa = so.getProperty("IO_sex_age_y_m").toString().trim();
        } catch (Exception e) {
        }
        try {
          patientNm = so.getProperty("IO_Pt_Name").toString().trim();
        } catch (Exception e) {
        }
        try {
          juminNo = so.getProperty("IO_JuminNo").toString().trim();
        } catch (Exception e) {
        }
        try {
          hosType = so.getProperty("IO_HosType").toString().trim();
        } catch (Exception e) {
        }
        try {
          ward = so.getProperty("IO_Ward").toString().trim();
        } catch (Exception e) {
        }
        try {
          roomNo = so.getProperty("IO_RoomNo").toString().trim();
        } catch (Exception e) {
        }
        try {
          adDate = so.getProperty("IO_ADdate").toString().trim();
        } catch (Exception e) {
        }
        try {
          dschDd = so.getProperty("IO_Dschdd").toString().trim();
        } catch (Exception e) {
        }
        try {
          visitType = so.getProperty("IO_VisitType").toString().trim();
        } catch (Exception e) {
        }
        try {
          deptCd = so.getProperty("IO_DeptCd").toString().trim();
        } catch (Exception e) {
        }
        try {
          deptHngNm = so.getProperty("IO_DeptNm").toString().trim();
        } catch (Exception e) {
        }
        try {
          deptEngNm = so.getProperty("IO_Dept2").toString().trim();
        } catch (Exception e) {
        }
        try {
          opDeptCd = so.getProperty("IO_OPdeptCd").toString().trim();
        } catch (Exception e) {
        }
        try {
          opDeptNm = so.getProperty("IO_OPdeptNm").toString().trim();
        } catch (Exception e) {
        }
        try {
          opDrId = so.getProperty("IO_OPdrId").toString().trim();
        } catch (Exception e) {
        }
        try {
          opDrNm = so.getProperty("IO_OPdrNm").toString().trim();
        } catch (Exception e) {
        }
        try {
          dxCd = so.getProperty("IO_DxCd").toString().trim();
        } catch (Exception e) {
        }
        try {
          dxNm = so.getProperty("IO_DxNm").toString().trim();
        } catch (Exception e) {
        }
        try {
          bp = so.getProperty("IO_bp").toString().trim();
        } catch (Exception e) {
        }
        try {
          dm = so.getProperty("IO_dm").toString().trim();
        } catch (Exception e) {
        }
        try {
          heart = so.getProperty("IO_heart").toString().trim();
        } catch (Exception e) {
        }
        try {
          kidney = so.getProperty("IO_kidney").toString().trim();
        } catch (Exception e) {
        }
        try {
          respiration = so.getProperty("IO_respiration").toString().trim();
        } catch (Exception e) {
        }
        try {
          hx = so.getProperty("IO_hx").toString().trim();
        } catch (Exception e) {
        }
        try {
          allergy = so.getProperty("IO_allergy").toString().trim();
        } catch (Exception e) {
        }
        try {
          drug = so.getProperty("IO_drug").toString().trim();
        } catch (Exception e) {
        }
        try {
          smoking = so.getProperty("IO_smoking").toString().trim();
        } catch (Exception e) {
        }
        try {
          idio = so.getProperty("IO_idio").toString().trim();
        } catch (Exception e) {
        }
        try {
          nacrotics = so.getProperty("IO_nacrotics").toString().trim();
        } catch (Exception e) {
        }
        try {
          airway = so.getProperty("IO_airway").toString().trim();
        } catch (Exception e) {
        }
        try {
          hemorrhage = so.getProperty("IO_hemorrhage").toString().trim();
        } catch (Exception e) {
        }
        try {
          statusEtc = so.getProperty("IO_status_etc").toString().trim();
        } catch (Exception e) {
        }
        try {
          orderNo = so.getProperty("IO_OrderNo").toString().trim();
        } catch (Exception e) {
        }
        try {
          printTime = so.getProperty("IO_PrintTime").toString().trim();
        } catch (Exception e) {
        }
        try {
          mainDrId = so.getProperty("IO_MaindrId").toString().trim();
        } catch (Exception e) {
        }
        try {
          mainDrNm = so.getProperty("IO_MaindrNm").toString().trim();
        } catch (Exception e) {
        }
        try {
          ocrCd = so.getProperty("IO_OcrCd").toString().trim();
        } catch (Exception e) {
        }
        try {
          inputId = so.getProperty("IO_InputId").toString().trim();
        } catch (Exception e) {
        }
        try {
          inputNm = so.getProperty("IO_InputNm").toString().trim();
        } catch (Exception e) {
        }
        try {
          signImg = so.getProperty("IO_SignImg").toString().trim();
        } catch (Exception e) {
        }
        try {
          cretNo = so.getProperty("IO_CretNo").toString().trim();
        } catch (Exception e) {
        }
        try {
          zipCdAddr = so.getProperty("IO_Zipcdaddr").toString().trim();
        } catch (Exception e) {
        }
        try {
          telNo = so.getProperty("IO_Tel").toString().trim();
        } catch (Exception e) {
        }
        try {
          insuKind = so.getProperty("IO_Insukind").toString().trim();
        } catch (Exception e) {
        }
        try {
          erDrNm = so.getProperty("IO_ErdrNm").toString().trim();
        } catch (Exception e) {
        }

        pid = pid.equals(ConsentConfig.RESULT_NULL) ? "" : pid;
        sa = sa.equals(ConsentConfig.RESULT_NULL) ? "" : sa;
        patientNm = patientNm.equals(ConsentConfig.RESULT_NULL) ? "" : patientNm;
        juminNo = juminNo.equals(ConsentConfig.RESULT_NULL) ? "" : juminNo;
        hosType = hosType.equals(ConsentConfig.RESULT_NULL) ? "" : hosType;
        ward = ward.equals(ConsentConfig.RESULT_NULL) ? "" : ward;
        roomNo = roomNo.equals(ConsentConfig.RESULT_NULL) ? "" : roomNo;
        adDate = adDate.equals(ConsentConfig.RESULT_NULL) ? "" : adDate;
        dschDd = dschDd.equals(ConsentConfig.RESULT_NULL) ? "" : dschDd;
        visitType = visitType.equals(ConsentConfig.RESULT_NULL) ? "" : visitType;
        deptCd = deptCd.equals(ConsentConfig.RESULT_NULL) ? "" : deptCd;
        deptHngNm = deptHngNm.equals(ConsentConfig.RESULT_NULL) ? "" : deptHngNm;
        deptEngNm = deptEngNm.equals(ConsentConfig.RESULT_NULL) ? "" : deptEngNm;
        opDeptCd = opDeptCd.equals(ConsentConfig.RESULT_NULL) ? "" : opDeptCd;
        opDeptNm = opDeptNm.equals(ConsentConfig.RESULT_NULL) ? "" : opDeptNm;
        opDrId = opDrId.equals(ConsentConfig.RESULT_NULL) ? "" : opDrId;
        opDrNm = opDrNm.equals(ConsentConfig.RESULT_NULL) ? "" : opDrNm;
        dxCd = dxCd.equals(ConsentConfig.RESULT_NULL) ? "" : dxCd;
        dxNm = dxNm.equals(ConsentConfig.RESULT_NULL) ? "" : dxNm;
        bp = bp.equals(ConsentConfig.RESULT_NULL) ? "" : bp;
        dm = dm.equals(ConsentConfig.RESULT_NULL) ? "" : dm;
        heart = heart.equals(ConsentConfig.RESULT_NULL) ? "" : heart;
        kidney = kidney.equals(ConsentConfig.RESULT_NULL) ? "" : kidney;
        respiration = respiration.equals(ConsentConfig.RESULT_NULL) ? "" : respiration;
        hx = hx.equals(ConsentConfig.RESULT_NULL) ? "" : hx;
        allergy = allergy.equals(ConsentConfig.RESULT_NULL) ? "" : allergy;
        drug = drug.equals(ConsentConfig.RESULT_NULL) ? "" : drug;
        smoking = smoking.equals(ConsentConfig.RESULT_NULL) ? "" : smoking;
        idio = idio.equals(ConsentConfig.RESULT_NULL) ? "" : idio;
        nacrotics = nacrotics.equals(ConsentConfig.RESULT_NULL) ? "" : nacrotics;
        airway = airway.equals(ConsentConfig.RESULT_NULL) ? "" : airway;
        hemorrhage = hemorrhage.equals(ConsentConfig.RESULT_NULL) ? "" : hemorrhage;
        statusEtc = statusEtc.equals(ConsentConfig.RESULT_NULL) ? "" : statusEtc;
        orderNo = orderNo.equals(ConsentConfig.RESULT_NULL) ? "" : orderNo;
        printTime = printTime.equals(ConsentConfig.RESULT_NULL) ? "" : printTime;
        mainDrId = mainDrId.equals(ConsentConfig.RESULT_NULL) ? "" : mainDrId;
        mainDrNm = mainDrNm.equals(ConsentConfig.RESULT_NULL) ? "" : mainDrNm;
        ocrCd = ocrCd.equals(ConsentConfig.RESULT_NULL) ? "" : ocrCd;
        inputId = inputId.equals(ConsentConfig.RESULT_NULL) ? "" : inputId;
        inputNm = inputNm.equals(ConsentConfig.RESULT_NULL) ? "" : inputNm;
        signImg = signImg.equals(ConsentConfig.RESULT_NULL) ? "" : signImg;
        cretNo = cretNo.equals(ConsentConfig.RESULT_NULL) ? "" : cretNo;
        zipCdAddr = zipCdAddr.equals(ConsentConfig.RESULT_NULL) ? "" : zipCdAddr;
        telNo = telNo.equals(ConsentConfig.RESULT_NULL) ? "" : telNo;
        insuKind = insuKind.equals(ConsentConfig.RESULT_NULL) ? "" : insuKind;
        erDrNm = erDrNm.equals(ConsentConfig.RESULT_NULL) ? "" : erDrNm;

        patientInfoVO.setPid(pid);
        patientInfoVO.setSa(sa);
        patientInfoVO.setPatientNm(patientNm);
        patientInfoVO.setJuminNo(juminNo);
        patientInfoVO.setHosType(hosType);
        patientInfoVO.setWard(ward);
        patientInfoVO.setRoomNo(roomNo);
        patientInfoVO.setAdDate(adDate);
        patientInfoVO.setDschDd(dschDd);
        patientInfoVO.setVisitType(visitType);
        patientInfoVO.setDeptCd(deptCd);
        patientInfoVO.setDeptHngNm(deptHngNm);
        patientInfoVO.setDeptEngNm(deptEngNm);
        patientInfoVO.setOpDeptCd(opDeptCd);
        patientInfoVO.setOpDeptNm(opDeptNm);
        patientInfoVO.setOpDrId(opDrId);
        patientInfoVO.setOpDrNm(opDrNm);
        patientInfoVO.setDxCd(dxCd);
        patientInfoVO.setDxNm(dxNm);
        patientInfoVO.setBp(bp);
        patientInfoVO.setDm(dm);
        patientInfoVO.setHeart(heart);
        patientInfoVO.setKidney(kidney);
        patientInfoVO.setRespiration(respiration);
        patientInfoVO.setHx(hx);
        patientInfoVO.setAllergy(allergy);
        patientInfoVO.setDrug(drug);
        patientInfoVO.setSmoking(smoking);
        patientInfoVO.setIdio(idio);
        patientInfoVO.setNacrotics(nacrotics);
        patientInfoVO.setAirway(airway);
        patientInfoVO.setHemorrhage(hemorrhage);
        patientInfoVO.setStatusEtc(statusEtc);
        patientInfoVO.setOrderNo(orderNo);
        patientInfoVO.setPrintTime(printTime);
        patientInfoVO.setMainDrId(mainDrId);
        patientInfoVO.setMainDrNm(mainDrNm);
        patientInfoVO.setOcrCd(ocrCd);
        patientInfoVO.setInputId(inputId);
        patientInfoVO.setInputNm(inputNm);
        patientInfoVO.setSignImg(signImg);
        patientInfoVO.setCretNo(cretNo);
        patientInfoVO.setZipCdAddr(zipCdAddr);
        patientInfoVO.setTelNo(telNo);
        patientInfoVO.setInsuKind(insuKind);
        patientInfoVO.setErDrNm(erDrNm);
      }

      return patientInfoVO;
    }

    return null;
  }

  public static ArrayList<ConsentListVO> getConsentList(SoapObject object) {
    ArrayList<ConsentListVO> arrayList = new ArrayList<ConsentListVO>();

    int total = 0;
    if (object != null) {
      total = object.getPropertyCount();
      if (total == 1) {
        if (object.getProperty(0) == null) {
          total = 0;
        }
      }
    }

    if (total == 0) {
    } else {
      for (int i = 0; i < total; i++) {
        SoapObject so = (SoapObject) object.getProperty(i);
        String consentMstRid = "";
        String consentStateDisp = "";
        String consentName = "";
        String hosType = "";
        String patientCode = "";
        String visitType = "";
        String orderNo = "";
        String orderCd = "";
        String orderNm = "";
        String clnDeptCd = "";
        String clnDeptNm = "";
        String ward = "";
        String roomCd = "";
        String formRid = "";
        String formCd = "";
        String formGuid = "";
        String prntCnt = "";
        String ocrNumber = "";
        String consentState = "";
        String cosignDcId = "";
        String cosignDcName = "";
        String createUserId = "";
        String createUserName = "";
        String createDateTime = "";
        String clnDate = "";
        String cretno = "";
        String ocrTagYN = "";

        try {
          consentMstRid = so.getProperty("ConsentMstRid").toString().trim();
        } catch (Exception e) {
        }
        try {
          consentStateDisp = so.getProperty("ConsentStateDisp").toString().trim();
        } catch (Exception e) {
        }
        try {
          consentName = so.getProperty("ConsentName").toString().trim();
        } catch (Exception e) {
        }
        try {
          hosType = so.getProperty("HosType").toString().trim();
        } catch (Exception e) {
        }
        try {
          patientCode = so.getProperty("PatientCode").toString().trim();
        } catch (Exception e) {
        }
        try {
          visitType = so.getProperty("VisitType").toString().trim();
        } catch (Exception e) {
        }
        try {
          orderNo = so.getProperty("orderNo").toString().trim();
        } catch (Exception e) {
        }
        try {
          orderCd = so.getProperty("OrderCd").toString().trim();
        } catch (Exception e) {
        }
        try {
          orderNm = so.getProperty("OrderNm").toString().trim();
        } catch (Exception e) {
        }
        try {
          clnDeptCd = so.getProperty("ClnDeptCd").toString().trim();
        } catch (Exception e) {
        }
        try {
          clnDeptNm = so.getProperty("ClnDeptNm").toString().trim();
        } catch (Exception e) {
        }
        try {
          ward = so.getProperty("Ward").toString().trim();
        } catch (Exception e) {
        }
        try {
          roomCd = so.getProperty("RoomCd").toString().trim();
        } catch (Exception e) {
        }
        try {
          formRid = so.getProperty("FormRid").toString().trim();
        } catch (Exception e) {
        }
        try {
          formCd = so.getProperty("FormCd").toString().trim();
        } catch (Exception e) {
        }
        try {
          formGuid = so.getProperty("FormGuid").toString().trim();
        } catch (Exception e) {
        }
        try {
          prntCnt = so.getProperty("PrntCnt").toString().trim();
        } catch (Exception e) {
        }
        try {
          ocrNumber = so.getProperty("OcrNumber").toString().trim();
        } catch (Exception e) {
        }
        try {
          consentState = so.getProperty("ConsentState").toString().trim();
        } catch (Exception e) {
        }
        try {
          cosignDcId = so.getProperty("CosignDcId").toString().trim();
        } catch (Exception e) {
        }
        try {
          cosignDcName = so.getProperty("CosignDcName").toString().trim();
        } catch (Exception e) {
        }
        try {
          createUserId = so.getProperty("CreateUserId").toString().trim();
        } catch (Exception e) {
        }
        try {
          createUserName = so.getProperty("CreateUserName").toString().trim();
        } catch (Exception e) {
        }
        try {
          createDateTime = so.getProperty("CreateDateTime").toString().trim();
        } catch (Exception e) {
        }
        try {
          clnDate = so.getProperty("ClnDate").toString().trim();
        } catch (Exception e) {
        }
        try {
          cretno = so.getProperty("Cretno").toString().trim();
        } catch (Exception e) {
        }
        try {
          ocrTagYN = so.getProperty("OcrTagYN").toString().trim();
        } catch (Exception e) {
        }

        consentMstRid = consentMstRid.equals(ConsentConfig.RESULT_NULL) ? "" : consentMstRid;
        consentStateDisp = consentStateDisp.equals(ConsentConfig.RESULT_NULL) ? "" : consentStateDisp;
        consentName = consentName.equals(ConsentConfig.RESULT_NULL) ? "" : consentName;
        hosType = hosType.equals(ConsentConfig.RESULT_NULL) ? "" : hosType;
        patientCode = patientCode.equals(ConsentConfig.RESULT_NULL) ? "" : patientCode;
        visitType = visitType.equals(ConsentConfig.RESULT_NULL) ? "" : visitType;
        orderNo = orderNo.equals(ConsentConfig.RESULT_NULL) ? "" : orderNo;
        orderCd = orderCd.equals(ConsentConfig.RESULT_NULL) ? "" : orderCd;
        orderNm = orderNm.equals(ConsentConfig.RESULT_NULL) ? "" : orderNm;
        clnDeptCd = clnDeptCd.equals(ConsentConfig.RESULT_NULL) ? "" : clnDeptCd;
        clnDeptNm = clnDeptNm.equals(ConsentConfig.RESULT_NULL) ? "" : clnDeptNm;
        ward = ward.equals(ConsentConfig.RESULT_NULL) ? "" : ward;
        roomCd = roomCd.equals(ConsentConfig.RESULT_NULL) ? "" : roomCd;
        formRid = formRid.equals(ConsentConfig.RESULT_NULL) ? "" : formRid;
        formCd = formCd.equals(ConsentConfig.RESULT_NULL) ? "" : formCd;
        formGuid = formGuid.equals(ConsentConfig.RESULT_NULL) ? "" : formGuid;
        prntCnt = prntCnt.equals(ConsentConfig.RESULT_NULL) ? "" : prntCnt;
        ocrNumber = ocrNumber.equals(ConsentConfig.RESULT_NULL) ? "" : ocrNumber;
        consentState = consentState.equals(ConsentConfig.RESULT_NULL) ? "" : consentState;
        cosignDcId = cosignDcId.equals(ConsentConfig.RESULT_NULL) ? "" : cosignDcId;
        cosignDcName = cosignDcName.equals(ConsentConfig.RESULT_NULL) ? "" : cosignDcName;
        createUserId = createUserId.equals(ConsentConfig.RESULT_NULL) ? "" : createUserId;
        createUserName = createUserName.equals(ConsentConfig.RESULT_NULL) ? "" : createUserName;
        createDateTime = createDateTime.equals(ConsentConfig.RESULT_NULL) ? "" : createDateTime;
        clnDate = clnDate.equals(ConsentConfig.RESULT_NULL) ? "" : clnDate;
        cretno = cretno.equals(ConsentConfig.RESULT_NULL) ? "" : cretno;
        ocrTagYN = ocrTagYN.equals(ConsentConfig.RESULT_NULL) ? "" : ocrTagYN;

        arrayList.add(new ConsentListVO(consentMstRid, consentStateDisp, consentName, hosType, patientCode, visitType, orderNo, orderCd, orderNm, clnDeptCd, clnDeptNm, ward, roomCd, formRid, formCd, formGuid, prntCnt, ocrNumber, consentState, cosignDcId, cosignDcName, createUserId, createUserName, createDateTime, clnDate, cretno, ocrTagYN));
      }
    }

    return arrayList;
  }

  public static ArrayList<ConsentSetListVO> getConsentSetList(SoapObject object, String apiType) {
    ArrayList<ConsentSetListVO> arrayList = new ArrayList<ConsentSetListVO>();

    int total = 0;
    if (object != null) {
      total = object.getPropertyCount();
      if (total == 1) {
        if (object.getProperty(0) == null) {
          total = 0;
        }
      }
    }

    if (total == 0) {
    } else {
      for (int i = 0; i < total; i++) {
        SoapObject so = (SoapObject) object.getProperty(i);
        String formRid = "";
        String formGuid = "";
        String formCd = "";
        String formName = "";
        String setAuth = "";
        String fullCategoryName = "";
        String prntCnt = "";
        String printOnly = "";
        String ocrTagYN = "";

        try {
          formRid = so.getProperty("FormRid").toString().trim();
        } catch (Exception e) {
        }
        try {
          formGuid = so.getProperty("FormGuid").toString().trim();
        } catch (Exception e) {
        }
        try {
          formCd = so.getProperty("FormCd").toString().trim();
        } catch (Exception e) {
        }
        try {
          formName = so.getProperty("FormName").toString().trim();
        } catch (Exception e) {
        }
        try {
          setAuth = so.getProperty("SetAuth").toString().trim();
        } catch (Exception e) {
        }
        try {
          fullCategoryName = so.getProperty("FullCategoryName").toString().trim();
        } catch (Exception e) {
        }
        try {
          prntCnt = so.getProperty("PrntCnt").toString().trim();
        } catch (Exception e) {
        }
        try {
          printOnly = so.getProperty("PrintOnly").toString().trim();
        } catch (Exception e) {
        }
        try {
          ocrTagYN = so.getProperty("OcrTagYN").toString().trim();
        } catch (Exception e) {
        }

        formRid = formRid.equals(ConsentConfig.RESULT_NULL) ? "" : formRid;
        formGuid = formGuid.equals(ConsentConfig.RESULT_NULL) ? "" : formGuid;
        formCd = formCd.equals(ConsentConfig.RESULT_NULL) ? "" : formCd;
        formName = formName.equals(ConsentConfig.RESULT_NULL) ? "" : formName;
        setAuth = setAuth.equals(ConsentConfig.RESULT_NULL) ? "" : setAuth;
        prntCnt = prntCnt.equals(ConsentConfig.RESULT_NULL) ? "" : prntCnt;
        printOnly = printOnly.equals(ConsentConfig.RESULT_NULL) ? "" : printOnly;
        ocrTagYN = ocrTagYN.equals(ConsentConfig.RESULT_NULL) ? "" : ocrTagYN;

        arrayList.add(new ConsentSetListVO(formRid, formGuid, formCd, formName, setAuth, apiType.equals(ConsentConfig.GET_CONSENT_SET_LIST) ? "" : fullCategoryName, prntCnt, printOnly, ocrTagYN));
      }
    }

    return arrayList;
  }

  public static ArrayList<CategoryVO> getCategoryList(SoapObject object) {
    ArrayList<CategoryVO> arrayList = new ArrayList<CategoryVO>();

    int total = 0;
    if (object != null) {
      total = object.getPropertyCount();
      if (total == 1) {
        if (object.getProperty(0) == null) {
          total = 0;
        }
      }
    }

    if (total == 0) {
    } else {
      for (int i = 0; i < total; i++) {
        String categoryType = "";
        String categoryId = "";
        String categoryName = "";

        SoapObject so = (SoapObject) object.getProperty(i);
        try {
          categoryType = so.getProperty("CategoryType").toString().trim();
        } catch (Exception e) {
        }
        try {
          categoryId = so.getProperty("CategoryId").toString().trim();
        } catch (Exception e) {
        }
        try {
          categoryName = so.getProperty("CategoryName").toString().trim();
        } catch (Exception e) {
        }

        categoryType = categoryType.equals(ConsentConfig.RESULT_NULL) ? "" : categoryType;
        categoryId = categoryId.equals(ConsentConfig.RESULT_NULL) ? "" : categoryId;
        categoryName = categoryName.equals(ConsentConfig.RESULT_NULL) ? "" : categoryName;
        arrayList.add(new CategoryVO(categoryType, categoryId, categoryName));
      }
    }

    return arrayList;
  }

  public static ArrayList<ConsentWriteListVO> getUnfinishedListPerDoctor(SoapObject object) {
    ArrayList<ConsentWriteListVO> arrayList = new ArrayList<ConsentWriteListVO>();

    int total = 0;
    if (object != null) {
      total = object.getPropertyCount();
      if (total == 1) {
        if (object.getProperty(0) == null) {
          total = 0;
        }
      }
    }

    if (total == 0) {
    } else {
      for (int i = 0; i < total; i++) {
        SoapObject so = (SoapObject) object.getProperty(i);

        String pid = "";
        String formCd = "";
        String formNm = "";
        String hngNm = "";
        String orderDate = "";
        String printOnly = "";
        String certTarget = "";
        String consentState = "";
        String consentMstRid = "";
        String ordDd = "";
        String ordType = "";
        String ordDeptCd = "";
        String orderNo = "";
        String orderCd = "";
        String ocrNumber = "";
        String cretNo = "";
        String createUserName = "";
        String formRid = "";
        String formGuid = "";

        try {
          pid = so.getProperty("pid").toString().trim();
        } catch(Exception e){

        }
        try {
          formCd = so.getProperty("formcd").toString().trim();
        } catch(Exception e){

        }
        try {
          formNm = so.getProperty("formnm").toString().trim();
        } catch (Exception e) {

        }
        try {
          hngNm = so.getProperty("hngnm").toString().trim();
        } catch(Exception e){

        }
        try {
          orderDate = so.getProperty("orderdate").toString().trim();
        } catch(Exception e){

        }
        try {
          printOnly = so.getProperty("printonly").toString().trim();
        } catch(Exception e){

        }
        try {
          certTarget = so.getProperty("certtarget").toString().trim();
        } catch(Exception e){

        }
        try {
          consentState = so.getProperty("consentstate").toString().trim();
        } catch(Exception e){

        }
        try {
          consentMstRid = so.getProperty("consentmstrid").toString().trim();
        } catch(Exception e){

        }
        try {
          ordDd = so.getProperty("orddd").toString().trim();
        } catch(Exception e){

        }
        try {
          ordType = so.getProperty("ordtype").toString().trim();
        } catch(Exception e){

        }
        try {
          ordDeptCd = so.getProperty("orddeptcd").toString().trim();
        } catch(Exception e){

        }
        try {
          orderNo = so.getProperty("orderno").toString().trim();
        } catch(Exception e){

        }
        try {
          orderCd = so.getProperty("ordercd").toString().trim();
        } catch (Exception e) {

        }
        try {
          ocrNumber = so.getProperty("ocrnumber").toString().trim();
        } catch(Exception e){

        }
        try {
          cretNo = so.getProperty("cretno").toString().trim();
        } catch(Exception e){

        }
        try {
          createUserName = so.getProperty("createusername").toString().trim();
        } catch(Exception e){

        }
        try {
          formRid = so.getProperty("formrid").toString().trim();
        } catch(Exception e){

        }
        try {
          formGuid = so.getProperty("formguid").toString().trim();
        } catch(Exception e){

        }

        arrayList.add(new ConsentWriteListVO(pid, formCd, formNm, hngNm, orderDate, printOnly, certTarget, consentState, consentMstRid, ordDd, ordType, ordDeptCd, orderNo, orderCd, ocrNumber, cretNo, createUserName, formRid, formGuid));
      }
    }

    return arrayList;
  }

  public static ArrayList<ConsentImageListVO> getConsetImageList(SoapObject object) {
    ArrayList<ConsentImageListVO> arrayList = new ArrayList<>();
    int total = 0;
    if (object != null) {
      total = object.getPropertyCount();
      if (total == 1) {
        if (object.getProperty(0) == null) {
          total = 0;
        }
      }
    }

    for (int i = 0; i < total; i++) {
      SoapObject so = (SoapObject) object.getProperty(i);
      String _consentMstRid = "";
      String _consentImageRid = "";
      String _formRid = "";
      String _imagePath = "";
      String _imageFileName = "";
      String _completeYn = "";
      String _createUserId = "";
      String _createDateTime = "";

      try {
        _consentMstRid = so.getProperty("ConsentMstRid").toString().trim();
      } catch (Exception e) {
      }
      try {
        _consentImageRid = so.getProperty("ConsentImageRid").toString().trim();
      } catch (Exception e) {
      }
      try {
        _formRid = so.getProperty("FormRid").toString().trim();
      } catch (Exception e) {
      }
      try {
        _imagePath = so.getProperty("ImagePath").toString().trim();
      } catch (Exception e) {
      }
      try {
        _imageFileName = so.getProperty("ImageFilename").toString().trim();
      } catch (Exception e) {
      }
      try {
        _completeYn = so.getProperty("CompleteYn").toString().trim();
      } catch (Exception e) {
      }
      try {
        _createUserId = so.getProperty("CreateUserId").toString().trim();
      } catch (Exception e) {
      }
      try {
        _createDateTime = so.getProperty("CreateDatetime").toString().trim();
      } catch (Exception e) {
      }

      _consentMstRid = _consentMstRid.equals(ConsentConfig.RESULT_NULL) ? "" : _consentMstRid;
      _consentImageRid = _consentImageRid.equals(ConsentConfig.RESULT_NULL) ? "" : _consentImageRid;
      _formRid = _formRid.equals(ConsentConfig.RESULT_NULL) ? "" : _formRid;
      _imagePath = _imagePath.equals(ConsentConfig.RESULT_NULL) ? "" : _imagePath;
      _imageFileName = _imageFileName.equals(ConsentConfig.RESULT_NULL) ? "" : _imageFileName;
      _completeYn = _completeYn.equals(ConsentConfig.RESULT_NULL) ? "" : _completeYn;
      _createUserId = _createUserId.equals(ConsentConfig.RESULT_NULL) ? "" : _createUserId;
      _createDateTime = _createDateTime.equals(ConsentConfig.RESULT_NULL) ? "" : _createDateTime;

      arrayList.add(new ConsentImageListVO(_consentMstRid, _consentImageRid, _formRid, _imagePath, _imageFileName, _completeYn, _createUserId, _createDateTime));
    }

    return arrayList;
  }
}
