/**
   * Create the ValueObject collection to hold the set of DomainObjects.
   *
   * @param map - maps DomainObjects to created ValueObjects
   * @param domainObjectSet - Set of ims.core.clinical.domain.objects.Service objects.
   */
  public static ims.core.vo.ServiceShortVoCollection createServiceShortVoCollectionFromService(
      DomainObjectMap map, java.util.Set domainObjectSet) {
    ims.core.vo.ServiceShortVoCollection voList = new ims.core.vo.ServiceShortVoCollection();
    if (null == domainObjectSet) {
      return voList;
    }
    int rieCount = 0;
    int activeCount = 0;
    java.util.Iterator iterator = domainObjectSet.iterator();
    while (iterator.hasNext()) {
      ims.core.clinical.domain.objects.Service domainObject =
          (ims.core.clinical.domain.objects.Service) iterator.next();
      ims.core.vo.ServiceShortVo vo = create(map, domainObject);

      if (vo != null) voList.add(vo);

      if (domainObject != null) {
        if (domainObject.getIsRIE() != null && domainObject.getIsRIE().booleanValue() == true)
          rieCount++;
        else activeCount++;
      }
    }
    voList.setRieCount(rieCount);
    voList.setActiveCount(activeCount);
    return voList;
  }
  /**
   * Create the ValueObject collection to hold the list of DomainObjects.
   *
   * @param map - maps DomainObjects to created ValueObjects
   * @param domainObjectList - List of ims.core.clinical.domain.objects.Service objects.
   */
  public static ims.core.vo.ServiceShortVoCollection createServiceShortVoCollectionFromService(
      DomainObjectMap map, java.util.List domainObjectList) {
    ims.core.vo.ServiceShortVoCollection voList = new ims.core.vo.ServiceShortVoCollection();
    if (null == domainObjectList) {
      return voList;
    }
    int rieCount = 0;
    int activeCount = 0;
    for (int i = 0; i < domainObjectList.size(); i++) {
      ims.core.clinical.domain.objects.Service domainObject =
          (ims.core.clinical.domain.objects.Service) domainObjectList.get(i);
      ims.core.vo.ServiceShortVo vo = create(map, domainObject);

      if (vo != null) voList.add(vo);

      if (domainObject != null) {
        if (domainObject.getIsRIE() != null && domainObject.getIsRIE().booleanValue() == true)
          rieCount++;
        else activeCount++;
      }
    }

    voList.setRieCount(rieCount);
    voList.setActiveCount(activeCount);
    return voList;
  }
  /**
   * Create the ValueObject from the ims.core.clinical.domain.objects.Service object.
   *
   * @param map DomainObjectMap of DomainObjects to already created ValueObjects.
   * @param domainObject
   */
  public static ims.core.vo.ServiceShortVo create(
      DomainObjectMap map, ims.core.clinical.domain.objects.Service domainObject) {
    if (null == domainObject) {
      return null;
    }
    // check if the domainObject already has a valueObject created for it
    ims.core.vo.ServiceShortVo valueObject =
        (ims.core.vo.ServiceShortVo)
            map.getValueObject(domainObject, ims.core.vo.ServiceShortVo.class);
    if (null == valueObject) {
      valueObject = new ims.core.vo.ServiceShortVo(domainObject.getId(), domainObject.getVersion());
      map.addValueObject(domainObject, valueObject);

      valueObject = insert(map, valueObject, domainObject);
    }
    return valueObject;
  }
 public static void fillFieldsfromXML(
     org.dom4j.Element el,
     ims.domain.DomainFactory factory,
     ElectiveListConfiguration obj,
     java.util.HashMap domMap)
     throws Exception {
   org.dom4j.Element fldEl;
   fldEl = el.element("waitingListName");
   if (fldEl != null) {
     obj.setWaitingListName(new String(fldEl.getTextTrim()));
   }
   fldEl = el.element("startDate");
   if (fldEl != null) {
     obj.setStartDate(
         new java.text.SimpleDateFormat("yyyyMMddHHmmssSSS").parse(fldEl.getTextTrim()));
   }
   fldEl = el.element("endDate");
   if (fldEl != null) {
     obj.setEndDate(
         new java.text.SimpleDateFormat("yyyyMMddHHmmssSSS").parse(fldEl.getTextTrim()));
   }
   fldEl = el.element("service");
   if (fldEl != null) {
     fldEl = fldEl.element("class");
     obj.setService(
         ims.core.clinical.domain.objects.Service.getServicefromXML(fldEl, factory, domMap));
   }
   fldEl = el.element("hCPs");
   if (fldEl != null) {
     fldEl = fldEl.element("list");
     obj.setHCPs(
         ims.core.configuration.domain.objects.ElectiveListConsultationConfiguration
             .fromListXMLString(fldEl, factory, obj.getHCPs(), domMap));
   }
   fldEl = el.element("listLocations");
   if (fldEl != null) {
     fldEl = fldEl.element("list");
     obj.setListLocations(
         ims.core.configuration.domain.objects.ElectiveListHospitalConfiguration.fromListXMLString(
             fldEl, factory, obj.getListLocations(), domMap));
   }
   fldEl = el.element("waitingListCode");
   if (fldEl != null) {
     obj.setWaitingListCode(new String(fldEl.getTextTrim()));
   }
   fldEl = el.element("isActive");
   if (fldEl != null) {
     obj.setIsActive(new Boolean(fldEl.getTextTrim()));
   }
 }
 public static void fillFieldsfromXML(
     org.dom4j.Element el,
     ims.domain.DomainFactory factory,
     LoCallWaitingListDetails obj,
     java.util.HashMap domMap)
     throws Exception {
   org.dom4j.Element fldEl;
   fldEl = el.element("speciality");
   if (fldEl != null) {
     fldEl = fldEl.element("class");
     obj.setSpeciality(
         ims.core.clinical.domain.objects.Service.getServicefromXML(fldEl, factory, domMap));
   }
   fldEl = el.element("procedure");
   if (fldEl != null) {
     fldEl = fldEl.element("class");
     obj.setProcedure(
         ims.core.resource.place.domain.objects.Activity.getActivityfromXML(
             fldEl, factory, domMap));
   }
   fldEl = el.element("procedureText");
   if (fldEl != null) {
     obj.setProcedureText(new String(fldEl.getTextTrim()));
   }
   fldEl = el.element("referringHospital");
   if (fldEl != null) {
     fldEl = fldEl.element("class");
     obj.setReferringHospital(
         ims.core.resource.place.domain.objects.Location.getLocationfromXML(
             fldEl, factory, domMap));
   }
   fldEl = el.element("referringConsultant");
   if (fldEl != null) {
     fldEl = fldEl.element("class");
     obj.setReferringConsultant(
         ims.core.resource.people.domain.objects.Medic.getMedicfromXML(fldEl, factory, domMap));
   }
   fldEl = el.element("referringConsultantText");
   if (fldEl != null) {
     obj.setReferringConsultantText(new String(fldEl.getTextTrim()));
   }
   fldEl = el.element("category");
   if (fldEl != null) {
     fldEl = fldEl.element("lki");
     obj.setCategory(ims.domain.lookups.LookupInstance.fromXMLString(fldEl, factory));
   }
   fldEl = el.element("waitingListType");
   if (fldEl != null) {
     fldEl = fldEl.element("lki");
     obj.setWaitingListType(ims.domain.lookups.LookupInstance.fromXMLString(fldEl, factory));
   }
   fldEl = el.element("waitingListDate");
   if (fldEl != null) {
     obj.setWaitingListDate(
         new java.text.SimpleDateFormat("yyyyMMddHHmmssSSS").parse(fldEl.getTextTrim()));
   }
   fldEl = el.element("waitingListMonthInterval");
   if (fldEl != null) {
     obj.setWaitingListMonthInterval(new Integer(fldEl.getTextTrim()));
   }
   fldEl = el.element("waitingListLengthQualifier");
   if (fldEl != null) {
     fldEl = fldEl.element("lki");
     obj.setWaitingListLengthQualifier(
         ims.domain.lookups.LookupInstance.fromXMLString(fldEl, factory));
   }
   fldEl = el.element("faxTo");
   if (fldEl != null) {
     fldEl = fldEl.element("class");
     obj.setFaxTo(
         ims.core.resource.people.domain.objects.MemberOfStaff.getMemberOfStafffromXML(
             fldEl, factory, domMap));
   }
   fldEl = el.element("faxDate");
   if (fldEl != null) {
     obj.setFaxDate(
         new java.text.SimpleDateFormat("yyyyMMddHHmmssSSS").parse(fldEl.getTextTrim()));
   }
   fldEl = el.element("liaisonQuery");
   if (fldEl != null) {
     obj.setLiaisonQuery(new String(fldEl.getTextTrim()));
   }
   fldEl = el.element("statusHistory");
   if (fldEl != null) {
     fldEl = fldEl.element("set");
     obj.setStatusHistory(
         ims.ntpf.locall.domain.objects.LoCallStatus.fromSetXMLString(
             fldEl, factory, obj.getStatusHistory(), domMap));
   }
   fldEl = el.element("currentStatus");
   if (fldEl != null) {
     fldEl = fldEl.element("lki");
     obj.setCurrentStatus(ims.domain.lookups.LookupInstance.fromXMLString(fldEl, factory));
   }
   fldEl = el.element("currentStatusReason");
   if (fldEl != null) {
     fldEl = fldEl.element("lki");
     obj.setCurrentStatusReason(ims.domain.lookups.LookupInstance.fromXMLString(fldEl, factory));
   }
   fldEl = el.element("isLinkedtoCase");
   if (fldEl != null) {
     obj.setIsLinkedtoCase(new Boolean(fldEl.getTextTrim()));
   }
   fldEl = el.element("assocCase");
   if (fldEl != null) {
     fldEl = fldEl.element("class");
     obj.setAssocCase(
         ims.ntpf.casereferral.domain.objects.CaseReferral.getCaseReferralfromXML(
             fldEl, factory, domMap));
   }
   fldEl = el.element("assocLocall");
   if (fldEl != null) {
     fldEl = fldEl.element("class");
     obj.setAssocLocall(
         ims.ntpf.locall.domain.objects.LoCall.getLoCallfromXML(fldEl, factory, domMap));
   }
   fldEl = el.element("hospital");
   if (fldEl != null) {
     fldEl = fldEl.element("class");
     obj.setHospital(
         ims.core.resource.place.domain.objects.Location.getLocationfromXML(
             fldEl, factory, domMap));
   }
   fldEl = el.element("mrn");
   if (fldEl != null) {
     obj.setMrn(new String(fldEl.getTextTrim()));
   }
   fldEl = el.element("episodeNumber");
   if (fldEl != null) {
     obj.setEpisodeNumber(new String(fldEl.getTextTrim()));
   }
 }
  public String toAuditString() {
    StringBuffer auditStr = new StringBuffer();

    auditStr.append("\r\n*speciality* :");
    if (speciality != null) {
      auditStr.append(toShortClassName(speciality));

      auditStr.append(speciality.getId());
    }
    auditStr.append("; ");
    auditStr.append("\r\n*procedure* :");
    if (procedure != null) {
      auditStr.append(toShortClassName(procedure));

      auditStr.append(procedure.getId());
    }
    auditStr.append("; ");
    auditStr.append("\r\n*procedureText* :");
    auditStr.append(procedureText);
    auditStr.append("; ");
    auditStr.append("\r\n*referringHospital* :");
    if (referringHospital != null) {
      auditStr.append(toShortClassName(referringHospital));

      auditStr.append(referringHospital.getId());
    }
    auditStr.append("; ");
    auditStr.append("\r\n*referringConsultant* :");
    if (referringConsultant != null) {
      auditStr.append(toShortClassName(referringConsultant));

      auditStr.append(referringConsultant.getId());
    }
    auditStr.append("; ");
    auditStr.append("\r\n*referringConsultantText* :");
    auditStr.append(referringConsultantText);
    auditStr.append("; ");
    auditStr.append("\r\n*category* :");
    if (category != null) auditStr.append(category.getText());
    auditStr.append("; ");
    auditStr.append("\r\n*waitingListType* :");
    if (waitingListType != null) auditStr.append(waitingListType.getText());
    auditStr.append("; ");
    auditStr.append("\r\n*waitingListDate* :");
    auditStr.append(waitingListDate);
    auditStr.append("; ");
    auditStr.append("\r\n*waitingListMonthInterval* :");
    auditStr.append(waitingListMonthInterval);
    auditStr.append("; ");
    auditStr.append("\r\n*waitingListLengthQualifier* :");
    if (waitingListLengthQualifier != null) auditStr.append(waitingListLengthQualifier.getText());
    auditStr.append("; ");
    auditStr.append("\r\n*faxTo* :");
    if (faxTo != null) {
      auditStr.append(toShortClassName(faxTo));

      auditStr.append(faxTo.getId());
    }
    auditStr.append("; ");
    auditStr.append("\r\n*faxDate* :");
    auditStr.append(faxDate);
    auditStr.append("; ");
    auditStr.append("\r\n*liaisonQuery* :");
    auditStr.append(liaisonQuery);
    auditStr.append("; ");
    auditStr.append("\r\n*statusHistory* :");
    if (statusHistory != null) {
      java.util.Iterator it15 = statusHistory.iterator();
      int i15 = 0;
      while (it15.hasNext()) {
        if (i15 > 0) auditStr.append(",");
        ims.ntpf.locall.domain.objects.LoCallStatus obj =
            (ims.ntpf.locall.domain.objects.LoCallStatus) it15.next();
        if (obj != null) {
          if (i15 == 0) {
            auditStr.append(toShortClassName(obj));
            auditStr.append("[");
          }

          auditStr.append(obj.getId());
        }
        i15++;
      }
      if (i15 > 0) auditStr.append("] " + i15);
    }
    auditStr.append("; ");
    auditStr.append("\r\n*currentStatus* :");
    if (currentStatus != null) auditStr.append(currentStatus.getText());
    auditStr.append("; ");
    auditStr.append("\r\n*currentStatusReason* :");
    if (currentStatusReason != null) auditStr.append(currentStatusReason.getText());
    auditStr.append("; ");
    auditStr.append("\r\n*isLinkedtoCase* :");
    auditStr.append(isLinkedtoCase);
    auditStr.append("; ");
    auditStr.append("\r\n*assocCase* :");
    if (assocCase != null) {
      auditStr.append(toShortClassName(assocCase));

      auditStr.append(assocCase.getId());
    }
    auditStr.append("; ");
    auditStr.append("\r\n*assocLocall* :");
    if (assocLocall != null) {
      auditStr.append(toShortClassName(assocLocall));

      auditStr.append(assocLocall.getId());
    }
    auditStr.append("; ");
    auditStr.append("\r\n*hospital* :");
    if (hospital != null) {
      auditStr.append(toShortClassName(hospital));

      auditStr.append(hospital.getId());
    }
    auditStr.append("; ");
    auditStr.append("\r\n*mrn* :");
    auditStr.append(mrn);
    auditStr.append("; ");
    auditStr.append("\r\n*episodeNumber* :");
    auditStr.append(episodeNumber);
    auditStr.append("; ");
    return auditStr.toString();
  }
  public String toAuditString() {
    StringBuffer auditStr = new StringBuffer();

    auditStr.append("\r\n*waitingListName* :");
    auditStr.append(waitingListName);
    auditStr.append("; ");
    auditStr.append("\r\n*startDate* :");
    auditStr.append(startDate);
    auditStr.append("; ");
    auditStr.append("\r\n*endDate* :");
    auditStr.append(endDate);
    auditStr.append("; ");
    auditStr.append("\r\n*service* :");
    if (service != null) {
      auditStr.append(toShortClassName(service));

      auditStr.append(service.getId());
    }
    auditStr.append("; ");
    auditStr.append("\r\n*hCPs* :");
    if (hCPs != null) {
      int i5 = 0;
      for (i5 = 0; i5 < hCPs.size(); i5++) {
        if (i5 > 0) auditStr.append(",");
        ims.core.configuration.domain.objects.ElectiveListConsultationConfiguration obj =
            (ims.core.configuration.domain.objects.ElectiveListConsultationConfiguration)
                hCPs.get(i5);
        if (obj != null) {
          if (i5 == 0) {
            auditStr.append(toShortClassName(obj));
            auditStr.append("[");
          }
          auditStr.append(obj.getId());
        }
      }
      if (i5 > 0) auditStr.append("] " + i5);
    }
    auditStr.append("; ");
    auditStr.append("\r\n*listLocations* :");
    if (listLocations != null) {
      int i6 = 0;
      for (i6 = 0; i6 < listLocations.size(); i6++) {
        if (i6 > 0) auditStr.append(",");
        ims.core.configuration.domain.objects.ElectiveListHospitalConfiguration obj =
            (ims.core.configuration.domain.objects.ElectiveListHospitalConfiguration)
                listLocations.get(i6);
        if (obj != null) {
          if (i6 == 0) {
            auditStr.append(toShortClassName(obj));
            auditStr.append("[");
          }
          auditStr.append(obj.getId());
        }
      }
      if (i6 > 0) auditStr.append("] " + i6);
    }
    auditStr.append("; ");
    auditStr.append("\r\n*waitingListCode* :");
    auditStr.append(waitingListCode);
    auditStr.append("; ");
    auditStr.append("\r\n*isActive* :");
    auditStr.append(isActive);
    auditStr.append("; ");
    return auditStr.toString();
  }
  public static ims.core.clinical.domain.objects.Service extractService(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.core.vo.ServiceShortVo valueObject,
      HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_Service();
    ims.core.clinical.domain.objects.Service domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.core.clinical.domain.objects.Service) domMap.get(valueObject);
      }
      // ims.core.vo.ServiceShortVo ID_Service field is unknown
      domainObject = new ims.core.clinical.domain.objects.Service();
      domMap.put(valueObject, domainObject);
    } else {
      String key = (valueObject.getClass().getName() + "__" + valueObject.getID_Service());
      if (domMap.get(key) != null) {
        return (ims.core.clinical.domain.objects.Service) domMap.get(key);
      }
      domainObject =
          (ims.core.clinical.domain.objects.Service)
              domainFactory.getDomainObject(ims.core.clinical.domain.objects.Service.class, id);

      // TODO: Not sure how this should be handled. Effectively it must be a staleobject exception,
      // but maybe should be handled as that further up.
      if (domainObject == null) return null;

      domMap.put(key, domainObject);
    }
    domainObject.setVersion(valueObject.getVersion_Service());

    // This is to overcome a bug in both Sybase and Oracle which prevents them from storing an empty
    // string correctly
    // Sybase stores it as a single space, Oracle stores it as NULL. This fix will make them
    // consistent at least.
    if (valueObject.getServiceDescription() != null
        && valueObject.getServiceDescription().equals("")) {
      valueObject.setServiceDescription(null);
    }
    domainObject.setServiceDescription(valueObject.getServiceDescription());
    domainObject.setIsActive(valueObject.getIsActive());
    // This is to overcome a bug in both Sybase and Oracle which prevents them from storing an empty
    // string correctly
    // Sybase stores it as a single space, Oracle stores it as NULL. This fix will make them
    // consistent at least.
    if (valueObject.getAlternateServiceCode() != null
        && valueObject.getAlternateServiceCode().equals("")) {
      valueObject.setAlternateServiceCode(null);
    }
    domainObject.setAlternateServiceCode(valueObject.getAlternateServiceCode());
    // This is to overcome a bug in both Sybase and Oracle which prevents them from storing an empty
    // string correctly
    // Sybase stores it as a single space, Oracle stores it as NULL. This fix will make them
    // consistent at least.
    if (valueObject.getServiceName() != null && valueObject.getServiceName().equals("")) {
      valueObject.setServiceName(null);
    }
    domainObject.setServiceName(valueObject.getServiceName());
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value5 = null;
    if (null != valueObject.getServiceCategory()) {
      value5 = domainFactory.getLookupInstance(valueObject.getServiceCategory().getID());
    }
    domainObject.setServiceCategory(value5);
    domainObject.setCanBeScheduled(valueObject.getCanBeScheduled());
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value7 = null;
    if (null != valueObject.getSpecialty()) {
      value7 = domainFactory.getLookupInstance(valueObject.getSpecialty().getID());
    }
    domainObject.setSpecialty(value7);
    domainObject.setExpectedTurnaround(valueObject.getExpectedTurnaround());
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value9 = null;
    if (null != valueObject.getTurnaroundMeasure()) {
      value9 = domainFactory.getLookupInstance(valueObject.getTurnaroundMeasure().getID());
    }
    domainObject.setTurnaroundMeasure(value9);
    domainObject.setMaternityIndicator(valueObject.getMaternityIndicator());

    return domainObject;
  }
  /**
   * Update the ValueObject with the Domain Object.
   *
   * @param map DomainObjectMap of DomainObjects to already created ValueObjects.
   * @param valueObject to be updated
   * @param domainObject ims.core.clinical.domain.objects.Service
   */
  public static ims.core.vo.ServiceShortVo insert(
      DomainObjectMap map,
      ims.core.vo.ServiceShortVo valueObject,
      ims.core.clinical.domain.objects.Service domainObject) {
    if (null == domainObject) {
      return valueObject;
    }
    if (null == map) {
      map = new DomainObjectMap();
    }

    valueObject.setID_Service(domainObject.getId());
    valueObject.setIsRIE(domainObject.getIsRIE());

    // If this is a recordedInError record, and the domainObject
    // value isIncludeRecord has not been set, then we return null and
    // not the value object
    if (valueObject.getIsRIE() != null
        && valueObject.getIsRIE().booleanValue() == true
        && !domainObject.isIncludeRecord()) return null;

    // If this is not a recordedInError record, and the domainObject
    // value isIncludeRecord has been set, then we return null and
    // not the value object
    if ((valueObject.getIsRIE() == null || valueObject.getIsRIE().booleanValue() == false)
        && domainObject.isIncludeRecord()) return null;

    // ServiceDescription
    valueObject.setServiceDescription(domainObject.getServiceDescription());
    // isActive
    valueObject.setIsActive(domainObject.isIsActive());
    // AlternateServiceCode
    valueObject.setAlternateServiceCode(domainObject.getAlternateServiceCode());
    // ServiceName
    valueObject.setServiceName(domainObject.getServiceName());
    // ServiceCategory
    ims.domain.lookups.LookupInstance instance5 = domainObject.getServiceCategory();
    if (null != instance5) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance5.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance5.getImage().getImageId(), instance5.getImage().getImagePath());
      }
      color = instance5.getColor();
      if (color != null) color.getValue();

      ims.core.vo.lookups.ServiceCategory voLookup5 =
          new ims.core.vo.lookups.ServiceCategory(
              instance5.getId(), instance5.getText(), instance5.isActive(), null, img, color);
      ims.core.vo.lookups.ServiceCategory parentVoLookup5 = voLookup5;
      ims.domain.lookups.LookupInstance parent5 = instance5.getParent();
      while (parent5 != null) {
        if (parent5.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent5.getImage().getImageId(), parent5.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent5.getColor();
        if (color != null) color.getValue();
        parentVoLookup5.setParent(
            new ims.core.vo.lookups.ServiceCategory(
                parent5.getId(), parent5.getText(), parent5.isActive(), null, img, color));
        parentVoLookup5 = parentVoLookup5.getParent();
        parent5 = parent5.getParent();
      }
      valueObject.setServiceCategory(voLookup5);
    }
    // CanBeScheduled
    valueObject.setCanBeScheduled(domainObject.isCanBeScheduled());
    // Specialty
    ims.domain.lookups.LookupInstance instance7 = domainObject.getSpecialty();
    if (null != instance7) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance7.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance7.getImage().getImageId(), instance7.getImage().getImagePath());
      }
      color = instance7.getColor();
      if (color != null) color.getValue();

      ims.core.vo.lookups.Specialty voLookup7 =
          new ims.core.vo.lookups.Specialty(
              instance7.getId(), instance7.getText(), instance7.isActive(), null, img, color);
      ims.core.vo.lookups.Specialty parentVoLookup7 = voLookup7;
      ims.domain.lookups.LookupInstance parent7 = instance7.getParent();
      while (parent7 != null) {
        if (parent7.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent7.getImage().getImageId(), parent7.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent7.getColor();
        if (color != null) color.getValue();
        parentVoLookup7.setParent(
            new ims.core.vo.lookups.Specialty(
                parent7.getId(), parent7.getText(), parent7.isActive(), null, img, color));
        parentVoLookup7 = parentVoLookup7.getParent();
        parent7 = parent7.getParent();
      }
      valueObject.setSpecialty(voLookup7);
    }
    // ExpectedTurnaround
    valueObject.setExpectedTurnaround(domainObject.getExpectedTurnaround());
    // TurnaroundMeasure
    ims.domain.lookups.LookupInstance instance9 = domainObject.getTurnaroundMeasure();
    if (null != instance9) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance9.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance9.getImage().getImageId(), instance9.getImage().getImagePath());
      }
      color = instance9.getColor();
      if (color != null) color.getValue();

      ims.ocrr.vo.lookups.MinReorderPeriod voLookup9 =
          new ims.ocrr.vo.lookups.MinReorderPeriod(
              instance9.getId(), instance9.getText(), instance9.isActive(), null, img, color);
      ims.ocrr.vo.lookups.MinReorderPeriod parentVoLookup9 = voLookup9;
      ims.domain.lookups.LookupInstance parent9 = instance9.getParent();
      while (parent9 != null) {
        if (parent9.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent9.getImage().getImageId(), parent9.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent9.getColor();
        if (color != null) color.getValue();
        parentVoLookup9.setParent(
            new ims.ocrr.vo.lookups.MinReorderPeriod(
                parent9.getId(), parent9.getText(), parent9.isActive(), null, img, color));
        parentVoLookup9 = parentVoLookup9.getParent();
        parent9 = parent9.getParent();
      }
      valueObject.setTurnaroundMeasure(voLookup9);
    }
    // MaternityIndicator
    valueObject.setMaternityIndicator(domainObject.isMaternityIndicator());
    return valueObject;
  }
  /**
   * Update the ValueObject with the Domain Object.
   *
   * @param map DomainObjectMap of DomainObjects to already created ValueObjects.
   * @param valueObject to be updated
   * @param domainObject ims.core.clinical.domain.objects.Service
   */
  public static ims.admin.vo.ServiceForElectiveListConfigVo insert(
      DomainObjectMap map,
      ims.admin.vo.ServiceForElectiveListConfigVo valueObject,
      ims.core.clinical.domain.objects.Service domainObject) {
    if (null == domainObject) {
      return valueObject;
    }
    if (null == map) {
      map = new DomainObjectMap();
    }

    valueObject.setID_Service(domainObject.getId());
    valueObject.setIsRIE(domainObject.getIsRIE());

    // If this is a recordedInError record, and the domainObject
    // value isIncludeRecord has not been set, then we return null and
    // not the value object
    if (valueObject.getIsRIE() != null
        && valueObject.getIsRIE().booleanValue() == true
        && !domainObject.isIncludeRecord()) return null;

    // If this is not a recordedInError record, and the domainObject
    // value isIncludeRecord has been set, then we return null and
    // not the value object
    if ((valueObject.getIsRIE() == null || valueObject.getIsRIE().booleanValue() == false)
        && domainObject.isIncludeRecord()) return null;

    // ServiceName
    valueObject.setServiceName(domainObject.getServiceName());
    // ServiceDescription
    valueObject.setServiceDescription(domainObject.getServiceDescription());
    // ServiceCategory
    ims.domain.lookups.LookupInstance instance3 = domainObject.getServiceCategory();
    if (null != instance3) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance3.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance3.getImage().getImageId(), instance3.getImage().getImagePath());
      }
      color = instance3.getColor();
      if (color != null) color.getValue();

      ims.core.vo.lookups.ServiceCategory voLookup3 =
          new ims.core.vo.lookups.ServiceCategory(
              instance3.getId(), instance3.getText(), instance3.isActive(), null, img, color);
      ims.core.vo.lookups.ServiceCategory parentVoLookup3 = voLookup3;
      ims.domain.lookups.LookupInstance parent3 = instance3.getParent();
      while (parent3 != null) {
        if (parent3.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent3.getImage().getImageId(), parent3.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent3.getColor();
        if (color != null) color.getValue();
        parentVoLookup3.setParent(
            new ims.core.vo.lookups.ServiceCategory(
                parent3.getId(), parent3.getText(), parent3.isActive(), null, img, color));
        parentVoLookup3 = parentVoLookup3.getParent();
        parent3 = parent3.getParent();
      }
      valueObject.setServiceCategory(voLookup3);
    }
    // Specialty
    ims.domain.lookups.LookupInstance instance4 = domainObject.getSpecialty();
    if (null != instance4) {
      ims.framework.utils.ImagePath img = null;
      ims.framework.utils.Color color = null;
      img = null;
      if (instance4.getImage() != null) {
        img =
            new ims.framework.utils.ImagePath(
                instance4.getImage().getImageId(), instance4.getImage().getImagePath());
      }
      color = instance4.getColor();
      if (color != null) color.getValue();

      ims.core.vo.lookups.Specialty voLookup4 =
          new ims.core.vo.lookups.Specialty(
              instance4.getId(), instance4.getText(), instance4.isActive(), null, img, color);
      ims.core.vo.lookups.Specialty parentVoLookup4 = voLookup4;
      ims.domain.lookups.LookupInstance parent4 = instance4.getParent();
      while (parent4 != null) {
        if (parent4.getImage() != null) {
          img =
              new ims.framework.utils.ImagePath(
                  parent4.getImage().getImageId(), parent4.getImage().getImagePath());
        } else {
          img = null;
        }
        color = parent4.getColor();
        if (color != null) color.getValue();
        parentVoLookup4.setParent(
            new ims.core.vo.lookups.Specialty(
                parent4.getId(), parent4.getText(), parent4.isActive(), null, img, color));
        parentVoLookup4 = parentVoLookup4.getParent();
        parent4 = parent4.getParent();
      }
      valueObject.setSpecialty(voLookup4);
    }
    // isActive
    valueObject.setIsActive(domainObject.isIsActive());
    // UpperName
    valueObject.setUpperName(domainObject.getUpperName());
    return valueObject;
  }