<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:aop="http://www.springframework.org/schema/aop" xmlns="http://www.springframework.org/schema/beans" xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
	xsi:schemaLocation="
		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

	<bean id="hdr2Readable" class="gov.va.med.cds.persistence.hibernate.DefaultHibernateReadPersistenceManager">
		<property name="managerIdentifier" value="HDRII-R" />
		<property name="sessionFactoryMap" ref="hdr2ReadableSessionFactoryMap" />
		<property name="queryThreadWorkManager" ref="queryThreadWorkManager" />
		<property name="pointInTimeUserType" value="gov.va.med.cds.persistence.hibernate.common.PointInTimeUserType" />
		<property name="templateTimeoutMap" ref="templateTimeoutMap" />
		<property name="hdrExcludedTemplateIdsList" ref="hdrExcludedClientTemplateIdsList" />
		<property name="defaultCDSResponse" ref="clinicalDataResponse400" />
		<property name="rules">
			<list>
				<bean class="gov.va.med.cds.rules.DomainEntryPointRule">
					<property name="entryPoint" value="IntoleranceCondition" />
				</bean>
				<bean class="gov.va.med.cds.rules.DomainEntryPointRule">
					<property name="entryPoint" value="AllergyAssessment" />
				</bean>
				<bean class="gov.va.med.cds.rules.DomainEntryPointRule">
					<property name="entryPoint" value="VitalSignObservationEvent" />
				</bean>
				<bean class="gov.va.med.cds.rules.DomainEntryPointRule">
					<property name="entryPoint" value="OutpatientMedicationPromise" />
				</bean>
				<bean class="gov.va.med.cds.rules.DomainEntryPointRule">
					<property name="entryPoint" value="LabTestPromise" />
				</bean>
				<bean class="gov.va.med.cds.rules.DomainEntryPointRule">
					<property name="entryPoint" value="PatientGeneratedDataEvent" />
				</bean>
			</list>
		</property>
		<property name="templateQueryStrategyMap" ref="hdr2TemplateQueryStrategyMap" />
		<property name="marshallerUnmarshaller" ref="marshallerUnmarshaller"/>
	</bean>
	
	<util:list id="hdrExcludedClientTemplateIdsList">
		<value>VWAllergiesRead40010-AllergyAssessment</value>
		<value>AllergiesRead40010-AllergyAssessment</value>
	</util:list>

	<bean id="hdr2Writeable" class="gov.va.med.cds.persistence.hibernate.WriteableHibernatePersistenceManager">
		<property name="managerIdentifier" value="HDRII-W" />
		<property name="sessionFactoryMap" ref="hdr2WritableSessionFactoryMap" />
		<property name="rules">
			<list>
				<bean class="gov.va.med.cds.rules.DomainEntryPointRule">
					<property name="entryPoint" value="IntoleranceCondition" />
				</bean>
				<bean class="gov.va.med.cds.rules.DomainEntryPointRule">
					<property name="entryPoint" value="AllergyAssessment" />
				</bean>
				<bean class="gov.va.med.cds.rules.DomainEntryPointRule">
					<property name="entryPoint" value="VitalSignObservationEvent" />
				</bean>
				<bean class="gov.va.med.cds.rules.DomainEntryPointRule">
					<property name="entryPoint" value="OutpatientMedicationPromise" />
				</bean>
				<bean class="gov.va.med.cds.rules.DomainEntryPointRule">
					<property name="entryPoint" value="LabTestPromise" />
				</bean>
				<bean class="gov.va.med.cds.rules.DomainEntryPointRule">
					<property name="entryPoint" value="PatientGeneratedDataEvent" />
				</bean>
			</list>
		</property>
		<property name="cdsAppName" ref="cdsAppName" />
		<property name="logicalDeleteTemplateIdsMap" ref="logicalDeleteTemplateIdsMap" />
		<property name="marshallerUnmarshaller" ref="marshallerUnmarshaller"/>
	</bean>

	<bean id="hdr2SurveyWriteable" class="gov.va.med.cds.persistence.hibernate.WriteableSurveyPersistenceManager">
		<property name="managerIdentifier" value="HDRII-SW" />
		<property name="sessionFactoryMap" ref="hdr2WritableSessionFactoryMap" />
		<property name="rules">
			<list>
				<bean class="gov.va.med.cds.rules.DomainEntryPointRule">
					<property name="entryPoint" value="PSSurveyResponse" />
				</bean>
				<bean class="gov.va.med.cds.rules.DomainEntryPointRule">
					<property name="entryPoint" value="ADLSurveyResponse" />
				</bean>
			</list>
		</property>
		<property name="marshallerUnmarshaller" ref="marshallerUnmarshaller"/>
	</bean>

	<bean id="hdr2DMPSurveyWriteable" class="gov.va.med.cds.persistence.hibernate.WriteableDMPSurveyPersistenceManager">
		<property name="managerIdentifier" value="HDRII-DW" />
		<property name="sessionFactoryMap" ref="hdr2WritableSessionFactoryMap" />
		<property name="rules">
			<list>
				<bean class="gov.va.med.cds.rules.DomainEntryPointRule">
					<property name="entryPoint" value="DMPSurveyResponse" />
				</bean>
			</list>
		</property>
		<property name="marshallerUnmarshaller" ref="marshallerUnmarshaller"/>
	</bean>

	<bean id="hdr2CensusSurveyWriteable" class="gov.va.med.cds.persistence.hibernate.WriteableCensusSurveyPersistenceManager">
		<property name="managerIdentifier" value="HDRII-CW" />
		<property name="sessionFactoryMap" ref="hdr2WritableSessionFactoryMap" />
		<property name="rules">
			<list>
				<bean class="gov.va.med.cds.rules.DomainEntryPointRule">
					<property name="entryPoint" value="CensusSurveyResponse" />
				</bean>
			</list>
		</property>
		<property name="marshallerUnmarshaller" ref="marshallerUnmarshaller"/>
	</bean>

	<bean id="marshallerUnmarshaller" class="gov.va.med.cds.template.generated.JaxBMarshallerUnmarshaller" lazy-init="false"/>

	<util:map id="hdr2TemplateQueryStrategyMap">
		<entry key="AllergiesRead40010-IntoleranceCondition" value-ref="hdr2IntoleranceConditionQueryStrategy" />
		<entry key="AllergyAssessmentRead40010-AllergyAssessment" value-ref="hdr2AllergyAssessmentQueryStrategy" />
		<entry key="IntoleranceConditionRead40010-IntoleranceCondition" value-ref="hdr2IntoleranceConditionQueryStrategy" />
		<entry key="IntoleranceConditionReducedRead40011-IntoleranceCondition" value-ref="hdr2IntoleranceConditionQueryStrategy" />
		<entry key="VitalsignsRead40010-VitalSignObservationEvent" value-ref="hdr2VitalsignsQueryStrategy" />
		<entry key="MHVVitalsignsRead40010-VitalSignObservationEvent" value-ref="hdr2VitalsignsQueryStrategy" />
		<entry key="MHVLabRead40011-LabTestPromise" value-ref="hdr2MHVLabRead40011QueryStrategy" />
		<entry key="MHVIntoleranceConditionRead40011-IntoleranceCondition" value-ref="hdr2IntoleranceConditionQueryStrategy" />
		<entry key="VWAllergiesRead40010-IntoleranceCondition" value-ref="hdr2IntoleranceConditionQueryStrategy" />
		<entry key="VWIntoleranceConditionRead40010-IntoleranceCondition" value-ref="hdr2IntoleranceConditionQueryStrategy" />
		<entry key="VWVitalsignsRead40010-VitalSignObservationEvent" value-ref="hdr2VitalsignsQueryStrategy" />
		<entry key="OutpatientPharmacyRead1-OutpatientMedicationPromise" value-ref="hdr2OutpatientPharmacyQueryStrategy" />
		<entry key="VWOutpatientPharmacyRead1-OutpatientMedicationPromise" value-ref="hdr2OutpatientPharmacyQueryStrategy" />
		<entry key="VWOutpatientPharmacyDetailRead1-OutpatientMedicationPromise" value-ref="hdr2OutpatientPharmacyQueryStrategy" />
		<entry key="PharmacyRead40010-OutpatientMedicationPromise" value-ref="hdr2PharmacyQueryStrategy" />
		<entry key="VWPharmacyRead40010-OutpatientMedicationPromise" value-ref="hdr2PharmacyQueryStrategy" />
		<entry key="VWPharmacyDetailRead40010-OutpatientMedicationPromise" value-ref="hdr2PharmacyQueryStrategy" />
		<entry key="RDIIntoleranceConditionPharmacyRead40010-OutpatientMedicationPromise" value-ref="hdr2PharmacyQueryStrategy" />
		<entry key="RDIIntoleranceConditionPharmacyRead40010-IntoleranceCondition" value-ref="hdr2IntoleranceConditionQueryStrategy" />
		<entry key="RDIIntoleranceConditionPharmacyRead40011-OutpatientMedicationPromise" value-ref="hdr2PharmacyQueryStrategy" />
		<entry key="RDIIntoleranceConditionPharmacyRead40011-IntoleranceCondition" value-ref="hdr2IntoleranceConditionQueryStrategy" />
		<entry key="RDIIntoleranceConditionPharmacyRead40012-OutpatientMedicationPromise" value-ref="hdr2PharmacyQueryStrategy" />
		<entry key="RDIIntoleranceConditionPharmacyRead40012-IntoleranceCondition" value-ref="hdr2IntoleranceConditionQueryStrategy" />
		<entry key="RDIAllergiesPharmacyRead40013-OutpatientMedicationPromise" value-ref="hdr2PharmacyQueryStrategy" />
		<entry key="RDIAllergiesPharmacyRead40013-IntoleranceCondition" value-ref="hdr2IntoleranceConditionQueryStrategy" />
		<entry key="RDIAllergiesPharmacyRead40013-AllergyAssessment" value-ref="hdr2AllergyAssessmentQueryStrategy" />
		<entry key="PGDRead1-PatientGeneratedDataEvent" value-ref="hdr2PGDQueryStrategy" />
		
	</util:map>

	<util:map id="logicalDeleteTemplateIdsMap">
		<!--<entry key="HealthAdapterDelete1" value="recordStatus" /> -->
		<entry key="PGDDelete1" value="recordStatus" />
	</util:map>

	<bean id="legacyQueryNameBuilder" class="gov.va.med.cds.persistence.hibernate.LegacyQueryNameBuilder" />
	<bean id="legacyFilterParameterExtractor" class="gov.va.med.cds.persistence.hibernate.LegacyFilterParameterExtractor" />
	<bean id="defaultQueryParameterBinder" class="gov.va.med.cds.persistence.hibernate.DefaultQueryParameterBinder" />

	<util:map id="pointInTimeParameterTransformerMap">
		<entry key="startDate">
			<bean class="gov.va.med.cds.persistence.hibernate.PointInTimeQueryParameterTransformer" />
		</entry>
		<entry key="endDate">
			<bean class="gov.va.med.cds.persistence.hibernate.PointInTimeQueryParameterTransformer" />
		</entry>
		<entry key="anyDate">
			<bean class="gov.va.med.cds.persistence.hibernate.PointInTimeQueryParameterTransformer" />
		</entry>
	</util:map>
	
	<util:map id="pointInTimeParameterTransformerMapPojo">
		<entry key="startDate">
			<bean class="gov.va.med.cds.persistence.hibernate.PointInTimeQueryParameterTransformerPojo" />
		</entry>
		<entry key="endDate">
			<bean class="gov.va.med.cds.persistence.hibernate.PointInTimeQueryParameterTransformerPojo" />
		</entry>
		<entry key="anyDate">
			<bean class="gov.va.med.cds.persistence.hibernate.PointInTimeQueryParameterTransformerPojo" />
		</entry>
	</util:map>

	<util:map id="timestampParameterTransformerMap">
		<entry key="startDate">
			<bean class="gov.va.med.cds.persistence.hibernate.TimestampQueryParameterTransformer" />
		</entry>
		<entry key="endDate">
			<bean class="gov.va.med.cds.persistence.hibernate.TimestampQueryParameterTransformer" />
		</entry>
		<entry key="anyDate">
			<bean class="gov.va.med.cds.persistence.hibernate.TimestampQueryParameterTransformer" />
		</entry>
	</util:map>

	<bean id="hdr2AllergyAssessmentQueryStrategy" class="gov.va.med.cds.persistence.DefaultAssociationBasedQueryStrategy">
		<property name="templateTimeoutMap" ref="templateTimeoutMap" />
		<property name="modelAssembler" ref="modelAssembler" />
		<property name="queryPlanMap">
			<map>
				<entry key="allergyAssessments">
					<bean class="gov.va.med.cds.persistence.QueryAssociationMetaData">
						<property name="filterModelName" value="allergyAssessments" />
						<property name="associationName" value="patient" />
						<property name="associationParent" value="patient" />
						<property name="key" value="id" />
					</bean>
				</entry>
			</map>
		</property>
		<property name="queryNameBuilder" ref="legacyQueryNameBuilder" />
		<property name="filterParameterExtractor" ref="legacyFilterParameterExtractor" />
		<property name="parameterTransformerMap" ref="pointInTimeParameterTransformerMapPojo" />
		<property name="queryParameterBinder" ref="defaultQueryParameterBinder" />
	</bean>



	<bean id="hdr2IntoleranceConditionQueryStrategy" class="gov.va.med.cds.persistence.DefaultAssociationBasedQueryStrategy">
		<property name="templateTimeoutMap" ref="templateTimeoutMap" />
		<property name="modelAssembler" ref="modelAssembler" />
		<property name="queryPlanMap">
			<map>
				<entry key="intoleranceConditions">
					<bean class="gov.va.med.cds.persistence.QueryAssociationMetaData">
						<property name="filterModelName" value="intoleranceConditions" />
						<property name="associationName" value="patient" />
						<property name="associationParent" value="patient" />
						<property name="key" value="id" />
					</bean>
				</entry>
			</map>
		</property>
		<property name="queryNameBuilder" ref="legacyQueryNameBuilder" />
		<property name="filterParameterExtractor" ref="legacyFilterParameterExtractor" />
		<property name="parameterTransformerMap" ref="pointInTimeParameterTransformerMapPojo" />
		<property name="queryParameterBinder" ref="defaultQueryParameterBinder" />
	</bean>

	<bean id="hdr2MHVLabRead40011QueryStrategy" class="gov.va.med.cds.persistence.DefaultAssociationBasedQueryStrategy">
		<property name="templateTimeoutMap" ref="templateTimeoutMap" />
		<property name="modelAssembler" ref="modelAssembler" />
		<property name="queryPlanMap">
			<map>
				<entry key="labTestPromises">
					<bean class="gov.va.med.cds.persistence.QueryAssociationMetaData">
						<property name="filterModelName" value="labTestPromises" />
						<property name="associationName" value="patient" />
						<property name="associationParent" value="patient" />
						<property name="key" value="id" />
					</bean>
				</entry>
			</map>
		</property>
		<property name="queryNameBuilder" ref="legacyQueryNameBuilder" />
		<property name="filterParameterExtractor" ref="legacyFilterParameterExtractor" />
		<property name="parameterTransformerMap" ref="pointInTimeParameterTransformerMapPojo" />
		<property name="queryParameterBinder" ref="defaultQueryParameterBinder" />
	</bean>


	<bean id="hdr2VitalsignsQueryStrategy" class="gov.va.med.cds.persistence.DefaultAssociationBasedQueryStrategy">
		<property name="templateTimeoutMap" ref="templateTimeoutMap" />
		<property name="modelAssembler" ref="modelAssembler" />
		<property name="queryPlanMap">
			<map>
				<entry key="vitalSignObservationEvents">
					<bean class="gov.va.med.cds.persistence.QueryAssociationMetaData">
						<property name="filterModelName" value="vitalSignObservationEvents" />
						<property name="associationName" value="patient" />
						<property name="associationParent" value="patient" />
						<property name="key" value="id" />
					</bean>
				</entry>
			</map>
		</property>
		<property name="queryNameBuilder" ref="legacyQueryNameBuilder" />
		<property name="filterParameterExtractor" ref="legacyFilterParameterExtractor" />
		<property name="parameterTransformerMap" ref="pointInTimeParameterTransformerMapPojo" />
		<property name="queryParameterBinder" ref="defaultQueryParameterBinder" />
	</bean>

	<bean id="hdr2PharmacyQueryStrategy" class="gov.va.med.cds.persistence.DefaultAssociationBasedQueryStrategy">
		<property name="templateTimeoutMap" ref="templateTimeoutMap" />
		<property name="modelAssembler" ref="modelAssembler" />
		<property name="queryPlanMap">
			<map>
				<entry key="outpatientMedicationPromises">
					<bean class="gov.va.med.cds.persistence.QueryAssociationMetaData">
						<property name="filterModelName" value="outpatientMedicationPromises" />
						<property name="associationName" value="patient" />
						<property name="associationParent" value="patient" />
						<property name="key" value="id" />
					</bean>
				</entry>
			</map>
		</property>
		<property name="queryNameBuilder" ref="legacyQueryNameBuilder" />
		<property name="filterParameterExtractor" ref="legacyFilterParameterExtractor" />
		<property name="parameterTransformerMap" ref="pointInTimeParameterTransformerMapPojo" />
		<!-- <property name="queryParameterBinder" ref="defaultQueryParameterBinder" /> -->
		<property name="queryParameterBinder" ref="optionalParameterQueryParameterBinder" />
	</bean>

	<bean id="hdr2OutpatientPharmacyQueryStrategy" class="gov.va.med.cds.persistence.DefaultAssociationBasedQueryStrategy">
		<property name="templateTimeoutMap" ref="templateTimeoutMap" />
		<property name="modelAssembler" ref="outpatientMedicationPromiseModelAssembler" />
		<property name="queryPlanMap">
			<map>
				<entry key="outpatientMedicationPromises">
					<bean class="gov.va.med.cds.persistence.QueryAssociationMetaData">
						<property name="filterModelName" value="outpatientMedicationPromises" />
						<property name="associationName" value="patient" />
						<property name="associationParent" value="patient" />
						<property name="key" value="id" />
					</bean>
				</entry>
			</map>
		</property>
		<property name="queryNameBuilder" ref="legacyQueryNameBuilder" />
		<property name="filterParameterExtractor" ref="legacyFilterParameterExtractor" />
		<property name="parameterTransformerMap" ref="pointInTimeParameterTransformerMapPojo" />
		<!-- <property name="queryParameterBinder" ref="defaultQueryParameterBinder" /> -->
		<property name="queryParameterBinder" ref="optionalParameterQueryParameterBinder" />
	</bean>

	<bean id="xmlTypeExtractQueryInterceptor" 
		class="gov.va.med.cds.persistence.hibernate.interceptor.XmlTypeExtractQueryInterceptor" 
		scope="prototype">
		<property name="xPathParameterName" value=":xpathExpression" />
		<property name="xPathNamespaceParameterName" value=":xpathNamespace" />
	</bean>

	<bean id="optionalParameterQueryNameBuilder" class="gov.va.med.cds.persistence.hibernate.OptionalParameterQueryNameBuilder" />
	<bean id="optionalParameterQueryParameterBinder" class="gov.va.med.cds.persistence.hibernate.OptionalParameterQueryParameterBinder" />

	<bean id="hdr2PGDQueryStrategy" class="gov.va.med.cds.persistence.DefaultAssociationBasedQueryStrategy">
		<property name="templateTimeoutMap" ref="templateTimeoutMap" />
		<property name="modelAssembler" ref="pgdModelAssemblerHdr" />
		<property name="queryPlanMap">
			<map>
				<entry key="patientGeneratedDataEvents"> <!-- DomainEntryPoint -->
					<bean class="gov.va.med.cds.persistence.QueryAssociationMetaData">
						<property name="filterModelName" value="patientGeneratedDataEvent" />
						<property name="associationParent" value="patient" />
						<property name="associationName" value="patient" />
						<property name="key" value="id" />
					</bean>
				</entry>
			</map>
		</property>
		<property name="applicationName" ref="cdsAppName" />
		<property name="queryNameBuilder" ref="legacyQueryNameBuilder" />
		<property name="filterParameterExtractor" ref="legacyFilterParameterExtractor" />
		<property name="parameterTransformerMap" ref="timestampParameterTransformerMap" />
		<property name="queryParameterBinder" ref="defaultQueryParameterBinder" />
	</bean>

	<!-- <bean id="hdr2OutpatientPharmacyQueryStrategy" class="gov.va.med.cds.persistence.DefaultAssociationBasedQueryStrategy"> <property name="templateTimeoutMap" 
		ref="templateTimeoutMap" /> <property name="modelAssembler" ref="outpatientMedicationPromiseModelAssembler" /> <property name="queryPlanMap"> <map> 
		<entry key="outpatientMedicationPromises"> <bean class="gov.va.med.cds.persistence.QueryAssociationMetaData"> <property name="filterModelName" value="outpatientMedicationPromises" 
		/> <property name="associationName" value="patient" /> <property name="associationParent" value="patient" /> <property name="key" value="id" /> </bean> 
		</entry> </map> </property> <property name="queryNameBuilder" ref="legacyQueryNameBuilder" /> <property name="filterParameterExtractor" ref="legacyFilterParameterExtractor" 
		/> <property name="parameterTransformerMap" ref="pointInTimeParameterTransformerMap" /> <property name="queryParameterBinder" ref="defaultQueryParameterBinder" 
		/> </bean> -->


</beans>
