Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Raphael
histream
Commits
a30513d1
Commit
a30513d1
authored
Aug 22, 2015
by
R.W.Majeed
Browse files
patient and visit extensions implemented
parent
fe627d90
Changes
4
Hide whitespace changes
Inline
Side-by-side
histream-import/src/main/java/de/sekmi/histream/etl/ETLObservationSupplier.java
View file @
a30513d1
...
...
@@ -14,6 +14,7 @@ import de.sekmi.histream.etl.config.PatientTable;
import
de.sekmi.histream.etl.config.VisitTable
;
import
de.sekmi.histream.etl.config.WideTable
;
import
de.sekmi.histream.ext.Patient
;
import
de.sekmi.histream.ext.Visit
;
/**
* Supplier for observations which are loaded from arbitrary
...
...
@@ -71,7 +72,10 @@ public class ETLObservationSupplier implements ObservationSupplier{
try
{
pr
=
pt
.
open
(
factory
);
vr
=
vt
.
open
(
factory
);
queue
=
new
FactGroupingQueue
(
pr
,
vr
,
factory
.
getExtensionAccessor
(
Patient
.
class
),
ds
.
getMeta
().
getSource
());
queue
=
new
FactGroupingQueue
(
pr
,
vr
,
factory
.
getExtensionAccessor
(
Patient
.
class
),
factory
.
getExtensionAccessor
(
Visit
.
class
),
ds
.
getMeta
().
getSource
());
// open all tables
wr
=
new
ArrayList
<>(
wt
.
size
());
...
...
histream-import/src/main/java/de/sekmi/histream/etl/FactGroupingQueue.java
View file @
a30513d1
...
...
@@ -10,6 +10,7 @@ import de.sekmi.histream.ExtensionAccessor;
import
de.sekmi.histream.Observation
;
import
de.sekmi.histream.ext.ExternalSourceType
;
import
de.sekmi.histream.ext.Patient
;
import
de.sekmi.histream.ext.Visit
;
/**
* Algorithm:
...
...
@@ -23,15 +24,20 @@ import de.sekmi.histream.ext.Patient;
*
*/
public
class
FactGroupingQueue
{
private
RecordSupplier
<?
extends
FactRow
>
patientTable
,
visitTable
;
private
RecordSupplier
<
PatientRow
>
patientTable
;
private
RecordSupplier
<
VisitRow
>
visitTable
;
private
ExtensionAccessor
<
Patient
>
patientAccessor
;
private
ExtensionAccessor
<
Visit
>
visitAccessor
;
private
ExternalSourceType
metaSource
;
private
List
<
RecordSupplier
<?
extends
FactRow
>>
factTables
;
private
FactRow
currentPatient
,
nextVisit
;
private
PatientRow
currentPatient
;
private
VisitRow
nextVisit
;
private
Patient
currentPatientInstance
;
private
Visit
currentVisitInstance
;
private
String
currentVisitId
;
private
List
<
FactRow
>
currentRows
;
...
...
@@ -58,10 +64,12 @@ public class FactGroupingQueue{
}
public
FactGroupingQueue
(
RecordSupplier
<
?
extends
Fac
tRow
>
patientTable
,
RecordSupplier
<
?
extends
Fac
tRow
>
visitTable
,
ExtensionAccessor
<
Patient
>
patientAccessor
,
ExternalSourceType
metaSource
){
public
FactGroupingQueue
(
RecordSupplier
<
Patien
tRow
>
patientTable
,
RecordSupplier
<
Visi
tRow
>
visitTable
,
ExtensionAccessor
<
Patient
>
patientAccessor
,
ExtensionAccessor
<
Visit
>
visitAccessor
,
ExternalSourceType
metaSource
){
this
.
patientTable
=
patientTable
;
this
.
patientAccessor
=
patientAccessor
;
Objects
.
requireNonNull
(
patientAccessor
);
Objects
.
requireNonNull
(
visitAccessor
);
this
.
patientAccessor
=
patientAccessor
;
this
.
visitAccessor
=
visitAccessor
;
this
.
visitTable
=
visitTable
;
this
.
factTables
=
new
ArrayList
<>();
this
.
workQueue
=
new
ArrayDeque
<>();
...
...
@@ -78,7 +86,11 @@ public class FactGroupingQueue{
*/
private
void
patientChanged
(){
currentPatientInstance
=
patientAccessor
.
accessStatic
(
currentPatient
.
getPatientId
(),
metaSource
);
// TODO sync patient with extension factory
currentPatientInstance
.
setBirthDate
(
currentPatient
.
getBirthDate
());
currentPatientInstance
.
setDeathDate
(
currentPatient
.
getDeathDate
());
currentPatientInstance
.
setSex
(
currentPatient
.
getSex
());
// TODO sync patient with extension factory / add fields
addFactsToWorkQueue
(
currentPatient
);
}
...
...
@@ -88,12 +100,18 @@ public class FactGroupingQueue{
* If {@link #currentVisitId} is not null, nextVisit will contain the current visit's information.
*/
private
void
visitChanged
(){
// TODO for facts contained in visit, add facts to work queue
if
(
currentVisitId
==
null
){
// set visit extension to null
// TODO later support facts without encounter
}
else
{
// TODO sync visit with extension factory
// sync visit with extension factory
currentVisitInstance
=
visitAccessor
.
accessStatic
(
currentVisitId
,
currentPatientInstance
,
metaSource
);
currentVisitInstance
.
setStartTime
(
nextVisit
.
getStartTime
());
currentVisitInstance
.
setEndTime
(
nextVisit
.
getEndTime
());
currentVisitInstance
.
setLocationId
(
nextVisit
.
getLocationId
());
currentVisitInstance
.
setStatus
(
nextVisit
.
getStatus
());
addFactsToWorkQueue
(
nextVisit
);
}
}
...
...
@@ -124,6 +142,7 @@ public class FactGroupingQueue{
for
(
Observation
f
:
r
.
getFacts
()
){
// set patient extension
patientAccessor
.
set
(
f
,
currentPatientInstance
);
visitAccessor
.
set
(
f
,
currentVisitInstance
);
workQueue
.
add
(
f
);
}
}
...
...
histream-import/src/main/java/de/sekmi/histream/etl/config/VisitTable.java
View file @
a30513d1
...
...
@@ -28,6 +28,7 @@ public class VisitTable extends Table<VisitRow> implements ConceptTable{
StringColumn
visitId
;
DateTimeColumn
start
;
DateTimeColumn
end
;
StringColumn
location
;
// TODO inpatient/outpatient state
Column
<?>[]
ignore
;
}
...
...
@@ -39,6 +40,9 @@ public class VisitTable extends Table<VisitRow> implements ConceptTable{
map
.
registerColumn
(
idat
.
visitId
);
map
.
registerColumn
(
idat
.
start
);
map
.
registerColumn
(
idat
.
end
);
if
(
idat
.
location
!=
null
){
map
.
registerColumn
(
idat
.
location
);
}
for
(
Concept
c
:
concepts
){
mapRegisterConcept
(
map
,
c
);
}
...
...
@@ -53,6 +57,9 @@ public class VisitTable extends Table<VisitRow> implements ConceptTable{
visit
.
setPatientId
(
idat
.
patientId
.
valueOf
(
map
,
row
));
visit
.
setStartTime
(
idat
.
start
.
valueOf
(
map
,
row
));
visit
.
setEndTime
(
idat
.
end
.
valueOf
(
map
,
row
));
if
(
idat
.
location
!=
null
){
visit
.
setLocationId
(
idat
.
location
.
valueOf
(
map
,
row
));
}
// TODO other
// concepts
...
...
histream-import/src/test/java/de/sekmi/histream/etl/TestETLSupplier.java
View file @
a30513d1
...
...
@@ -10,10 +10,12 @@ import org.junit.Assert;
import
org.junit.Before
;
import
org.junit.Test
;
import
de.sekmi.histream.DateTimeAccuracy
;
import
de.sekmi.histream.Observation
;
import
de.sekmi.histream.ObservationFactory
;
import
de.sekmi.histream.etl.config.DataSource
;
import
de.sekmi.histream.ext.Patient
;
import
de.sekmi.histream.ext.Visit
;
import
de.sekmi.histream.impl.ObservationFactoryImpl
;
import
de.sekmi.histream.impl.SimplePatientExtension
;
import
de.sekmi.histream.impl.SimpleVisitExtension
;
...
...
@@ -64,7 +66,26 @@ public class TestETLSupplier {
Patient
p
=
fact
.
getExtension
(
Patient
.
class
);
Assert
.
assertNotNull
(
p
);
Assert
.
assertEquals
(
"p1"
,
p
.
getId
());
Assert
.
assertEquals
(
DateTimeAccuracy
.
parsePartialIso8601
(
"2003-02-01"
),
p
.
getBirthDate
());
Assert
.
assertEquals
(
DateTimeAccuracy
.
parsePartialIso8601
(
"2003-02-11"
),
p
.
getDeathDate
());
// TODO verify other patient information
}
@Test
public
void
testVisitExtension
()
throws
IOException
{
Observation
fact
=
os
.
get
();
Assert
.
assertNotNull
(
fact
);
Visit
v
=
fact
.
getExtension
(
Visit
.
class
);
Assert
.
assertNotNull
(
v
);
Assert
.
assertEquals
(
"v1"
,
v
.
getId
());
// TODO make sure custom partial date format is parsed correctly
//Assert.assertEquals(DateTimeAccuracy.parsePartialIso8601("2013-03-20T09:00"), v.getStartTime());
Assert
.
assertEquals
(
DateTimeAccuracy
.
parsePartialIso8601
(
"2013-03-21T13:00:21"
),
v
.
getEndTime
());
Assert
.
assertEquals
(
"v1"
,
v
.
getId
());
Assert
.
assertEquals
(
null
,
v
.
getLocationId
());
}
}
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