package com.dbs.consent.demo.httpTask;

import com.dbs.consent.demo.model.CategoryVO;
import com.dbs.consent.demo.model.ConsentFormListVO;
import com.dbs.consent.demo.model.ConsentImageVO;
import com.dbs.consent.demo.model.DeptListVO;
import com.dbs.consent.demo.model.DoctorListVO;
import com.dbs.consent.demo.model.PatientInfoVO;
import com.dbs.consent.demo.model.PatientListVO;
import com.dbs.consent.demo.model.TestVO;
import com.dbs.consent.demo.model.UserLoginDeptList;
import com.dbs.consent.demo.util.ConsentConfig;

import org.ksoap2.serialization.SoapObject;

import java.util.ArrayList;

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

  public static ArrayList<UserLoginDeptList> userLoginDeptList(SoapObject object) {
    ArrayList<UserLoginDeptList> arrayList = new ArrayList<>();
    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 dutplceInstCd = so.getProperty("dutplceInstCd").toString().trim();
        String dutplceInstNm = so.getProperty("dutplceInstNm").toString().trim();
        String dutplceCd     = so.getProperty("dutplceCd").toString().trim();
        String deptHngNm     = so.getProperty("deptHngNm").toString().trim();
        String fromDd        = so.getProperty("fromDd").toString().trim();
        String sortNo        = so.getProperty("sortNo").toString().trim();
        String deptCd        = so.getProperty("deptCd").toString().trim();
        String jobKindCd     = so.getProperty("jobKindCd").toString().trim();
        String jobKindNm     = so.getProperty("jobKindNm").toString().trim();
        String indexPage     = so.getProperty("indexPage").toString().trim();
        String userId        = so.getProperty("userId").toString().trim();
        String userName      = so.getProperty("userName").toString().trim();
        String drKind        = so.getProperty("drKind").toString().trim();

        dutplceInstCd = dutplceInstCd.equals(ConsentConfig.RETURN_NULL) ? "" : dutplceInstCd;
        dutplceInstNm = dutplceInstNm.equals(ConsentConfig.RETURN_NULL) ? "" : dutplceInstNm;
        dutplceCd     = dutplceCd.equals(ConsentConfig.RETURN_NULL) ? "" : dutplceCd;
        deptHngNm     = deptHngNm.equals(ConsentConfig.RETURN_NULL) ? "" : deptHngNm;
        fromDd        = fromDd.equals(ConsentConfig.RETURN_NULL) ? "" : fromDd;
        sortNo        = sortNo.equals(ConsentConfig.RETURN_NULL) ? "" : sortNo;
        deptCd        = deptCd.equals(ConsentConfig.RETURN_NULL) ? "" : deptCd;
        jobKindCd     = jobKindCd.equals(ConsentConfig.RETURN_NULL) ? "" : jobKindCd;
        jobKindNm     = jobKindNm.equals(ConsentConfig.RETURN_NULL) ? "" : jobKindNm;
        indexPage     = indexPage.equals(ConsentConfig.RETURN_NULL) ? "" : indexPage;
        userId        = userId.equals(ConsentConfig.RETURN_NULL) ? "" : userId;
        userName      = userName.equals(ConsentConfig.RETURN_NULL) ? "" : userName;
        drKind        = drKind.equals(ConsentConfig.RETURN_NULL) ? "" : drKind;

        arrayList.add(new UserLoginDeptList(dutplceInstCd, dutplceInstNm, dutplceCd, deptHngNm, fromDd, sortNo, deptCd, jobKindCd, jobKindNm, indexPage, userId, userName, drKind));
      }
    }

    return arrayList;
  }

  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();

        deptCd = deptCd.equals(ConsentConfig.RETURN_NULL) ? "" : deptCd;
        deptNm = deptNm.equals(ConsentConfig.RETURN_NULL) ? "" : deptNm;

        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();
        String doctorKind = so.getProperty("doctorKind").toString().trim();
        String drKind     = so.getProperty("drKind").toString().trim();

        doctorId   = doctorId.equals(ConsentConfig.RETURN_NULL) ? "" : doctorId;
        doctorNm   = doctorNm.equals(ConsentConfig.RETURN_NULL) ? "" : doctorNm;
        doctorKind = doctorKind.equals(ConsentConfig.RETURN_NULL) ? "" : doctorKind;
        drKind     = drKind.equals(ConsentConfig.RETURN_NULL) ? "" : drKind;

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

    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       = so.getProperty("pid").toString().trim();
        String inDd      = so.getProperty("inDd").toString().trim();
        String cretNo    = so.getProperty("cretNo").toString().trim();
        String ordType   = so.getProperty("ordType").toString().trim();
        String instCd    = so.getProperty("instCd").toString().trim();
        String hngNm     = so.getProperty("hngNm").toString().trim();
        String ordDeptCd = so.getProperty("ordDeptCd").toString().trim();
        String doctorId  = so.getProperty("doctorId").toString().trim();
        String sa        = so.getProperty("sa").toString().trim();
        String deptNm    = so.getProperty("deptNm").toString().trim();
        String doctorNm  = so.getProperty("doctorNm").toString().trim();
        String roomCd    = so.getProperty("roomCd").toString().trim();
        String opRoomNm  = so.getProperty("opRoomNm").toString().trim();
        String oprsRvNo  = so.getProperty("oprsRvNo").toString().trim();

        pid       = pid.equals(ConsentConfig.RETURN_NULL) ? "" : pid;
        inDd      = inDd.equals(ConsentConfig.RETURN_NULL) ? "" : inDd;
        cretNo    = cretNo.equals(ConsentConfig.RETURN_NULL) ? "" : cretNo;
        ordType   = ordType.equals(ConsentConfig.RETURN_NULL) ? "" : ordType;
        instCd    = instCd.equals(ConsentConfig.RETURN_NULL) ? "" : instCd;
        hngNm     = hngNm.equals(ConsentConfig.RETURN_NULL) ? "" : hngNm;
        ordDeptCd = ordDeptCd.equals(ConsentConfig.RETURN_NULL) ? "" : ordDeptCd;
        doctorId  = doctorId.equals(ConsentConfig.RETURN_NULL) ? "" : doctorId;
        sa        = sa.equals(ConsentConfig.RETURN_NULL) ? "" : sa;
        deptNm    = deptNm.equals(ConsentConfig.RETURN_NULL) ? "" : deptNm;
        doctorNm  = doctorNm.equals(ConsentConfig.RETURN_NULL) ? "" : doctorNm;
        roomCd    = roomCd.equals(ConsentConfig.RETURN_NULL) ? "" : roomCd;
        opRoomNm  = opRoomNm.equals(ConsentConfig.RETURN_NULL) ? "" : opRoomNm;
        oprsRvNo  = oprsRvNo.equals(ConsentConfig.RETURN_NULL) ? "" : oprsRvNo;



        arrayList.add(new PatientListVO(pid, inDd, cretNo, ordType, instCd, hngNm, ordDeptCd, doctorId, sa, deptNm, doctorNm, roomCd, opRoomNm, oprsRvNo));
      }
    }

    return arrayList;
  }

  public static ArrayList<CategoryVO> getHospitalList(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++) {
        SoapObject so = (SoapObject) object.getProperty(i);

        String categoryId = so.getProperty("categoryId").toString().trim();
        String categoryCode = so.getProperty("categoryCode").toString().trim();;
        String parentCategoryId = so.getProperty("parentCategoryId").toString().trim();
        String categoryName = so.getProperty("categoryName").toString().trim();

        categoryId   = categoryId.equals(ConsentConfig.RETURN_NULL) ? "" : categoryId;
        categoryCode = categoryCode.equals(ConsentConfig.RETURN_NULL) ? "" : categoryCode;
        parentCategoryId = parentCategoryId.equals(ConsentConfig.RETURN_NULL) ? "" : parentCategoryId;
        categoryName = categoryName.equals(ConsentConfig.RETURN_NULL) ? "" : categoryName;

        arrayList.add(new CategoryVO(categoryId, categoryCode, parentCategoryId, categoryName));

      }
    }

    return arrayList;
  }

  public static ArrayList<ConsentFormListVO> getConsentList(SoapObject object) {

    ArrayList<ConsentFormListVO> arrayList = new ArrayList<ConsentFormListVO>();

    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 idx             = so.getProperty("idx").toString().trim();
        String consentMstRid   = so.getProperty("consentMstRid").toString().trim();
        String formId          = so.getProperty("formId").toString().trim();
        String formCode        = so.getProperty("formCode").toString().trim();
        String formName        = so.getProperty("formName").toString().trim();
        String consentState    = so.getProperty("consentState").toString().trim();
        String consentStateEng = so.getProperty("consentStateEng").toString().trim();
        String prntCnt         = so.getProperty("prntCnt").toString().trim();
        String ocrTag          = so.getProperty("ocrTag").toString().trim();
        String cretNo          = so.getProperty("cretNo").toString().trim();
        String pid             = so.getProperty("pid").toString().trim();
        String patientName     = so.getProperty("patientName").toString().trim();
        String createUserId    = so.getProperty("createUserId").toString().trim();
        String deptCd          = so.getProperty("deptCd").toString().trim();
        String mainDrId        = so.getProperty("mainDrId").toString().trim();
        String inDd            = so.getProperty("inDd").toString().trim();
        String ordDeptCd       = so.getProperty("ordDeptCd").toString().trim();
        String ordType         = so.getProperty("ordType").toString().trim();

        idx             = idx.equals(ConsentConfig.RETURN_NULL) ? "" : idx;
        consentMstRid   = consentMstRid.equals(ConsentConfig.RETURN_NULL) ? "" : consentMstRid;
        formId          = formId.equals(ConsentConfig.RETURN_NULL) ? "" : formId;
        formCode        = formCode.equals(ConsentConfig.RETURN_NULL) ? "" : formCode;
        formName        = formName.equals(ConsentConfig.RETURN_NULL) ? "" : formName;
        consentState    = consentState.equals(ConsentConfig.RETURN_NULL) ? "" : consentState;
        consentStateEng = consentStateEng.equals(ConsentConfig.RETURN_NULL) ?  "" : consentStateEng;
        prntCnt         = prntCnt.equals(ConsentConfig.RETURN_NULL) ? "" : prntCnt;
        ocrTag          = ocrTag.equals(ConsentConfig.RETURN_NULL) ? "" : ocrTag;
        cretNo          = cretNo.equals(ConsentConfig.RETURN_NULL) ? "" : cretNo;
        pid             = pid.equals(ConsentConfig.RETURN_NULL) ? "" : pid;
        patientName     = patientName.equals(ConsentConfig.RETURN_NULL) ? "" : patientName;
        createUserId    = createUserId.equals(ConsentConfig.RETURN_NULL) ? "" : deptCd;
        deptCd          = deptCd.equals(ConsentConfig.RETURN_NULL) ? "" : deptCd;
        mainDrId        = mainDrId.equals(ConsentConfig.RETURN_NULL) ? "" : mainDrId;
        inDd            = inDd.equals(ConsentConfig.RETURN_NULL) ? "" : inDd;
        ordDeptCd       = ordDeptCd.equals(ConsentConfig.RETURN_NULL) ? "" : ordDeptCd;
        ordType         = ordType.equals(ConsentConfig.RETURN_NULL) ? "" : ordType;

//        arrayList.add(new ConsentFormListVO(consentMstRid, createUserId, ocrTag, pid, inDd, ordType, ordDeptCd, cretNo, opRsrvNo, patientName, consentState, consentStateEng, formCd, formGuid, formName, formRid, printOnly, pageCnt, ocrTagPrntYn, formPrntNm, certUseYn, opDiagNm, opNm, userDrFlag, linkFormCd, jinjeongCd, idx, formId, formCode));
        arrayList.add(new ConsentFormListVO(idx, consentMstRid, formId, formCode, formName, consentState, consentStateEng, prntCnt, ocrTag, cretNo, pid, patientName, createUserId, deptCd, mainDrId, inDd, ordDeptCd, ordType));
      }
    }

    return arrayList;
  }

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

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

        String ordDeptCd   = so.getProperty("ordDeptCd").toString().trim();
        String deptEngAbbr = so.getProperty("deptEngAbbr").toString().trim();
        String ordDeptNm   = so.getProperty("ordDeptNm").toString().trim();
        String pid         = so.getProperty("pid").toString().trim();
        String cretNo      = so.getProperty("cretNo").toString().trim();
        String roomCd      = so.getProperty("roomCd").toString().trim();
        String inDd        = so.getProperty("inDd").toString().trim();
        String dschDd      = so.getProperty("dschDd").toString().trim();
        String ordType     = so.getProperty("ordType").toString().trim();
        String instCd      = so.getProperty("instCd").toString().trim();
        String mainDrId    = so.getProperty("mainDrId").toString().trim();
        String mainDrName  = so.getProperty("mainDrName").toString().trim();
        String erDrNm      = so.getProperty("erDrNm").toString().trim();
        String firstRgstDt = so.getProperty("firstRgstDt").toString().trim();
        String sa          = so.getProperty("sa").toString().trim();
        String patientName = so.getProperty("patientName").toString().trim();
        String juminNo     = so.getProperty("juminNo").toString().trim();
        String zipCdAddr   = so.getProperty("zipCdAddr").toString().trim();
        String telNum      = so.getProperty("telNum").toString().trim();
        String insuKind    = so.getProperty("insuKind").toString().trim();
        String ward        = so.getProperty("ward").toString().trim();
        String dxCd        = so.getProperty("dxCd").toString().trim();
        String dxNm        = so.getProperty("dxNm").toString().trim();
        String gbn         = so.getProperty("gbn").toString().trim();
        String opDeptCd    = so.getProperty("opDeptCd").toString().trim();
        String opDeptNm    = so.getProperty("opDeptNm").toString().trim();
        String opDrNm      = so.getProperty("opDrNm").toString().trim();
        String opDrId      = so.getProperty("opDrId").toString().trim();
        String opCnfmDd    = so.getProperty("opCnfmDd").toString().trim();
        String perfDrNm    = so.getProperty("perfDrNm").toString().trim();
        String perfDrFlag  = so.getProperty("perfDrFlag").toString().trim();
        String perfDrDept  = so.getProperty("perfDrDept").toString().trim();
        String opDiagNm    = so.getProperty("opDiagNm").toString().trim();
        String opNm        = so.getProperty("opNm").toString().trim();
        String anstDrNm1   = so.getProperty("anstDrNm1").toString().trim();
        String anstDrFlag1 = so.getProperty("anstDrFlag1").toString().trim();
        String anstDeptNm1 = so.getProperty("anstDeptNm1").toString().trim();
        String anstDrNm2   = so.getProperty("anstDrNm2").toString().trim();
        String anstDrFlag2 = so.getProperty("anstDrFlag2").toString().trim();
        String anstDeptNm2 = so.getProperty("anstDeptNm2").toString().trim();
        String anstDrNm3   = so.getProperty("anstDrNm3").toString().trim();
        String anstDrFlag3 = so.getProperty("anstDrFlag3").toString().trim();
        String anstDeptNm3 = so.getProperty("anstDeptNm3").toString().trim();
        String opRsrvNo    = so.getProperty("opRsrvNo").toString().trim();
        String orderNo     = so.getProperty("orderNo").toString().trim();
        String printTime   = so.getProperty("printTime").toString().trim();
        String ocrCd       = so.getProperty("ocrCd").toString().trim();
        String inputId     = so.getProperty("inputId").toString().trim();
        String inputNm     = so.getProperty("inputNm").toString().trim();
        String signImg     = so.getProperty("signImg").toString().trim();
        String bp          = so.getProperty("bp").toString().trim();
        String dm          = so.getProperty("dm").toString().trim();
        String heart       = so.getProperty("heart").toString().trim();
        String kidney      = so.getProperty("kidney").toString().trim();
        String respiration = so.getProperty("respiration").toString().trim();
        String hx          = so.getProperty("hx").toString().trim();
        String allergy     = so.getProperty("allergy").toString().trim();
        String drug        = so.getProperty("drug").toString().trim();
        String smoking     = so.getProperty("smoking").toString().trim();
        String idio        = so.getProperty("idio").toString().trim();
        String nacrotics   = so.getProperty("nacrotics").toString().trim();
        String airway      = so.getProperty("airway").toString().trim();
        String hemorrhage  = so.getProperty("hemorrhage").toString().trim();
        String statusEtc   = so.getProperty("statusEtc").toString().trim();

        ordDeptCd   = ordDeptCd.equals(ConsentConfig.RETURN_NULL) ? "" : ordDeptCd;
        deptEngAbbr = deptEngAbbr.equals(ConsentConfig.RETURN_NULL) ? "" : deptEngAbbr;
        ordDeptNm   = ordDeptNm.equals(ConsentConfig.RETURN_NULL) ? "" : ordDeptNm;
        pid         = pid.equals(ConsentConfig.RETURN_NULL) ? "" : pid;
        cretNo      = cretNo.equals(ConsentConfig.RETURN_NULL) ? "" : cretNo;
        roomCd      = roomCd.equals(ConsentConfig.RETURN_NULL) ? "" : roomCd;
        inDd        = inDd .equals(ConsentConfig.RETURN_NULL) ? "" : inDd;
        dschDd      = dschDd.equals(ConsentConfig.RETURN_NULL) ? "" : dschDd;
        ordType     = ordType.equals(ConsentConfig.RETURN_NULL) ? "" : ordType;
        instCd      = instCd.equals(ConsentConfig.RETURN_NULL) ? "" : instCd;
        mainDrId    = mainDrId.equals(ConsentConfig.RETURN_NULL) ? "" : mainDrId;
        mainDrName  = mainDrName.equals(ConsentConfig.RETURN_NULL) ? "" : mainDrName;
        erDrNm      = erDrNm.equals(ConsentConfig.RETURN_NULL) ? "" : erDrNm;
        firstRgstDt = firstRgstDt.equals(ConsentConfig.RETURN_NULL) ? "" : firstRgstDt;
        sa          = sa.equals(ConsentConfig.RETURN_NULL) ? "" : sa;
        patientName = patientName.equals(ConsentConfig.RETURN_NULL) ? "" : patientName;
        juminNo     = juminNo.equals(ConsentConfig.RETURN_NULL) ? "" : juminNo;
        zipCdAddr   = zipCdAddr.equals(ConsentConfig.RETURN_NULL) ? "" : zipCdAddr;
        telNum      = telNum.equals(ConsentConfig.RETURN_NULL) ? "" : telNum;
        insuKind    = insuKind.equals(ConsentConfig.RETURN_NULL) ? "" : insuKind;
        ward        = ward.equals(ConsentConfig.RETURN_NULL) ? "" : ward;
        dxCd        = dxCd.equals(ConsentConfig.RETURN_NULL) ? "" : dxCd;
        dxNm        = dxNm.equals(ConsentConfig.RETURN_NULL) ? "" : dxNm;
        gbn         = gbn.equals(ConsentConfig.RETURN_NULL) ? "" : gbn;
        opDeptCd    = opDeptCd.equals(ConsentConfig.RETURN_NULL) ? "" : opDeptCd;
        opDeptNm    = opDeptNm.equals(ConsentConfig.RETURN_NULL) ? "" : opDeptNm;
        opDrNm      = opDrNm.equals(ConsentConfig.RETURN_NULL) ? "" : opDrNm;
        opDrId      = opDrId.equals(ConsentConfig.RETURN_NULL) ? "" : opDrId;
        opCnfmDd    = opCnfmDd.equals(ConsentConfig.RETURN_NULL) ? "" : opCnfmDd;
        perfDrNm    = perfDrNm.equals(ConsentConfig.RETURN_NULL) ? "" : perfDrNm;
        perfDrFlag  = perfDrFlag.equals(ConsentConfig.RETURN_NULL) ? "" : perfDrFlag;
        perfDrDept  = perfDrDept.equals(ConsentConfig.RETURN_NULL) ? "" : perfDrDept;
        opDiagNm    = opDiagNm.equals(ConsentConfig.RETURN_NULL) ? "" : opDiagNm;
        opNm        = opNm.equals(ConsentConfig.RETURN_NULL) ? "" : opNm;
        anstDrNm1   = anstDrNm1.equals(ConsentConfig.RETURN_NULL) ? "" : anstDrNm1;
        anstDrFlag1 = anstDrFlag1.equals(ConsentConfig.RETURN_NULL) ? "" : anstDrFlag1;
        anstDeptNm1 = anstDeptNm1.equals(ConsentConfig.RETURN_NULL) ? "" : anstDeptNm1;
        anstDrNm2   = anstDrNm2.equals(ConsentConfig.RETURN_NULL) ? "" : anstDrNm2;
        anstDrFlag2 = anstDrFlag2.equals(ConsentConfig.RETURN_NULL) ? "" : anstDrFlag2;
        anstDeptNm2 = anstDeptNm2.equals(ConsentConfig.RETURN_NULL) ? "" : anstDeptNm2;
        anstDrNm3   = anstDrNm3.equals(ConsentConfig.RETURN_NULL) ? "" : anstDrNm3;
        anstDrFlag3 = anstDrFlag3.equals(ConsentConfig.RETURN_NULL) ? "" : anstDrFlag3;
        anstDeptNm3 = anstDeptNm3.equals(ConsentConfig.RETURN_NULL) ? "" : anstDeptNm3;
        opRsrvNo    = opRsrvNo.equals(ConsentConfig.RETURN_NULL) ? "" : opRsrvNo;
        orderNo     = orderNo.equals(ConsentConfig.RETURN_NULL) ? "" : orderNo;
        printTime   = printTime.equals(ConsentConfig.RETURN_NULL) ? "" : printTime;
        ocrCd       = ocrCd.equals(ConsentConfig.RETURN_NULL) ? "" : ocrCd;
        inputId     = inputId.equals(ConsentConfig.RETURN_NULL) ? "" : inputId;
        inputNm     = inputNm.equals(ConsentConfig.RETURN_NULL) ? "" : inputNm;
        signImg     = signImg.equals(ConsentConfig.RETURN_NULL) ? "" : signImg;
        bp          = bp.equals(ConsentConfig.RETURN_NULL) ? "" : bp;
        dm          = dm.equals(ConsentConfig.RETURN_NULL) ? "" : dm;
        heart       = heart.equals(ConsentConfig.RETURN_NULL) ? "" : heart;
        kidney      = kidney.equals(ConsentConfig.RETURN_NULL) ? "" : kidney;
        respiration = respiration.equals(ConsentConfig.RETURN_NULL) ? "" : respiration;
        hx          = hx.equals(ConsentConfig.RETURN_NULL) ? "" : hx;
        allergy     = allergy.equals(ConsentConfig.RETURN_NULL) ? "" : allergy;
        drug        = drug.equals(ConsentConfig.RETURN_NULL) ? "" : drug;
        smoking     = smoking.equals(ConsentConfig.RETURN_NULL) ? "" : smoking;
        idio        = idio.equals(ConsentConfig.RETURN_NULL) ? "" : idio;
        nacrotics   = nacrotics.equals(ConsentConfig.RETURN_NULL) ? "" : nacrotics;
        airway      = airway.equals(ConsentConfig.RETURN_NULL) ? "" : airway;
        hemorrhage  = hemorrhage.equals(ConsentConfig.RETURN_NULL) ? "" : hemorrhage;
        statusEtc   = statusEtc.equals(ConsentConfig.RETURN_NULL) ? "" : statusEtc;

        patientInfoVO.setOrdDeptCd(ordDeptCd);
        patientInfoVO.setDeptEngAbbr(deptEngAbbr);
        patientInfoVO.setOrdDeptNm(ordDeptNm);
        patientInfoVO.setPid(pid);
        patientInfoVO.setCretNo(cretNo);
        patientInfoVO.setRoomCd(roomCd);
        patientInfoVO.setInDd(inDd);
        patientInfoVO.setDschDd(dschDd);
        patientInfoVO.setOrdType(ordType);
        patientInfoVO.setInstCd(instCd);
        patientInfoVO.setMainDrId(mainDrId);
        patientInfoVO.setMainDrName(mainDrName);
        patientInfoVO.setErDrNm(erDrNm);
        patientInfoVO.setFirstRgstDt(firstRgstDt);
        patientInfoVO.setSa(sa);
        patientInfoVO.setPatientName(patientName);
        patientInfoVO.setJuminNo(juminNo);
        patientInfoVO.setZipCdAddr(zipCdAddr);
        patientInfoVO.setTelNum(telNum);
        patientInfoVO.setInsuKind(insuKind);
        patientInfoVO.setWard(ward);
        patientInfoVO.setDxCd(dxCd);
        patientInfoVO.setDxNm(dxNm);
        patientInfoVO.setGbn(gbn);
        patientInfoVO.setOpDeptCd(opDeptCd);
        patientInfoVO.setOpDeptNm(opDeptNm);
        patientInfoVO.setOpDrNm(opDrNm);
        patientInfoVO.setOpDrId(opDrId);
        patientInfoVO.setOpCnfmDd(opCnfmDd);
        patientInfoVO.setPerfDrNm(perfDrNm);
        patientInfoVO.setPerfDrFlag(perfDrFlag);
        patientInfoVO.setPerfDrDept(perfDrDept);
        patientInfoVO.setOpDiagNm(opDiagNm);
        patientInfoVO.setOpNm(opNm);
        patientInfoVO.setAnstDrNm1(anstDrNm1);
        patientInfoVO.setAnstDrFlag1(anstDrFlag1);
        patientInfoVO.setAnstDeptNm1(anstDeptNm1);
        patientInfoVO.setAnstDrNm2(anstDrNm2);
        patientInfoVO.setAnstDrFlag2(anstDrFlag2);
        patientInfoVO.setAnstDeptNm2(anstDeptNm2);
        patientInfoVO.setAnstDrNm3(anstDrNm3);
        patientInfoVO.setAnstDrFlag3(anstDrFlag3);
        patientInfoVO.setAnstDeptNm3(anstDeptNm3);
        patientInfoVO.setOpRsrvNo(opRsrvNo);
        patientInfoVO.setOrderNo(orderNo);
        patientInfoVO.setPrintTime(printTime);
        patientInfoVO.setOcrCd(ocrCd);
        patientInfoVO.setInputId(inputId);
        patientInfoVO.setInputNm(inputNm);
        patientInfoVO.setSignImg(signImg);
        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);

      }
    }

    return patientInfoVO;
  }

  public static ArrayList<ConsentImageVO> getConsentImage(SoapObject object) {

    ArrayList<ConsentImageVO> arrayList = new ArrayList<ConsentImageVO>();

    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 imagePath     = so.getProperty("imagePath").toString().trim();
        String imageFileName = so.getProperty("imageFilename").toString().trim();

        arrayList.add(new ConsentImageVO(imagePath, imageFileName));
      }
    }

    return arrayList;
  }

  public static ArrayList<TestVO> getDemoConsentList(SoapObject object) {

    ArrayList<TestVO> arrayList = new ArrayList<TestVO>();

    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 idx      = so.getProperty("idx").toString().trim();
        String formId   = so.getProperty("formId").toString().trim();;
        String formCode = so.getProperty("formCode").toString().trim();
        String formName = so.getProperty("formName").toString().trim();

        idx   = idx.equals(ConsentConfig.RETURN_NULL) ? "" : idx;
        formId = formId.equals(ConsentConfig.RETURN_NULL) ? "" : formId;
        formCode = formCode.equals(ConsentConfig.RETURN_NULL) ? "" : formCode;
        formName = formName.equals(ConsentConfig.RETURN_NULL) ? "" : formName;

        arrayList.add(new TestVO(idx, formId, formCode, formName));

      }
    }

    return arrayList;
  }

}

