<?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"
[
]
>

<hibernate-mapping default-cascade="all">
    <class entity-name="censusCompleteWeek" name="gov.va.med.cds.scheduler.persistence.CensusCompleteWeek" table="CENSUS_COMPLETE_WEEK" lazy="false"  >

        <id name="censusCompleteWeekId" type="java.lang.Long">
            <column name="CENSUS_COMPLETE_WEEK_ID" />
            <generator class="assigned" />
        </id>
        
		<property name="vendorId" column="VENDOR_ID" type="java.lang.Long" />
		<property name="vendorFacility" column="VENDOR_FACILITY" type="java.lang.String" />
		<property name="reportStartDt" column="REPORT_START_DT" type="date" />
		<property name="ingestStatus" column="INGEST_STATUS" type="java.lang.String" />
		<property name="ingestStatusDt" column="INGEST_STATUS_DT" type="date" />
		<property name="transformStatus" column="TRANSFORM_STATUS" type="java.lang.String" />
		<property name="transformStatusDt" column="TRANSFORM_STATUS_DT" type="date" />
		<property name="messageInsertionTime" column="MESSAGE_INSERTION_TIME" type="timestamp" />
		<property name="ackStatus" column="ACK_STATUS" type="java.lang.String" />
		<property name="ackStatusDt" column="ACK_STATUS_DT" type="date" />
		<property name="reportEndDt" column="REPORT_END_DT" type="date" />
		<property name="requestId" column="REQUEST_ID" type="java.lang.String" />
		<property name="sendingApplication" column="SENDING_APPLICATION" type="java.lang.String" />
		<property name="stationNumber" column="STATION_NO" type="java.lang.String" />
		<property name="sendingFacility" column="SENDING_FACILITY" type="java.lang.String" />
		<property name="receivingApplication" column="RECEIVING_APPLICATION" type="java.lang.String" />
		<property name="receivingFacility" column="RECEIVING_FACILITY" type="java.lang.String" />
    </class>
    
	<query name="censusCompleteWeek.list.censusMasterId">
		<![CDATA[ from censusCompleteWeek ccw where ccw.vendorFacility = :vendorFacility and ccw.reportStartDt = :reportStartDt ]]>
	</query>
	
	<query name="censusCompleteWeek.update.ingestStatus">
		<![CDATA[
			update censusCompleteWeek ccw 
			set ccw.ingestStatus = 'EXPIRED', ccw.ingestStatusDt = SYSDATE, ccw.ackStatus = 'INPROGRESS', ccw.ackStatusDt = SYSDATE
			where ccw.censusCompleteWeekId = :censusCompleteWeekId ]]>
	</query>
	
	<query name="censusCompleteWeek.update.ackStatus">
		<![CDATA[ 
			update censusCompleteWeek ccw 
			set ccw.ackStatus = :ackStatus, ccw.ackStatusDt = SYSDATE
			where ccw.censusCompleteWeekId = :censusCompleteWeekId ]]>
	</query>
</hibernate-mapping>
