<?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>
    <class entity-name="drugIngredient40010" table="VISTA_HDSI.PATIX_DRUG_INGRDNT_120_802_EXT" lazy="false" name="gov.va.med.cds.template.generated.allergies.DrugIngredient" >
        <id name="idV" type="java.lang.String">
            <column name="ROWID" />
            <generator class="assigned" />
        </id>
        
        <property name="patientAllergies" column="PATIENT_ALLERGIES"  type="big_decimal" insert="false" update="false" />
        
        <component name="code" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
          <property name="code" column="DrugIngredientVuid" type="java.lang.String" insert="false" update="false"  />
          <property name="displayText" column="DrugIngredientName" type="java.lang.String" insert="false" update="false"  />
          <property name="codingSystem" type="java.lang.String" >
        		<formula>
        		(CASE
				    WHEN (DrugIngredientVuid IS NOT NULL OR DrugIngredientName IS NOT NULL) THEN '99VA50.416'
				    ELSE NULL
				 END)
        		</formula>
        	</property>
        </component>

    </class>
    
    <class entity-name="drugIngredient_multiquery" table="VISTA_HDSI.PATIX_DRUG_INGRDNT_120_802_EXT" lazy="false" name="gov.va.med.cds.template.generated.allergies.subquery.DrugIngredientWrapper" >
        
        <id name="id" type="java.lang.String">
            <column name="ROWID" />
            <generator class="assigned" />
        </id>
        
        <property name="patientAllergies" column="PATIENT_ALLERGIES"  type="big_decimal" insert="false" update="false" />
        
        <component name="code" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
          <property name="code" column="DrugIngredientVuid" type="java.lang.String" insert="false" update="false"  />
          <property name="displayText" column="DrugIngredientName" type="java.lang.String" insert="false" update="false"  />
          <property name="codingSystem" type="java.lang.String" >
                <formula>
                (CASE
                    WHEN (DrugIngredientVuid IS NOT NULL OR DrugIngredientName IS NOT NULL) THEN '99VA50.416'
                    ELSE NULL
                 END)
                </formula>
            </property>
        </component>

    </class>
    
    
     <query name="IntoleranceConditionRead40010.IntoleranceCondition.drugIngredient">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
      ]]>
    </query>
    
     <query name="IntoleranceConditionRead40010.IntoleranceCondition.drugIngredient.date">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ( (ic.observationTime.timestamp between :startDate and :endDate) or (ic.observationTime.timestamp is null)  )
      ]]>
    </query>
    
     <query name="IntoleranceConditionRead40010.IntoleranceCondition.drugIngredient.identifiers">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ic.id in ( :recordIdentifiers )
      ]]>
    </query>
    
     <query name="VWIntoleranceConditionRead40010.IntoleranceCondition.drugIngredient">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
      ]]>
    </query>
    
     <query name="VWIntoleranceConditionRead40010.IntoleranceCondition.drugIngredient.date">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ( (ic.observationTime.timestamp between :startDate and :endDate) or (ic.observationTime.timestamp is null)  )
      ]]>
    </query>
    
     <query name="VWIntoleranceConditionRead40010.IntoleranceCondition.drugIngredient.identifiers">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ic.id in ( :recordIdentifiers )
      ]]>
    </query>
 
    <query name="RDIIntoleranceConditionPharmacyRead40010.IntoleranceCondition.drugIngredient.patient">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
      ]]>
    </query>
    
    <query name="RDIIntoleranceConditionPharmacyRead40010.IntoleranceCondition.drugIngredient.patient.date">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ( (ic.observationTime.timestamp between :startDate and :endDate) or (ic.observationTime.timestamp is null)  )
      ]]>
    </query>
    
    <query name="RDIIntoleranceConditionPharmacyRead40010.IntoleranceCondition.drugIngredient.patient.identifiers">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ic.id in ( :recordIdentifiers )
      ]]>
    </query>     
    
    <query name="RDIIntoleranceConditionPharmacyRead40010.IntoleranceCondition.drugIngredient">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
      ]]>
    </query>
    
    <query name="RDIIntoleranceConditionPharmacyRead40010.IntoleranceCondition.drugIngredient.date">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ( (ic.observationTime.timestamp between :startDate and :endDate) or (ic.observationTime.timestamp is null)  )
      ]]>
    </query>
    
    <query name="RDIIntoleranceConditionPharmacyRead40010.IntoleranceCondition.drugIngredient.identifiers">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ic.id in ( :recordIdentifiers )
      ]]>
    </query>    

    <query name="RDIIntoleranceConditionPharmacyRead40011.IntoleranceCondition.drugIngredient.patient">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
      ]]>
    </query>
    
    <query name="RDIIntoleranceConditionPharmacyRead40011.IntoleranceCondition.drugIngredient.patient.date">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ( (ic.observationTime.timestamp between :startDate and :endDate) or (ic.observationTime.timestamp is null)  )
      ]]>
    </query>
    
    <query name="RDIIntoleranceConditionPharmacyRead40011.IntoleranceCondition.drugIngredient.patient.identifiers">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ic.id in ( :recordIdentifiers )
      ]]>
    </query>     
    
    <query name="RDIIntoleranceConditionPharmacyRead40011.IntoleranceCondition.drugIngredient">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
      ]]>
    </query>
    
    <query name="RDIIntoleranceConditionPharmacyRead40011.IntoleranceCondition.drugIngredient.date">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ( (ic.observationTime.timestamp between :startDate and :endDate) or (ic.observationTime.timestamp is null)  )
      ]]>
    </query>
    
    <query name="RDIIntoleranceConditionPharmacyRead40011.IntoleranceCondition.drugIngredient.identifiers">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ic.id in ( :recordIdentifiers )
      ]]>
    </query>   
    <query name="RDIIntoleranceConditionPharmacyRead40012.IntoleranceCondition.drugIngredient.patient">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
      ]]>
    </query>
    
    <query name="RDIIntoleranceConditionPharmacyRead40012.IntoleranceCondition.drugIngredient.patient.date">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ( (ic.observationTime.timestamp between :startDate and :endDate) or (ic.observationTime.timestamp is null)  )
      ]]>
    </query>
    
    <query name="RDIIntoleranceConditionPharmacyRead40012.IntoleranceCondition.drugIngredient.patient.identifiers">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ic.id in ( :recordIdentifiers )
      ]]>
    </query>     
    
    <query name="RDIIntoleranceConditionPharmacyRead40012.IntoleranceCondition.drugIngredient">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
      ]]>
    </query>
    
    <query name="RDIIntoleranceConditionPharmacyRead40012.IntoleranceCondition.drugIngredient.date">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ( (ic.observationTime.timestamp between :startDate and :endDate) or (ic.observationTime.timestamp is null)  )
      ]]>
    </query>
    
    <query name="RDIIntoleranceConditionPharmacyRead40012.IntoleranceCondition.drugIngredient.identifiers">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ic.id in ( :recordIdentifiers )
      ]]>
    </query>
    
     <query name="RDIAllergiesPharmacyRead40013.IntoleranceCondition.drugIngredient.patient">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
      ]]>
    </query>
    
    <query name="RDIAllergiesPharmacyRead40013.IntoleranceCondition.drugIngredient.patient.date">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ( (ic.observationTime.timestamp between :startDate and :endDate) or (ic.observationTime.timestamp is null)  )
      ]]>
    </query>
    
    <query name="RDIAllergiesPharmacyRead40013.IntoleranceCondition.drugIngredient.patient.identifiers">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ic.id in ( :recordIdentifiers )
      ]]>
    </query>     
    
    <query name="RDIAllergiesPharmacyRead40013.IntoleranceCondition.drugIngredient">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
      ]]>
    </query>
    
    <query name="RDIAllergiesPharmacyRead40013.IntoleranceCondition.drugIngredient.date">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ( (ic.observationTime.timestamp between :startDate and :endDate) or (ic.observationTime.timestamp is null)  )
      ]]>
    </query>
    
    <query name="RDIAllergiesPharmacyRead40013.IntoleranceCondition.drugIngredient.identifiers">
     <![CDATA[
        select di
        from drugIngredient_multiquery di, intoleranceConditions ic
        where ic.id = di.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ic.id in ( :recordIdentifiers )
      ]]>
    </query>                             
</hibernate-mapping>
