<?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="reaction40010" lazy="false" table="VISTA_HDSI.PAT_ALLEX_REACTIONS_120_81_EXT"  name="gov.va.med.cds.template.generated.allergies.ReactionObservationEvent">        
       <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" />
               
        <property name="observationTime" formula="STRING(DATE_ENTERED,'^',(VISTA_HDSI.HDSREPSQLUtil1_StationNumber()))"  type="gov.va.med.cds.persistence.hibernate.common.VistaPointInTimeUserType" insert="false" update="false"  />

        <component name="reaction" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
            <property name="code" column="ReactionVuid" type="java.lang.String" />
	        <property name="displayText" column="REACTIONX" type="java.lang.String"  />
            <property name="codingSystem" type="java.lang.String" >
        		<formula>
        		(CASE
				    WHEN (ReactionVuid IS NOT NULL OR REACTIONX IS NOT NULL) THEN '99VA120.83'
				    ELSE NULL
				 END)
        		</formula>
        	</property>
        </component>

        <component name="author" class="gov.va.med.cds.template.generated.common.PractitionerParticipationLite">
          	<property name="comment"  column="ReactionAuthorComment" type="java.lang.String" />
       
       		<component name="practitioner" class="gov.va.med.cds.template.generated.common.PractitionerLite">
            	<property name="identifier" formula="ReactionAuthorNE||'^'||(VISTA_HDSI.HDSREPSQLUtil1_StationNumber())" type="gov.va.med.cds.persistence.hibernate.common.VistaPersonIdentifierUserType" insert="false" update="false"/>
            	<property name="name"  column="ReactionAuthorNE" type="gov.va.med.cds.persistence.hibernate.common.VistaPersonNameUserType" insert="false" update="false"/>
        	</component>
         </component>
    </class>
    
    <class entity-name="rdiReaction" lazy="false" table="VISTA_HDSI.PAT_ALLEX_REACTIONS_120_81_EXT" name="gov.va.med.cds.template.generated.allergies.ReactionObservationEvent">
        
        <id name="id" type="gov.va.med.cds.persistence.hibernate.common.VistaStringRowIdUserType">
            <column name="ROWID" />
            <generator class="assigned" />
        </id>
   
        <component name="reaction" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
            <property name="code" column="ReactionVuid" type="java.lang.String"  />
            <property name="displayText" column="REACTIONX" type="java.lang.String"  />
            <property name="codingSystem" type="java.lang.String" >
                <formula>
                (CASE
                    WHEN (ReactionVuid IS NOT NULL OR REACTIONX IS NOT NULL) THEN '99VA120.83'
                    ELSE NULL
                 END)
                </formula>
            </property>
        </component>
        
        <property name="observationTime" formula="STRING(DATE_ENTERED,'^',(VISTA_HDSI.HDSREPSQLUtil1_StationNumber()))"  type="gov.va.med.cds.persistence.hibernate.common.VistaPointInTimeUserType" insert="false" update="false"  />
           
    </class>

    <class entity-name="mhvReaction" lazy="false" table="VISTA_HDSI.PAT_ALLEX_REACTIONS_120_81_EXT" name="gov.va.med.cds.template.generated.allergies.ReactionObservationEvent">
        
        <id name="id" type="gov.va.med.cds.persistence.hibernate.common.VistaStringRowIdUserType">
            <column name="ROWID" />
            <generator class="assigned" />
        </id>

        <component name="reaction" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
            <property name="code" column="ReactionVuid" type="java.lang.String"  />
            <property name="displayText" column="REACTIONX" type="java.lang.String" />
            <property name="codingSystem" type="java.lang.String" >
        		<formula>
        		(CASE
				    WHEN (ReactionVuid IS NOT NULL OR REACTIONX IS NOT NULL) THEN '99VA120.83'
				    ELSE NULL
				 END)
        		</formula>
        	</property>
        </component>
    </class>
    
    <class entity-name="reaction_multiquery" lazy="false" table="VISTA_HDSI.PAT_ALLEX_REACTIONS_120_81_EXT" name="gov.va.med.cds.template.generated.allergies.subquery.ReactionObservationEventWrapper">
        
        <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" />
        
        <property name="observationTime" formula="STRING(DATE_ENTERED,'^',(VISTA_HDSI.HDSREPSQLUtil1_StationNumber()))"  type="gov.va.med.cds.persistence.hibernate.common.VistaPointInTimeUserType" insert="false" update="false"  />
 
       <component name="reaction" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
            <property name="code" column="ReactionVuid" type="java.lang.String" />
	        <property name="displayText" column="REACTIONX" type="java.lang.String"  />
            <property name="codingSystem" type="java.lang.String" >
        		<formula>
        		(CASE
				    WHEN (ReactionVuid IS NOT NULL OR REACTIONX IS NOT NULL) THEN '99VA120.83'
				    ELSE NULL
				 END)
        		</formula>
        	</property>
        </component>

        <component name="author" class="gov.va.med.cds.template.generated.common.PractitionerParticipationLite">
          	<property name="comment"  column="ReactionAuthorComment" type="java.lang.String" />
       
       		<component name="practitioner" class="gov.va.med.cds.template.generated.common.PractitionerLite">
            	<property name="identifier" formula="ReactionAuthorNE||'^'||(VISTA_HDSI.HDSREPSQLUtil1_StationNumber())" type="gov.va.med.cds.persistence.hibernate.common.VistaPersonIdentifierUserType" insert="false" update="false"/>
            	<property name="name"  column="ReactionAuthorNE" type="gov.va.med.cds.persistence.hibernate.common.VistaPersonNameUserType" insert="false" update="false"/>
        	</component>
         </component>

    </class>
    
    
    <class entity-name="mhvReaction_multiquery" lazy="false" table="VISTA_HDSI.PAT_ALLEX_REACTIONS_120_81_EXT" name="gov.va.med.cds.template.generated.allergies.subquery.ReactionObservationEventWrapper">
        
        <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="reaction" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
            <property name="code" column="ReactionVuid" type="java.lang.String"  />
            <property name="displayText" column="REACTIONX" type="java.lang.String" />
            <property name="codingSystem" type="java.lang.String" >
        		<formula>
        		(CASE
				    WHEN (ReactionVuid IS NOT NULL OR REACTIONX IS NOT NULL) THEN '99VA120.83'
				    ELSE NULL
				 END)
        		</formula>
        	</property>
        </component>
    </class>
    
    
    <query name="IntoleranceConditionRead40010.IntoleranceCondition.reaction">
     <![CDATA[
        select r
        from reaction_multiquery r, intoleranceConditions ic
        where ic.id = r.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
      ]]>
    </query>
    
     <query name="IntoleranceConditionRead40010.IntoleranceCondition.reaction.date">
     <![CDATA[
        select r
        from reaction_multiquery r, intoleranceConditions ic
        where ic.id = r.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.reaction.identifiers">
     <![CDATA[
        select r
        from reaction_multiquery r, intoleranceConditions ic
        where ic.id = r.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ic.id in ( :recordIdentifiers )
      ]]>
    </query>
    
    
     <query name="MHVIntoleranceConditionRead40011.IntoleranceCondition.reaction">
     <![CDATA[
        select r
        from mhvReaction_multiquery r, intoleranceConditions ic
        where ic.id = r.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
      ]]>
    </query>
    
     <query name="MHVIntoleranceConditionRead40011.IntoleranceCondition.reaction.date">
     <![CDATA[
        select r
        from mhvReaction_multiquery r, intoleranceConditions ic
        where ic.id = r.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.reaction.identifiers">
     <![CDATA[
        select r
        from mhvReaction_multiquery r, intoleranceConditions ic
        where ic.id = r.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ic.id in ( :recordIdentifiers )
      ]]>
    </query>
    
    
    <query name="VWIntoleranceConditionRead40010.IntoleranceCondition.reaction">
     <![CDATA[
        select r
        from reaction_multiquery r, intoleranceConditions ic
        where ic.id = r.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
      ]]>
    </query>
    
    <query name="VWIntoleranceConditionRead40010.IntoleranceCondition.reaction.date">
     <![CDATA[
        select r
        from reaction_multiquery r, intoleranceConditions ic
        where ic.id = r.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.reaction.identifiers">
     <![CDATA[
        select r
        from reaction_multiquery r, intoleranceConditions ic
        where ic.id = r.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ic.id in ( :recordIdentifiers )
      ]]>
    </query>
                                  
</hibernate-mapping>