<?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="detectedIssueEvent" lazy="false" table="VISTA_HDSI.PHARM_X_ORDER_CHCKS_55_051_EXT" name="gov.va.med.cds.template.generated.pharmacy.NonVaMedicationEvent$DetectedIssueEvents"> 
		
		<composite-id name="nvmId" class="gov.va.med.cds.persistence.hibernate.common.VistaNonVAMedsCompositeRowIdUserType">
			<key-property name="SUB_NONVA_MEDS" type="java.lang.String" />
			<key-property name="CHILDSUB2" type="big_decimal" />
		</composite-id>
	
		<property name="subNonVaMeds" column="SUB_NONVA_MEDS" type="java.lang.String" insert="false" update="false"/>
	
		<component name="singleDetectedIssueEvent" class="gov.va.med.cds.template.generated.pharmacy.DetectedIssueEvent">
			<component name="id" class="gov.va.med.cds.template.generated.basedatatypes.HL72EntityIdentifier">
				<property name="identity" column="ROWID" type="java.lang.String" insert="false" update="false"/>
				<property name="namespaceId" formula="VISTA_HDSI.HDSREPSQLUtil1_StationNumber()||'_55.051'" type="java.lang.String"/>
			</component>
			<property name="narrativeText" column="ORDER_CHECK_NARRATIVE" type="java.lang.String" />
			<component name="overridingProvider" class="gov.va.med.cds.template.generated.common.PractitionerParticipationLite" >
				<component name="practitioner" class="gov.va.med.cds.template.generated.common.PractitionerLite">
					<component name="identifier" class="gov.va.med.cds.template.generated.basedatatypes.HL72PersonIdentifier" >
						<property name="identity" column="OVERRIDING_PROVIDER" type="gov.va.med.cds.persistence.hibernate.common.VistaIdentityUserType" insert="false" update="false"/>
						<property name="assigningFacility" formula="VISTA_HDSI.HDSREPSQLUtil1_StationNumber()" type="java.lang.String" insert="false" update="false"  />
						<property name="assigningAuthority" formula="'USVHA'" type="java.lang.String"/>
					</component>
					<property name="idSourceTable" formula="'VistA200'" type="java.lang.String"/>
					<property name="name" column="OverridingProviderNE" type="gov.va.med.cds.persistence.hibernate.common.VistaPersonNameUserType" insert="false" update="false"/>
				</component>		
			</component>
			<component name="detectedIssuesManagement" class="gov.va.med.cds.template.generated.pharmacy.DetectedIssueEvent$DetectedIssuesManagement">
				<component name="singleDetectedIssueManagement" class="gov.va.med.cds.template.generated.pharmacy.DetectedIssueManagement">
					<property name="overrideReason" type="java.lang.String">
						<formula>
							(CASE
								WHEN (CONVERT(VARCHAR(256), OVERRIDINGREASON1WP) IS NOT NULL) THEN OVERRIDINGREASON1WP
							END)
						</formula>
					</property>
				</component>
			</component>
		</component>
    </class>
    
    <!-- Association detectedIssueEvents Queries -->
    <query name="NonVAMedicationsRead2.NonVaMedicationEvent.detectedIssueEvents">
        <![CDATA[
         select die
         from detectedIssueEvent die, NonVAMedicationsRead2 as nme
         where nme.nvmId = die.subNonVaMeds
            and nme.pharmacyPatient.identifier.identity in ( :pids )
      ]]>
    </query>
    
    
    <query name="NonVAMedicationsRead2.NonVaMedicationEvent.detectedIssueEvents.status">
        <![CDATA[
         select die
         from detectedIssueEvent die, NonVAMedicationsRead2 as nme
         where nme.nvmId = die.subNonVaMeds
            and nme.pharmacyPatient.identifier.identity in ( :pids )
            and nme.StatusQuery in ( :status )
      ]]>
    </query>
    
    
    <query name="NonVAMedicationsRead2.NonVaMedicationEvent.detectedIssueEvents.identifiers">
        <![CDATA[
         select die
         from detectedIssueEvent die, NonVAMedicationsRead2 as nme
         where nme.nvmId = die.subNonVaMeds
            and nme.pharmacyPatient.identifier.identity in ( :pids )
            and nme.nvmId in ( :recordIdentifiers )
      ]]>
    </query>
</hibernate-mapping>