<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<!-- cascade="all|none|save-update|delete|all-delete-orphan"  -->

<hibernate-mapping default-lazy="false" default-cascade="save-update">

    <class entity-name="censusSurveyResponse" table="CENSUS_RESPONSE" lazy="false">
        <id type="java.lang.Long" name="id">
            <column name="CENSUS_RESPONSE_ID"/>
            <generator class="sequence" >
				<param name="sequence">census_response_seq_id</param>
			</generator>
        </id>

		<property name="enrollmentDate" node="enrollmentDate">
			<column name="ENROLLMENT_DT"/>
			<type name="gov.va.med.cds.persistence.hibernate.common.Dom4jDateUserType">
				<param name="dateFormat">yyyy-MM-dd</param>
				<param name="nodeName">enrollmentDate</param>
			</type>
		</property>
			
		<property name="disenrollmentDate" node="disenrollmentDate">
			<column name="DISENRMENT_DT"/>
			<type name="gov.va.med.cds.persistence.hibernate.common.Dom4jDateUserType">
				<param name="dateFormat">yyyy-MM-dd</param>
				<param name="nodeName">disenrollmentDate</param>
			</type>
		</property>
		
		<property name="activationDate" node="activationDate">
			<column name="ACTIVATION_DT"/>
			<type name="gov.va.med.cds.persistence.hibernate.common.Dom4jDateUserType">
				<param name="dateFormat">yyyy-MM-dd</param>
				<param name="nodeName">activationDate</param>
			</type>
		</property>
		
		<property name="inactivationDate" node="inactivationDate">
			<column name="INACTIVATION_DT"/>
			<type name="gov.va.med.cds.persistence.hibernate.common.Dom4jDateUserType">
				<param name="dateFormat">yyyy-MM-dd</param>
				<param name="nodeName">activationDate</param>
			</type>
		</property>
		
		<property name="programName" column="PROGRAM_NAME" type="java.lang.String" node="programName"/>
		
		<component name="recordSource" node="recordSource">
			<property name="namespaceId" column="RECORDSOURCE_NAMESPACEID" type="java.lang.String" node="namespaceId" />
			<property name="universalId" column="RECORDSOURCE_UNIVERSALID" type="java.lang.String" node="universalId" />
			<property name="universalIdType" column="RECORDSOURCE_UNIVERSTYP" type="java.lang.String" node="universalIdType" />
		</component>
		
		<component name="recordUpdateTime" node="recordUpdateTime">
          <property name="literal" type="gov.va.med.cds.persistence.hibernate.common.Dom4jPointInTimeUserType" node="literal" >
            <column name="RECORD_CREATION_TM"/>
            <column name="RECORD_CREATION_TM_NBR"/>
          </property>
        </component>	
        
        <property name="submittedDate" node="submittedDate">
			<column name="SUBMITTED_DT"/>
			<type name="gov.va.med.cds.persistence.hibernate.common.Dom4jDateUserType">
				<param name="dateFormat">yyyy-MM-dd</param>
				<param name="nodeName">submittedDate</param>
			</type>
		</property>
		
		<component name="homeDevice" node="homeDevice">
			<property name="model" column="HOME_DEVICE_MODEL" type="java.lang.String" node="model" />
			<property name="serial" column="HOME_DEVICE_SERIAL" type="java.lang.String" node="serial" />
		</component>
		
		<property name="reportStartDate" node="reportStartDate">
			<column name="REPORT_START_DT"/>
			<type name="gov.va.med.cds.persistence.hibernate.common.Dom4jDateUserType">
				<param name="dateFormat">yyyy-MM-dd</param>
				<param name="nodeName">reportStartDate</param>
			</type>
		</property>
		
		<property name="reportEndDate" node="reportEndDate">
			<column name="REPORT_END_DT"/>
			<type name="gov.va.med.cds.persistence.hibernate.common.Dom4jDateUserType">
				<param name="dateFormat">yyyy-MM-dd</param>
				<param name="nodeName">reportEndDate</param>
			</type>
		</property>
		
		<property name="levelOfCare" column="LEVEL_OF_CARE" type="double" node="levelOfCare"/>
		<property name="compliance" column="COMPLIANCE" type="double" node="compliance"/>
		
		<component name="responseRate" node="responseRate">
			<property name="actual" column="RESPONSE_RATE_ACTUAL" type="double" node="actual" />
			<property name="expected" column="RESPONSE_RATE_EXPECTED" type="double" node="expected" />
		</component>
		
		<property name="dataAge" column="DATA_AGE" type="double" node="dataAge"/>

		<property name="requestId" column="REQUEST_ID" type="java.lang.String" node="requestId" />

		<!--  one-to-one relationships (use many to one when parent and child primary key are different-->
		

 		<many-to-one name="survey" entity-name="survey" column="SURVEY_ID" unique="true"/>
  	
		<many-to-one name="vendor" entity-name="vendor" column="VENDOR_ID" unique="true"/>

		<many-to-one name="facility" entity-name="facility" column="FACILITY_ID" unique="true"/>

		<many-to-one name="surveyPatient" entity-name="surveyPatient" column="SURVEY_PATIENT_ID" unique="true"/>

		<many-to-one name="careCoordinator" entity-name="careCoordinator" column="CARE_COORDINATOR_ID" unique="true"/>

		<list name="modalitiesList" cascade="all" node="modalities" collection-type="gov.va.med.cds.persistence.hibernate.common.Dom4JAbleListType">
			<key column="CENSUS_RESPONSE_ID" not-null="true" update="false" />
			<list-index column="LINE_NBR"/>
			<one-to-many entity-name="censusModalityResponse" node="modality" embed-xml="true"/>
		</list> 	
		
	</class>

</hibernate-mapping>
