public static ims.clinical.domain.objects.PatientSpecialNeed extractPatientSpecialNeed(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.clinical.vo.PatientSpecialNeedVo valueObject,
      HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_PatientSpecialNeed();
    ims.clinical.domain.objects.PatientSpecialNeed domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.clinical.domain.objects.PatientSpecialNeed) domMap.get(valueObject);
      }
      // ims.clinical.vo.PatientSpecialNeedVo ID_PatientSpecialNeed field is unknown
      domainObject = new ims.clinical.domain.objects.PatientSpecialNeed();
      domMap.put(valueObject, domainObject);
    } else {
      String key =
          (valueObject.getClass().getName() + "__" + valueObject.getID_PatientSpecialNeed());
      if (domMap.get(key) != null) {
        return (ims.clinical.domain.objects.PatientSpecialNeed) domMap.get(key);
      }
      domainObject =
          (ims.clinical.domain.objects.PatientSpecialNeed)
              domainFactory.getDomainObject(
                  ims.clinical.domain.objects.PatientSpecialNeed.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_PatientSpecialNeed());

    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value1 = null;
    if (null != valueObject.getSpecialNeed()) {
      value1 = domainFactory.getLookupInstance(valueObject.getSpecialNeed().getID());
    }
    domainObject.setSpecialNeed(value1);
    // 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.getDetails() != null && valueObject.getDetails().equals("")) {
      valueObject.setDetails(null);
    }
    domainObject.setDetails(valueObject.getDetails());
    domainObject.setIsActive(valueObject.getIsActive());

    return domainObject;
  }