<?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="OutpatientPharmacyRead1" table="VISTA_HDSI.PRESCRIPTION_52_EXT" lazy="false" name="gov.va.med.cds.template.generated.pharmacy.OutpatientMedicationPromise1" >
		<id name="id" type="gov.va.med.cds.persistence.hibernate.common.VistaRowIdUserType">
			<column name="ROWID"/>
			<generator class="assigned"/>
		</id>
		
		<component name="recordIdentifier" class="gov.va.med.cds.template.generated.basedatatypes.HL72EntityIdentifier" >
			<property name="identity" type="gov.va.med.cds.persistence.hibernate.common.VistaIdentityUserType" insert="false" update="false">
				<column name="RowId"/>
			</property>
			<property name="namespaceId" formula="VISTA_HDSI.HDSREPSQLUtil1_StationNumber()||'_52'" type="java.lang.String" />
			<property name="universalId" formula="VISTA_HDSI.HDSREPSQLUtil1_KSPDomainName()" type="java.lang.String" insert="false" update="false" />
			<property name="universalIdType" formula="'DNS'" type="java.lang.String" insert="false" update="false" />
		</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" type="gov.va.med.cds.persistence.hibernate.common.VistaIdentityUserType" insert="false" update="false">
					<column name="PATIENT"/>
				</property>
				<property name="assigningFacility" formula="VISTA_HDSI.HDSREPSQLUtil1_StationNumber()" type="java.lang.String" />
				<property name="assigningAuthority" formula="'USVHA'" type="java.lang.String" />
			</component>
			<property name="name" formula="VISTA_HDSI.HDSREPSQLUtil1_PatientNE(PATIENT)" type="gov.va.med.cds.persistence.hibernate.common.VistaPersonNameUserType" insert="false" update="false" />
		</component>
		
		<property name="expirationDate" type="gov.va.med.cds.persistence.hibernate.common.VistaPointInTimeUserTypeQuery" insert="false" update="false" >
			<column name="EXPIRATION_DATE"/>
			<formula>VISTA_HDSI.HDSREPSQLUtil1_StationNumber()</formula>
		</property>
				
		<property name="lastDispenseDate" formula="STRING(LAST_DISPENSED_DATE,'^',(VISTA_HDSI.HDSREPSQLUtil1_StationNumber()))" type="gov.va.med.cds.persistence.hibernate.common.VistaPointInTimeUserType" insert="false" update="false" />
		
		<property name="numberOfRefillsAuthorized" column="OF_REFILLS" type="integer" />
		
		<component name="patientInstructions" class="gov.va.med.cds.template.generated.pharmacy.OutpatientMedicationPromise1$PatientInstructions">
			<property name="singleInstruction" column="PATIENT_INSTRUCTIONS" type="java.lang.String" />
		</component>
		
		<component name="otherPatientInstructions" class="gov.va.med.cds.template.generated.pharmacy.OutpatientMedicationPromise1$OtherPatientInstructions">
			<property name="singleInstruction" column="OTHER_PATIENT_INSTRUCTIONS" type="java.lang.String" />
		</component>
		
		<component name="expandedPatientInstructions" class="gov.va.med.cds.template.generated.pharmacy.OutpatientMedicationPromise1$ExpandedPatientInstructions" > 
			<property name="singleInstruction" column="EXPANDEDPATIENTINSTRUCWP" type="java.lang.String" />
		</component>
		
		<component name="pharmacyInstructions" class="gov.va.med.cds.template.generated.pharmacy.OutpatientMedicationPromise1$PharmacyInstructions" > 
			<property name="singleInstruction" column="PHARMACYINSTRUCTIONSWP" type="java.lang.String" />
		</component>
		
			
		<component name="sigs" class="gov.va.med.cds.template.generated.pharmacy.OutpatientMedicationPromise1$Sigs">
			 <property name="singleSig" type="java.lang.String" >
            	<formula>
                    (CASE
                    WHEN ( SIG IS NOT NULL ) THEN SIG
                    ELSE SIGX 
                    END)
            	</formula>
        	</property>	
		</component>
		
		<component name="digitalSignatureIndicator" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
			<property name="code" type="java.lang.String" >
				<formula>
					(CASE
					WHEN ( SIGNATURE_STATUS = 'NO' ) THEN '0'
					WHEN ( SIGNATURE_STATUS = 'YES' ) THEN '1'
					ELSE NULL
					END)
				</formula>
			</property>
			<property name="displayText" column="SIGNATURE_STATUS" type="java.lang.String" />
            <property name="codingSystem" type="java.lang.String" >
                    <formula>
                     (CASE
                         WHEN (SIGNATURE_STATUS IS NOT NULL) THEN VISTA_HDSI.HDSREPSQLUtil1_StationNumber()||'_52'
                         ELSE NULL
                      END)
                    </formula>                
            </property>
		</component>
		
		<component name="copayTransactionType" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
			<property name="code" column="COPAY_TRANSACTION_TYPE" type="java.lang.String" />
			<property name="displayText" column="COPAYTRANSACTIONTYPEX" type="java.lang.String" />
			<property name="codingSystem" type="java.lang.String" >
				<formula>
					(CASE
                         WHEN (COPAY_TRANSACTION_TYPE IS NOT NULL) THEN VISTA_HDSI.HDSREPSQLUtil1_StationNumber()||'_52'
                         ELSE NULL
                      END)
				</formula>
			</property>
		</component>
		
        <component name="transitionalRxBenefit" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
            <property name="code" type="java.lang.String" >
                <formula>
                        (CASE
                        WHEN ( TPB_RX = 'NO' ) THEN '0'
                        WHEN ( TPB_RX = 'YES' ) THEN '1'
                        ELSE NULL
                        END)
                    </formula>
            </property>
            <property name="displayText" column="TPB_RX" type="java.lang.String" />
            <property name="codingSystem" type="java.lang.String">
                    <formula>
                     (CASE
                         WHEN (TPB_RX IS NOT NULL) THEN VISTA_HDSI.HDSREPSQLUtil1_StationNumber()||'_52'
                         ELSE NULL
                      END)
                    </formula>                
            </property>
        </component>
		
		<component name="originalDispense" class="gov.va.med.cds.template.generated.pharmacy.OutpatientMedicationDispense1" >
			<property name="daysSupply" column="DAYS_SUPPLY" type="gov.va.med.cds.persistence.hibernate.common.VistaIntegerToStringUserType" />
			<component name="identifier" 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()||'_52'" type="java.lang.String" />
			</component>
			
			<component name="levelOfUnderstanding" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
				<property name="code" type="java.lang.String" >
					<formula>
						(CASE
						WHEN ( WAS_COUNSELING_UNDERSTOOD = 'NO' ) THEN '4500630'
						WHEN ( WAS_COUNSELING_UNDERSTOOD = 'YES' ) THEN '4500633'
						ELSE NULL
						END)
					</formula>
				</property>
				<property name="displayText" column="WAS_COUNSELING_UNDERSTOOD" type="java.lang.String" />
				<property name="codingSystem" type="java.lang.String" >
                    <formula>
                     (CASE
                         WHEN (WAS_COUNSELING_UNDERSTOOD IS NOT NULL) THEN VISTA_HDSI.HDSREPSQLUtil1_StationNumber()||'_52'
                         ELSE NULL
                      END)
                    </formula>                
                </property>
			</component>
			
			<property name="mailWindow" column="MAILWINDOW" type="java.lang.String" />
			<property name="releaseDate" formula="STRING(RELEASED_DATETIME,'^',(VISTA_HDSI.HDSREPSQLUtil1_StationNumber()))" type="gov.va.med.cds.persistence.hibernate.common.VistaPointInTimeUserType" insert="false" update="false" />
			
			<component name="wasPatientCounseled" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
				<property name="code" type="java.lang.String" >
					<formula>
						(CASE
                        WHEN ( WAS_THE_PATIENT_COUNSELED = 'NO' ) THEN '4500630'
                        WHEN ( WAS_THE_PATIENT_COUNSELED = 'YES' ) THEN '4500633'
						ELSE NULL
						END)
					</formula>
				</property>
				<property name="displayText" column="WAS_THE_PATIENT_COUNSELED" type="java.lang.String" />
			    <property name="codingSystem" type="java.lang.String" >
                    <formula>
                     (CASE
                         WHEN (WAS_THE_PATIENT_COUNSELED IS NOT NULL) THEN VISTA_HDSI.HDSREPSQLUtil1_StationNumber()||'_52'
                         ELSE NULL
                      END)
                    </formula>                
                </property>
			</component>
			
			<component name="division" class="gov.va.med.cds.template.generated.common.PharmacyDivision">
				<component name="divisionId" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
					<property name="code" column="SITE_NUMBER" type="java.lang.String" />
					<property name="displayText" column="DIVISIONX" type="java.lang.String" insert="false" update="false"/>
					<property name="codingSystem" type="java.lang.String">
						<formula>
	                 		(CASE
	                    		 WHEN (SITE_NUMBER IS NOT NULL) THEN VISTA_HDSI.HDSREPSQLUtil1_StationNumber()||'_59'
	                     		ELSE NULL
	                  		END)
	                	</formula>
                	</property>	
				</component>
				
				<component name="ncpdpId" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
					<property name="code" column="NCPDP_NUMBER" type="java.lang.String" insert="false" update="false" />
					<property name="codingSystem" type="java.lang.String" >
						<formula>
							(CASE
                         		WHEN (NCPDP_NUMBER IS NOT NULL) THEN VISTA_HDSI.HDSREPSQLUtil1_StationNumber()||'_59'
                         		ELSE NULL
                      		END)
						</formula>
					</property>
				</component>
			</component>
			
			<component name="dispensedDrug" class="gov.va.med.cds.template.generated.pharmacy.DispensedDrugInstance">
				<component name="drugUnitPrice" class="gov.va.med.cds.template.generated.basedatatypes.Money">
					<property name="value" column="UNIT_PRICE_OF_DRUG" type="java.lang.String" insert="false" update="false" />
				</component>
				
				<property name="expirationDate" formula="STRING(DRUG_EXPIRATION_DATE,'^',(VISTA_HDSI.HDSREPSQLUtil1_StationNumber()))" type="gov.va.med.cds.persistence.hibernate.common.VistaPointInTimeUserType" insert="false" update="false" />
				<property name="lotId" column="LOT_" type="java.lang.String" insert="false" update="false" />
				
				<component name="ndc" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
					<property name="code" column="NDC" type="java.lang.String" insert="false" update="false" />
					<property name="codingSystem" type="java.lang.String" insert="false" update="false" >
						<formula>
							(CASE
                         		WHEN (NDC IS NOT NULL) THEN VISTA_HDSI.HDSREPSQLUtil1_StationNumber()||'_50'
                         		ELSE NULL
                      		END)
						</formula>
					</property>
				</component>
			</component>
			
			<component name="pharmacist" 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="PHARMACIST" type="gov.va.med.cds.persistence.hibernate.common.VistaIdentityUserType" insert="false" update="false"/>
						<property name="assigningFacility" type="java.lang.String" insert="false" update="false" >
							<formula>
								(CASE
                         			WHEN (PHARMACIST IS NOT NULL) THEN VISTA_HDSI.HDSREPSQLUtil1_StationNumber()
                         			ELSE NULL
                      			END)
							</formula>
						</property>
						<property name="assigningAuthority" type="java.lang.String">
							<formula>
								(CASE
                         			WHEN (PHARMACIST IS NOT NULL) THEN 'USVHA'
                         			ELSE NULL
                      			END)
							</formula>
						</property>
					</component>
					<property name="idSourceTable" type="java.lang.String">
						<formula>
							(CASE
                         		WHEN (PHARMACIST IS NOT NULL) THEN 'VISTA200'
                         		ELSE NULL
                      		END)
						</formula>
					</property>
					<property name="name" formula="VISTA_HDSI.HDSREPSQLUtil1_MiscNameNE(PHARMACIST)" type="gov.va.med.cds.persistence.hibernate.common.VistaPersonNameUserType" insert="false" update="false" />
				</component>
 			</component>
			
			<component name="cmopEventStatus" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
				<property name="code" type="java.lang.String" >
				    <formula>
                        (CASE
                        WHEN ( CMOP_EVENT_STATUS = 'TRANSMITTED' ) THEN '0'
                        WHEN ( CMOP_EVENT_STATUS = 'DISPENSED' ) THEN '1'
                        WHEN ( CMOP_EVENT_STATUS = 'RETRANSMITTED' ) THEN '2'
                        WHEN ( CMOP_EVENT_STATUS = 'NOT DISPENSED' ) THEN '3'
                        ELSE NULL
                        END)
                    </formula>
				</property>
				<property name="displayText" column="CMOP_EVENT_STATUS" type="java.lang.String" />
				<property name="codingSystem" type="java.lang.String" >
					<formula>
							(CASE
                         		WHEN (CMOP_EVENT_STATUS IS NOT NULL) THEN VISTA_HDSI.HDSREPSQLUtil1_StationNumber()||'_52.01'
                         		ELSE NULL
                      		END)
						</formula>
				</property>
			</component>
        					
			<component name="comments"  class="gov.va.med.cds.template.generated.pharmacy.MedicationDispense1$Comments">
				<property name="singleComment" column="REMARKS" type="java.lang.String" node="comment"/>
			</component> 
						
			<property name="dispenseDate" formula="STRING(DISPENSED_DATE,'^',(VISTA_HDSI.HDSREPSQLUtil1_StationNumber()))" type="gov.va.med.cds.persistence.hibernate.common.VistaPointInTimeUserType" insert="false" update="false" />
			<property name="fillDate" formula="STRING(FILL_DATE,'^',(VISTA_HDSI.HDSREPSQLUtil1_StationNumber()))" type="gov.va.med.cds.persistence.hibernate.common.VistaPointInTimeUserType" insert="false" update="false" />
			
			<component name="quantityDispensed" class="gov.va.med.cds.template.generated.basedatatypes.PhysicalQuantity">
				<property name="value" column="QTY" type="gov.va.med.cds.persistence.hibernate.common.VistaBigDecimalToStringUserType" />
				<component name="unit" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
					<property name="displayText" column="DISPENSED_UNIT" type="java.lang.String" />
					<property name="codingSystem" type="java.lang.String">
						<formula>
							(CASE
                         		WHEN (DISPENSED_UNIT IS NOT NULL) THEN VISTA_HDSI.HDSREPSQLUtil1_StationNumber()||'_50'
                         		ELSE NULL
                      		END)
						</formula>
					</property>
				</component>
			</component>
			
			<component name="currentProvider"  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="PROVIDER" type="gov.va.med.cds.persistence.hibernate.common.VistaIdentityUserType"/>
					<property name="assigningFacility" type="java.lang.String" insert="false" update="false" >
						<formula>
								(CASE
                         			WHEN (PROVIDER IS NOT NULL) THEN VISTA_HDSI.HDSREPSQLUtil1_StationNumber()
                         			ELSE NULL
                      			END)
							</formula>
						</property>
						<property name="assigningAuthority" type="java.lang.String">
							<formula>
								(CASE
                         			WHEN (PROVIDER IS NOT NULL) THEN 'USVHA'
                         			ELSE NULL
                      			END)
							</formula>
						</property>
					</component>
					<property name="idSourceTable" type="java.lang.String">
						<formula>
							(CASE
                         		WHEN (PROVIDER IS NOT NULL) THEN 'VISTA200'
                         		ELSE NULL
                      		END)
						</formula>
					</property>
				<property name="name" formula="VISTA_HDSI.HDSREPSQLUtil1_MiscNameNE(PROVIDER)" type="gov.va.med.cds.persistence.hibernate.common.VistaPersonNameUserType" insert="false" update="false" />
			</component>
			
		  	<component name="currentProviderComments"  class="gov.va.med.cds.template.generated.pharmacy.MedicationDispense1$CurrentProviderComments">
            	<property name="singleComment" column="PROVIDERCOMMENTSWP" type="java.lang.String" />
		  	</component>
		
			<property name="loginDate" formula="STRING(LOGIN_DATE,'^',(VISTA_HDSI.HDSREPSQLUtil1_StationNumber()))" type="gov.va.med.cds.persistence.hibernate.common.VistaPointInTimeUserType" insert="false" update="false" />
		</component>
		
		<component name="cancel" class="gov.va.med.cds.template.generated.pharmacy.CancelAct1">
			<property name="cancelDate" type="gov.va.med.cds.persistence.hibernate.common.VistaPointInTimeUserTypeQuery" insert="false" update="false">
				<column name="CANCEL_DATE"/>
				<formula>VISTA_HDSI.HDSREPSQLUtil1_StationNumber()</formula>
			</property>
		
			<component name="comments" class="gov.va.med.cds.template.generated.pharmacy.CancelAct1$Comments">
				<property name="singleComment" column="DELETION_COMMENTS" type="java.lang.String" />
			</component>
		</component>
		
		<component name="finisher" class="gov.va.med.cds.template.generated.common.PractitionerParticipationLite">
			<property name="time" formula="STRING(FinishDateTime,'^',(VISTA_HDSI.HDSREPSQLUtil1_StationNumber()))" type="gov.va.med.cds.persistence.hibernate.common.VistaPointInTimeUserType" insert="false" update="false" />
			<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="FINISHING_PERSON"  type="gov.va.med.cds.persistence.hibernate.common.VistaIdentityUserType" />
					<property name="assigningFacility" type="java.lang.String" insert="false" update="false">
						<formula>
							(CASE
                         		WHEN (FINISHING_PERSON IS NOT NULL) THEN VISTA_HDSI.HDSREPSQLUtil1_StationNumber()
                         		ELSE NULL
                      		END)
						</formula>
					</property>
					<property name="assigningAuthority" type="java.lang.String">
						<formula>
							(CASE
                         		WHEN (FINISHING_PERSON IS NOT NULL) THEN 'USVHA'
                         		ELSE NULL
                      		END)
						</formula>
					</property>
				</component>
				<property name="idSourceTable" type="java.lang.String">
					<formula>
						(CASE
                         	WHEN (FINISHING_PERSON IS NOT NULL) THEN 'VISTA200'
                         	ELSE NULL
                      	END)
					</formula>
				</property>
		    	
		    	<property name="name" formula="VISTA_HDSI.HDSREPSQLUtil1_MiscNameNE(FINISHING_PERSON)" type="gov.va.med.cds.persistence.hibernate.common.VistaPersonNameUserType" insert="false" update="false" />
			</component>
		</component>
		
		<component name="recordSource" class="gov.va.med.cds.template.generated.basedatatypes.HL72FacilityIdentifier">
			<property name="namespaceId" formula="VISTA_HDSI.HDSREPSQLUtil1_StationNumber()||'_52'" type="java.lang.String" />
			<property name="universalId" formula="VISTA_HDSI.HDSREPSQLUtil1_KSPDomainName()" type="java.lang.String" />
			<property name="universalIdType" formula="'DNS'" type="java.lang.String" />
		</component>
		
		<!-- need inner class wrapper here -->
		<component name="treatmentFactors" class="gov.va.med.cds.template.generated.pharmacy.OutpatientMedicationPromise1$TreatmentFactors">
			<property name="treatmentFactor" type="gov.va.med.cds.persistence.hibernate.common.VistaOutpatientPharmacyTreatmentFactorType" insert="false" update="false" >
		  		<column name="SERVICE_CONNECTED"/>
		  		<column name="MILITARY_SEXUAL_TRAUMA"/>
		  		<column name="AGENT_ORANGE_EXPOSURE"/>
		  		<column name="IONIZING_RADIATION_EXPOSURE"/>
		  		<column name="SouthwestAsiaConditions"/>
		  		<column name="HEAD_ANDOR_NECK_CANCER"/>
		  		<column name="COMBAT_VETERAN"/>
		  		<column name="Proj112Shad"/>
			</property>
		</component>
		 
		<property name="prescriptionId" column="RX_" type="java.lang.String" insert="false" update="false" />
		
		<property name="pharmacyPatientType" column="PharmacyPatientType" type="java.lang.String" />

		<component name="specialDrugTracking" class="gov.va.med.cds.template.generated.pharmacy.SpecialDrugTracking">
			<component name="totalDailyDosage" class="gov.va.med.cds.template.generated.basedatatypes.PhysicalQuantity">
				<property name="value" column="CLOZAPINE_DOSAGE_MGDAY" type="java.lang.String"/>
				<component name="unit" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
					<property name="displayText" type="java.lang.String" >
						<formula>
							(CASE
                         		WHEN (CLOZAPINE_DOSAGE_MGDAY IS NOT NULL) THEN 'MG/DAY'
                         		ELSE NULL
                      		END)
						</formula>
					</property>
				</component>
			</component>
			
			<component name="wbcObservation" class="gov.va.med.cds.template.generated.pharmacy.WbcObservation">
				<component name="count" class="gov.va.med.cds.template.generated.basedatatypes.PhysicalQuantity">
					<property name="value" column="WBC_RESULTS" type="java.lang.String"/>
				</component>
				<property name="testDate" formula="STRING(DATE_OF_WBC_TEST,'^',(VISTA_HDSI.HDSREPSQLUtil1_StationNumber()))" type="gov.va.med.cds.persistence.hibernate.common.VistaPointInTimeUserType" insert="false" update="false" />
			</component>
		</component>
		
		<component name="dataEnterer"  class="gov.va.med.cds.template.generated.common.PractitionerParticipationLite" >
			<property name="time" formula="STRING(LOGIN_DATE,'^',(VISTA_HDSI.HDSREPSQLUtil1_StationNumber()))" type="gov.va.med.cds.persistence.hibernate.common.VistaPointInTimeUserType" />
			<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" type="gov.va.med.cds.persistence.hibernate.common.VistaIdentityUserType" insert="false" update="false">
						<column name="ENTERED_BY"/>
					</property>
					<property name="assigningFacility" type="java.lang.String" insert="false" update="false">
						<formula>
								(CASE
                         			WHEN (ENTERED_BY IS NOT NULL) THEN VISTA_HDSI.HDSREPSQLUtil1_StationNumber()
                         			ELSE NULL
                      			END)
							</formula>
						</property>
						<property name="assigningAuthority" type="java.lang.String">
							<formula>
								(CASE
                         			WHEN (ENTERED_BY IS NOT NULL) THEN 'USVHA'
                         			ELSE NULL
                      			END)
							</formula>
						</property>
					</component>
					<property name="idSourceTable" type="java.lang.String">
						<formula>
							(CASE
                         		WHEN (ENTERED_BY IS NOT NULL) THEN 'VISTA200'
                         		ELSE NULL
                      		END)
						</formula>
					</property>
				<property name="name" formula="VISTA_HDSI.HDSREPSQLUtil1_MiscNameNE(ENTERED_BY)" type="gov.va.med.cds.persistence.hibernate.common.VistaPersonNameUserType"  />
			</component>	
		</component>
		
		<component name="pharmacyRequest" class="gov.va.med.cds.template.generated.pharmacy.PharmacyRequest">
			<component name="cosigner" 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="COSIGNING_PHYSICIAN" type="gov.va.med.cds.persistence.hibernate.common.VistaIdentityUserType" />
						<property name="assigningFacility" type="java.lang.String" insert="false" update="false">
							<formula>
								(CASE
                         			WHEN (COSIGNING_PHYSICIAN IS NOT NULL) THEN VISTA_HDSI.HDSREPSQLUtil1_StationNumber()
                         			ELSE NULL
                      			END)
							</formula>
						</property>
						<property name="assigningAuthority" type="java.lang.String">
							<formula>
								(CASE
                         			WHEN (COSIGNING_PHYSICIAN IS NOT NULL) THEN 'USVHA'
                         			ELSE NULL
                      			END)
							</formula>
						</property>
					</component>
					<property name="idSourceTable" type="java.lang.String">
						<formula>
							(CASE
                         		WHEN (COSIGNING_PHYSICIAN IS NOT NULL) THEN 'VISTA200'
                         		ELSE NULL
                      		END)
						</formula>
					</property>
					<property name="name" formula="VISTA_HDSI.HDSREPSQLUtil1_MiscNameNE(COSIGNING_PHYSICIAN)" type="gov.va.med.cds.persistence.hibernate.common.VistaPersonNameUserType"/>
				</component>
			</component>
			
			<component name="orderedMedication" class="gov.va.med.cds.template.generated.common.Medicine">
				<component name="cmopDrugCode" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
					<property name="code" column="CMOP_ID" type="java.lang.String" />
					<property name="codingSystem" type="java.lang.String">
						<formula>
							(CASE
                         		WHEN (CMOP_ID IS NOT NULL) THEN VISTA_HDSI.HDSREPSQLUtil1_StationNumber()||'_50' 
                         		ELSE NULL
                      		END)
						</formula>
					</property>
				</component>
				
				<component name="medicationCode" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElement">
					<property name="code" column="MEDICATIONCODE_CODE" type="java.lang.String" />
					<property name="displayText" column="MEDICATIONCODE_TEXT" type="java.lang.String" />
					<property name="codingSystem" column="MEDICATIONCODE_SYSTEM" type="java.lang.String"/>
				</component>
				
				<component name="tradeName" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
					<property name="displayText" column="TRADE_NAME" type="java.lang.String" />
					<property name="codingSystem" type="java.lang.String" >
						<formula>
							(CASE
                         		WHEN (TRADE_NAME IS NOT NULL) THEN VISTA_HDSI.HDSREPSQLUtil1_StationNumber()||'_52' 
                         		ELSE NULL
                      		END)
						</formula>
					</property>
				</component>
			</component>
			
			<component name="genericRequestIdentifier" class="gov.va.med.cds.template.generated.basedatatypes.HL72EntityIdentifier">
				<property name="identity" column="GENERIC_REQUEST_IDENTIFIER" type="java.lang.String" />
				<property name="namespaceId" type="java.lang.String" >
	                <formula>
	                 (CASE
	                     WHEN (GENERIC_REQUEST_IDENTIFIER IS NOT NULL) THEN VISTA_HDSI.HDSREPSQLUtil1_StationNumber()||'_100'
	                     ELSE NULL
	                  END)
	                </formula>
                </property>
			</component>
			
			<component name="orderLocationIdentifier" class="gov.va.med.cds.template.generated.basedatatypes.HL72LocationIdentifier">
				<property name="pointOfCare" column="CLINICX" type="java.lang.String" />
                <property name="room" column="CLINIC" type="gov.va.med.cds.persistence.hibernate.common.VistaIntegerToStringUserType" />
			</component>
			
			<component name="orderedItem" class="gov.va.med.cds.template.generated.common.PharmacyOrderableItem">
				<component name="itemCode" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
					<property name="code" column="PHARMACY_ORDERABLE_ITEM" type="gov.va.med.cds.persistence.hibernate.common.VistaIntegerToStringUserType" />
					<property name="displayText" column="PHARMACYORDERABLEITEMX" type="java.lang.String" />
					<property name="codingSystem" type="java.lang.String" >
					 	<formula>
	                 		(CASE
	                    		 WHEN (PHARMACY_ORDERABLE_ITEM IS NOT NULL) THEN VISTA_HDSI.HDSREPSQLUtil1_StationNumber()||'_52'
	                     		ELSE NULL
	                  		END)
	                	</formula>
                	</property>	
				</component>
				
				<component name="dosageFormCode" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
					<property name="code" column="DOSAGE_FORM" type="java.lang.String" />
					<property name="displayText" column="DOSAGE_NAME" type="java.lang.String" />
					<property name="codingSystem" type="java.lang.String">
						<formula>
	                 		(CASE
	                    		 WHEN (DOSAGE_FORM IS NOT NULL) THEN VISTA_HDSI.HDSREPSQLUtil1_StationNumber()||'_50.606'
	                     		ELSE NULL
	                  		END)
	                	</formula>
                	</property>	
				</component>
			</component>
			
            <component name="orderingInstitutionIdentifier" class="gov.va.med.cds.template.generated.basedatatypes.HL72OrganizationIdentifier">
                <property name="identity" column="OrderingInstitutionIdentity" type="java.lang.String" />
                <property name="name" column="DIVISIONX" type="java.lang.String" />
                <property name="assigningAuthority" type="java.lang.String" >
                    <formula>
                     (CASE
                         WHEN (OrderingInstitutionIdentity IS NOT NULL) THEN 'USVHA'
                         ELSE NULL
                      END)
                    </formula>
                </property>
            </component>
		
			<property name="orderDate" formula="STRING(ISSUE_DATE,'^',(VISTA_HDSI.HDSREPSQLUtil1_StationNumber()))" type="gov.va.med.cds.persistence.hibernate.common.VistaPointInTimeUserType" insert="false" update="false"/>
			
            <property name="status" column="PHARMACYREQUEST_STATUS" type="java.lang.String" />
            
            <component name="statusModifier" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
                <property name="code" type="java.lang.String" >
                    <formula>
                        (CASE
                        WHEN ( STATUS = 'ACTIVE' ) THEN '4500659'
                        WHEN ( STATUS = 'NON-VERIFIED' ) THEN '4500817'
                        WHEN ( STATUS = 'REFILL' ) THEN '4500869'
                        WHEN ( STATUS = 'HOLD' ) THEN '4500752'
                        WHEN ( STATUS = 'DRUG INTERACTIONS' ) THEN '4500716'
                        WHEN ( STATUS = 'SUSPENDED' ) THEN '4500913'
                        WHEN ( STATUS = 'DONE' ) THEN '4500710'
                        WHEN ( STATUS = 'EXPIRED' ) THEN '4500725'
                        WHEN ( STATUS = 'DISCONTINUED' ) THEN '4500704'
                        WHEN ( STATUS = 'DELETED' ) THEN '4500698'
                        WHEN ( STATUS = 'DISCONTINUED BY PROVIDER' ) THEN '4500706'
                        WHEN ( STATUS = 'DISCONTINUED (EDIT)' ) THEN '4500705'
                        WHEN ( STATUS = 'PROVIDER HOLD' ) THEN '4500861'
                        ELSE NULL
                        END)
                    </formula>
                </property>
                <property name="displayText" column="STATUS" type="java.lang.String"/>
                <property name="codingSystem" type="java.lang.String" >
                    <formula>
                     (CASE
                         WHEN (STATUS IS NOT NULL) THEN '99VA_52_100'
                         ELSE NULL
                      END)
                    </formula>                
                </property>
            </component>
            
        </component>
	</class>
	

    <sql-query name="OutpatientMedicationPromise.storedprocedure.rowids" callable="true">
        <![CDATA[
        { call VISTA_HDSI.HDSREPOPRxUtil1_getRxProfiles(?) }
         ]]>
    </sql-query>
    
    <sql-query name="OutpatientMedicationPromise.storedprocedure.rowids.date" callable="true">
        <![CDATA[
        { call VISTA_HDSI.HDSREPOPRxUtil1_getRxByDate(?,?,?) }
         ]]>
    </sql-query>

    <query name="OutpatientPharmacyRead1.OutpatientMedicationPromise.outpatientMedicationPromises">
        <![CDATA[
            from OutpatientPharmacyRead1 pr
            where pr.id in (:pids)
        ]]>
    </query>
 	
    <query name="OutpatientPharmacyRead1.OutpatientMedicationPromise.outpatientMedicationPromises.patient"><![CDATA[
        from OutpatientPharmacyRead1 pr
        where pr.recordIdentifier.identity in (:pids)
      ]]></query>
 
    <query name="OutpatientPharmacyRead1.OutpatientMedicationPromise.outpatientMedicationPromises.patient.identifiers">
        <![CDATA[
             from OutpatientPharmacyRead1 pr
             where pr.recordIdentifier.identity in (:pids)
             and pr.id in ( :recordIdentifiers )
         ]]> 
     </query>

    <query name="OutpatientPharmacyRead1.OutpatientMedicationPromise.outpatientMedicationPromises.date"><![CDATA[
         from OutpatientPharmacyRead1 pr
         where pr.recordIdentifier.identity in (:pids)
            and ( ( pr.expirationDate.timestamp between :startDate and :endDate ) or ( pr.expirationDate.timestamp is null )  )
    ]]></query>
</hibernate-mapping>

