/**
   * Create the ValueObject collection to hold the list of DomainObjects.
   *
   * @param map - maps DomainObjects to created ValueObjects
   * @param domainObjectList - List of ims.core.resource.place.domain.objects.Location objects.
   */
  public static ims.admin.vo.LocationShortVoCollection createLocationShortVoCollectionFromLocation(
      DomainObjectMap map, java.util.List domainObjectList) {
    ims.admin.vo.LocationShortVoCollection voList = new ims.admin.vo.LocationShortVoCollection();
    if (null == domainObjectList) {
      return voList;
    }
    int rieCount = 0;
    int activeCount = 0;
    for (int i = 0; i < domainObjectList.size(); i++) {
      ims.core.resource.place.domain.objects.Location domainObject =
          (ims.core.resource.place.domain.objects.Location) domainObjectList.get(i);
      ims.admin.vo.LocationShortVo 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 set of DomainObjects.
   *
   * @param map - maps DomainObjects to created ValueObjects
   * @param domainObjectSet - Set of ims.core.resource.place.domain.objects.Location objects.
   */
  public static ims.admin.vo.LocationShortVoCollection createLocationShortVoCollectionFromLocation(
      DomainObjectMap map, java.util.Set domainObjectSet) {
    ims.admin.vo.LocationShortVoCollection voList = new ims.admin.vo.LocationShortVoCollection();
    if (null == domainObjectSet) {
      return voList;
    }
    int rieCount = 0;
    int activeCount = 0;
    java.util.Iterator iterator = domainObjectSet.iterator();
    while (iterator.hasNext()) {
      ims.core.resource.place.domain.objects.Location domainObject =
          (ims.core.resource.place.domain.objects.Location) iterator.next();
      ims.admin.vo.LocationShortVo 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;
  }
  private Location getHospital(Location doLocation) {
    if (doLocation == null) return null;

    if (doLocation instanceof Location
        && doLocation.getType().equals(getDomLookup(LocationType.HOSP))) return doLocation;

    while (doLocation.getParentLocation() != null) {
      doLocation = doLocation.getParentLocation();
      if (doLocation instanceof Location
          && doLocation.getType().equals(getDomLookup(LocationType.HOSP))) return doLocation;
    }

    return null;
  }
  public String toAuditString() {
    StringBuffer auditStr = new StringBuffer();

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

      auditStr.append(clinicLocation.getId());
    }
    auditStr.append("; ");
    auditStr.append("\r\n*isActive* :");
    auditStr.append(isActive);
    auditStr.append("; ");
    auditStr.append("\r\n*upperName* :");
    auditStr.append(upperName);
    auditStr.append("; ");
    auditStr.append("\r\n*codeMappings* :");
    if (codeMappings != null) {
      int i5 = 0;
      for (i5 = 0; i5 < codeMappings.size(); i5++) {
        if (i5 > 0) auditStr.append(",");
        ims.core.clinical.domain.objects.TaxonomyMap obj =
            (ims.core.clinical.domain.objects.TaxonomyMap) codeMappings.get(i5);
        if (obj != null) {
          if (i5 == 0) {
            auditStr.append(toShortClassName(obj));
            auditStr.append("[");
          }
          auditStr.append(obj.toString());
        }
      }
      if (i5 > 0) auditStr.append("] " + i5);
    }
    auditStr.append("; ");
    auditStr.append("\r\n*outpatientDept* :");
    if (outpatientDept != null) {
      auditStr.append(toShortClassName(outpatientDept));

      auditStr.append(outpatientDept.getId());
    }
    auditStr.append("; ");
    return auditStr.toString();
  }
  /**
   * Create the ValueObject from the ims.core.resource.place.domain.objects.Location object.
   *
   * @param map DomainObjectMap of DomainObjects to already created ValueObjects.
   * @param domainObject
   */
  public static ims.admin.vo.LocationShortVo create(
      DomainObjectMap map, ims.core.resource.place.domain.objects.Location domainObject) {
    if (null == domainObject) {
      return null;
    }
    // check if the domainObject already has a valueObject created for it
    ims.admin.vo.LocationShortVo valueObject =
        (ims.admin.vo.LocationShortVo)
            map.getValueObject(domainObject, ims.admin.vo.LocationShortVo.class);
    if (null == valueObject) {
      valueObject =
          new ims.admin.vo.LocationShortVo(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, Clinic obj, java.util.HashMap domMap)
     throws Exception {
   org.dom4j.Element fldEl;
   fldEl = el.element("clinicName");
   if (fldEl != null) {
     obj.setClinicName(new String(fldEl.getTextTrim()));
   }
   fldEl = el.element("clinicLocation");
   if (fldEl != null) {
     fldEl = fldEl.element("class");
     obj.setClinicLocation(
         ims.core.resource.place.domain.objects.Location.getLocationfromXML(
             fldEl, factory, domMap));
   }
   fldEl = el.element("isActive");
   if (fldEl != null) {
     obj.setIsActive(new Boolean(fldEl.getTextTrim()));
   }
   fldEl = el.element("upperName");
   if (fldEl != null) {
     obj.setUpperName(new String(fldEl.getTextTrim()));
   }
   fldEl = el.element("codeMappings");
   if (fldEl != null) {
     fldEl = fldEl.element("list");
     obj.setCodeMappings(
         ims.core.clinical.domain.objects.TaxonomyMap.fromListXMLString(
             fldEl, factory, obj.getCodeMappings(), domMap));
   }
   fldEl = el.element("outpatientDept");
   if (fldEl != null) {
     fldEl = fldEl.element("class");
     obj.setOutpatientDept(
         ims.core.resource.place.domain.objects.Location.getLocationfromXML(
             fldEl, factory, domMap));
   }
 }
 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 static ims.core.resource.place.domain.objects.Location extractLocation(
      ims.domain.ILightweightDomainFactory domainFactory,
      ims.admin.vo.LocationShortVo valueObject,
      HashMap domMap) {
    if (null == valueObject) {
      return null;
    }
    Integer id = valueObject.getID_Location();
    ims.core.resource.place.domain.objects.Location domainObject = null;
    if (null == id) {
      if (domMap.get(valueObject) != null) {
        return (ims.core.resource.place.domain.objects.Location) domMap.get(valueObject);
      }
      // ims.admin.vo.LocationShortVo ID_Location field is unknown
      domainObject = new ims.core.resource.place.domain.objects.Location();
      domMap.put(valueObject, domainObject);
    } else {
      String key = (valueObject.getClass().getName() + "__" + valueObject.getID_Location());
      if (domMap.get(key) != null) {
        return (ims.core.resource.place.domain.objects.Location) domMap.get(key);
      }
      domainObject =
          (ims.core.resource.place.domain.objects.Location)
              domainFactory.getDomainObject(
                  ims.core.resource.place.domain.objects.Location.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_Location());

    // 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.getUpperName() != null && valueObject.getUpperName().equals("")) {
      valueObject.setUpperName(null);
    }
    domainObject.setUpperName(valueObject.getUpperName());
    // 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.getName() != null && valueObject.getName().equals("")) {
      valueObject.setName(null);
    }
    domainObject.setName(valueObject.getName());
    domainObject.setIsActive(valueObject.getIsActive());
    domainObject.setIsVirtual(valueObject.getIsVirtual());
    // create LookupInstance from vo LookupType
    ims.domain.lookups.LookupInstance value5 = null;
    if (null != valueObject.getType()) {
      value5 = domainFactory.getLookupInstance(valueObject.getType().getID());
    }
    domainObject.setType(value5);
    domainObject.setDisplayInEDTracking(valueObject.getDisplayInEDTracking());
    domainObject.setCaseNoteFolderLocation(valueObject.getCaseNoteFolderLocation());

    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.resource.place.domain.objects.Location
   */
  public static ims.admin.vo.LocationShortVo insert(
      DomainObjectMap map,
      ims.admin.vo.LocationShortVo valueObject,
      ims.core.resource.place.domain.objects.Location domainObject) {
    if (null == domainObject) {
      return valueObject;
    }
    if (null == map) {
      map = new DomainObjectMap();
    }

    valueObject.setID_Location(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;

    // UpperName
    valueObject.setUpperName(domainObject.getUpperName());
    // Name
    valueObject.setName(domainObject.getName());
    // isActive
    valueObject.setIsActive(domainObject.isIsActive());
    // IsVirtual
    valueObject.setIsVirtual(domainObject.isIsVirtual());
    // Type
    ims.domain.lookups.LookupInstance instance5 = domainObject.getType();
    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.LocationType voLookup5 =
          new ims.core.vo.lookups.LocationType(
              instance5.getId(), instance5.getText(), instance5.isActive(), null, img, color);
      ims.core.vo.lookups.LocationType 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.LocationType(
                parent5.getId(), parent5.getText(), parent5.isActive(), null, img, color));
        parentVoLookup5 = parentVoLookup5.getParent();
        parent5 = parent5.getParent();
      }
      valueObject.setType(voLookup5);
    }
    // DisplayInEDTracking
    valueObject.setDisplayInEDTracking(domainObject.isDisplayInEDTracking());
    // CaseNoteFolderLocation
    valueObject.setCaseNoteFolderLocation(domainObject.isCaseNoteFolderLocation());
    return valueObject;
  }
 public static void fillFieldsfromXML(
     org.dom4j.Element el,
     ims.domain.DomainFactory factory,
     OcsOrderSession obj,
     java.util.HashMap domMap)
     throws Exception {
   org.dom4j.Element fldEl;
   fldEl = el.element("clinicalContact");
   if (fldEl != null) {
     fldEl = fldEl.element("class");
     obj.setClinicalContact(
         ims.core.admin.domain.objects.ClinicalContact.getClinicalContactfromXML(
             fldEl, factory, domMap));
   }
   fldEl = el.element("patient");
   if (fldEl != null) {
     fldEl = fldEl.element("class");
     obj.setPatient(
         ims.core.patient.domain.objects.Patient.getPatientfromXML(fldEl, factory, domMap));
   }
   fldEl = el.element("investigations");
   if (fldEl != null) {
     fldEl = fldEl.element("set");
     obj.setInvestigations(
         ims.ocrr.orderingresults.domain.objects.OrderInvestigation.fromSetXMLString(
             fldEl, factory, obj.getInvestigations(), domMap));
   }
   fldEl = el.element("orderedBy");
   if (fldEl != null) {
     fldEl = fldEl.element("class");
     obj.setOrderedBy(
         ims.core.resource.people.domain.objects.MemberOfStaff.getMemberOfStafffromXML(
             fldEl, factory, domMap));
   }
   fldEl = el.element("responsibleClinician");
   if (fldEl != null) {
     fldEl = fldEl.element("class");
     obj.setResponsibleClinician(
         ims.core.resource.people.domain.objects.Hcp.getHcpfromXML(fldEl, factory, domMap));
   }
   fldEl = el.element("responsibleGp");
   if (fldEl != null) {
     fldEl = fldEl.element("class");
     obj.setResponsibleGp(
         ims.core.resource.people.domain.objects.Gp.getGpfromXML(fldEl, factory, domMap));
   }
   fldEl = el.element("patientLocation");
   if (fldEl != null) {
     fldEl = fldEl.element("class");
     obj.setPatientLocation(
         ims.core.resource.place.domain.objects.Location.getLocationfromXML(
             fldEl, factory, domMap));
   }
   fldEl = el.element("patientClinic");
   if (fldEl != null) {
     fldEl = fldEl.element("class");
     obj.setPatientClinic(
         ims.core.resource.place.domain.objects.Clinic.getClinicfromXML(fldEl, factory, domMap));
   }
   fldEl = el.element("hcpAlerts");
   if (fldEl != null) {
     fldEl = fldEl.element("set");
     obj.setHcpAlerts(
         ims.ocrr.orderingresults.domain.objects.OrderHCPAlert.fromSetXMLString(
             fldEl, factory, obj.getHcpAlerts(), domMap));
   }
   fldEl = el.element("clinicalTrial");
   if (fldEl != null) {
     obj.setClinicalTrial(new Boolean(fldEl.getTextTrim()));
   }
   fldEl = el.element("clinicalTrialTxt");
   if (fldEl != null) {
     obj.setClinicalTrialTxt(new String(fldEl.getTextTrim()));
   }
   fldEl = el.element("clinicalInfo");
   if (fldEl != null) {
     fldEl = fldEl.element("class");
     obj.setClinicalInfo(
         ims.ocrr.orderingresults.domain.objects.OcsQASession.getOcsQASessionfromXML(
             fldEl, factory, domMap));
   }
   fldEl = el.element("additClinNotes");
   if (fldEl != null) {
     obj.setAdditClinNotes(new String(fldEl.getTextTrim()));
   }
   fldEl = el.element("patMobility");
   if (fldEl != null) {
     fldEl = fldEl.element("lki");
     obj.setPatMobility(ims.domain.lookups.LookupInstance.fromXMLString(fldEl, factory));
   }
   fldEl = el.element("orderCategory");
   if (fldEl != null) {
     fldEl = fldEl.element("lki");
     obj.setOrderCategory(ims.domain.lookups.LookupInstance.fromXMLString(fldEl, factory));
   }
   fldEl = el.element("reportTo");
   if (fldEl != null) {
     fldEl = fldEl.element("list");
     obj.setReportTo(
         ims.ocrr.orderingresults.domain.objects.OcsReportTo.fromListXMLString(
             fldEl, factory, obj.getReportTo(), domMap));
   }
   fldEl = el.element("specimens");
   if (fldEl != null) {
     fldEl = fldEl.element("set");
     obj.setSpecimens(
         ims.ocrr.orderingresults.domain.objects.OrderSpecimen.fromSetXMLString(
             fldEl, factory, obj.getSpecimens(), domMap));
   }
   fldEl = el.element("wasProcessed");
   if (fldEl != null) {
     obj.setWasProcessed(new Boolean(fldEl.getTextTrim()));
   }
   fldEl = el.element("authorisationOrderStatus");
   if (fldEl != null) {
     fldEl = fldEl.element("lki");
     obj.setAuthorisationOrderStatus(
         ims.domain.lookups.LookupInstance.fromXMLString(fldEl, factory));
   }
   fldEl = el.element("wasDiscarded");
   if (fldEl != null) {
     obj.setWasDiscarded(new Boolean(fldEl.getTextTrim()));
   }
   fldEl = el.element("careContext");
   if (fldEl != null) {
     fldEl = fldEl.element("class");
     obj.setCareContext(
         ims.core.admin.domain.objects.CareContext.getCareContextfromXML(fldEl, factory, domMap));
   }
   fldEl = el.element("orderingHospital");
   if (fldEl != null) {
     fldEl = fldEl.element("class");
     obj.setOrderingHospital(
         ims.core.resource.place.domain.objects.LocSite.getLocSitefromXML(fldEl, factory, domMap));
   }
   fldEl = el.element("hasNewOrUpdatedResults");
   if (fldEl != null) {
     obj.setHasNewOrUpdatedResults(new Boolean(fldEl.getTextTrim()));
   }
   fldEl = el.element("bedNumber");
   if (fldEl != null) {
     obj.setBedNumber(new String(fldEl.getTextTrim()));
   }
   fldEl = el.element("sendNumber");
   if (fldEl != null) {
     obj.setSendNumber(new Boolean(fldEl.getTextTrim()));
   }
   fldEl = el.element("outpatientDept");
   if (fldEl != null) {
     fldEl = fldEl.element("class");
     obj.setOutpatientDept(
         ims.core.resource.place.domain.objects.Location.getLocationfromXML(
             fldEl, factory, domMap));
   }
   fldEl = el.element("summaryClinicalInformation");
   if (fldEl != null) {
     obj.setSummaryClinicalInformation(new String(fldEl.getTextTrim()));
   }
   fldEl = el.element("bleepExtNumber");
   if (fldEl != null) {
     obj.setBleepExtNumber(new String(fldEl.getTextTrim()));
   }
 }
  public String toAuditString() {
    StringBuffer auditStr = new StringBuffer();

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

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

      auditStr.append(patient.getId());
    }
    auditStr.append("; ");
    auditStr.append("\r\n*investigations* :");
    if (investigations != null) {
      java.util.Iterator it3 = investigations.iterator();
      int i3 = 0;
      while (it3.hasNext()) {
        if (i3 > 0) auditStr.append(",");
        ims.ocrr.orderingresults.domain.objects.OrderInvestigation obj =
            (ims.ocrr.orderingresults.domain.objects.OrderInvestigation) it3.next();
        if (obj != null) {
          if (i3 == 0) {
            auditStr.append(toShortClassName(obj));
            auditStr.append("[");
          }

          auditStr.append(obj.getId());
        }
        i3++;
      }
      if (i3 > 0) auditStr.append("] " + i3);
    }
    auditStr.append("; ");
    auditStr.append("\r\n*orderedBy* :");
    if (orderedBy != null) {
      auditStr.append(toShortClassName(orderedBy));

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

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

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

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

      auditStr.append(patientClinic.getId());
    }
    auditStr.append("; ");
    auditStr.append("\r\n*hcpAlerts* :");
    if (hcpAlerts != null) {
      java.util.Iterator it9 = hcpAlerts.iterator();
      int i9 = 0;
      while (it9.hasNext()) {
        if (i9 > 0) auditStr.append(",");
        ims.ocrr.orderingresults.domain.objects.OrderHCPAlert obj =
            (ims.ocrr.orderingresults.domain.objects.OrderHCPAlert) it9.next();
        if (obj != null) {
          if (i9 == 0) {
            auditStr.append(toShortClassName(obj));
            auditStr.append("[");
          }

          auditStr.append(obj.getId());
        }
        i9++;
      }
      if (i9 > 0) auditStr.append("] " + i9);
    }
    auditStr.append("; ");
    auditStr.append("\r\n*clinicalTrial* :");
    auditStr.append(clinicalTrial);
    auditStr.append("; ");
    auditStr.append("\r\n*clinicalTrialTxt* :");
    auditStr.append(clinicalTrialTxt);
    auditStr.append("; ");
    auditStr.append("\r\n*clinicalInfo* :");
    if (clinicalInfo != null) {
      auditStr.append(toShortClassName(clinicalInfo));

      auditStr.append(clinicalInfo.getId());
    }
    auditStr.append("; ");
    auditStr.append("\r\n*additClinNotes* :");
    auditStr.append(additClinNotes);
    auditStr.append("; ");
    auditStr.append("\r\n*patMobility* :");
    if (patMobility != null) auditStr.append(patMobility.getText());
    auditStr.append("; ");
    auditStr.append("\r\n*orderCategory* :");
    if (orderCategory != null) auditStr.append(orderCategory.getText());
    auditStr.append("; ");
    auditStr.append("\r\n*reportTo* :");
    if (reportTo != null) {
      int i16 = 0;
      for (i16 = 0; i16 < reportTo.size(); i16++) {
        if (i16 > 0) auditStr.append(",");
        ims.ocrr.orderingresults.domain.objects.OcsReportTo obj =
            (ims.ocrr.orderingresults.domain.objects.OcsReportTo) reportTo.get(i16);
        if (obj != null) {
          if (i16 == 0) {
            auditStr.append(toShortClassName(obj));
            auditStr.append("[");
          }
          auditStr.append(obj.toString());
        }
      }
      if (i16 > 0) auditStr.append("] " + i16);
    }
    auditStr.append("; ");
    auditStr.append("\r\n*specimens* :");
    if (specimens != null) {
      java.util.Iterator it17 = specimens.iterator();
      int i17 = 0;
      while (it17.hasNext()) {
        if (i17 > 0) auditStr.append(",");
        ims.ocrr.orderingresults.domain.objects.OrderSpecimen obj =
            (ims.ocrr.orderingresults.domain.objects.OrderSpecimen) it17.next();
        if (obj != null) {
          if (i17 == 0) {
            auditStr.append(toShortClassName(obj));
            auditStr.append("[");
          }

          auditStr.append(obj.getId());
        }
        i17++;
      }
      if (i17 > 0) auditStr.append("] " + i17);
    }
    auditStr.append("; ");
    auditStr.append("\r\n*wasProcessed* :");
    auditStr.append(wasProcessed);
    auditStr.append("; ");
    auditStr.append("\r\n*authorisationOrderStatus* :");
    if (authorisationOrderStatus != null) auditStr.append(authorisationOrderStatus.getText());
    auditStr.append("; ");
    auditStr.append("\r\n*wasDiscarded* :");
    auditStr.append(wasDiscarded);
    auditStr.append("; ");
    auditStr.append("\r\n*careContext* :");
    if (careContext != null) {
      auditStr.append(toShortClassName(careContext));

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

      auditStr.append(orderingHospital.getId());
    }
    auditStr.append("; ");
    auditStr.append("\r\n*hasNewOrUpdatedResults* :");
    auditStr.append(hasNewOrUpdatedResults);
    auditStr.append("; ");
    auditStr.append("\r\n*bedNumber* :");
    auditStr.append(bedNumber);
    auditStr.append("; ");
    auditStr.append("\r\n*sendNumber* :");
    auditStr.append(sendNumber);
    auditStr.append("; ");
    auditStr.append("\r\n*outpatientDept* :");
    if (outpatientDept != null) {
      auditStr.append(toShortClassName(outpatientDept));

      auditStr.append(outpatientDept.getId());
    }
    auditStr.append("; ");
    auditStr.append("\r\n*summaryClinicalInformation* :");
    auditStr.append(summaryClinicalInformation);
    auditStr.append("; ");
    auditStr.append("\r\n*bleepExtNumber* :");
    auditStr.append(bleepExtNumber);
    auditStr.append("; ");
    return auditStr.toString();
  }