<?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="chemistryResult" table="VISTA_HDSI.LABORATORYX_SITESPECIMEN_60_01_EXT" lazy="false" node="chemistryResult">

		<id name="id" type="java.lang.String">
			<column name="ROWID"/>
			<generator class="assigned"/>
		</id>

		<property name="siteSpecimen" type="big_decimal" column="SITESPECIMEN" insert="false" update="false" node="siteSpecimen"/>

		<property name="laboratoryTest" type="big_decimal" column="LABORATORY_TEST" insert="false" update="false" node="laboratoryTest"/>

		<property name="referenceLow" type="java.lang.String" insert="false" update="false" node="referenceLow">
			<formula>
				(CASE
				WHEN (REFERENCE_LOW IS NOT NULL) THEN REFERENCE_LOW
				ELSE ''
				END)	
			</formula>
		</property>
		<property name="referenceHigh" type="java.lang.String" insert="false" update="false" node="referenceHigh">
			<formula>
				(CASE
				WHEN (REFERENCE_HIGH IS NOT NULL) THEN REFERENCE_HIGH
				ELSE ''
				END)	
			</formula>
		</property>
		<property name="criticalLow" type="java.lang.String" insert="false" update="false" node="criticalLow">
			<formula>
				(CASE
				WHEN (CRITICAL_LOW IS NOT NULL) THEN CRITICAL_LOW
				ELSE ''
				END)	
			</formula>
		</property>
		<property name="criticalHigh" type="java.lang.String" insert="false" update="false" node="criticalHigh">
			<formula>
				(CASE
				WHEN (CRITICAL_HIGH IS NOT NULL) THEN CRITICAL_HIGH
				ELSE ''
				END)	
			</formula>
		</property>

		<property name="valueInterpretation" type="java.lang.String" formula="''" node="valueInterpretation"/>

		<component name="observationDate" node="observationDate">
			<property name="literal" formula="''" type="java.lang.String" node="literal"/>
		</component>

		<property name="observationStatus" type="java.lang.String" formula="'F'" node="observationStatus"/>

		<component name="testIdentifier" node="testIdentifier">
			<property name="code" type="java.lang.String" column="LOINCCODEX" node="code"/>
			<property name="displayText" type="java.lang.String" node="displayText">
				<formula>
					(CASE
					WHEN (TestIdentifierTextExt IS NOT NULL) THEN TestIdentifierTextExt
					ELSE ''
					END)				
				</formula>
			</property>
			<property name="codingSystem" type="java.lang.String" node="codingSystem">
				<formula>
					(CASE
					WHEN ((LOINCCODEX IS NOT NULL) AND (TestIdentifierTextExt IS NOT NULL)) THEN VISTA_HDSI.HDSREPSQLUtil1_StationNumber()||'_95_3'
					ELSE NULL
					END)
				</formula>
			</property>
			<property name="alternateCode" type="java.lang.String" node="alternateCode">
				<formula>
					(CASE
					WHEN (LOINCCODEX IS NOT NULL) THEN TestIdentifierAlternateCodeExt
					ELSE NULL
					END)				
				</formula>
			</property>
			<property name="alternateCodingSystem" type="java.lang.String" node="alternateCodingSystem">
				<formula>
					(CASE
					WHEN (LOINCCODEX IS NOT NULL) THEN '99VA95.3'
					ELSE NULL
					END)				
				</formula>
			</property>
			<property name="originalText" type="java.lang.String" node="originalText">
				<formula>
					(CASE
					WHEN (TestIdentifierOriginalTextExt IS NOT NULL) THEN TestIdentifierOriginalTextExt
					ELSE ''
					END)				
				</formula>
			</property>
		</component>

		<property name="referenceRange" type="java.lang.String" node="referenceRange">
			<formula>
				(CASE
				WHEN ((REFERENCE_LOW IS NOT NULL) AND (REFERENCE_HIGH IS NOT NULL)) THEN REFERENCE_LOW ||'-'||REFERENCE_HIGH
				ELSE ''
				END)				
				</formula>
		</property>

		<component name="labCommentEvents" node="labCommentEvents">
			<set name="labCommentEvents" table="VISTA_HDSI.LABX_INTERPRETATION_60_07" order-by="ChildSub2" fetch="subselect" batch-size="100" node="labCommentEvent//comments">
				<key column="SUB_SITESPECIMEN" update="false"/>
				<element type="java.lang.String" column="INTERPRETATION" node="comment"/>
			</set>
		</component>

		<property name="observationValue" type="java.lang.String" formula="''" node="observationValue"/>

		<component name="observationUnits" node="observationUnits">
			<property name="code" type="java.lang.String" insert="false" update="false" node="code">
				<formula>
					(CASE
					WHEN (UNITS IS NOT NULL) THEN UNITS
					ELSE ''
					END)
				</formula>
			</property>
			<property name="displayText" type="java.lang.String" insert="false" update="false" node="displayText">
				<formula>
					(CASE
					WHEN (UNITS IS NOT NULL) THEN UNITS
					ELSE ''
					END)
				</formula>
			</property>
			<property name="codingSystem" formula="VISTA_HDSI.HDSREPSQLUtil1_StationNumber()||'_60_01'" type="java.lang.String" node="codingSystem"/>
		</component>

		<!-- from 63_04 -->
		<component name="producerCode" node="producerCode">
			<property name="code" type="java.lang.String" formula="''" node="code"/>
			<property name="displayText" type="java.lang.String" formula="''" node="displayText"/>
			<property name="codingSystem" type="java.lang.String" formula="VISTA_HDSI.HDSREPSQLUtil1_StationNumber()" node="codingSystem"/>
		</component>

	</class>

	<query name="LabChemHemRead1.labTests.labTest.chemistryResults.chemistryResult"> 
	 <![CDATA[ 
	 from chemistryResult chemistryResult
	 where chemistryResult.laboratoryTest = :labTestFieldNum and chemistryResult.siteSpecimen = :siteSpecimen
	 ]]>
	</query>

</hibernate-mapping>