<?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="transactionManager" class="gov.va.med.cds.transaction.DefaultTransactionManager">
		<property name="persistenceLocator" ref="persistenceLocator" />
		<property name="workManager" ref="workManager" />
		<property name="validNonVistaSites" ref="validNonVistaSites" />
		<property name="templateIdToDomainEntryPointListMap" ref="templateIdToDomainEntryPointListMap" />
		<property name="createdRecordLimitIndex">
			<value>20</value>
		</property>
		<property name="templateHelper" ref="templateHelper" />
		<property name="domainClinicalRecordOwnerMap" ref="domainClinicalRecordOwnerMap" />
		<property name="templateTimeoutMap" ref="templateTimeoutMap" />
		<property name="cdsVistaWrite" ref="cdsVistaWrite" />		
	</bean>
	
	<util:map id="templateIdToDomainEntryPointListMap">
		<!-- So that the transaction manager can resolve template ids to a list of domain entry points. (writes only) -->
		<entry key="IntoleranceConditionCreateOrUpdate40060">
			<list>
				<value>IntoleranceCondition</value>
			</list>
		</entry>
		<entry key="AllergyAssessmentCreateOrUpdate40060">
			<list>
				<value>AllergyAssessment</value>
			</list>
		</entry>
		<entry key="LabCreate40020">
			<list>
				<value>LabTestPromise</value>
			</list>
		</entry>
		<entry key="LabCreateOrUpdate40060">
			<list>
				<value>LabTestPromise</value>
			</list>
		</entry>
		<entry key="PharmacyCreate40020">
			<list>
				<value>OutpatientMedicationPromise</value>
			</list>
		</entry>
		<entry key="PharmacyCreateOrUpdate40060">
			<list>
				<value>OutpatientMedicationPromise</value>
			</list>
		</entry>
		<entry key="VitalsignsCreate40020">
			<list>
				<value>VitalSignObservationEvent</value>
			</list>
		</entry>
		<entry key="VitalsignsCreateOrUpdate40060">
			<list>
				<value>VitalSignObservationEvent</value>
			</list>
		</entry>
		<entry key="ADLSurveyCreate40021">
			<list>
				<value>ADLSurveyResponse</value>
			</list>
		</entry>
		<entry key="ADLSurveyCreate40024">
			<list>
				<value>ADLSurveyResponse</value>
			</list>
		</entry>
		<entry key="PSSurveyCreate40021">
			<list>
				<value>PSSurveyResponse</value>
			</list>
		</entry>
		<entry key="PSSurveyCreate40022">
			<list>
				<value>PSSurveyResponse</value>
			</list>
		</entry>
		<entry key="PSSurveyCreate40023">
			<list>
				<value>PSSurveyResponse</value>
			</list>
		</entry>
		<entry key="PSSurveyCreate40024">
			<list>
				<value>PSSurveyResponse</value>
			</list>
		</entry>	
		<entry key="PSSurveyCreate40025">
			<list>
				<value>PSSurveyResponse</value>
			</list>
		</entry>
		<entry key="DMPSurveyCreate40020">
			<list>
				<value>DMPSurveyResponse</value>
			</list>
		</entry>
		<entry key="DMPSurveyCreate40021">
			<list>
				<value>DMPSurveyResponse</value>
			</list>
		</entry>
		<entry key="DMPSurveyCreate40024">
			<list>
				<value>DMPSurveyResponse</value>
			</list>
		</entry>
		<entry key="CensusSurveyCreate40024">
			<list>
				<value>CensusSurveyResponse</value>
			</list>
		</entry>
		<entry key="PGDCreateOrUpdate1">
			<list>
				<value>PatientGeneratedDataEvent</value>
			</list>
		</entry>
		<entry key="PGDDelete1">
			<list>
				<value>PatientGeneratedDataEvent</value>
			</list>
		</entry>
		<entry key="SensitivePatientAccessCreate1">
			<list>
				<value>PatientDataAccessedEvent</value>
			</list>
		</entry>		
		<!--<entry key="GenericHl7CreateOrUpdate1">
			<list>
				<value>GenericHl7DataEvent</value>
			</list>
		</entry>-->		
	</util:map>

	<!--define the clinical record's recordIdentifier/identity path -->
	<util:map id="domainClinicalRecordOwnerMap">
		<entry key="defaultDomainOwner">
			<bean class="gov.va.med.cds.clinicaldata.DomainClinicalRecordElementHelper">
				<property name="domainIdentityOwner" value="recordIdentifier.identity" />
				<property name="facilityOwner" value="patient.identifier.assigningFacility" />
				<property name="authorityOwner" value="patient.identifier.assigningAuthority" />
			</bean>
		</entry>			
	</util:map>

	<bean id="persistenceLocator" class="gov.va.med.cds.persistence.PersistenceLocator">
		<property name="staticPersistenceManagers">
			<list>
				<ref bean="hdr2Readable" />
				<!-- <ref bean="vista503Readable"/> <ref bean="vista504Readable"/> -->
				<ref bean="hdr2Writeable" />
				<ref bean="hdr2SurveyWriteable" />
				<ref bean="hdr2DMPSurveyWriteable" />
				<ref bean="hdr2CensusSurveyWriteable" />
				<!--<ref bean="vistaWriteable" />-->
			</list>
		</property>
		<property name="dynamicPersistenceManagers">
			<bean factory-bean="vistaPersistenceManagerFactory" factory-method="create" />
		</property>
	</bean>

	<bean id="validNonVistaSitesMBeanExporter" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false">
		<property name="beans">
			<map>
				<entry key="gov.va.med.cds.transaction:name=cds-valid-non-vista-sites-updater" value-ref="transactionManager" />
			</map>
		</property>
		<property name="assembler">
			<bean class="org.springframework.jmx.export.assembler.InterfaceBasedMBeanInfoAssembler">
				<property name="interfaceMappings">
					<props>
						<prop key="gov.va.med.cds.transaction:name=cds-valid-non-vista-sites-updater">
							gov.va.med.cds.transaction.ValidNonVistaSitesMBeanInterface
						</prop>
					</props>
				</property>
			</bean>
		</property>
		<property name="server" ref="mbeanServer" />
		<property name="registrationBehaviorName" value="REGISTRATION_REPLACE_EXISTING" />
	</bean>

	<aop:config>
		<aop:pointcut id="clobStoreTxMethods" expression="execution(* gov.va.med.cds.audit.persistence.CdsAuditClobStoreInterface.*(..))" />
		<aop:pointcut id="writeTxMethods" expression="execution(* gov.va.med.cds.transaction.TransactionManagerInterface.*(..))" />
		<aop:advisor advice-ref="clobStoreTxAdvice" pointcut-ref="clobStoreTxMethods" order="1" />
		<aop:advisor advice-ref="writeTxAdvice" pointcut-ref="writeTxMethods" order="2" />
	</aop:config>

	<tx:advice id="clobStoreTxAdvice" transaction-manager="hdr2TransactionManager">
		<tx:attributes>
			<tx:method name="persistPathwaysAuditClob" propagation="REQUIRES_NEW" isolation="READ_COMMITTED" timeout="60" />
			<tx:method name="persistCdsAuditClob" propagation="REQUIRES_NEW" isolation="READ_COMMITTED" />
		</tx:attributes>
	</tx:advice>

	<tx:advice id="writeTxAdvice" transaction-manager="hdr2TransactionManager">
		<tx:attributes>
			<tx:method name="performCUADOnClinicalData" propagation="REQUIRED" isolation="READ_COMMITTED" />
			<tx:method name="performReadOnCensusMetaData" propagation="REQUIRED" isolation="READ_COMMITTED" />
			<tx:method name="performCUADOnCensusMetaData" propagation="REQUIRED" isolation="READ_COMMITTED" />
		</tx:attributes>
	</tx:advice>
	<aop:config>
		<aop:pointcut id="readTxMethods" expression="execution(* gov.va.med.cds.persistence.ReadPersistenceManagerInterface.*(..))" />
		<aop:advisor advice-ref="readTxAdvice" pointcut-ref="readTxMethods" order="1" />
		<!-- aop:advisor advice-ref="hxReadTxAdvice" pointcut-ref="readTxMethods" order="2"/ -->
	</aop:config>

	<tx:advice id="readTxAdvice" transaction-manager="hdr2TransactionManager">
		<tx:attributes>
			<tx:method name="performReadOnClinicalData" propagation="SUPPORTS" isolation="READ_COMMITTED" read-only="true" />
		</tx:attributes>
	</tx:advice>

	<aop:config>
		<aop:pointcut id="tfrWriteTemplateTxMethods" expression="execution(* gov.va.med.cds.template.TemplateCachePersistenceInterface.*(..))" />
		<aop:advisor advice-ref="tfrWriteTemplateTxAdvice" pointcut-ref="tfrWriteTemplateTxMethods" order="1" />
	</aop:config>

	<tx:advice id="tfrWriteTemplateTxAdvice" transaction-manager="hdr2TransactionManager">
		<tx:attributes>
			<tx:method name="saveTemplateMetaDataToPersistence" propagation="REQUIRED" isolation="READ_COMMITTED" />
		</tx:attributes>
	</tx:advice>

	<aop:config>
		<aop:pointcut id="tfrReadTemplateTxMethods" expression="execution(* gov.va.med.cds.template.TemplateCachePersistenceInterface.*(..))" />
		<aop:advisor advice-ref="tfrReadTemplateTxAdvice" pointcut-ref="tfrReadTemplateTxMethods" order="1" />
	</aop:config>

	<tx:advice id="tfrReadTemplateTxAdvice" transaction-manager="hdr2TransactionManager">
		<tx:attributes>
			<tx:method name="loadTemplateIntoCache" propagation="SUPPORTS" isolation="READ_COMMITTED" read-only="true" />
			<tx:method name="loadAllTemplatesIntoCache" propagation="SUPPORTS" isolation="READ_COMMITTED" read-only="true" />
		</tx:attributes>
	</tx:advice>

	<aop:config>
		<aop:pointcut id="tfrReadFilterTxMethods" expression="execution(* gov.va.med.cds.filter.FilterCachePersistenceInterface.*(..))" />
		<aop:advisor advice-ref="tfrReadFilterTxAdvice" pointcut-ref="tfrReadFilterTxMethods" order="1" />
	</aop:config>

	<tx:advice id="tfrReadFilterTxAdvice" transaction-manager="hdr2TransactionManager">
		<tx:attributes>
			<tx:method name="loadFilterIntoMemoryCache" propagation="SUPPORTS" isolation="READ_COMMITTED" read-only="true" />
			<tx:method name="loadAllFilterSchemasIntoMemoryCache" propagation="SUPPORTS" isolation="READ_COMMITTED" read-only="true" />
			<tx:method name="getFilterIdentifiers" propagation="SUPPORTS" isolation="READ_COMMITTED" read-only="true" />
		</tx:attributes>
	</tx:advice>

	<aop:config>
		<aop:pointcut id="tfrWriteFilterTxMethods" expression="execution(* gov.va.med.cds.filter.FilterCachePersistenceInterface.*(..))" />
		<aop:advisor advice-ref="tfrWriteFilterTxAdvice" pointcut-ref="tfrWriteFilterTxMethods" order="1" />
	</aop:config>

	<tx:advice id="tfrWriteFilterTxAdvice" transaction-manager="hdr2TransactionManager">
		<tx:attributes>
			<tx:method name="removeFilterSchema" propagation="REQUIRED" isolation="READ_COMMITTED" />
			<tx:method name="replaceFilterPersistence" propagation="REQUIRED" isolation="READ_COMMITTED" />
			<tx:method name="persistFilterSchema" propagation="REQUIRED" isolation="READ_COMMITTED" />
		</tx:attributes>
	</tx:advice>

	<bean id="cdsVistaWrite"	class="gov.va.med.cds.request.vista.write.CdsWrite">
		<property name="templateEntryPointMap" ref="templateEntryPointMap" />
	</bean>

	<util:map id="templateEntryPointMap">
		<entry key="SensitivePatientAccessCreate1-PatientDataAccessedEvent" value="patientDataAccessedEvent" />
	</util:map>
	
	<util:map id="templateTimeoutMap">
		<entry key="NonVAMedicationsRead2-NonVaMedicationEvent" value="120" />
		<entry key="PGDRead1-PatientGeneratedDataEvent" value="60" />
		<entry key="TiuDocumentListRead2-ClinicalDocumentEvent" value="60" />
		<entry key="TiuDocumentDetailRead2-ClinicalDocumentEvent" value="60" />
		<entry key="AllergiesRead40010-AllergyAssessment" value="60" />
		<entry key="AllergiesRead40010-IntoleranceCondition" value="60" />
		<entry key="AllergyAssessmentRead40010-AllergyAssessment" value="60" />
		<entry key="IntoleranceConditionRead40010-IntoleranceCondition" value="60" />
		<entry key="IntoleranceConditionReducedRead40011-IntoleranceCondition" value="60" />
		<entry key="VWIntoleranceConditionRead40010-IntoleranceCondition" value="60" />
		<entry key="MHVIntoleranceConditionRead40011-IntoleranceCondition" value="60" />
		<entry key="VWAllergiesRead40010-IntoleranceCondition" value="60" />
		<entry key="VWAllergiesRead40010-AllergyAssessment" value="60" />
		<entry key="VitalsignsRead40010-VitalSignObservationEvent" value="60" />
		<entry key="VWVitalsignsRead40010-VitalSignObservationEvent" value="60" />
		<entry key="ImmunizationRead3-ImmunizationEvent" value="60" />
		<entry key="SkintestRead3-SkinTestProcedure" value="60" />
		<entry key="ProblemListRead2-HealthConcern" value="60" />
		<entry key="RequestsAndExamsRead1-ExamRequest2507" value="60" />
		<entry key="RequestsAndExamsRead1-Exam2507" value="60" />
		<entry key="RequestsAndExamsRead2-ExamRequest2507" value="60" />
		<entry key="RequestsAndExamsRead2-Exam2507" value="60" />
		<entry key="AppointmentsRead1-Appointment" value="60" />
		<!-- <entry key="ReleaseOfInformationRead1-ReleaseOfInformation" value="60" />
		<entry key="ClinicalRemindersRead1-ClinicalReminder" value="60" />		
		<entry key="DemographicsRead1-DemographicsRead" value="60" />-->
		<entry key="PatientAlertListRead1-PatientAlert" value="600"/>
		<entry key="PatientAlertDetailRead1-PatientAlert" value="600"/>
		<entry key="MHVLabRead40011-LabTestPromise" value="600" />
		<!-- <entry key="LabChemHemRead1-LabTestPromise" value="600" /> -->
		<!-- <entry key="MHVLabChemHemRead1-LabTestPromise" value="600" /> -->
		<!-- <entry key="MHVVitalsignsRead40010-VitalSignObservationEvent" value="60" /> -->
		<entry key="OutpatientPharmacyRead1-OutpatientMedicationPromise" value="120" />
		<entry key="VWOutpatientPharmacyRead1-OutpatientMedicationPromise" value="120" />
		<entry key="VWOutpatientPharmacyDetailRead1-OutpatientMedicationPromise" value="120" />
		<entry key="PharmacyRead40010-OutpatientMedicationPromise" value="120" />
		<entry key="VWPharmacyRead40010-OutpatientMedicationPromise" value="120" />
		<entry key="VWPharmacyDetailRead40010-OutpatientMedicationPromise" value="120" />
		<entry key="RDIIntoleranceConditionPharmacyRead40010-OutpatientMedicationPromise" value="600" />
		<entry key="RDIIntoleranceConditionPharmacyRead40010-IntoleranceCondition" value="600" />
		<entry key="RDIIntoleranceConditionPharmacyRead40011-OutpatientMedicationPromise" value="600" />
		<entry key="RDIIntoleranceConditionPharmacyRead40011-IntoleranceCondition" value="600" />
		<entry key="RDIIntoleranceConditionPharmacyRead40012-OutpatientMedicationPromise" value="600" />
		<entry key="RDIIntoleranceConditionPharmacyRead40012-IntoleranceCondition" value="600" />
		<entry key="RDIAllergiesPharmacyRead40013-OutpatientMedicationPromise" value="600" />
		<entry key="RDIAllergiesPharmacyRead40013-IntoleranceCondition" value="600" />
		<entry key="RDIAllergiesPharmacyRead40013-AllergyAssessment" value="600" />
		<entry key="GenericObservationRead1-GenericObservation" value="600" />
		<entry key="SensitivePatientAccessCreate1-PatientDataAccessedEvent" value="600" />
		<entry key="AppointmentLetter1" value="600"/>
		<entry key="upperLimitTimeout" value="600" />
	</util:map>

	<util:list id="validNonVistaSites">
		<value>200CORP</value>
		<value>200BRLS</value>
		<value>200AMAS</value>
		<value>200BOSS</value>
		<value>200KK</value>
		<value>200NC</value>
		<value>200NK1</value>
		<value>200NKK</value>
		<value>200NKK</value>
		<value>200NSS</value>
		<value>200</value>
		<value>200AA</value>
		<value>200BA</value>
		<value>200BB</value>
		<value>200BR</value>
		<value>200BR1</value>
		<value>200CH</value>
		<value>200CH1</value>
		<value>200CPP</value>
		<value>200DOD</value>
		<value>200EBEN</value>
		<value>200ESR</value>
		<value>200FSC</value>
		<value>200HD</value>
		<value>200HD1</value>
		<value>200LR4</value>
		<value>200M</value>
		<value>200MH</value>
		<value>200MHD</value>
		<value>200MHI</value>
		<value>200MHS</value>
		<value>200MHU</value>
		<value>200NCM</value>
		<value>200NDD</value>
		<value>200NH</value>
		<value>200NHKP</value>
		<value>200NIN</value>
		<value>200NK2</value>
		<value>200NKP</value>
		<value>200NMN</value>
		<value>200NMV</value>
		<value>200NNC</value>
		<value>200NQH</value>
		<value>200NSC</value>
		<value>200NUC</value>
		<value>200NUT</value>
		<value>200NWA</value>
		<value>200NWN</value>
		<value>200NWS</value>
		<value>200PS</value>
		<value>200RS</value>
		<value>200SCI</value>
		<value>200SD0</value>
		<value>200SD1</value>
		<value>200SD2</value>
		<value>200SD3</value>
		<value>200SD4</value>
		<value>200SD5</value>
		<value>200SD6</value>
		<value>200SD7</value>
		<value>200SD8</value>
		<value>200SSA</value>
		<value>200T1</value>
		<value>200T2</value>
		<value>200T3</value>
		<value>200T4</value>
		<value>200T5</value>
		<value>200T6</value>
		<value>200T7</value>
		<value>200T8</value>
		<value>200TX</value>
		<value>200LR1</value>
		<value>200NVW</value>
		<value>200IP</value>
		<value>200HMP</value>
		<value>358</value>
		<value>402</value>
		<value>405</value>
		<value>436</value>
		<value>436GJ</value>
		<value>437</value>
		<value>438</value>
		<value>442</value>
		<value>459</value>
		<value>460</value>
		<value>463</value>
		<value>501</value>
		<value>502</value>
		<value>503</value>
		<value>504</value>
		<value>506</value>
		<value>508</value>
		<value>509</value>
		<value>512</value>
		<value>515</value>
		<value>515BY</value>
		<value>515GA</value>
		<value>515GB</value>
		<value>515GC</value>
		<value>516</value>
		<value>516BZ</value>
		<value>517</value>
		<value>518</value>
		<value>519</value>
		<value>520</value>
		<value>521</value>
		<value>523</value>
		<value>526</value>
		<value>528</value>
		<value>528A5</value>
		<value>528A6</value>
		<value>528A7</value>
		<value>528A8</value>
		<value>529</value>
		<value>531</value>
		<value>534</value>
		<value>537</value>
		<value>538</value>
		<value>539</value>
		<value>540</value>
		<value>541</value>
		<value>541A0</value>
		<value>542</value>
		<value>544</value>
		<value>546</value>
		<value>548</value>
		<value>548GF</value>
		<value>549</value>
		<value>550</value>
		<value>550BY</value>
		<value>550GA</value>
		<value>550GD</value>
		<value>552</value>
		<value>553</value>
		<value>554</value>
		<value>556</value>
		<value>557</value>
		<value>558</value>
		<value>561</value>
		<value>562</value>
		<value>564</value>
		<value>565</value>
		<value>568</value>
		<value>568A4</value>
		<value>570</value>
		<value>573</value>
		<value>573A4</value>
		<value>575</value>
		<value>578</value>
		<value>580</value>
		<value>580BZ</value>
		<value>581</value>
		<value>583</value>
		<value>583GA</value>
		<value>583GB</value>
		<value>584</value>
		<value>585</value>
		<value>586</value>
		<value>589</value>
		<value>589A4</value>
		<value>589A5</value>
		<value>589A6</value>
		<value>589A7</value>
		<value>589PA</value>
		<value>590</value>
		<value>593</value>
		<value>593GA</value>
		<value>595</value>
		<value>596</value>
		<value>598</value>
		<value>598PA</value>
		<value>600</value>
		<value>603</value>
		<value>605</value>
		<value>607</value>
		<value>608</value>
		<value>610</value>
		<value>610A4</value>
		<value>612</value>
		<value>612A4</value>
		<value>612B4</value>
		<value>612GG</value>
		<value>613</value>
		<value>614</value>
		<value>618</value>
		<value>618DT</value>
		<value>619</value>
		<value>619A4</value>
		<value>620</value>
		<value>621</value>
		<value>623</value>
		<value>626</value>
		<value>629</value>
		<value>630</value>
		<value>630A4</value>
		<value>631</value>
		<value>632</value>
		<value>635</value>
		<value>635PA</value>
		<value>636</value>
		<value>636A4</value>
		<value>636A5</value>
		<value>636A6</value>
		<value>636A8</value>
		<value>636DT</value>
		<value>637</value>
		<value>640</value>
		<value>642</value>
		<value>642GB</value>
		<value>642GC</value>
		<value>642GD</value>
		<value>644</value>
		<value>646</value>
		<value>646A5</value>
		<value>648</value>
		<value>649</value>
		<value>650</value>
		<value>652</value>
		<value>653</value>
		<value>654</value>
		<value>655</value>
		<value>655GA</value>
		<value>656</value>
		<value>657</value>
		<value>657A4</value>
		<value>657A5</value>
		<value>658</value>
		<value>659</value>
		<value>660</value>
		<value>660GG</value>
		<value>662</value>
		<value>663</value>
		<value>664</value>
		<value>666</value>
		<value>667</value>
		<value>668</value>
		<value>671</value>
		<value>672</value>
		<value>673</value>
		<value>674</value>
		<value>675</value>
		<value>676</value>
		<value>678</value>
		<value>679</value>
		<value>687</value>
		<value>688</value>
		<value>689</value>
		<value>691</value>
		<value>692</value>
		<value>693</value>
		<value>695</value>
		<value>742V1</value>
		<value>740</value>
		<value>756</value>
		<value>757</value>
		<value>979</value>
		<value>982</value>
		<value>983</value>
		<value>984</value>
		<value>989</value>
		<value>992</value>
	</util:list>

</beans>
