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

<facts> wrapper removed from XML

parent f2e1254c
Loading
Loading
Loading
Loading
+0 −82
Original line number Diff line number Diff line
<!--
  #%L
  histream
  %%
  Copyright (C) 2013 - 2015 R.W.Majeed
  %%
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
  
       http://www.apache.org/licenses/LICENSE-2.0
  
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  #L%
  -->
<eav-data xmlns="http://sekmi.de/histream/ns/eav-data"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<!-- chronologisch impliziert, dass der zeitstempel eines nachfolgenden elementes 
	größer als alle vorangehenden elemente sein muss. Der Zeitstempel kann vor dem 
	Encounter-Start liegen -->
	<meta>
		<!-- Zeitpunkt, an dem der Export erstellt wurde bzw. Datenstand -->
		<etl-strategy>replace-visit</etl-strategy>
		<source timestamp="2015-04-21T06:58:00Z" id="test"/>
		
		<!-- weitere metadaten nötig? wertebereich, datentypen, ontologie, ...? -->
	</meta>
	<patient id="XX12345">
		<given-name>A B</given-name>
		<surname>Dampf</surname>
		<!-- Gender allows for female, male, indeterminate -->
		<!-- Gender element can also be removed or left empty -->
		<gender>female</gender>
		<birthdate>2001-01-01</birthdate>
		<deceased>2020</deceased>
		<source timestamp="2015-09-28T09:41:10Z"/>
		<encounter id="XXE12345">
			<start>2014-01-01T10:30:00</start>
			<end>2014-01-05T10:30:00</end>
			<location>Zuhause</location>
			<!-- TODO inpatient/outpatient 
			<provider>xxxa</provider>-->
			<source timestamp="2015-09-28T08:41:10Z"/>
			<facts>
				<fact concept="T:date:secs" start="2014-09-07T10:40:03"/>
				<fact concept="T:date:mins" start="2014-09-07T10:40"/>
				<fact concept="T:date:hours" start="2014-09-07T10"/>
				<fact concept="T:date:day" start="2014-09-07"/>
				<fact concept="T:date:month" start="2014-09"/>
				<fact concept="T:date:year" start="2014"/>
	
				<!-- test parsing of data types -->
				<fact concept="T:type:str"><value xsi:type="string">abc123</value></fact>
				<fact concept="T:type:int"><value xsi:type="numeric">123</value></fact>
				<!-- value attributes can be used in elements fact and value -->
				<fact concept="T:type:dec"><value xsi:type="numeric" unit="mm">123.456</value></fact>
				<fact concept="T:full" start="2010" end="2011" location="T:LOC"><value xsi:type="numeric" unit="mm">123.456</value></fact>
				<!-- 
				<fact concept="T:type:enum" type="xsi:integer">1</fact>
					-->
				<!--  test group items -->
				
				<fact concept="T:group:1">
					<value xsi:type="string">groupvalue</value>
					<modifier code="T:mod:1"/>
					<modifier code="T:mod:2"><value xsi:type="string">def456</value></modifier>
					<modifier code="T:mod:3"><value xsi:type="numeric" unit="mm">78.9</value></modifier>
				</fact>
				<!--  group without value -->
				<fact concept="T:group:2">
					<modifier code="T:mod:1"/>
				</fact>
	
			</facts>
		</encounter>	
	</patient>
	
</eav-data>
+5 −4
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ public class GroupedXMLReader implements ObservationSupplier {
	static final String DOCUMENT_ROOT = "eav-data";
	static final String PATIENT_ELEMENT = "patient";
	static final String ENCOUNTER_ELEMENT = "encounter";
	static final String FACT_WRAPPER = "facts";
	static final String FACT_ELEMENT = "fact";
	
	private ObservationFactory factory;
	private ExtensionAccessor<Patient> patientAccessor;
@@ -217,7 +217,7 @@ public class GroupedXMLReader implements ObservationSupplier {
		encounterId = reader.getAttributeValue(null, "id");
		reader.nextTag();
		while( reader.isStartElement() 
				&& !reader.getLocalName().equals(FACT_WRAPPER)
				&& !reader.getLocalName().equals(FACT_ELEMENT)
				&& !reader.getLocalName().equals("source") )
		{
			visitData.put(reader.getLocalName(), reader.getElementText());
@@ -236,7 +236,7 @@ public class GroupedXMLReader implements ObservationSupplier {
		ExternalSourceType es = readSource();
		
		// TODO assert at <facts>
		reader.nextTag();
		//reader.nextTag();

		currentVisit = visitAccessor.accessStatic(encounterId, currentPatient, (ExternalSourceType)es);
		currentVisit.setStartTime(encounterStart);
@@ -259,9 +259,10 @@ public class GroupedXMLReader implements ObservationSupplier {
		// </facts> might occur after previous call to readObservation()
		while( reader.isEndElement() ){
			switch( reader.getLocalName() ){
			case FACT_WRAPPER:
			/*case FACT_WRAPPER:
				// end of facts
				reader.nextTag();
				*/
				// fall through to end of visit, 
				// XXX this doesn't work, if facts are allowed outside of encounter (e.g. directly under patient)
			case ENCOUNTER_ELEMENT:
+8 −8
Original line number Diff line number Diff line
@@ -182,10 +182,10 @@ public class GroupedXMLWriter extends GroupedObservationHandler{
				throw new ObservationException(e);
			}
			// TODO more data
			formatIndent();
			writer.writeStartElement(GroupedXMLReader.FACT_WRAPPER);
			formatNewline();
			formatPush();
//			formatIndent();
//			writer.writeStartElement(GroupedXMLReader.FACT_WRAPPER);
//			formatNewline();
//			formatPush();
		} catch (XMLStreamException e) {
			throw new ObservationException(e);
		}
@@ -194,10 +194,10 @@ public class GroupedXMLWriter extends GroupedObservationHandler{
	protected void endEncounter(Visit visit) throws ObservationException{
		formatPop();
		try {
			formatIndent();
			writer.writeEndElement(); // fact wrapper
			formatNewline();
			formatPop();
//			formatIndent();
//			writer.writeEndElement(); // fact wrapper
//			formatNewline();
//			formatPop();
			formatIndent();
			writer.writeEndElement(); // encounter
			formatNewline();
+2 −2
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ public class TestEncryptDecrypt {
	@Test
	public void testEncryptDecryptChannels() throws GeneralSecurityException, IOException{
		
		Path source = Paths.get("examples/dwh-jaxb.xml");
		Path source = Paths.get("src/test/resources/dwh.xml");
		Path temp = Files.createTempFile("encrypted", ".enc");
		Path dec = Files.createTempFile("decrypted", ".xml");

@@ -101,7 +101,7 @@ public class TestEncryptDecrypt {
	@Test
	public void testEncryptDecryptStreams() throws GeneralSecurityException, IOException{
		
		Path source = Paths.get("examples/dwh-jaxb.xml");
		Path source = Paths.get("src/test/resources/dwh.xml");
		Path temp = Files.createTempFile("encrypted", ".enc");
		Path dec = Files.createTempFile("decrypted", ".xml");

+1 −1
Original line number Diff line number Diff line
@@ -229,7 +229,7 @@ public class FileObservationProviderTest {
	
	@Test
	public void testJAXBReader() throws FileNotFoundException, XMLStreamException, FactoryConfigurationError, JAXBException  {
		GroupedXMLReader xos = new GroupedXMLReader(factory, new FileInputStream("examples/dwh-jaxb.xml"));
		GroupedXMLReader xos = new GroupedXMLReader(factory, getClass().getResourceAsStream("/dwh.xml"));
		validateExample(xos);
		xos.close();
	}
Loading