<?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="drugClass40010" table="VISTA_HDSI.PAT_X_DRUG_CLASSES_120_803_EXT" lazy="false" name="gov.va.med.cds.template.generated.allergies.DrugClass">
        <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.HL72CodedElement">
          <property name="code" column="DrugClassVuid" type="java.lang.String" />
          <property name="displayText" column="DrugClassClassification" type="java.lang.String" insert="false" update="false"  />
          <property name="codingSystem" formula="'99VA50.605'" type="java.lang.String"/>
          <property name="alternateCode" column="DrugClassCode" type="java.lang.String" insert="false" update="false"  />
          <property name="alternateDisplayText" column="DrugClassClassification" type="java.lang.String" insert="false" update="false"  />
          <property name="alternateCodingSystem" type="java.lang.String" >
        		<formula>
        			(CASE
				   	 	WHEN (DrugClassCode IS NOT NULL OR DrugClassClassification IS NOT NULL) THEN DefaultInstitution||'_50.605'
				    	ELSE NULL
				 	END)
        		</formula>
          </property>
        </component>

    </class>
    
    <class entity-name="rdiDrugClass" table="VISTA_HDSI.PAT_X_DRUG_CLASSES_120_803_EXT" lazy="false" name="gov.va.med.cds.template.generated.allergies.DrugClass">
        
        <id name="id" type="gov.va.med.cds.persistence.hibernate.common.VistaStringRowIdUserType">
            <column name="ROWID" />
            <generator class="assigned" />
        </id>
   
        <component name="code" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElement">
          <property name="code" column="DrugClassVuid" type="java.lang.String"  />
          <property name="displayText" column="DrugClassClassification" type="java.lang.String" insert="false" update="false"  />
          <property name="codingSystem" formula="'99VA50.605'" type="java.lang.String" />
          <property name="alternateCode" column="DrugClassCode" type="java.lang.String" insert="false" update="false"  />
          <property name="alternateCodingSystem" type="java.lang.String" >
                <formula>
                    (CASE
                        WHEN (DrugClassCode IS NOT NULL OR DrugClassClassification IS NOT NULL) THEN DefaultInstitution||'_50.605'
                        ELSE NULL
                    END)
                </formula>
          </property>
        </component>

    </class>
    
    <class entity-name="drugClass_multiquery" table="VISTA_HDSI.PAT_X_DRUG_CLASSES_120_803_EXT" lazy="false" name="gov.va.med.cds.template.generated.allergies.subquery.DrugClassWrapper">
        
        <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.HL72CodedElement">
          <property name="code" column="DrugClassVuid" type="java.lang.String" />
          <property name="displayText" column="DrugClassClassification" type="java.lang.String" insert="false" update="false"  />
          <property name="codingSystem" formula="'99VA50.605'" type="java.lang.String"  />
          <property name="alternateCode" column="DrugClassCode" type="java.lang.String" insert="false" update="false"/>
          <property name="alternateCodingSystem" type="java.lang.String" >
                <formula>
                    (CASE
                        WHEN (DrugClassCode IS NOT NULL OR DrugClassClassification IS NOT NULL) THEN DefaultInstitution||'_50.605'
                        ELSE NULL
                    END)
                </formula>
          </property>
        </component>

    </class>    
        
     <query name="IntoleranceConditionRead40010.IntoleranceCondition.drugClass">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
      ]]>
    </query>
    
     <query name="IntoleranceConditionRead40010.IntoleranceCondition.drugClass.date">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.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.drugClass.identifiers">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ic.id in ( :recordIdentifiers )
      ]]>
    </query>
    
     <query name="VWIntoleranceConditionRead40010.IntoleranceCondition.drugClass">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
      ]]>
    </query>
    
     <query name="VWIntoleranceConditionRead40010.IntoleranceCondition.drugClass.date">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.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.drugClass.identifiers">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ic.id in ( :recordIdentifiers )
      ]]>
    </query>
 
     <query name="MHVIntoleranceConditionRead40011.IntoleranceCondition.drugClass">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
      ]]>
    </query>
    
     <query name="MHVIntoleranceConditionRead40011.IntoleranceCondition.drugClass.date">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.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="MHVIntoleranceConditionRead40011.IntoleranceCondition.drugClass.identifiers">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ic.id in ( :recordIdentifiers )
      ]]>
    </query>

    <query name="RDIIntoleranceConditionPharmacyRead40010.IntoleranceCondition.drugClass.patient">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
      ]]>
    </query>
    
     <query name="RDIIntoleranceConditionPharmacyRead40010.IntoleranceCondition.drugClass.patient.date">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.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.drugClass.patient.identifiers">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ic.id in ( :recordIdentifiers )
      ]]>
    </query> 
    
    <query name="RDIIntoleranceConditionPharmacyRead40010.IntoleranceCondition.drugClass">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
      ]]>
    </query>
    
     <query name="RDIIntoleranceConditionPharmacyRead40010.IntoleranceCondition.drugClass.date">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.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.drugClass.identifiers">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ic.id in ( :recordIdentifiers )
      ]]>
    </query>    
    
    <query name="RDIIntoleranceConditionPharmacyRead40011.IntoleranceCondition.drugClass.patient">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
      ]]>
    </query>
    
     <query name="RDIIntoleranceConditionPharmacyRead40011.IntoleranceCondition.drugClass.patient.date">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.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.drugClass.patient.identifiers">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ic.id in ( :recordIdentifiers )
      ]]>
    </query> 
    
    <query name="RDIIntoleranceConditionPharmacyRead40011.IntoleranceCondition.drugClass">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
      ]]>
    </query>
    
     <query name="RDIIntoleranceConditionPharmacyRead40011.IntoleranceCondition.drugClass.date">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.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.drugClass.identifiers">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ic.id in ( :recordIdentifiers )
      ]]>
    </query> 
    <query name="RDIIntoleranceConditionPharmacyRead40012.IntoleranceCondition.drugClass.patient">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
      ]]>
    </query>
    
     <query name="RDIIntoleranceConditionPharmacyRead40012.IntoleranceCondition.drugClass.patient.date">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.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.drugClass.patient.identifiers">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ic.id in ( :recordIdentifiers )
      ]]>
    </query> 
    
    <query name="RDIIntoleranceConditionPharmacyRead40012.IntoleranceCondition.drugClass">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
      ]]>
    </query>
    
     <query name="RDIIntoleranceConditionPharmacyRead40012.IntoleranceCondition.drugClass.date">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.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.drugClass.identifiers">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ic.id in ( :recordIdentifiers )
      ]]>
    </query>              
<query name="RDIAllergiesPharmacyRead40013.IntoleranceCondition.drugClass.patient">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
      ]]>
    </query>
    
     <query name="RDIAllergiesPharmacyRead40013.IntoleranceCondition.drugClass.patient.date">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.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.drugClass.patient.identifiers">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ic.id in ( :recordIdentifiers )
      ]]>
    </query> 
    
    <query name="RDIAllergiesPharmacyRead40013.IntoleranceCondition.drugClass">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
      ]]>
    </query>
    
     <query name="RDIAllergiesPharmacyRead40013.IntoleranceCondition.drugClass.date">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.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.drugClass.identifiers">
     <![CDATA[
        select dc
        from drugClass_multiquery dc, intoleranceConditions ic
        where ic.id = dc.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ic.id in ( :recordIdentifiers )
      ]]>
    </query>                                        
</hibernate-mapping>
