<?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-lazy="false" default-cascade="all">
     <class entity-name="patientGeneratedDataEvent" table="PGD_V" lazy="false" name="gov.va.med.cds.template.generated.pgd.PatientGeneratedDataEvent" >
        <id name="id" type="java.lang.Long">
            <column name="PGD_ID" />
            <generator class="sequence" >
				<param name="sequence">PGD_ID_SEQ_ID</param>
			</generator>
        </id>
        
         <property name="requestId" column="REQUEST_ID" type="java.lang.String" insert="true" update="false"  />
        
        <component name="uniqueIdentifier" class="gov.va.med.cds.template.generated.basedatatypes.HL72EntityIdentifier"> 
           <property name="identity" column="UNIQUE_ID" type="java.lang.String" not-null="true" />
        </component>
                  
        <component name="patient" class="gov.va.med.cds.template.generated.common.PatientLite">
            <component name="identifier" class="gov.va.med.cds.template.generated.basedatatypes.HL72PersonIdentifier">
                <property name="identity" column="PATIENT_IDENTITY" type="java.lang.String" not-null="true" />
                <property name="assigningFacility" column="PATIENT_ASSIGNING_FACILITY" type="java.lang.String" not-null="true" />
                <property name="assigningAuthority" column="PATIENT_ASSIGNING_AUTHORITY" type="java.lang.String" />
            </component>
        </component>
           
        <property name="collectionType" column="COLLECTION_TYPE" type="java.lang.String" />
        
	    <property name="recordUpdateTime" type="gov.va.med.cds.persistence.hibernate.common.PointInTimeWithPatternUserType">
			<column name="RECORD_UPDATE_TM"/>
			<column name="RECORD_UPDATE_TM_UTC"/>
        </property>
  		
		<property name="pgdContent" column="PGD_CONTENT" type="java.lang.String" />
		
    </class>
    
    <query name="PGDRead1.PatientGeneratedDataEvent.patient">
        <![CDATA[
        from patientGeneratedDataEvent pgd
        where pgd.patient.identifier.assigningFacility || '/' || pgd.patient.identifier.identity in ( :pids )
      ]]>
    </query>
     
   <query name="PGDRead1.PatientGeneratedDataEvent.patient.collectionType">
        <![CDATA[
        from patientGeneratedDataEvent pgd
        where pgd.patient.identifier.assigningFacility || '/' || pgd.patient.identifier.identity in ( :pids )
        and upper(pgd.collectionType)=upper(:collectionType)
      ]]>
    </query>

   <query name="PGDRead1.PatientGeneratedDataEvent.patient.identifiers">
        <![CDATA[
        from patientGeneratedDataEvent pgd
        where pgd.uniqueIdentifier.identity || '///' in ( :recordIdentifiers  )
        ]]>
     </query>
  
</hibernate-mapping>
