Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
histream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Raphael
histream
Commits
987f3ca5
Commit
987f3ca5
authored
Aug 02, 2016
by
R.W.Majeed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test case for concept class annotator
parent
7d664d83
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
11 deletions
+54
-11
histream-export/src/test/java/de/sekmi/histream/export/MemoryExportWriter.java
...est/java/de/sekmi/histream/export/MemoryExportWriter.java
+49
-9
histream-export/src/test/java/de/sekmi/histream/export/TestExport.java
...rt/src/test/java/de/sekmi/histream/export/TestExport.java
+2
-0
histream-export/src/test/resources/export1.xml
histream-export/src/test/resources/export1.xml
+3
-2
No files found.
histream-export/src/test/java/de/sekmi/histream/export/MemoryExportWriter.java
View file @
987f3ca5
...
...
@@ -2,14 +2,29 @@ package de.sekmi.histream.export;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.LinkedList
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* Keeps the table data in memory. Mainly useful for
* tests.
* <p>
* The patient and visit tables can be accessed with the
* constants {@link #PATIENT_TABLE} and {@link #VISIT_TABLE}.
* </p>
* @author R.W.Majeed
*
*/
public
class
MemoryExportWriter
implements
ExportWriter
{
List
<
MemoryTable
>
tables
;
public
static
final
String
PATIENT_TABLE
=
"patients"
;
public
static
final
String
VISIT_TABLE
=
"visits"
;
Map
<
String
,
MemoryTable
>
tables
;
public
MemoryExportWriter
(){
tables
=
new
LinkedList
<>();
tables
=
new
HashMap
<>();
}
public
static
class
MemoryTable
implements
TableWriter
{
List
<
String
[]>
rows
;
...
...
@@ -52,32 +67,57 @@ public class MemoryExportWriter implements ExportWriter{
@Override
public
TableWriter
openPatientTable
()
{
MemoryTable
t
=
new
MemoryTable
(
"patients"
);
tables
.
add
(
t
);
MemoryTable
t
=
new
MemoryTable
(
PATIENT_TABLE
);
tables
.
put
(
t
.
id
,
t
);
return
t
;
}
@Override
public
TableWriter
openVisitTable
()
{
MemoryTable
t
=
new
MemoryTable
(
"visits"
);
tables
.
add
(
t
);
MemoryTable
t
=
new
MemoryTable
(
VISIT_TABLE
);
tables
.
put
(
t
.
id
,
t
);
return
t
;
}
@Override
public
TableWriter
openEAVTable
(
String
id
)
{
if
(
tables
.
containsKey
(
id
)
){
throw
new
IllegalArgumentException
(
"Duplicate table id: "
+
id
);
}
MemoryTable
t
=
new
MemoryTable
(
id
);
tables
.
add
(
t
);
tables
.
put
(
t
.
id
,
t
);
return
t
;
}
public
void
dump
(){
for
(
MemoryTable
t
:
tables
){
for
(
MemoryTable
t
:
tables
.
values
()
){
t
.
dump
();
System
.
out
.
println
();
}
}
/**
* Access table data
* @param table table id
* @param column column name
* @param row row number
* @return data
* @throws IndexOutOfBoundsException if any of table, column, row does not exist
*/
public
String
get
(
String
table
,
String
column
,
int
row
)
throws
IndexOutOfBoundsException
{
MemoryTable
t
=
tables
.
get
(
table
);
if
(
t
==
null
){
throw
new
IndexOutOfBoundsException
(
"Non-existing table "
+
table
);
}
int
index
=
Arrays
.
asList
(
t
.
headers
).
indexOf
(
column
);
if
(
index
==
-
1
){
throw
new
IndexOutOfBoundsException
(
"Table "
+
table
+
" does not contain column "
+
column
);
}
if
(
row
<
0
||
row
>=
t
.
rows
.
size
()
){
throw
new
IndexOutOfBoundsException
(
"Unable to access row "
+
row
+
" in table "
+
table
+
" (has only "
+
t
.
rows
.
size
()+
" rows)"
);
}
return
t
.
rows
.
get
(
row
)[
index
];
}
@Override
public
void
close
(){
}
...
...
histream-export/src/test/java/de/sekmi/histream/export/TestExport.java
View file @
987f3ca5
...
...
@@ -34,6 +34,8 @@ public class TestExport {
try
(
ObservationSupplier
s
=
t
.
getExampleSupplier
()
){
export
.
export
(
s
,
m
);
}
// verify class lookup
Assert
.
assertEquals
(
"T:date:year"
,
m
.
get
(
MemoryExportWriter
.
VISIT_TABLE
,
"byclass"
,
0
));
m
.
dump
();
// TODO something wrong with namespaces in xpath/dom
}
...
...
histream-export/src/test/resources/export1.xml
View file @
987f3ca5
...
...
@@ -2,8 +2,8 @@
<export
xmlns=
"http://sekmi.de/ns/histream/export-v1"
xmlns:eav=
"http://sekmi.de/histream/ns/eav-data"
>
<concepts>
<group
class=
"
diag
"
>
<concept
wildcard-notation=
"
ICD10:
*"
/>
<group
class=
"
testclass
"
>
<concept
wildcard-notation=
"
T:date:yea
*"
/>
</group>
<concept
notation=
"T:full"
/>
<concept
wildcard-notation=
"CEDIS:*"
/>
...
...
@@ -18,6 +18,7 @@
<column
header=
"pid"
xpath=
"../@id"
/>
<column
header=
"vid"
xpath=
"@id"
/>
<column
header=
"start"
xpath=
"eav:start"
/>
<column
header=
"byclass"
xpath=
"eav:fact[@class='testclass']/@concept"
/>
<column
header=
"f_start"
xpath=
"eav:fact[@concept='T:full']/@start"
/>
<column
header=
"f_end"
xpath=
"eav:fact[@concept='T:full']/@end"
/>
<column
header=
"f_loc"
xpath=
"eav:fact[@concept='T:full']/@location"
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment