Commit a9f30afa authored by R.W.Majeed's avatar R.W.Majeed
Browse files

fixed missed duplicate during validation (when first concept for a patient is a duplicate)

parent fb9b3622
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -75,6 +75,10 @@ public class Validator extends AbstractObservationHandler implements Transformat


			// clear concepts
			// clear concepts
			concepts.clear();
			concepts.clear();
			// add concept
			if( duplicateConceptCheck ){
				concepts.add(new StartPlusConcept(t));
			}
			
			
			prevPatient = patid; // remember patient to suppress errors for the same patient
			prevPatient = patid; // remember patient to suppress errors for the same patient


+18 −0
Original line number Original line Diff line number Diff line
@@ -51,4 +51,22 @@ public class TestValidator {
			Streams.transfer(os, v);
			Streams.transfer(os, v);
		}
		}
	}
	}
	@Test
	public void validateData4() throws Exception{
		// duplicate concepts
		try( ObservationSupplier os = ETLObservationSupplier.load(getClass().getResource("/data/test-4-datasource.xml")) ){
			Validator v = new Validator(true,true);
			v.setErrorHandler(e -> {throw new RuntimeException(e);});
			Streams.transfer(os, v);
		}catch( RuntimeException e ){
			if( e.getCause() instanceof DuplicateConceptException ){
				// expected behaviour
				return;
			}else{
				// unexpected exceptoin
				throw e;
			}
		}
		Assert.fail("Exception expected");
	}
}
}
+79 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<datasource version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<!-- Duplicate concept for patient -->
	<meta>
		<id>LTx_PH_ILD_COPD</id>
		<etl-strategy>replace-source</etl-strategy>
	</meta>
	
	 <patient-table>
		<source xsi:type="csv-file">
			<url>test-4-table.csv</url>
			<separator>;</separator>
		</source>
		<idat>
      <!-- Vorname, Nachname, Geschlecht unbekannt -->
			<patient-id column="Pheno-ID"/>
			<given-name column="Pheno-ID"/>
			<surname column="Pheno-ID"/>
		</idat>
		<ignore xsi:type="string" column="*"/>
	</patient-table>
	<visit-table>
		<source xsi:type="csv-file">
			<url>test-4-table.csv</url>
			<type>text/csv</type>
			<separator>;</separator>
		</source>
		<idat>
			<patient-id column="Pheno-ID"/>
			<visit-id column="Zeitpunkt"/>
			<start column="Zeitpunkt" format="d.M.u[ H[:m[:s]]]"/>
		</idat>
	<ignore xsi:type="string" column="*"/>
	</visit-table>
	<eav-table>
		<source xsi:type="csv-file">
			<url>test-4-table.csv</url>
			<type>text/csv</type>
			<separator>;</separator>
		</source>	
		<idat>
			<patient-id column="Pheno-ID"/>
			<visit-id column="Zeitpunkt"/>
		</idat>
		<mdat>
			<concept column="Export-Param"/>
			<start column="Zeitpunkt" format="d.M.u[ H[:m[:s]]]"/>
			<end column="Zeitpunkt" format="d.M.u[ H[:m[:s]]]"/>
			<type constant-value="string"/>
			<value column="Wert" na=""/>
			<unit column="Einheiten" na=""/>
		</mdat>
		<virtual>
			<value column="Diagnose" xsi:type="string" na="">
				<map>					
					<otherwise log-warning="Unexpected value" action="drop-fact" />
				</map>
			</value>
			<value column="Zusatzdiagnose" xsi:type="string" na="">
				<map>
					<case value="IPF" set-concept="B:DP-ID-IPF" set-value=""/>
					<case value="UIP" set-concept="B:DP-ID-IPF" set-value=""/>
					<otherwise log-warning="Unexpected value" action="drop-fact" />
				</map>
			</value>
			<value column="Probenart" xsi:type="string" na="">
				<map>
					<otherwise action="drop-fact"/>
				</map>
			</value>
			<value column="Diesease Area" xsi:type="string" na="">
				<map>
					<otherwise action="drop-fact"/>
				</map>
			</value>
		</virtual>	
		<ignore xsi:type="string" column="*"/>
	</eav-table>
</datasource>
+3 −0
Original line number Original line Diff line number Diff line
Pheno-ID;Bereich;Zeitpunkt;Export-Param;Wert;Einheiten;
Mmqp212;Biobank-IDs;21.04.2016;Zusatzdiagnose;UIP;;
Mmqp212;Biobank-IDs;21.04.2016;Zusatzdiagnose;IPF;;
 No newline at end of file