<?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"
[
<!ENTITY patientLite SYSTEM 	"classpath://gov/va/med/cds/persistence/hibernate/common/PatientLitePojo.hbm">
<!ENTITY author SYSTEM 			"classpath://gov/va/med/cds/persistence/hibernate/common/AuthorPractitionerParticipationPojo.hbm">
<!ENTITY verifier SYSTEM 			"classpath://gov/va/med/cds/persistence/hibernate/common/VerifierPractitionerParticipationPojo.hbm">
<!ENTITY errorEnterer SYSTEM "classpath://gov/va/med/cds/persistence/hibernate/common/ErrorEntererPractitionerParticipationPojo.hbm">
]
>

<hibernate-mapping default-lazy="false" default-cascade="all">
    <class entity-name="intoleranceConditionPharmacyRead40010" 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>
        
<!-- import from .../common/PatientLite.hbm -->
&patientLite;
        
        <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="allergyType"  class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
			<property name="code" column="ALLERGY_TYP_CODE" type="java.lang.String"  />
			<property name="displayText" column="ALLERGY_TYP_DSPLYTXT" type="java.lang.String" />
			<property name="codingSystem" column="ALLERGY_TYP_CODSYS" type="java.lang.String"  />
		</component>

        <component name="gmrAllergyAgent" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElement">
			<property name="code" column="GMR_ALLERGY_CODE" type="java.lang.String"  />
			<property name="displayText" column="GMR_ALLERGY_DSPLYTXT" type="java.lang.String" />
			<property name="codingSystem" column="GMR_ALLERGY_CODSYS" type="java.lang.String"  />
			<property name="alternateCode" column="GMR_ALLERGY_ALT_CODE" type="java.lang.String" />
			<property name="alternateDisplayText" column="GMR_ALLERGY_ALT_DSPLYTXT" type="java.lang.String" />
			<property name="alternateCodingSystem" column="GMR_ALLERGY_ALT_CODSYS" type="java.lang.String"  />
		</component>

       <component name="informationSourceCategory"  class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
			<property name="code" column="INFO_SRC_CAT_CODE" type="java.lang.String"  />
			<property name="displayText" column="INFO_SRC_CAT_DSPLYTXT" type="java.lang.String" />
			<property name="codingSystem" column="INFO_SRC_CAT_CODSYS" type="java.lang.String"  />
		</component>

       <component name="mechanism"  class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
			<property name="code" column="MECHANISM_CODE" type="java.lang.String" />
			<property name="displayText" column="MECHANISM_DSPLYTXT" type="java.lang.String" />
			<property name="codingSystem" column="MECHANISM_CODSYS" type="java.lang.String"  />
		</component>

		<property name="status" column="ALLERGY_STATUS" type="java.lang.String" />

		<property name="verified" column="ALLERGY_IS_VERIFIED" type="java.lang.String" />
    
    
        <list name="reaction" fetch="subselect" batch-size="100">
            <key column="ALLERGY_ID" update="false"/>
            <list-index column="LINE_NBR"  />
            <one-to-many entity-name="Reaction" />
        </list>

<!-- import from .../common/VerifierPractitionerParticipation.hbm -->
&verifier;

<!-- import from .../common/AuthorPractitionerParticipation.hbm -->
&author;

<!-- import from .../common/ErrorEntererPractitionerParticipation.hbm -->
&errorEnterer;

        <list name="idBandMarker" where="discriminator='I'" fetch="subselect" batch-size="100">
            <key column="ALLERGY_ID" update="false"/>
            <list-index column="LINE_NBR"  />
            <one-to-many entity-name="idBandMarker" />
        </list>
        
        <list name="chartMarker" where="discriminator='C'" fetch="subselect" batch-size="100">
            <key column="ALLERGY_ID" update="false"/>
            <list-index column="LINE_NBR"  />
            <one-to-many entity-name="chartMarker" />
        </list>
        
        <list name="commentEvent" fetch="subselect" batch-size="100">
            <key column="ALLERGY_ID" update="false"/>
            <list-index column="LINE_NBR" />
            <one-to-many entity-name="commentEvents" />
        </list>
        
        <list name="drugClass" fetch="subselect" batch-size="100">
            <key column="ALLERGY_ID" update="false"/>
            <list-index column="LINE_NBR"  />
            <one-to-many entity-name="drugClass" />
        </list>
        
        <list name="drugIngredient" fetch="subselect" batch-size="100">
            <key column="ALLERGY_ID" update="false"/>
            <list-index column="LINE_NBR"  />
            <one-to-many entity-name="DrugIngredient" />
        </list>
        
         <component name="facilityIdentifier"  class="gov.va.med.cds.template.generated.basedatatypes.HL72OrganizationIdentifier">
			<property name="name" column="FACILITY_NAME" type="java.lang.String"  />
			<property name="identity" column="FACILITY_IDENTITY" type="java.lang.String" />
			<property name="assigningAuthority" column="FACILITY_ASSIGNING_AUTHORITY" 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="recordUpdateTime" type="gov.va.med.cds.persistence.hibernate.common.PointInTimeUserType" >
			<column name="RECORD_UPDATE_TM"/>
			<column name="RECORD_UPDATE_TM_NBR"/>
		</property>
        
		<property name="requestId" column="REQUEST_ID" type="java.lang.String" />

    </class>

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

	<query name="IntoleranceConditionPharmacyRead40010.IntoleranceCondition.patient.date">
		<![CDATA[
		from intoleranceConditionPharmacyRead40010 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="IntoleranceConditionPharmacyRead40010.IntoleranceCondition.patient.identifiers">
		<![CDATA[
		from intoleranceConditionPharmacyRead40010 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>
	
    <query name="RDIIntoleranceConditionPharmacyRead40010.IntoleranceCondition.patient">
		<![CDATA[
		from intoleranceConditionPharmacyRead40010 ic
		where ic.patient.identifier.assigningFacility || '/' || ic.patient.identifier.identity in ( :pids )
      ]]>
	</query>

	<query name="RDIIntoleranceConditionPharmacyRead40010.IntoleranceCondition.patient.date">
		<![CDATA[
		from intoleranceConditionPharmacyRead40010 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="RDIIntoleranceConditionPharmacyRead40010.IntoleranceCondition.patient.identifiers">
		<![CDATA[
		from intoleranceConditionPharmacyRead40010 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>

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

	<query name="RDIIntoleranceConditionPharmacyRead40011.IntoleranceCondition.patient.date">
		<![CDATA[
		from intoleranceConditionPharmacyRead40010 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="RDIIntoleranceConditionPharmacyRead40011.IntoleranceCondition.patient.identifiers">
		<![CDATA[
		from intoleranceConditionPharmacyRead40010 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>
    <query name="RDIIntoleranceConditionPharmacyRead40012.IntoleranceCondition.patient">
		<![CDATA[
		from intoleranceConditionPharmacyRead40010 ic
		where ic.patient.identifier.assigningFacility || '/' || ic.patient.identifier.identity in ( :pids )
      ]]>
	</query>

	<query name="RDIIntoleranceConditionPharmacyRead40012.IntoleranceCondition.patient.date">
		<![CDATA[
		from intoleranceConditionPharmacyRead40010 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="RDIIntoleranceConditionPharmacyRead40012.IntoleranceCondition.patient.identifiers">
		<![CDATA[
		from intoleranceConditionPharmacyRead40010 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>
	
	   <query name="RDIAllergiesPharmacyRead40013.IntoleranceCondition.patient">
		<![CDATA[
		from intoleranceConditionPharmacyRead40010 ic
		where ic.patient.identifier.assigningFacility || '/' || ic.patient.identifier.identity in ( :pids )
      ]]>
	</query>

	<query name="RDIAllergiesPharmacyRead40013.IntoleranceCondition.patient.date">
		<![CDATA[
		from intoleranceConditionPharmacyRead40010 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="RDIAllergiesPharmacyRead40013.IntoleranceCondition.patient.identifiers">
		<![CDATA[
		from intoleranceConditionPharmacyRead40010 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>
