/**
  * Copy one ValueObject to another
  *
  * @param valueObjectDest to be updated
  * @param valueObjectSrc to copy values from
  */
 public static ims.core.vo.CareContextMinVo copy(
     ims.core.vo.CareContextMinVo valueObjectDest, ims.core.vo.CareContextMinVo valueObjectSrc) {
   if (null == valueObjectSrc) {
     return valueObjectSrc;
   }
   valueObjectDest.setID_CareContext(valueObjectSrc.getID_CareContext());
   valueObjectDest.setIsRIE(valueObjectSrc.getIsRIE());
   // EpisodeOfCare
   valueObjectDest.setEpisodeOfCare(valueObjectSrc.getEpisodeOfCare());
   // StartDateTime
   valueObjectDest.setStartDateTime(valueObjectSrc.getStartDateTime());
   // ResponsibleHCP
   valueObjectDest.setResponsibleHCP(valueObjectSrc.getResponsibleHCP());
   return valueObjectDest;
 }
  public static ims.core.admin.domain.objects.CareContext extractCareContext(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.core.vo.CareContextMinVo valueObject,
      HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_CareContext();
    ims.core.admin.domain.objects.CareContext domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.core.admin.domain.objects.CareContext) domMap.get(valueObject);
      }
      // ims.core.vo.CareContextMinVo ID_CareContext field is unknown
      domainObject = new ims.core.admin.domain.objects.CareContext();
      domMap.put(valueObject, domainObject);
    } else {
      String key = (valueObject.getClass().getName() + "__" + valueObject.getID_CareContext());
      if (domMap.get(key) != null) {
        return (ims.core.admin.domain.objects.CareContext) domMap.get(key);
      }
      domainObject =
          (ims.core.admin.domain.objects.CareContext)
              domainFactory.getDomainObject(ims.core.admin.domain.objects.CareContext.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_CareContext());

    // SaveAsRefVO - treated as a refVo in extract methods
    ims.core.admin.domain.objects.EpisodeOfCare value1 = null;
    if (null != valueObject.getEpisodeOfCare()) {
      if (valueObject.getEpisodeOfCare().getBoId() == null) {
        if (domMap.get(valueObject.getEpisodeOfCare()) != null) {
          value1 =
              (ims.core.admin.domain.objects.EpisodeOfCare)
                  domMap.get(valueObject.getEpisodeOfCare());
        }
      } else {
        value1 =
            (ims.core.admin.domain.objects.EpisodeOfCare)
                domainFactory.getDomainObject(
                    ims.core.admin.domain.objects.EpisodeOfCare.class,
                    valueObject.getEpisodeOfCare().getBoId());
      }
    }
    domainObject.setEpisodeOfCare(value1);
    ims.framework.utils.DateTime dateTime2 = valueObject.getStartDateTime();
    java.util.Date value2 = null;
    if (dateTime2 != null) {
      value2 = dateTime2.getJavaDate();
    }
    domainObject.setStartDateTime(value2);
    ims.core.resource.people.domain.objects.Hcp value3 = null;
    if (null != valueObject.getResponsibleHCP()) {
      if (valueObject.getResponsibleHCP().getBoId() == null) {
        if (domMap.get(valueObject.getResponsibleHCP()) != null) {
          value3 =
              (ims.core.resource.people.domain.objects.Hcp)
                  domMap.get(valueObject.getResponsibleHCP());
        }
      } else if (valueObject.getBoVersion()
          == -1) // RefVo was not modified since obtained from the Assembler, no need to update the
      // BO field
      {
        value3 = domainObject.getResponsibleHCP();
      } else {
        value3 =
            (ims.core.resource.people.domain.objects.Hcp)
                domainFactory.getDomainObject(
                    ims.core.resource.people.domain.objects.Hcp.class,
                    valueObject.getResponsibleHCP().getBoId());
      }
    }
    domainObject.setResponsibleHCP(value3);

    return domainObject;
  }