<?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 author SYSTEM 			"classpath://gov/va/med/cds/persistence/hibernate/common/AuthorPractitionerParticipationPojo.hbm">
]
>

<hibernate-mapping default-cascade="all">
    <class entity-name="vwallergiesRead40010" name="gov.va.med.cds.template.generated.allergies.AllergyAssessment" table="ALLERGY_ASSESSMENT30_V" lazy="false"  >
        <id name="id" type="java.lang.Long">
            <column name="ALLERGY_ASSESSMENT_ID" />
            <generator class="sequence" >
				<param name="sequence">allergy_assessment_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>

		<component name="patient" class="gov.va.med.cds.template.generated.common.PatientLite">
			<component name="identifier" class="gov.va.med.cds.template.generated.basedatatypes.HL72PersonIdentifier">
				<property name="identity" column="PATIENT_IDENTITY" type="java.lang.String" not-null="true" />
				<property name="assigningFacility" column="PATIENT_ASSIGNING_FACILITY" type="java.lang.String" not-null="true" />
				<property name="assigningAuthority" column="PATIENT_ASSIGNING_AUTHORITY" type="java.lang.String" />
			</component>
	
			<component name="name" class="gov.va.med.cds.template.generated.basedatatypes.HL72PersonName">
				<property name="prefix" column="PATIENT_NAME_PREFIX" type="java.lang.String" />
				<property name="given" column="PATIENT_NAME_GIVEN" type="java.lang.String" />
				<property name="middle" column="PATIENT_NAME_MIDDLE" type="java.lang.String" />
				<property name="family" column="PATIENT_NAME_FAMILY" type="java.lang.String" />
				<property name="suffix" column="PATIENT_NAME_SUFFIX" type="java.lang.String" />
				<property name="title" column="PATIENT_NAME_TITLE" type="java.lang.String" />
			</component>
		</component>

       <property name="observationTime" type="gov.va.med.cds.persistence.hibernate.common.PointInTimeUserType" >
             <column name="ALGYASMT_OBSERVATION_TM"/>
            <column name="ALGYASMT_OBSERVATION_TM_NBR"/>
        </property>
        
         <component name="assessmentValue"  class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
			<property name="code" column="ASSESSMENT_VAL_CODE" type="java.lang.String"/>
			<property name="displayText" column="ASSESSMENT_VAL_DSPLYTXT" type="java.lang.String" />
			<property name="codingSystem" column="ASSESSMENT_VAL_CODSYS" type="java.lang.String" />
		</component>

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

        <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="VWAllergiesRead40010.AllergyAssessment.patient">
		<![CDATA[
		from vwallergiesRead40010 aa
		where aa.patient.identifier.assigningFacility || '/' || aa.patient.identifier.identity in ( :pids )
      ]]>
	</query>

	<query name="VWAllergiesRead40010.AllergyAssessment.patient.date">
		<![CDATA[
		from vwallergiesRead40010 aa
		where aa.patient.identifier.assigningFacility || '/' || aa.patient.identifier.identity in ( :pids )
		and ( aa.observationTime.numeric between :startDate and :endDate or aa.observationTime.numeric is null )
      ]]>
	</query>

    <query name="VWAllergiesRead40010.AllergyAssessment.patient.identifiers">
		<![CDATA[
		from vwallergiesRead40010 aa
		where aa.patient.identifier.assigningFacility || '/' || aa.patient.identifier.identity in ( :pids ) and
		aa.recordIdentifier.identity || '/' || aa.recordIdentifier.namespaceId || '/' ||
		aa.recordIdentifier.universalId || '/' || aa.recordIdentifier.universalIdType in ( :recordIdentifiers )
      ]]>
	</query>

</hibernate-mapping>
