<?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="commentEvents40010" table="VISTA_HDSI.PAT_ALLEX_COMMENTS_120_826_EXT" lazy="false" name="gov.va.med.cds.template.generated.allergies.AllergyCommentEvent">
         <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="date" formula="STRING(DATETIME_COMMENT_ENTERED,'^',(VISTA_HDSI.HDSREPSQLUtil1_StationNumber()))"  type="gov.va.med.cds.persistence.hibernate.common.VistaPointInTimeUserType" insert="false" update="false"  />
  
         <component name="author" class="gov.va.med.cds.template.generated.common.PractitionerLite">
            <property name="identifier" formula="AuthorNE||'^'||(VISTA_HDSI.HDSREPSQLUtil1_StationNumber())" type="gov.va.med.cds.persistence.hibernate.common.VistaPersonIdentifierUserType" insert="false" update="false" />
            <property name="name" column="AuthorNE" type="gov.va.med.cds.persistence.hibernate.common.VistaPersonNameUserType" insert="false" update="false"  />
        </component>
        
        <component name="commentType" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
          <property name="code" column="CommentTypeVuid" type="java.lang.String" insert="false" update="false"  />
          <property name="displayText" column="CommentTypeText" type="java.lang.String" insert="false" update="false"  />
          <property name="codingSystem" type="java.lang.String" >
        		<formula>
        			(CASE
				   	 	WHEN (CommentTypeVuid IS NOT NULL OR CommentTypeText IS NOT NULL) THEN '99VA8985.1'
				    	ELSE NULL
				 	END)
        		</formula>
          </property>
        </component>

         <property name="comments" column="COMMENTSMWP" type="gov.va.med.cds.persistence.hibernate.common.VistaCommentsUserType" insert="false" update="false" />
    </class>
       
    <class entity-name="mhvCommentEvents" table="VISTA_HDSI.PAT_ALLEX_COMMENTS_120_826_EXT" lazy="false" name="gov.va.med.cds.template.generated.allergies.AllergyCommentEvent">
        
        <id name="id" type="gov.va.med.cds.persistence.hibernate.common.VistaStringRowIdUserType">
            <column name="ROWID" />
            <generator class="assigned" />
        </id>
   
        <property name="date" formula="STRING(DATETIME_COMMENT_ENTERED,'^',(VISTA_HDSI.HDSREPSQLUtil1_StationNumber()))"  type="gov.va.med.cds.persistence.hibernate.common.VistaPointInTimeUserType" insert="false" update="false"  />
 
         <property name="comments" column="COMMENTSMWP" type="gov.va.med.cds.persistence.hibernate.common.VistaCommentsUserType" insert="false" update="false" />
    </class>
    
    <class entity-name="commentEvents_multiquery" table="VISTA_HDSI.PAT_ALLEX_COMMENTS_120_826_EXT" lazy="false" name="gov.va.med.cds.template.generated.allergies.subquery.AllergyCommentEventWrapper">
        
        <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="date" formula="STRING(DATETIME_COMMENT_ENTERED,'^',(VISTA_HDSI.HDSREPSQLUtil1_StationNumber()))"  type="gov.va.med.cds.persistence.hibernate.common.VistaPointInTimeUserType" insert="false" update="false"  />
 
       <component name="author" class="gov.va.med.cds.template.generated.common.PractitionerLite">
            <property name="identifier" formula="AuthorNE||'^'||(VISTA_HDSI.HDSREPSQLUtil1_StationNumber())" type="gov.va.med.cds.persistence.hibernate.common.VistaPersonIdentifierUserType" insert="false" update="false" />
            <property name="name" column="AuthorNE" type="gov.va.med.cds.persistence.hibernate.common.VistaPersonNameUserType" insert="false" update="false"  />
        </component>
        
        <component name="commentType" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
          <property name="code" column="CommentTypeVuid" type="java.lang.String" insert="false" update="false"  />
          <property name="displayText" column="CommentTypeText" type="java.lang.String" insert="false" update="false"  />
          <property name="codingSystem" type="java.lang.String" >
                <formula>
                    (CASE
                        WHEN (CommentTypeVuid IS NOT NULL OR CommentTypeText IS NOT NULL) THEN '99VA8985.1'
                        ELSE NULL
                    END)
                </formula>
          </property>
        </component>

         <property name="comments" column="COMMENTSMWP" type="gov.va.med.cds.persistence.hibernate.common.VistaCommentsUserType" insert="false" update="false" />
    </class>
    
    
    <class entity-name="mhvCommentEvents_multiquery" table="VISTA_HDSI.PAT_ALLEX_COMMENTS_120_826_EXT" lazy="false" name="gov.va.med.cds.template.generated.allergies.subquery.AllergyCommentEventWrapper">
        
        <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="date" formula="STRING(DATETIME_COMMENT_ENTERED,'^',(VISTA_HDSI.HDSREPSQLUtil1_StationNumber()))"  type="gov.va.med.cds.persistence.hibernate.common.VistaPointInTimeUserType" insert="false" update="false"  />

       <property name="comments" column="COMMENTSMWP" type="gov.va.med.cds.persistence.hibernate.common.VistaCommentsUserType" insert="false" update="false" />
    </class>
    
    
    <query name="IntoleranceConditionRead40010.IntoleranceCondition.commentEvents">
     <![CDATA[
        select cm
        from commentEvents_multiquery cm, intoleranceConditions ic
        where ic.id = cm.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
      ]]>
    </query>
    
     <query name="IntoleranceConditionRead40010.IntoleranceCondition.commentEvents.date">
     <![CDATA[
        select cm
        from commentEvents_multiquery cm, intoleranceConditions ic
        where ic.id = cm.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.commentEvents.identifiers">
     <![CDATA[
        select cm
        from commentEvents_multiquery cm, intoleranceConditions ic
        where ic.id = cm.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ic.id in ( :recordIdentifiers )
      ]]>
    </query>
    
     <query name="VWIntoleranceConditionRead40010.IntoleranceCondition.commentEvents">
     <![CDATA[
        select cm
        from commentEvents_multiquery cm, intoleranceConditions ic
        where ic.id = cm.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
      ]]>
    </query>
    
     <query name="VWIntoleranceConditionRead40010.IntoleranceCondition.commentEvents.date">
     <![CDATA[
        select cm
        from commentEvents_multiquery cm, intoleranceConditions ic
        where ic.id = cm.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.commentEvents.identifiers">
     <![CDATA[
        select cm
        from commentEvents_multiquery cm, intoleranceConditions ic
        where ic.id = cm.patientAllergies
        and ic.patient.identifier.identity in ( :pids )
        and ic.id in ( :recordIdentifiers )
      ]]>
    </query>

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

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