<?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="CHEMISTRY_RESULT_V" lazy="false" name="gov.va.med.cds.template.generated.lab.ChemistryResult" >
		<id type="java.lang.Long">
			<column name="CHEMISTRY_RESULT_ID" />
			<generator class="sequence">
				<param name="sequence">chemistry_result_seq_id</param>
			</generator>
		</id>

		<property name="valueInterpretation" column="VALUE_INTERPRETATION" type="java.lang.String" />

		<property name="observationStatus" column="OBSERVATION_STATUS" type="java.lang.String" />

		<component name="testIdentifier" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementExtended">
			<property name="code" column="TEST_ID_CODE" type="java.lang.String" />
			<property name="displayText" column="TEST_ID_DSPLYTXT" type="java.lang.String" />
			<property name="codingSystem" column="TEST_ID_CODSYS" type="java.lang.String" />
			<property name="codingSystemVersion" column="TEST_ID_CODSYS_VER" type="java.lang.String" />
			<property name="alternateCode" column="TEST_ID_ALT_CODE" type="java.lang.String" />
			<property name="alternateDisplayText" column="TEST_ID_ALT_DSPLYTXT" type="java.lang.String" />
			<property name="alternateCodingSystem" column="TEST_ID_ALT_CODSYS" type="java.lang.String" />
			<property name="alternateCodingSystemVersion" column="TEST_ID_ALT_CODSYS_VER" type="java.lang.String" />
			<property name="originalText" column="TEST_ID_ORIG_TXT" type="java.lang.String" />
		</component>

		<property name="referenceRange" column="REFERENCE_RANGE" type="java.lang.String" />

		<list name="labCommentEvents" fetch="subselect" batch-size="100">
			<key column="CHEMISTRY_RESULT_ID" not-null="true" update="false" />
			<list-index column="LINE_NBR" />
			<one-to-many entity-name="ChemistryResultComments" />
		</list>

		<property name="observationValue" column="OBSERVATION_VALUE" type="java.lang.String" />

		<component name="observationUnits" class="gov.va.med.cds.template.generated.basedatatypes.HL72CodedElementLite">
			<property name="code" column="OBSERVATION_UNIT_CODE" type="java.lang.String" />
			<property name="displayText" column="OBSERVATION_UNIT_DSPLYTXT" type="java.lang.String" />
			<property name="codingSystem" column="OBSERVATION_UNIT_CODSYS" type="java.lang.String" />
		</component>

		<component name="performingOrganization"  class="gov.va.med.cds.template.generated.lab.PerformingOrganization">
			<component name="identifier" class="gov.va.med.cds.template.generated.basedatatypes.HL72OrganizationIdentifierExtended">
				<property name="identity" column="PERF_ORG_IDENTITY" type="java.lang.String" />
				<property name="name" column="PERF_ORG_NAME" type="java.lang.String" />
				<property name="assigningAuthority" column="PERF_ORG_ASSIGNING_AUTHORITY" type="java.lang.String" />
				<property name="nameTypeCode" column="PERF_ORG_NAME_TYP_CODE" type="java.lang.String" />
				<property name="identityTypeCode" column="PERF_ORG_IDENTITY_TYP_CODE" type="java.lang.String" />
				<property name="nameRepresentation" column="PERF_ORG_NAME_REP" type="java.lang.String" />
				<property name="stationNumber" column="PERF_ORG_STATION_NUMBER" type="java.lang.String" />
			</component>

			<component name="address" class="gov.va.med.cds.template.generated.basedatatypes.UsMailingAddress">
				<property name="line1" column="PERF_ORG_ADDR_LINE1" type="java.lang.String" />
				<property name="line2" column="PERF_ORG_ADDR_LINE2" type="java.lang.String" />
				<property name="city" column="PERF_ORG_ADDR_CITY" type="java.lang.String" />
				<property name="postalCode" column="PERF_ORG_ADDR_POSTAL_CODE" type="java.lang.String" />
				<property name="country" column="PERF_ORG_ADDR_COUNTRY" type="java.lang.String" not-null="true" />
				<property name="state" column="PERF_ORG_ADDR_STATE" type="java.lang.String" not-null="true" />
			</component>
		</component>
	</class>

	<class entity-name="ChemistryResultComments" table="CHEMRSLT_COMMENT_EVENT_V" name="gov.va.med.cds.template.generated.lab.LabCommentEvent">
		<id name="id" type="java.lang.Long">
			<column name="CHEMRSLT_COMMENT_EVENT_ID" />
			<generator class="sequence">
				<param name="sequence">CHEMRSLT_CMNT_EVENT_SEQ_ID</param>
			</generator>
		</id>

		<list name="comments" table="CHEMRSLT_COMMENT_V" cascade="all" fetch="subselect" batch-size="100">
			<key column="CHEMRSLT_COMMENT_EVENT_ID" not-null="true" update="false"/>
			<list-index column="LINE_NBR" />
			<element type="string" column="COMMENT_TXT"  />
		</list>

	</class>
</hibernate-mapping>