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

<facts> wrapper removed from XML

parent f2e1254c
<!--
#%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>
......@@ -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:
......
......@@ -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();
......
......@@ -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");
......
......@@ -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();
}
......
......@@ -222,7 +222,10 @@ public class TestXMLWriter {
dbf.setIgnoringComments(true);
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc1 = db.parse(new File("examples/dwh-jaxb.xml"));
Document doc1 = null;
try( InputStream in = getClass().getResourceAsStream("/dwh.xml") ){
doc1 = db.parse(in);
}
doc1.normalizeDocument();
removeEmptyText(doc1);
......
......@@ -45,37 +45,35 @@
<!-- 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>
<!-- no more <facts> group -->
<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>
</encounter>
</patient>
......
......@@ -40,17 +40,13 @@
<location>Zuhause</location>
<!-- TODO inpatient/outpatient -->
<provider>xxxa</provider>
<facts>
<!-- test parsing of data types -->
<fact concept="source1"><value xsi:type="string">1</value></fact>
<fact concept="source1"><value xsi:type="string">2</value></fact>
<fact concept="source2"><value xsi:type="string">1</value></fact>
<fact concept="source3"><value xsi:type="string">1</value></fact>
<fact concept="source3"><value xsi:type="string">2</value></fact>
<fact concept="source3"><value xsi:type="string">99</value></fact>
</facts>
<!-- test parsing of data types -->
<fact concept="source1"><value xsi:type="string">1</value></fact>
<fact concept="source1"><value xsi:type="string">2</value></fact>
<fact concept="source2"><value xsi:type="string">1</value></fact>
<fact concept="source3"><value xsi:type="string">1</value></fact>
<fact concept="source3"><value xsi:type="string">2</value></fact>
<fact concept="source3"><value xsi:type="string">99</value></fact>
</encounter>
</patient>
<!-- weitere zeitstempel -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment