<?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="vwOutpatientPharmacyDetailRead1" name="gov.va.med.cds.template.generated.pharmacy.OutpatientMedicationPromise1" table="OUTPATIENT_MED_PRM30_V" lazy="false">
		<id name="id" type="java.lang.Long">
			<column name="OUTPATIENT_MED_PRM_ID"/>
			<generator class="sequence">
				<param name="sequence">outpatient_med_prm_seq_id</param>
			</generator>
		</id>
		<!-- From superclass.  Additional maps in the set section below -->
		<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>
		<property name="prescriptionId" column="PRESCRIPTION_ID" type="java.lang.String"/>
		
		<component name="pharmacyRequest" class="gov.va.med.cds.template.generated.pharmacy.PharmacyRequest">
			<component name="orderedMedication" class="gov.va.med.cds.template.generated.common.Medicine">
				<component name="medicationCode" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElement">
					<property name="displayText" column="PR_MEDICATION_DSPLYTXT" type="java.lang.String"  />
				</component>
			</component>
		</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>

		<property name="numberOfRefillsAuthorized" column="NUM_REFILLS_AUTHORIZED" type="integer"/>
		
		<component name="sigs"  class="gov.va.med.cds.template.generated.pharmacy.OutpatientMedicationPromise1$Sigs">
			<list name="sig" table="OUTPPHARM_SIG_V" fetch="subselect" batch-size="100">
				<key column="OUTPATIENT_MED_PRM_ID" not-null="true" update="false"/>
				<list-index column="LINE_NBR"/>
				<element type="string" column="PRESCRIPTION_SIG_TXT" />
			</list>
		</component>
				
		<list name="originalDispenseSet" where="discriminator='O'" fetch="subselect" batch-size="100">
			<key column="OUTPATIENT_MED_PRM_ID" not-null="true" update="false"/>
			<list-index column="LINE_NBR"/>
			<one-to-many entity-name="vwOutpatientPharmacyDetailOriginalMedicationDispense" />
		</list>
		
		<component name="refillDispenses"  class="gov.va.med.cds.template.generated.pharmacy.OutpatientMedicationPromise1$RefillDispenses">
			<list name="refillDispense" where="discriminator='R'" fetch="subselect" batch-size="100">
				<key column="OUTPATIENT_MED_PRM_ID" not-null="true" update="false"/>
				<list-index column="LINE_NBR"/>
				<one-to-many entity-name="vwOutpatientPharmacyDetailRefillMedicationDispense" />
			</list>
		</component>
			
		<component name="cancel" class="gov.va.med.cds.template.generated.pharmacy.CancelAct1">
			<property name="cancelDate" type="gov.va.med.cds.persistence.hibernate.common.PointInTimeUserType" >
				<column name="CANCEL_DT"/>
				<column name="CANCEL_DT_NBR"/>
			</property>
		</component>
		
		<component name="recordSource" class="gov.va.med.cds.template.generated.basedatatypes.HL72FacilityIdentifier">
			<property name="namespaceId" column="RECORDSOURCE_NAMESPACEID" type="java.lang.String" node="namespaceId"/>
			<property name="universalId" column="RECORDSOURCE_UNIVERSALID" type="java.lang.String" node="universalId"/>
			<property name="universalIdType" column="RECORDSOURCE_UNIVERSTYP" type="java.lang.String" node="universalIdType"/>
		</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="VWOutpatientPharmacyDetailRead1.OutpatientMedicationPromise.patient"><![CDATA[
		from vwOutpatientPharmacyDetailRead1 opmp
		where opmp.patient.identifier.assigningFacility || '/' || opmp.patient.identifier.identity in ( :pids )
      ]]></query>

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

	<query name="VWOutpatientPharmacyDetailRead1.OutpatientMedicationPromise.patient.date"><![CDATA[
		from vwOutpatientPharmacyDetailRead1 opmp
		where opmp.patient.identifier.identity in ( :pids )
		and ( (opmp.cancel.cancelDate.numeric between :startDate and :endDate) or (opmp.cancel.cancelDate.numeric is null)  )
    ]]></query>
</hibernate-mapping>
