gt: 		if (domainERODHistory27 == null)
context: /*
   * This code was generated
   * Copyright (C) 1995-2004 IMS MAXIMS plc. All rights reserved.
   * IMS Development Environment (version 1.80 build 5007.25751)
   * WARNING: DO NOT MODIFY the content of this file
   * Generated on 16/04/2014, 12:32
   *
   */
  package ims.RefMan.vo.domain;
  
  import ims.vo.domain.DomainObjectMap;
  import java.util.HashMap;
  
  import org.hibernate.proxy.HibernateProxy;
  
  /**
   * @author Florin Blindu
   */
  public class PatientElectiveListVoAssembler
  {
    	/**
  	 * Copy one ValueObject to another
  	 * @param valueObjectDest to be updated
  	 * @param valueObjectSrc to copy values from
  	 */
  	 public static ims.RefMan.vo.PatientElectiveListVo copy(ims.RefMan.vo.PatientElectiveListVo valueObjectDest, ims.RefMan.vo.PatientElectiveListVo valueObjectSrc) 
  	 {
  	 	if (null == valueObjectSrc) 
  		{
  			return valueObjectSrc;
  		}
  		valueObjectDest.setID_PatientElectiveList(valueObjectSrc.getID_PatientElectiveList());
  	    valueObjectDest.setIsRIE(valueObjectSrc.getIsRIE());
  		// ElectiveList
  		valueObjectDest.setElectiveList(valueObjectSrc.getElectiveList());
  		// ElectiveListStatus
  		valueObjectDest.setElectiveListStatus(valueObjectSrc.getElectiveListStatus());
  		// Patient
  		valueObjectDest.setPatient(valueObjectSrc.getPatient());
  		// Referral
  		valueObjectDest.setReferral(valueObjectSrc.getReferral());
  		// EpisodeOfCare
  		valueObjectDest.setEpisodeOfCare(valueObjectSrc.getEpisodeOfCare());
  		// Ward
  		valueObjectDest.setWard(valueObjectSrc.getWard());
  		// Consultant
  		valueObjectDest.setConsultant(valueObjectSrc.getConsultant());
  		// DateOnList
  		valueObjectDest.setDateOnList(valueObjectSrc.getDateOnList());
  		// OriginalDecisionDate
  		valueObjectDest.setOriginalDecisionDate(valueObjectSrc.getOriginalDecisionDate());
  		// IntendedManagement
  		valueObjectDest.setIntendedManagement(valueObjectSrc.getIntendedManagement());
  		// AnticipatedStay
  		valueObjectDest.setAnticipatedStay(valueObjectSrc.getAnticipatedStay());
  		// Priority
  		valueObjectDest.setPriority(valueObjectSrc.getPriority());
  		// Suspensions
  		valueObjectDest.setSuspensions(valueObjectSrc.getSuspensions());
  		// OperativeProcedureStatus
  		valueObjectDest.setOperativeProcedureStatus(valueObjectSrc.getOperativeProcedureStatus());
  		// PrimaryProcedure
  		valueObjectDest.setPrimaryProcedure(valueObjectSrc.getPrimaryProcedure());
  		// OtherProcedures
  		valueObjectDest.setOtherProcedures(valueObjectSrc.getOtherProcedures());
  		// TCIHistory
  		valueObjectDest.setTCIHistory(valueObjectSrc.getTCIHistory());
  		// InterpretatorRequired
  		valueObjectDest.setInterpretatorRequired(valueObjectSrc.getInterpretatorRequired());
  		// Transport
  		valueObjectDest.setTransport(valueObjectSrc.getTransport());
  		// Notes
  		valueObjectDest.setNotes(valueObjectSrc.getNotes());
  		// ElectiveAdmissionType
  		valueObjectDest.setElectiveAdmissionType(valueObjectSrc.getElectiveAdmissionType());
  		// EROD
  		valueObjectDest.setEROD(valueObjectSrc.getEROD());
  		// TCIDetails
  		valueObjectDest.setTCIDetails(valueObjectSrc.getTCIDetails());
  		// ElectiveListStatusHistory
  		valueObjectDest.setElectiveListStatusHistory(valueObjectSrc.getElectiveListStatusHistory());
  		// ElectiveListReason
  		valueObjectDest.setElectiveListReason(valueObjectSrc.getElectiveListReason());
  		// PathwayClock
  		valueObjectDest.setPathwayClock(valueObjectSrc.getPathwayClock());
  		// ERODHistory
  		valueObjectDest.setERODHistory(valueObjectSrc.getERODHistory());
  		// TCICancelledByProvider
  		valueObjectDest.setTCICancelledByProvider(valueObjectSrc.getTCICancelledByProvider());
  		// Bed
  		valueObjectDest.setBed(valueObjectSrc.getBed());
  		// TransportRequired
  		valueObjectDest.setTransportRequired(valueObjectSrc.getTransportRequired());
  		// ProcedureDescription
  		valueObjectDest.setProcedureDescription(valueObjectSrc.getProcedureDescription());
  		// Language
  		valueObjectDest.setLanguage(valueObjectSrc.getLanguage());
  		// PatientStatus
  		valueObjectDest.setPatientStatus(valueObjectSrc.getPatientStatus());
  		// RequiresTCIBy
  		valueObjectDest.setRequiresTCIBy(valueObjectSrc.getRequiresTCIBy());
  	 	return valueObjectDest;
  	 }
  
   
  	/**
  	 * Create the ValueObject collection to hold the set of DomainObjects.
  	 * This is a convenience method only.
  	 * It is intended to be used when one called to an Assembler is made.
   	 * If more than one call to an Assembler is made then #createPatientElectiveListVoCollectionFromPatientElectiveList(DomainObjectMap, Set) should be used.
  	 * @param domainObjectSet - Set of ims.RefMan.domain.objects.PatientElectiveList objects.
  	 */
  	public static ims.RefMan.vo.PatientElectiveListVoCollection createPatientElectiveListVoCollectionFromPatientElectiveList(java.util.Set domainObjectSet)	
  	{
  		return createPatientElectiveListVoCollectionFromPatientElectiveList(new DomainObjectMap(), domainObjectSet);
  	}
  	
  	/**
  	 * Create the ValueObject collection to hold the set of DomainObjects.
  	 * @param map - maps DomainObjects to created ValueObjects
  	 * @param domainObjectSet - Set of ims.RefMan.domain.objects.PatientElectiveList objects.
  	 */
  	public static ims.RefMan.vo.PatientElectiveListVoCollection createPatientElectiveListVoCollectionFromPatientElectiveList(DomainObjectMap map, java.util.Set domainObjectSet)	
  	{
  		ims.RefMan.vo.PatientElectiveListVoCollection voList = new ims.RefMan.vo.PatientElectiveListVoCollection();
  		if ( null == domainObjectSet ) 
  		{
  			return voList;
  		}
  		int rieCount=0;
  		int activeCount=0;
  		java.util.Iterator iterator = domainObjectSet.iterator();
  		while( iterator.hasNext() ) 
  		{
  			ims.RefMan.domain.objects.PatientElectiveList domainObject = (ims.RefMan.domain.objects.PatientElectiveList) iterator.next();
  			ims.RefMan.vo.PatientElectiveListVo 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 domainObjectList - List of ims.RefMan.domain.objects.PatientElectiveList objects.
  	 */
  	public static ims.RefMan.vo.PatientElectiveListVoCollection createPatientElectiveListVoCollectionFromPatientElectiveList(java.util.List domainObjectList) 
  	{
  		return createPatientElectiveListVoCollectionFromPatientElectiveList(new DomainObjectMap(), domainObjectList);
  	}
  	
  	/**
  	 * Create the ValueObject collection to hold the list of DomainObjects.
  	 * @param map - maps DomainObjects to created ValueObjects
  	 * @param domainObjectList - List of ims.RefMan.domain.objects.PatientElectiveList objects.
  	 */
  	public static ims.RefMan.vo.PatientElectiveListVoCollection createPatientElectiveListVoCollectionFromPatientElectiveList(DomainObjectMap map, java.util.List domainObjectList) 
  	{
  		ims.RefMan.vo.PatientElectiveListVoCollection voList = new ims.RefMan.vo.PatientElectiveListVoCollection();
  		if ( null == domainObjectList ) 
  		{
  			return voList;
  		}		
  		int rieCount=0;
  		int activeCount=0;
  		for (int i = 0; i < domainObjectList.size(); i++)
  		{
  			ims.RefMan.domain.objects.PatientElectiveList domainObject = (ims.RefMan.domain.objects.PatientElectiveList) domainObjectList.get(i);
  			ims.RefMan.vo.PatientElectiveListVo 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 ims.RefMan.domain.objects.PatientElectiveList set from the value object collection.
  	 * @param domainFactory - used to create existing (persistent) domain objects.
  	 * @param voCollection - the collection of value objects	 
  	 */
  	 public static java.util.Set extractPatientElectiveListSet(ims.domain.ILightweightDomainFactory domainFactory, ims.RefMan.vo.PatientElectiveListVoCollection voCollection) 
  	 {
  	 	return extractPatientElectiveListSet(domainFactory, voCollection, null, new HashMap());
  	 }
  	 
  	 public static java.util.Set extractPatientElectiveListSet(ims.domain.ILightweightDomainFactory domainFactory, ims.RefMan.vo.PatientElectiveListVoCollection voCollection, java.util.Set domainObjectSet, HashMap domMap) 
  	 {
  	 	int size = (null == voCollection) ? 0 : voCollection.size();
  		if (domainObjectSet == null)
  		{
  			domainObjectSet = new java.util.HashSet();			
  		}
  		java.util.Set newSet = new java.util.HashSet();
  		for(int i=0; i<size; i++) 
  		{
  			ims.RefMan.vo.PatientElectiveListVo vo = voCollection.get(i);
  			ims.RefMan.domain.objects.PatientElectiveList domainObject = PatientElectiveListVoAssembler.extractPatientElectiveList(domainFactory, vo, domMap);
  
  			//TODO: This can only occur in the situation of a stale object exception. For now leave it to the Interceptor to handle it.
  			if (domainObject == null)
  			{
  				continue;
  			}
  			
  			//Trying to avoid the hibernate collection being marked as dirty via its public interface methods. (like add)
  			if (!domainObjectSet.contains(domainObject)) domainObjectSet.add(domainObject);
  			newSet.add(domainObject);			
  		}
  		java.util.Set removedSet = new java.util.HashSet();
  		java.util.Iterator iter = domainObjectSet.iterator();
  		//Find out which objects need to be removed
  		while (iter.hasNext())
  		{
  			ims.domain.DomainObject o = (ims.domain.DomainObject)iter.next();			
  			if ((o == null || o.getIsRIE() == null || !o.getIsRIE().booleanValue()) && !newSet.contains(o))
  			{
  				removedSet.add(o);
  			}
  		}
  		iter = removedSet.iterator();
  		//Remove the unwanted objects
  		while (iter.hasNext())
  		{
  			domainObjectSet.remove(iter.next());
  		}
  		return domainObjectSet;	 
  	 }
  
  
  	/**
  	 * Create the ims.RefMan.domain.objects.PatientElectiveList list from the value object collection.
  	 * @param domainFactory - used to create existing (persistent) domain objects.
  	 * @param voCollection - the collection of value objects	 
  	 */
  	 public static java.util.List extractPatientElectiveListList(ims.domain.ILightweightDomainFactory domainFactory, ims.RefMan.vo.PatientElectiveListVoCollection voCollection) 
  	 {
  	 	return extractPatientElectiveListList(domainFactory, voCollection, null, new HashMap());
  	 }
  	 
  	 public static java.util.List extractPatientElectiveListList(ims.domain.ILightweightDomainFactory domainFactory, ims.RefMan.vo.PatientElectiveListVoCollection voCollection, java.util.List domainObjectList, HashMap domMap) 
  	 {
  	 	int size = (null == voCollection) ? 0 : voCollection.size();
  		if (domainObjectList == null)
  		{
  			domainObjectList = new java.util.ArrayList();			
  		}
  		for(int i=0; i<size; i++) 
  		{
  			ims.RefMan.vo.PatientElectiveListVo vo = voCollection.get(i);
  			ims.RefMan.domain.objects.PatientElectiveList domainObject = PatientElectiveListVoAssembler.extractPatientElectiveList(domainFactory, vo, domMap);
  
  			//TODO: This can only occur in the situation of a stale object exception. For now leave it to the Interceptor to handle it.
  			if (domainObject == null)
  			{
  				continue;
  			}
  
  			int domIdx = domainObjectList.indexOf(domainObject);
  			if (domIdx == -1)
  			{
  				domainObjectList.add(i, domainObject);
  			}
  			else if (i != domIdx && i < domainObjectList.size())
  			{
  				Object tmp = domainObjectList.get(i);
  				domainObjectList.set(i, domainObjectList.get(domIdx));
  				domainObjectList.set(domIdx, tmp);
  			}
  		}
  		
  		//Remove all ones in domList where index > voCollection.size() as these should
  		//now represent the ones removed from the VO collection. No longer referenced.
  		int i1=domainObjectList.size();
  		while (i1 > size)
  		{
  			domainObjectList.remove(i1-1);
  			i1=domainObjectList.size();
  		}
  		return domainObjectList;	 
  	 }
  
   
  
  	/**
  	 * Create the ValueObject from the ims.RefMan.domain.objects.PatientElectiveList object.
  	 * @param domainObject ims.RefMan.domain.objects.PatientElectiveList
  	 */
  	 public static ims.RefMan.vo.PatientElectiveListVo create(ims.RefMan.domain.objects.PatientElectiveList domainObject) 
  	 {
  	 	if (null == domainObject) 
  	 	{
  			return null;
  		}
  		DomainObjectMap map = new DomainObjectMap();
  		return create(map, domainObject);
  	 }
  	 
  	 /**
  	  * Create the ValueObject from the ims.RefMan.domain.objects.PatientElectiveList object.
  	  * @param map DomainObjectMap of DomainObjects to already created ValueObjects.
  	  * @param domainObject
  	  */
  	  public static ims.RefMan.vo.PatientElectiveListVo create(DomainObjectMap map, ims.RefMan.domain.objects.PatientElectiveList domainObject) 
  	  {
  	  		if (null == domainObject) 
  	  		{
  				return null;
  			}
  			// check if the domainObject already has a valueObject created for it
  			ims.RefMan.vo.PatientElectiveListVo valueObject = (ims.RefMan.vo.PatientElectiveListVo) map.getValueObject(domainObject, ims.RefMan.vo.PatientElectiveListVo.class);
  			if ( null == valueObject ) 
  			{
  				valueObject = new ims.RefMan.vo.PatientElectiveListVo(domainObject.getId(), domainObject.getVersion());
  				map.addValueObject(domainObject, valueObject);
  
  				valueObject = insert(map, valueObject, domainObject);
  				
  			}
  	 		return valueObject;
  	  }
  
  	/**
  	 * Update the ValueObject with the Domain Object.
  	 * @param valueObject to be updated
  	 * @param domainObject ims.RefMan.domain.objects.PatientElectiveList
  	 */
  	 public static ims.RefMan.vo.PatientElectiveListVo insert(ims.RefMan.vo.PatientElectiveListVo valueObject, ims.RefMan.domain.objects.PatientElectiveList domainObject) 
  	 {
  	 	if (null == domainObject) 
  	 	{
  			return valueObject;
  		}
  		DomainObjectMap map = new DomainObjectMap();
  		return insert(map, valueObject, 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.RefMan.domain.objects.PatientElectiveList
  	 */
  	 public static ims.RefMan.vo.PatientElectiveListVo insert(DomainObjectMap map, ims.RefMan.vo.PatientElectiveListVo valueObject, ims.RefMan.domain.objects.PatientElectiveList domainObject) 
  	 {
  	 	if (null == domainObject) 
  	 	{
  			return valueObject;
  		}
  	 	if (null == map) 
  	 	{
  			map = new DomainObjectMap();
  		}
  
  		valueObject.setID_PatientElectiveList(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;
  			
  		// ElectiveList
  		valueObject.setElectiveList(ims.admin.vo.domain.ElectiveListConfigurationVoAssembler.create(map, domainObject.getElectiveList()) );
  		// ElectiveListStatus
  		valueObject.setElectiveListStatus(ims.RefMan.vo.domain.ElectiveListStatusVoAssembler.create(map, domainObject.getElectiveListStatus()) );
  		// Patient
  		if (domainObject.getPatient() != null)
  		{
  			if(domainObject.getPatient() instanceof HibernateProxy) // If the proxy is set, there is no need to lazy load, the proxy knows the id already. 
  			{
  				HibernateProxy p = (HibernateProxy) domainObject.getPatient();
  				int id = Integer.parseInt(p.getHibernateLazyInitializer().getIdentifier().toString());				
  				valueObject.setPatient(new ims.core.patient.vo.PatientRefVo(id, -1));				
  			}
  			else
  			{
  				valueObject.setPatient(new ims.core.patient.vo.PatientRefVo(domainObject.getPatient().getId(), domainObject.getPatient().getVersion()));
  			}
  		}
  		// Referral
  		if (domainObject.getReferral() != null)
  		{
  			if(domainObject.getReferral() instanceof HibernateProxy) // If the proxy is set, there is no need to lazy load, the proxy knows the id already. 
  			{
  				HibernateProxy p = (HibernateProxy) domainObject.getReferral();
  				int id = Integer.parseInt(p.getHibernateLazyInitializer().getIdentifier().toString());				
  				valueObject.setReferral(new ims.RefMan.vo.CatsReferralRefVo(id, -1));				
  			}
  			else
  			{
  				valueObject.setReferral(new ims.RefMan.vo.CatsReferralRefVo(domainObject.getReferral().getId(), domainObject.getReferral().getVersion()));
  			}
  		}
  		// EpisodeOfCare
  		if (domainObject.getEpisodeOfCare() != null)
  		{
  			if(domainObject.getEpisodeOfCare() instanceof HibernateProxy) // If the proxy is set, there is no need to lazy load, the proxy knows the id already. 
  			{
  				HibernateProxy p = (HibernateProxy) domainObject.getEpisodeOfCare();
  				int id = Integer.parseInt(p.getHibernateLazyInitializer().getIdentifier().toString());				
  				valueObject.setEpisodeOfCare(new ims.core.admin.vo.EpisodeOfCareRefVo(id, -1));				
  			}
  			else
  			{
  				valueObject.setEpisodeOfCare(new ims.core.admin.vo.EpisodeOfCareRefVo(domainObject.getEpisodeOfCare().getId(), domainObject.getEpisodeOfCare().getVersion()));
  			}
  		}
  		// Ward
  		valueObject.setWard(ims.core.vo.domain.LocationLiteVoAssembler.create(map, domainObject.getWard()) );
  		// Consultant
  		valueObject.setConsultant(ims.core.vo.domain.HcpMinVoAssembler.create(map, domainObject.getConsultant()) );
  		// DateOnList
  		java.util.Date DateOnList = domainObject.getDateOnList();
  		if ( null != DateOnList ) 
  		{
  			valueObject.setDateOnList(new ims.framework.utils.Date(DateOnList) );
  		}
  		// OriginalDecisionDate
  		java.util.Date OriginalDecisionDate = domainObject.getOriginalDecisionDate();
  		if ( null != OriginalDecisionDate ) 
  		{
  			valueObject.setOriginalDecisionDate(new ims.framework.utils.Date(OriginalDecisionDate) );
  		}
  		// IntendedManagement
  		ims.domain.lookups.LookupInstance instance10 = domainObject.getIntendedManagement();
  		if ( null != instance10 ) {
  			ims.framework.utils.ImagePath img = null;
  			ims.framework.utils.Color color = null;		
  			img = null;
  			if (instance10.getImage() != null) 
  			{
  				img = new ims.framework.utils.ImagePath(instance10.getImage().getImageId(), instance10.getImage().getImagePath());
  			}
  			color = instance10.getColor();
  			if (color != null) 
  				color.getValue();
  
  			ims.core.vo.lookups.ManagementIntention voLookup10 = new ims.core.vo.lookups.ManagementIntention(instance10.getId(),instance10.getText(), instance10.isActive(), null, img, color);
  			ims.core.vo.lookups.ManagementIntention parentVoLookup10 = voLookup10;
  			ims.domain.lookups.LookupInstance parent10 = instance10.getParent();
  			while (parent10 != null)
  			{
  				if (parent10.getImage() != null) 
  				{
  					img = new ims.framework.utils.ImagePath(parent10.getImage().getImageId(), parent10.getImage().getImagePath() );
  				}
  				else 
  				{
  					img = null;
  				}
  				color = parent10.getColor();
      			if (color != null) 
      				color.getValue();
  								parentVoLookup10.setParent(new ims.core.vo.lookups.ManagementIntention(parent10.getId(),parent10.getText(), parent10.isActive(), null, img, color));
  				parentVoLookup10 = parentVoLookup10.getParent();
  								parent10 = parent10.getParent();
  			}			
  			valueObject.setIntendedManagement(voLookup10);
  		}
  				// AnticipatedStay
  		valueObject.setAnticipatedStay(domainObject.getAnticipatedStay());
  		// Priority
  		ims.domain.lookups.LookupInstance instance12 = domainObject.getPriority();
  		if ( null != instance12 ) {
  			ims.framework.utils.ImagePath img = null;
  			ims.framework.utils.Color color = null;		
  			img = null;
  			if (instance12.getImage() != null) 
  			{
  				img = new ims.framework.utils.ImagePath(instance12.getImage().getImageId(), instance12.getImage().getImagePath());
  			}
  			color = instance12.getColor();
  			if (color != null) 
  				color.getValue();
  
  			ims.RefMan.vo.lookups.ReferralUrgency voLookup12 = new ims.RefMan.vo.lookups.ReferralUrgency(instance12.getId(),instance12.getText(), instance12.isActive(), null, img, color);
  			ims.RefMan.vo.lookups.ReferralUrgency parentVoLookup12 = voLookup12;
  			ims.domain.lookups.LookupInstance parent12 = instance12.getParent();
  			while (parent12 != null)
  			{
  				if (parent12.getImage() != null) 
  				{
  					img = new ims.framework.utils.ImagePath(parent12.getImage().getImageId(), parent12.getImage().getImagePath() );
  				}
  				else 
  				{
  					img = null;
  				}
  				color = parent12.getColor();
      			if (color != null) 
      				color.getValue();
  								parentVoLookup12.setParent(new ims.RefMan.vo.lookups.ReferralUrgency(parent12.getId(),parent12.getText(), parent12.isActive(), null, img, color));
  				parentVoLookup12 = parentVoLookup12.getParent();
  								parent12 = parent12.getParent();
  			}			
  			valueObject.setPriority(voLookup12);
  		}
  				// Suspensions
  		valueObject.setSuspensions(ims.RefMan.vo.domain.SuspensionDetailsForPatientElectiveListVoAssembler.createSuspensionDetailsForPatientElectiveListVoCollectionFromSuspensionDetailsForPatientElectiveList(map, domainObject.getSuspensions()) );
  		// OperativeProcedureStatus
  		valueObject.setOperativeProcedureStatus( domainObject.isOperativeProcedureStatus() );
  		// PrimaryProcedure
  		valueObject.setPrimaryProcedure(ims.core.vo.domain.ProcedureLiteVoAssembler.create(map, domainObject.getPrimaryProcedure()) );
  		// OtherProcedures
  		valueObject.setOtherProcedures(ims.core.vo.domain.ProcedureLiteVoAssembler.createProcedureLiteVoCollectionFromProcedure(map, domainObject.getOtherProcedures()) );
  		// TCIHistory
  		valueObject.setTCIHistory(ims.RefMan.vo.domain.PatientElectiveListElectiveTCIVoAssembler.createPatientElectiveListElectiveTCIVoCollectionFromTCIForPatientElectiveList(map, domainObject.getTCIHistory()) );
  		// InterpretatorRequired
  		valueObject.setInterpretatorRequired( domainObject.isInterpretatorRequired() );
  		// Transport
  		ims.domain.lookups.LookupInstance instance19 = domainObject.getTransport();
  		if ( null != instance19 ) {
  			ims.framework.utils.ImagePath img = null;
  			ims.framework.utils.Color color = null;		
  			img = null;
  			if (instance19.getImage() != null) 
  			{
  				img = new ims.framework.utils.ImagePath(instance19.getImage().getImageId(), instance19.getImage().getImagePath());
  			}
  			color = instance19.getColor();
  			if (color != null) 
  				color.getValue();
  
  			ims.scheduling.vo.lookups.ApptTransportType voLookup19 = new ims.scheduling.vo.lookups.ApptTransportType(instance19.getId(),instance19.getText(), instance19.isActive(), null, img, color);
  			ims.scheduling.vo.lookups.ApptTransportType parentVoLookup19 = voLookup19;
  			ims.domain.lookups.LookupInstance parent19 = instance19.getParent();
  			while (parent19 != null)
  			{
  				if (parent19.getImage() != null) 
  				{
  					img = new ims.framework.utils.ImagePath(parent19.getImage().getImageId(), parent19.getImage().getImagePath() );
  				}
  				else 
  				{
  					img = null;
  				}
  				color = parent19.getColor();
      			if (color != null) 
      				color.getValue();
  								parentVoLookup19.setParent(new ims.scheduling.vo.lookups.ApptTransportType(parent19.getId(),parent19.getText(), parent19.isActive(), null, img, color));
  				parentVoLookup19 = parentVoLookup19.getParent();
  								parent19 = parent19.getParent();
  			}			
  			valueObject.setTransport(voLookup19);
  		}
  				// Notes
  		valueObject.setNotes(ims.RefMan.vo.domain.PatientElectiveListNotesVoAssembler.createPatientElectiveListNotesVoCollectionFromNotesForPatientElectiveList(map, domainObject.getNotes()) );
  		// ElectiveAdmissionType
  		ims.domain.lookups.LookupInstance instance21 = domainObject.getElectiveAdmissionType();
  		if ( null != instance21 ) {
  			ims.framework.utils.ImagePath img = null;
  			ims.framework.utils.Color color = null;		
  			img = null;
  			if (instance21.getImage() != null) 
  			{
  				img = new ims.framework.utils.ImagePath(instance21.getImage().getImageId(), instance21.getImage().getImagePath());
  			}
  			color = instance21.getColor();
  			if (color != null) 
  				color.getValue();
  
  			ims.RefMan.vo.lookups.ElectiveAdmissionType voLookup21 = new ims.RefMan.vo.lookups.ElectiveAdmissionType(instance21.getId(),instance21.getText(), instance21.isActive(), null, img, color);
  			ims.RefMan.vo.lookups.ElectiveAdmissionType parentVoLookup21 = voLookup21;
  			ims.domain.lookups.LookupInstance parent21 = instance21.getParent();
  			while (parent21 != null)
  			{
  				if (parent21.getImage() != null) 
  				{
  					img = new ims.framework.utils.ImagePath(parent21.getImage().getImageId(), parent21.getImage().getImagePath() );
  				}
  				else 
  				{
  					img = null;
  				}
  				color = parent21.getColor();
      			if (color != null) 
      				color.getValue();
  								parentVoLookup21.setParent(new ims.RefMan.vo.lookups.ElectiveAdmissionType(parent21.getId(),parent21.getText(), parent21.isActive(), null, img, color));
  				parentVoLookup21 = parentVoLookup21.getParent();
  								parent21 = parent21.getParent();
  			}			
  			valueObject.setElectiveAdmissionType(voLookup21);
  		}
  				// EROD
  		if (domainObject.getEROD() != null)
  		{
  			if(domainObject.getEROD() instanceof HibernateProxy) // If the proxy is set, there is no need to lazy load, the proxy knows the id already. 
  			{
  				HibernateProxy p = (HibernateProxy) domainObject.getEROD();
  				int id = Integer.parseInt(p.getHibernateLazyInitializer().getIdentifier().toString());				
  				valueObject.setEROD(new ims.RefMan.vo.ReferralERODRefVo(id, -1));				
  			}
  			else
  			{
  				valueObject.setEROD(new ims.RefMan.vo.ReferralERODRefVo(domainObject.getEROD().getId(), domainObject.getEROD().getVersion()));
  			}
  		}
  		// TCIDetails
  		valueObject.setTCIDetails(ims.RefMan.vo.domain.PatientElectiveListElectiveTCIVoAssembler.create(map, domainObject.getTCIDetails()) );
  		// ElectiveListStatusHistory
  		valueObject.setElectiveListStatusHistory(ims.RefMan.vo.domain.ElectiveListStatusVoAssembler.createElectiveListStatusVoCollectionFromElectiveListStatus(map, domainObject.getElectiveListStatusHistory()) );
  		// ElectiveListReason
  		ims.domain.lookups.LookupInstance instance25 = domainObject.getElectiveListReason();
  		if ( null != instance25 ) {
  			ims.framework.utils.ImagePath img = null;
  			ims.framework.utils.Color color = null;		
  			img = null;
  			if (instance25.getImage() != null) 
  			{
  				img = new ims.framework.utils.ImagePath(instance25.getImage().getImageId(), instance25.getImage().getImagePath());
  			}
  			color = instance25.getColor();
  			if (color != null) 
  				color.getValue();
  
  			ims.emergency.vo.lookups.ElectiveListReason voLookup25 = new ims.emergency.vo.lookups.ElectiveListReason(instance25.getId(),instance25.getText(), instance25.isActive(), null, img, color);
  			ims.emergency.vo.lookups.ElectiveListReason parentVoLookup25 = voLookup25;
  			ims.domain.lookups.LookupInstance parent25 = instance25.getParent();
  			while (parent25 != null)
  			{
  				if (parent25.getImage() != null) 
  				{
  					img = new ims.framework.utils.ImagePath(parent25.getImage().getImageId(), parent25.getImage().getImagePath() );
  				}
  				else 
  				{
  					img = null;
  				}
  				color = parent25.getColor();
      			if (color != null) 
      				color.getValue();
  								parentVoLookup25.setParent(new ims.emergency.vo.lookups.ElectiveListReason(parent25.getId(),parent25.getText(), parent25.isActive(), null, img, color));
  				parentVoLookup25 = parentVoLookup25.getParent();
  								parent25 = parent25.getParent();
  			}			
  			valueObject.setElectiveListReason(voLookup25);
  		}
  				// PathwayClock
  		if (domainObject.getPathwayClock() != null)
  		{
  			if(domainObject.getPathwayClock() instanceof HibernateProxy) // If the proxy is set, there is no need to lazy load, the proxy knows the id already. 
  			{
  				HibernateProxy p = (HibernateProxy) domainObject.getPathwayClock();
  				int id = Integer.parseInt(p.getHibernateLazyInitializer().getIdentifier().toString());				
  				valueObject.setPathwayClock(new ims.pathways.vo.PathwayClockRefVo(id, -1));				
  			}
  			else
  			{
  				valueObject.setPathwayClock(new ims.pathways.vo.PathwayClockRefVo(domainObject.getPathwayClock().getId(), domainObject.getPathwayClock().getVersion()));
  			}
  		}
  		// ERODHistory
  		ims.RefMan.vo.ReferralERODRefVoCollection ERODHistory = new ims.RefMan.vo.ReferralERODRefVoCollection();
  		for(java.util.Iterator iterator = domainObject.getERODHistory().iterator(); iterator.hasNext(); ) 
  		{
  			ims.RefMan.domain.objects.ReferralEROD tmp = (ims.RefMan.domain.objects.ReferralEROD)iterator.next();
  			if (tmp != null)
  				ERODHistory.add(new ims.RefMan.vo.ReferralERODRefVo(tmp.getId(),tmp.getVersion()));
  		}
  		valueObject.setERODHistory(ERODHistory);
  		// TCICancelledByProvider
  		valueObject.setTCICancelledByProvider( domainObject.isTCICancelledByProvider() );
  		// Bed
  		valueObject.setBed(domainObject.getBed());
  		// TransportRequired
  		valueObject.setTransportRequired( domainObject.isTransportRequired() );
  		// ProcedureDescription
  		valueObject.setProcedureDescription(domainObject.getProcedureDescription());
  		// Language
  		ims.domain.lookups.LookupInstance instance32 = domainObject.getLanguage();
  		if ( null != instance32 ) {
  			ims.framework.utils.ImagePath img = null;
  			ims.framework.utils.Color color = null;		
  			img = null;
  			if (instance32.getImage() != null) 
  			{
  				img = new ims.framework.utils.ImagePath(instance32.getImage().getImageId(), instance32.getImage().getImagePath());
  			}
  			color = instance32.getColor();
  			if (color != null) 
  				color.getValue();
  
  			ims.core.vo.lookups.Language voLookup32 = new ims.core.vo.lookups.Language(instance32.getId(),instance32.getText(), instance32.isActive(), null, img, color);
  			ims.core.vo.lookups.Language parentVoLookup32 = voLookup32;
  			ims.domain.lookups.LookupInstance parent32 = instance32.getParent();
  			while (parent32 != null)
  			{
  				if (parent32.getImage() != null) 
  				{
  					img = new ims.framework.utils.ImagePath(parent32.getImage().getImageId(), parent32.getImage().getImagePath() );
  				}
  				else 
  				{
  					img = null;
  				}
  				color = parent32.getColor();
      			if (color != null) 
      				color.getValue();
  								parentVoLookup32.setParent(new ims.core.vo.lookups.Language(parent32.getId(),parent32.getText(), parent32.isActive(), null, img, color));
  				parentVoLookup32 = parentVoLookup32.getParent();
  								parent32 = parent32.getParent();
  			}			
  			valueObject.setLanguage(voLookup32);
  		}
  				// PatientStatus
  		ims.domain.lookups.LookupInstance instance33 = domainObject.getPatientStatus();
  		if ( null != instance33 ) {
  			ims.framework.utils.ImagePath img = null;
  			ims.framework.utils.Color color = null;		
  			img = null;
  			if (instance33.getImage() != null) 
  			{
  				img = new ims.framework.utils.ImagePath(instance33.getImage().getImageId(), instance33.getImage().getImagePath());
  			}
  			color = instance33.getColor();
  			if (color != null) 
  				color.getValue();
  
  			ims.RefMan.vo.lookups.CatsReferralCategory voLookup33 = new ims.RefMan.vo.lookups.CatsReferralCategory(instance33.getId(),instance33.getText(), instance33.isActive(), null, img, color);
  			ims.RefMan.vo.lookups.CatsReferralCategory parentVoLookup33 = voLookup33;
  			ims.domain.lookups.LookupInstance parent33 = instance33.getParent();
  			while (parent33 != null)
  			{
  				if (parent33.getImage() != null) 
  				{
  					img = new ims.framework.utils.ImagePath(parent33.getImage().getImageId(), parent33.getImage().getImagePath() );
  				}
  				else 
  				{
  					img = null;
  				}
  				color = parent33.getColor();
      			if (color != null) 
      				color.getValue();
  								parentVoLookup33.setParent(new ims.RefMan.vo.lookups.CatsReferralCategory(parent33.getId(),parent33.getText(), parent33.isActive(), null, img, color));
  				parentVoLookup33 = parentVoLookup33.getParent();
  								parent33 = parent33.getParent();
  			}			
  			valueObject.setPatientStatus(voLookup33);
  		}
  				// RequiresTCIBy
  		java.util.Date RequiresTCIBy = domainObject.getRequiresTCIBy();
  		if ( null != RequiresTCIBy ) 
  		{
  			valueObject.setRequiresTCIBy(new ims.framework.utils.Date(RequiresTCIBy) );
  		}
   		return valueObject;
  	 }
  
  
  	/**
  	 * Create the domain object from the value object.
  	 * @param domainFactory - used to create existing (persistent) domain objects.
  	 * @param valueObject - extract the domain object fields from this.
  	 */
  	public static ims.RefMan.domain.objects.PatientElectiveList extractPatientElectiveList(ims.domain.ILightweightDomainFactory domainFactory, ims.RefMan.vo.PatientElectiveListVo valueObject) 
  	{
  		return 	extractPatientElectiveList(domainFactory, valueObject, new HashMap());
  	}
  
  	public static ims.RefMan.domain.objects.PatientElectiveList extractPatientElectiveList(ims.domain.ILightweightDomainFactory domainFactory, ims.RefMan.vo.PatientElectiveListVo valueObject, HashMap domMap) 
  	{
  		if (null == valueObject) 
  		{
  			return null;
  		}
  		Integer id = valueObject.getID_PatientElectiveList();
  		ims.RefMan.domain.objects.PatientElectiveList domainObject = null;
  		if ( null == id) 
  		{
  			if (domMap.get(valueObject) != null)
  			{
  				return (ims.RefMan.domain.objects.PatientElectiveList)domMap.get(valueObject);
  			}
  			// ims.RefMan.vo.PatientElectiveListVo ID_PatientElectiveList field is unknown
  			domainObject = new ims.RefMan.domain.objects.PatientElectiveList();
  			domMap.put(valueObject, domainObject);
  		}
  		else 
  		{
  			String key = (valueObject.getClass().getName() + "__" + valueObject.getID_PatientElectiveList());
  			if (domMap.get(key) != null)
  			{
  				return (ims.RefMan.domain.objects.PatientElectiveList)domMap.get(key);
  			}
  			domainObject = (ims.RefMan.domain.objects.PatientElectiveList) domainFactory.getDomainObject(ims.RefMan.domain.objects.PatientElectiveList.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_PatientElectiveList());
  
  	// SaveAsRefVO - treated as a refVo in extract methods
  	ims.core.configuration.domain.objects.ElectiveListConfiguration value1 = null;
  		if ( null != valueObject.getElectiveList() ) 
  		{
  			if (valueObject.getElectiveList().getBoId() == null)
  			{
  				if (domMap.get(valueObject.getElectiveList()) != null)
  				{
  					value1 = (ims.core.configuration.domain.objects.ElectiveListConfiguration)domMap.get(valueObject.getElectiveList());
  				}
  			}
  			else
  			{
  				value1 = (ims.core.configuration.domain.objects.ElectiveListConfiguration)domainFactory.getDomainObject(ims.core.configuration.domain.objects.ElectiveListConfiguration.class, valueObject.getElectiveList().getBoId());
  			}
  		}
  		domainObject.setElectiveList(value1);
  		domainObject.setElectiveListStatus(ims.RefMan.vo.domain.ElectiveListStatusVoAssembler.extractElectiveListStatus(domainFactory, valueObject.getElectiveListStatus(), domMap));
  		ims.core.patient.domain.objects.Patient value3 = null;
  		if ( null != valueObject.getPatient() ) 
  		{
  			if (valueObject.getPatient().getBoId() == null)
  			{
  				if (domMap.get(valueObject.getPatient()) != null)
  				{
  					value3 = (ims.core.patient.domain.objects.Patient)domMap.get(valueObject.getPatient());
  				}
  			}
  			else if (valueObject.getBoVersion() == -1) // RefVo was not modified since obtained from the Assembler, no need to update the BO field
  			{
  				value3 = domainObject.getPatient();	
  			}
  			else
  			{
  				value3 = (ims.core.patient.domain.objects.Patient)domainFactory.getDomainObject(ims.core.patient.domain.objects.Patient.class, valueObject.getPatient().getBoId());
  			}
  		}
  		domainObject.setPatient(value3);
  		ims.RefMan.domain.objects.CatsReferral value4 = null;
  		if ( null != valueObject.getReferral() ) 
  		{
  			if (valueObject.getReferral().getBoId() == null)
  			{
  				if (domMap.get(valueObject.getReferral()) != null)
  				{
  					value4 = (ims.RefMan.domain.objects.CatsReferral)domMap.get(valueObject.getReferral());
  				}
  			}
  			else if (valueObject.getBoVersion() == -1) // RefVo was not modified since obtained from the Assembler, no need to update the BO field
  			{
  				value4 = domainObject.getReferral();	
  			}
  			else
  			{
  				value4 = (ims.RefMan.domain.objects.CatsReferral)domainFactory.getDomainObject(ims.RefMan.domain.objects.CatsReferral.class, valueObject.getReferral().getBoId());
  			}
  		}
  		domainObject.setReferral(value4);
  		ims.core.admin.domain.objects.EpisodeOfCare value5 = null;
  		if ( null != valueObject.getEpisodeOfCare() ) 
  		{
  			if (valueObject.getEpisodeOfCare().getBoId() == null)
  			{
  				if (domMap.get(valueObject.getEpisodeOfCare()) != null)
  				{
  					value5 = (ims.core.admin.domain.objects.EpisodeOfCare)domMap.get(valueObject.getEpisodeOfCare());
  				}
  			}
  			else if (valueObject.getBoVersion() == -1) // RefVo was not modified since obtained from the Assembler, no need to update the BO field
  			{
  				value5 = domainObject.getEpisodeOfCare();	
  			}
  			else
  			{
  				value5 = (ims.core.admin.domain.objects.EpisodeOfCare)domainFactory.getDomainObject(ims.core.admin.domain.objects.EpisodeOfCare.class, valueObject.getEpisodeOfCare().getBoId());
  			}
  		}
  		domainObject.setEpisodeOfCare(value5);
  	// SaveAsRefVO - treated as a refVo in extract methods
  	ims.core.resource.place.domain.objects.Location value6 = null;
  		if ( null != valueObject.getWard() ) 
  		{
  			if (valueObject.getWard().getBoId() == null)
  			{
  				if (domMap.get(valueObject.getWard()) != null)
  				{
  					value6 = (ims.core.resource.place.domain.objects.Location)domMap.get(valueObject.getWard());
  				}
  			}
  			else
  			{
  				value6 = (ims.core.resource.place.domain.objects.Location)domainFactory.getDomainObject(ims.core.resource.place.domain.objects.Location.class, valueObject.getWard().getBoId());
  			}
  		}
  		domainObject.setWard(value6);
  	// SaveAsRefVO - treated as a refVo in extract methods
  	ims.core.resource.people.domain.objects.Hcp value7 = null;
  		if ( null != valueObject.getConsultant() ) 
  		{
  			if (valueObject.getConsultant().getBoId() == null)
  			{
  				if (domMap.get(valueObject.getConsultant()) != null)
  				{
  					value7 = (ims.core.resource.people.domain.objects.Hcp)domMap.get(valueObject.getConsultant());
  				}
  			}
  			else
  			{
  				value7 = (ims.core.resource.people.domain.objects.Hcp)domainFactory.getDomainObject(ims.core.resource.people.domain.objects.Hcp.class, valueObject.getConsultant().getBoId());
  			}
  		}
  		domainObject.setConsultant(value7);
  		java.util.Date value8 = null;
  		ims.framework.utils.Date date8 = valueObject.getDateOnList();		
  		if ( date8 != null ) 
  		{
  			value8 = date8.getDate();
  		}
  		domainObject.setDateOnList(value8);
  		java.util.Date value9 = null;
  		ims.framework.utils.Date date9 = valueObject.getOriginalDecisionDate();		
  		if ( date9 != null ) 
  		{
  			value9 = date9.getDate();
  		}
  		domainObject.setOriginalDecisionDate(value9);
  		// create LookupInstance from vo LookupType
  		ims.domain.lookups.LookupInstance value10 = null;
  		if ( null != valueObject.getIntendedManagement() ) 
  		{
  			value10 =
  				domainFactory.getLookupInstance(valueObject.getIntendedManagement().getID());
  		}
  		domainObject.setIntendedManagement(value10);
  		domainObject.setAnticipatedStay(valueObject.getAnticipatedStay());
  		// create LookupInstance from vo LookupType
  		ims.domain.lookups.LookupInstance value12 = null;
  		if ( null != valueObject.getPriority() ) 
  		{
  			value12 =
  				domainFactory.getLookupInstance(valueObject.getPriority().getID());
  		}
  		domainObject.setPriority(value12);
  		domainObject.setSuspensions(ims.RefMan.vo.domain.SuspensionDetailsForPatientElectiveListVoAssembler.extractSuspensionDetailsForPatientElectiveListList(domainFactory, valueObject.getSuspensions(), domainObject.getSuspensions(), domMap));		
  		domainObject.setOperativeProcedureStatus(valueObject.getOperativeProcedureStatus());
  	// SaveAsRefVO - treated as a refVo in extract methods
  	ims.core.clinical.domain.objects.Procedure value15 = null;
  		if ( null != valueObject.getPrimaryProcedure() ) 
  		{
  			if (valueObject.getPrimaryProcedure().getBoId() == null)
  			{
  				if (domMap.get(valueObject.getPrimaryProcedure()) != null)
  				{
  					value15 = (ims.core.clinical.domain.objects.Procedure)domMap.get(valueObject.getPrimaryProcedure());
  				}
  			}
  			else
  			{
  				value15 = (ims.core.clinical.domain.objects.Procedure)domainFactory.getDomainObject(ims.core.clinical.domain.objects.Procedure.class, valueObject.getPrimaryProcedure().getBoId());
  			}
  		}
  		domainObject.setPrimaryProcedure(value15);
  
  		// SaveAsRefVO treated as RefValueObject
  		ims.core.clinical.vo.ProcedureRefVoCollection refCollection16 = new ims.core.clinical.vo.ProcedureRefVoCollection();
  		if (valueObject.getOtherProcedures() != null)
  		{
  			for (int i16=0; i16<valueObject.getOtherProcedures().size(); i16++)
  			{
  				ims.core.clinical.vo.ProcedureRefVo ref16 = (ims.core.clinical.vo.ProcedureRefVo)valueObject.getOtherProcedures().get(i16);
  				refCollection16.add(ref16);
  			}
  		}
  		int size16 = (null == refCollection16) ? 0 : refCollection16.size();		
  		java.util.List domainOtherProcedures16 = domainObject.getOtherProcedures();
  		if (domainOtherProcedures16 == null)
  		{
  			domainOtherProcedures16 = new java.util.ArrayList();
  		}
  		for(int i=0; i < size16; i++) 
  		{
  			ims.core.clinical.vo.ProcedureRefVo vo = refCollection16.get(i);			
  			ims.core.clinical.domain.objects.Procedure dom = null;
  			if ( null != vo ) 
  			{
  				if (vo.getBoId() == null)
  				{
  					if (domMap.get(vo) != null)
  					{
  						dom = (ims.core.clinical.domain.objects.Procedure)domMap.get(vo);
  					}
  				}
  				else
  				{
  					dom = (ims.core.clinical.domain.objects.Procedure)domainFactory.getDomainObject( ims.core.clinical.domain.objects.Procedure.class, vo.getBoId());
  				}
  			}
  
  			int domIdx = domainOtherProcedures16.indexOf(dom);
  			if (domIdx == -1)
  			{
  				domainOtherProcedures16.add(i, dom);
  			}
  			else if (i != domIdx && i < domainOtherProcedures16.size())
  			{
  				Object tmp = domainOtherProcedures16.get(i);
  				domainOtherProcedures16.set(i, domainOtherProcedures16.get(domIdx));
  				domainOtherProcedures16.set(domIdx, tmp);
  			}
  		}
  		
  		//Remove all ones in domList where index > voCollection.size() as these should
  		//now represent the ones removed from the VO collection. No longer referenced.
  		int i16 = domainOtherProcedures16.size();
  		while (i16 > size16)
  		{
  			domainOtherProcedures16.remove(i16-1);
  			i16 = domainOtherProcedures16.size();
  		}
  		
  		domainObject.setOtherProcedures(domainOtherProcedures16);		
  		domainObject.setTCIHistory(ims.RefMan.vo.domain.PatientElectiveListElectiveTCIVoAssembler.extractTCIForPatientElectiveListList(domainFactory, valueObject.getTCIHistory(), domainObject.getTCIHistory(), domMap));		
  		domainObject.setInterpretatorRequired(valueObject.getInterpretatorRequired());
  		// create LookupInstance from vo LookupType
  		ims.domain.lookups.LookupInstance value19 = null;
  		if ( null != valueObject.getTransport() ) 
  		{
  			value19 =
  				domainFactory.getLookupInstance(valueObject.getTransport().getID());
  		}
  		domainObject.setTransport(value19);
  		domainObject.setNotes(ims.RefMan.vo.domain.PatientElectiveListNotesVoAssembler.extractNotesForPatientElectiveListSet(domainFactory, valueObject.getNotes(), domainObject.getNotes(), domMap));		
  		// create LookupInstance from vo LookupType
  		ims.domain.lookups.LookupInstance value21 = null;
  		if ( null != valueObject.getElectiveAdmissionType() ) 
  		{
  			value21 =
  				domainFactory.getLookupInstance(valueObject.getElectiveAdmissionType().getID());
  		}
  		domainObject.setElectiveAdmissionType(value21);
  		ims.RefMan.domain.objects.ReferralEROD value22 = null;
  		if ( null != valueObject.getEROD() ) 
  		{
  			if (valueObject.getEROD().getBoId() == null)
  			{
  				if (domMap.get(valueObject.getEROD()) != null)
  				{
  					value22 = (ims.RefMan.domain.objects.ReferralEROD)domMap.get(valueObject.getEROD());
  				}
  			}
  			else if (valueObject.getBoVersion() == -1) // RefVo was not modified since obtained from the Assembler, no need to update the BO field
  			{
  				value22 = domainObject.getEROD();	
  			}
  			else
  			{
  				value22 = (ims.RefMan.domain.objects.ReferralEROD)domainFactory.getDomainObject(ims.RefMan.domain.objects.ReferralEROD.class, valueObject.getEROD().getBoId());
  			}
  		}
  		domainObject.setEROD(value22);
  		domainObject.setTCIDetails(ims.RefMan.vo.domain.PatientElectiveListElectiveTCIVoAssembler.extractTCIForPatientElectiveList(domainFactory, valueObject.getTCIDetails(), domMap));
  		domainObject.setElectiveListStatusHistory(ims.RefMan.vo.domain.ElectiveListStatusVoAssembler.extractElectiveListStatusList(domainFactory, valueObject.getElectiveListStatusHistory(), domainObject.getElectiveListStatusHistory(), domMap));		
  		// create LookupInstance from vo LookupType
  		ims.domain.lookups.LookupInstance value25 = null;
  		if ( null != valueObject.getElectiveListReason() ) 
  		{
  			value25 =
  				domainFactory.getLookupInstance(valueObject.getElectiveListReason().getID());
  		}
  		domainObject.setElectiveListReason(value25);
  		ims.pathways.domain.objects.PathwayClock value26 = null;
  		if ( null != valueObject.getPathwayClock() ) 
  		{
  			if (valueObject.getPathwayClock().getBoId() == null)
  			{
  				if (domMap.get(valueObject.getPathwayClock()) != null)
  				{
  					value26 = (ims.pathways.domain.objects.PathwayClock)domMap.get(valueObject.getPathwayClock());
  				}
  			}
  			else if (valueObject.getBoVersion() == -1) // RefVo was not modified since obtained from the Assembler, no need to update the BO field
  			{
  				value26 = domainObject.getPathwayClock();	
  			}
  			else
  			{
  				value26 = (ims.pathways.domain.objects.PathwayClock)domainFactory.getDomainObject(ims.pathways.domain.objects.PathwayClock.class, valueObject.getPathwayClock().getBoId());
  			}
  		}
  		domainObject.setPathwayClock(value26);
  
  		ims.RefMan.vo.ReferralERODRefVoCollection refCollection27 = valueObject.getERODHistory();
  		int size27 = (null == refCollection27) ? 0 : refCollection27.size();		
  		java.util.List domainERODHistory27 = domainObject.getERODHistory();
  