<?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="intoleranceConditionReducedRead40011" name="gov.va.med.cds.template.generated.allergies.IntoleranceCondition" table="ALLERGY30_V" lazy="false"  >
        <id name="id" type="java.lang.Long" >
            <column name="ALLERGY_ID" />
 			<generator class="sequence">
				<param name="sequence">allergy_seq_id</param>
			</generator>
        </id>
        
        <component name="recordIdentifier" class="gov.va.med.cds.template.generated.basedatatypes.HL72EntityIdentifier">
            <property name="identity" column="RECORDIDENTIFIER_IDENTITY" type="java.lang.String"  />
            <property name="namespaceId" column="RECORDIDENTIFIER_NAMESPACEID" type="java.lang.String"  />
            <property name="universalId" column="RECORDIDENTIFIER_UNIVERSALID" type="java.lang.String"  />
            <property name="universalIdType" column="RECORDIDENTIFIER_UNIVERSTYP" type="java.lang.String"  />
        </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="observationTime" type="gov.va.med.cds.persistence.hibernate.common.PointInTimeUserType" >
            <column name="ALRGY_OBSERVATION_TM"/>
            <column name="ALRGY_OBSERVATION_TM_NBR"/>
        </property>
        
        <component name="agent"  class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
			<property name="code" column="AGENT_CODE" type="java.lang.String" />
			<property name="displayText" column="AGENT_DSPLYTXT" type="java.lang.String"  />
			<property name="codingSystem" column="AGENT_CODSYS" type="java.lang.String"  />
		</component>

       <component name="recordSource" class="gov.va.med.cds.template.generated.basedatatypes.HL72FacilityIdentifier">
			<property name="namespaceId" column="RECORDSOURCE_NAMESPACEID" type="java.lang.String" />
			<property name="universalId" column="RECORDSOURCE_UNIVERSALID" type="java.lang.String" />
			<property name="universalIdType" column="RECORDSOURCE_UNIVERSTYP" type="java.lang.String"  />
		</component>

		<property name="recordVersion" column="RECORD_VERSION" type="integer" />
		
		<property name="requestId" column="REQUEST_ID" type="java.lang.String" />

    </class>

    <query name="IntoleranceConditionReducedRead40011.IntoleranceCondition.patient">
		<![CDATA[
		from intoleranceConditionReducedRead40011 ic
		where ic.patient.identifier.assigningFacility || '/' || ic.patient.identifier.identity in ( :pids )
      ]]>
	</query>

	<query name="IntoleranceConditionReducedRead40011.IntoleranceCondition.patient.date">
		<![CDATA[
		from intoleranceConditionReducedRead40011 ic
		where ic.patient.identifier.assigningFacility || '/' || ic.patient.identifier.identity in ( :pids )
		and ( ic.observationTime.numeric between :startDate and :endDate or ic.observationTime.numeric is null )
      ]]>
	</query>

    <query name="IntoleranceConditionReducedRead40011.IntoleranceCondition.patient.identifiers">
		<![CDATA[
		from intoleranceConditionReducedRead40011 ic
		where ic.patient.identifier.assigningFacility || '/' || ic.patient.identifier.identity in ( :pids )
		and ic.recordIdentifier.identity || '/' || ic.recordIdentifier.namespaceId || '/' ||
		ic.recordIdentifier.universalId || '/' || ic.recordIdentifier.universalIdType in ( :recordIdentifiers )
      ]]>
	</query>

</hibernate-mapping>
