Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
elexis
elexis-3-core
Commits
015b4ff2
Commit
015b4ff2
authored
Oct 07, 2021
by
thomas
Browse files
[22205] add observation types boolean and date to findings and templates
parent
63a9d2a2
Pipeline
#22616
passed with stages
in 4 minutes and 15 seconds
Changes
9
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bundles/ch.elexis.core.findings.fhir.model/src/ch/elexis/core/findings/fhir/model/Observation.java
View file @
015b4ff2
...
...
@@ -4,6 +4,7 @@ import java.math.BigDecimal;
import
java.time.LocalDateTime
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
...
...
@@ -350,6 +351,24 @@ public class Observation
return
Optional
.
empty
();
}
@Override
public
void
setDateTimeValue
(
Date
value
){
Optional
<
IBaseResource
>
resource
=
loadResource
();
if
(
resource
.
isPresent
())
{
accessor
.
setDateTimeValue
((
DomainResource
)
resource
.
get
(),
value
);
saveResource
(
resource
.
get
());
}
}
@Override
public
Optional
<
Date
>
getDateTimeValue
(){
Optional
<
IBaseResource
>
resource
=
loadResource
();
if
(
resource
.
isPresent
())
{
return
accessor
.
getDateTimeValue
((
DomainResource
)
resource
.
get
());
}
return
Optional
.
empty
();
}
@Override
public
Optional
<
String
>
getNumericValueUnit
(){
Optional
<
IBaseResource
>
resource
=
loadResource
();
...
...
bundles/ch.elexis.core.findings.ui/META-INF/MANIFEST.MF
View file @
015b4ff2
...
...
@@ -22,7 +22,8 @@ Require-Bundle: ch.elexis.core.data,
org.eclipse.core.databinding.beans,
org.eclipse.core.runtime,
ch.elexis.core.findings.templates,
ch.elexis.core.ui.dbcheck
ch.elexis.core.ui.dbcheck,
org.eclipse.nebula.widgets.cdatetime
Bundle-ActivationPolicy: lazy
Import-Package: ch.elexis.core.services.holder,
ch.rgw.io,
...
...
bundles/ch.elexis.core.findings.ui/src/ch/elexis/core/findings/ui/composites/CompositeBoolean.java
View file @
015b4ff2
...
...
@@ -82,9 +82,6 @@ public class CompositeBoolean extends Composite implements ICompositeSaveable {
private
void
createContents
(
String
title
,
Boolean
value
,
boolean
componentChild
){
// Composite c = new Composite(this, SWT.NONE);
// c.setLayout(SWTHelper.createGridLayout(true, 2));
// c.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 2, 1));
lbl
=
new
Label
(
this
,
SWT
.
NONE
);
lbl
.
setText
(
title
);
...
...
@@ -98,12 +95,6 @@ public class CompositeBoolean extends Composite implements ICompositeSaveable {
fieldButton
.
setLayoutData
(
gdFieldText
);
fieldButton
.
setSelection
(
value
);
// Label lblTmp = new Label(this, SWT.NONE);
// lblTmp.setText("");
// GridData gdUnit = new GridData(SWT.FILL, SWT.TOP, false, false);
// gdUnit.widthHint = 40;
// lblTmp.setLayoutData(gdUnit);
fieldButton
.
addTraverseListener
(
new
TraverseListener
()
{
@Override
...
...
@@ -168,7 +159,7 @@ public class CompositeBoolean extends Composite implements ICompositeSaveable {
@Override
public
String
getFieldTextValue
(){
return
fieldButton
!=
null
?
(
fieldButton
.
getSelection
()
?
"Ja"
:
"Nein"
)
:
""
;
return
fieldButton
!=
null
?
Boolean
.
valueOf
(
fieldButton
.
getSelection
()
).
toString
(
)
:
""
;
}
@Override
...
...
bundles/ch.elexis.core.findings.ui/src/ch/elexis/core/findings/ui/composites/CompositeDate.java
View file @
015b4ff2
package
ch.elexis.core.findings.ui.composites
;
import
java.time.LocalDateTime
;
import
java.time.ZoneId
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Optional
;
import
org.eclipse.jface.action.Action
;
import
org.eclipse.nebula.widgets.cdatetime.CDT
;
import
org.eclipse.nebula.widgets.cdatetime.CDateTime
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.events.TraverseEvent
;
import
org.eclipse.swt.events.TraverseListener
;
import
org.eclipse.swt.events.VerifyEvent
;
import
org.eclipse.swt.events.VerifyListener
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.layout.GridLayout
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Label
;
import
org.eclipse.swt.widgets.Text
;
import
ch.elexis.core.findings.ICoding
;
import
ch.elexis.core.findings.IFinding
;
...
...
@@ -27,14 +28,12 @@ import ch.elexis.core.findings.codes.CodingSystem;
import
ch.elexis.core.findings.ui.services.FindingsServiceComponent
;
import
ch.elexis.core.findings.ui.util.FindingsUiUtil
;
import
ch.elexis.core.findings.util.ModelUtil
;
import
ch.elexis.core.ui.util.SWTHelper
;
public
class
CompositeDate
extends
Composite
implements
ICompositeSaveable
{
private
Text
fieldText
;
private
IFinding
iFinding
;
private
ObservationComponent
backboneComponent
;
private
Label
lblUnit
;
private
Label
lbl
;
private
CDateTime
dateTime
;
private
List
<
Action
>
toolbarActions
=
new
ArrayList
<>();
private
ObservationType
observationType
;
...
...
@@ -52,36 +51,24 @@ public class CompositeDate extends Composite implements ICompositeSaveable {
setLayout
(
gd
);
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
true
,
true
));
String
unit
=
null
;
String
numeric
=
null
;
List
<
ICoding
>
codings
=
null
;
String
title
=
null
;
String
textV
alue
=
null
;
Date
v
alue
=
null
;
if
(
backboneComponent
!=
null
)
{
this
.
observationType
=
backboneComponent
.
getTypeFromExtension
(
ObservationType
.
class
);
if
(
ObservationType
.
TEXT
.
equals
(
observationType
))
{
textValue
=
backboneComponent
.
getStringValue
().
orElse
(
""
);
}
else
if
(
ObservationType
.
NUMERIC
.
equals
(
observationType
))
{
unit
=
backboneComponent
.
getNumericValueUnit
().
orElse
(
""
);
numeric
=
backboneComponent
.
getNumericValue
().
isPresent
()
?
backboneComponent
.
getNumericValue
().
get
().
toPlainString
()
:
""
;
}
value
=
backboneComponent
.
getDateTimeValue
().
orElse
(
new
Date
());
codings
=
backboneComponent
.
getCoding
();
}
else
if
(
iFinding
instanceof
IObservation
)
{
IObservation
iObservation
=
(
IObservation
)
iFinding
;
this
.
observationType
=
iObservation
.
getObservationType
();
if
(
ObservationType
.
TEXT
.
equals
(
iObservation
.
getObservationType
()))
{
textValue
=
iObservation
.
getStringValue
().
orElse
(
""
);
}
else
if
(
ObservationType
.
NUMERIC
.
equals
(
iObservation
.
getObservationType
()))
{
unit
=
iObservation
.
getNumericValueUnit
().
orElse
(
""
);
numeric
=
iObservation
.
getNumericValue
().
isPresent
()
?
iObservation
.
getNumericValue
().
get
().
toPlainString
()
:
""
;
}
value
=
iObservation
.
getDateTimeValue
().
orElse
(
new
Date
());
codings
=
iObservation
.
getCoding
();
}
...
...
@@ -94,71 +81,26 @@ public class CompositeDate extends Composite implements ICompositeSaveable {
title
=
iFinding
.
getText
().
orElse
(
""
);
}
createContents
(
title
,
textValue
,
unit
,
numeric
,
backboneComponent
!=
null
);
createContents
(
title
,
value
,
backboneComponent
!=
null
);
}
private
void
createContents
(
String
title
,
String
textValue
,
String
unit
,
String
numeric
,
private
void
createContents
(
String
title
,
Date
value
,
boolean
componentChild
){
Composite
c
=
new
Composite
(
this
,
SWT
.
NONE
);
c
.
setLayout
(
SWTHelper
.
createGridLayout
(
true
,
2
));
c
.
setLayoutData
(
new
GridData
(
SWT
.
LEFT
,
SWT
.
TOP
,
false
,
false
,
2
,
1
));
lbl
=
new
Label
(
c
,
SWT
.
NONE
);
lbl
=
new
Label
(
this
,
SWT
.
NONE
);
lbl
.
setText
(
title
);
GridData
minGD
=
new
GridData
(
SWT
.
LEFT
,
SWT
.
BOTTOM
,
tru
e
,
false
,
1
,
1
);
GridData
minGD
=
new
GridData
(
SWT
.
LEFT
,
SWT
.
BOTTOM
,
fals
e
,
false
);
lbl
.
setLayoutData
(
minGD
);
if
(
numeric
!=
null
&&
unit
!=
null
)
{
if
(!
componentChild
&&
iFinding
instanceof
IObservation
)
{
toolbarActions
.
addAll
(
FindingsUiUtil
.
createToolbarSubComponents
(
c
,
(
IObservation
)
iFinding
,
1
));
}
fieldText
=
new
Text
(
this
,
SWT
.
BORDER
);
fieldText
.
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
TOP
,
true
,
false
));
fieldText
.
setText
(
numeric
);
fieldText
.
addVerifyListener
(
new
VerifyListener
()
{
@Override
public
void
verifyText
(
VerifyEvent
e
){
// checks if a numeric text is inserted
String
txt
=
e
.
text
;
if
(!
txt
.
isEmpty
())
{
StringBuilder
builder
=
new
StringBuilder
(((
Text
)
e
.
widget
).
getText
());
if
(
e
.
start
==
e
.
end
)
{
builder
.
insert
(
e
.
start
,
txt
);
}
else
{
builder
.
replace
(
e
.
start
,
e
.
end
,
txt
);
}
if
(!
builder
.
toString
().
matches
(
"-?(\\d+\\.)?\\d*$"
))
{
e
.
doit
=
false
;
}
}
}
});
lblUnit
=
new
Label
(
this
,
SWT
.
NONE
);
GridData
gdUnit
=
new
GridData
(
SWT
.
FILL
,
SWT
.
TOP
,
false
,
false
);
gdUnit
.
widthHint
=
40
;
lblUnit
.
setLayoutData
(
gdUnit
);
lblUnit
.
setAlignment
(
SWT
.
CENTER
);
lblUnit
.
setText
(
unit
);
}
if
(
fieldText
==
null
)
{
fieldText
=
new
Text
(
this
,
SWT
.
BORDER
|
SWT
.
MULTI
|
SWT
.
V_SCROLL
);
GridData
gdFieldText
=
new
GridData
(
SWT
.
FILL
,
SWT
.
TOP
,
true
,
false
);
gdFieldText
.
heightHint
=
40
;
fieldText
.
setLayoutData
(
gdFieldText
);
fieldText
.
setText
(
textValue
!=
null
?
textValue
:
""
);
Label
lblTmp
=
new
Label
(
this
,
SWT
.
NONE
);
lblTmp
.
setText
(
""
);
GridData
gdUnit
=
new
GridData
(
SWT
.
FILL
,
SWT
.
TOP
,
false
,
false
);
gdUnit
.
widthHint
=
40
;
lblTmp
.
setLayoutData
(
gdUnit
);
if
(
dateTime
==
null
)
{
dateTime
=
new
CDateTime
(
this
,
CDT
.
HORIZONTAL
|
CDT
.
DATE_SHORT
|
CDT
.
DROP_DOWN
|
SWT
.
BORDER
|
CDT
.
TAB_FIELDS
);
GridData
gdFieldText
=
new
GridData
(
SWT
.
LEFT
,
SWT
.
CENTER
,
true
,
false
);
dateTime
.
setLayoutData
(
gdFieldText
);
dateTime
.
setSelection
(
value
);
fieldText
.
addTraverseListener
(
new
TraverseListener
()
{
dateTime
.
addTraverseListener
(
new
TraverseListener
()
{
@Override
public
void
keyTraversed
(
TraverseEvent
e
){
...
...
@@ -181,16 +123,8 @@ public class CompositeDate extends Composite implements ICompositeSaveable {
@Override
public
void
hideLabel
(
boolean
all
){
if
(
lblUnit
!=
null
&&
all
)
{
lblUnit
.
setVisible
(
false
);
GridData
minGD
=
new
GridData
(
SWT
.
FILL
,
SWT
.
TOP
,
false
,
false
);
minGD
.
widthHint
=
0
;
minGD
.
heightHint
=
0
;
lblUnit
.
setLayoutData
(
minGD
);
}
if
(
lbl
!=
null
)
{
fieldText
.
setToolTipText
(
lbl
.
getText
());
fieldText
.
setMessage
(
lbl
.
getText
());
dateTime
.
setToolTipText
(
lbl
.
getText
());
lbl
.
setVisible
(
false
);
((
GridData
)
lbl
.
getLayoutData
()).
widthHint
=
0
;
((
GridData
)
lbl
.
getLayoutData
()).
heightHint
=
0
;
...
...
@@ -230,7 +164,8 @@ public class CompositeDate extends Composite implements ICompositeSaveable {
@Override
public
String
getFieldTextValue
(){
return
fieldText
!=
null
?
fieldText
.
getText
()
:
""
;
return
dateTime
!=
null
?
LocalDateTime
.
ofInstant
(
dateTime
.
getSelection
().
toInstant
(),
ZoneId
.
systemDefault
()).
toString
()
:
""
;
}
@Override
...
...
@@ -240,7 +175,6 @@ public class CompositeDate extends Composite implements ICompositeSaveable {
@Override
public
ObservationType
getObservationType
(){
// TODO Auto-generated method stub
return
observationType
;
}
}
bundles/ch.elexis.core.findings.ui/src/ch/elexis/core/findings/ui/util/FindingsUiUtil.java
View file @
015b4ff2
...
...
@@ -2,8 +2,10 @@ package ch.elexis.core.findings.ui.util;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
import
java.time.ZoneId
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Optional
;
...
...
@@ -185,6 +187,16 @@ public class FindingsUiUtil {
LoggerFactory
.
getLogger
(
FindingsUiUtil
.
class
)
.
warn
(
"cannot save number illegal format"
,
e
);
}
}
else
if
(
ObservationType
.
BOOLEAN
.
equals
(
observationType
))
{
if
(
StringUtils
.
isNotBlank
(
text
))
{
iObservation
.
setBooleanValue
(
Boolean
.
valueOf
(
text
));
}
}
else
if
(
ObservationType
.
DATE
.
equals
(
observationType
))
{
if
(
StringUtils
.
isNotBlank
(
text
))
{
LocalDateTime
dateTime
=
LocalDateTime
.
parse
(
text
);
iObservation
.
setDateTimeValue
(
Date
.
from
(
dateTime
.
atZone
(
ZoneId
.
systemDefault
()).
toInstant
()));
}
}
}
}
...
...
bundles/ch.elexis.core.findings.util/src/ch/elexis/core/findings/util/FindingsTextUtil.java
View file @
015b4ff2
package
ch.elexis.core.findings.util
;
import
java.text.SimpleDateFormat
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Optional
;
...
...
@@ -48,6 +49,10 @@ public class FindingsTextUtil {
stringBuilder
.
append
(
getObservationText
(
iObservation
,
shouldSet
));
}
else
if
(
ObservationType
.
NUMERIC
.
equals
(
iObservation
.
getObservationType
()))
{
stringBuilder
.
append
(
getObservationText
(
iObservation
,
shouldSet
));
}
else
if
(
ObservationType
.
BOOLEAN
.
equals
(
iObservation
.
getObservationType
()))
{
stringBuilder
.
append
(
getObservationText
(
iObservation
,
shouldSet
));
}
else
if
(
ObservationType
.
DATE
.
equals
(
iObservation
.
getObservationType
()))
{
stringBuilder
.
append
(
getObservationText
(
iObservation
,
shouldSet
));
}
else
{
LoggerFactory
.
getLogger
(
FindingsTextUtil
.
class
)
.
warn
(
"Unknown ObservationType "
+
iObservation
.
getObservationType
());
...
...
@@ -103,7 +108,6 @@ public class FindingsTextUtil {
if
(
observation
.
getComment
().
isPresent
())
{
stringBuilder
.
append
(
" ["
+
observation
.
getComment
().
get
()
+
"]"
);
}
}
else
if
(
ObservationType
.
NUMERIC
.
equals
(
observation
.
getObservationType
()))
{
try
{
stringBuilder
.
append
(
title
);
...
...
@@ -119,6 +123,27 @@ public class FindingsTextUtil {
}
catch
(
NumberFormatException
e
)
{
LoggerFactory
.
getLogger
(
FindingsTextUtil
.
class
).
warn
(
"number illegal format"
,
e
);
}
}
else
if
(
ObservationType
.
BOOLEAN
.
equals
(
observation
.
getObservationType
()))
{
stringBuilder
.
append
(
title
);
stringBuilder
.
append
(
" "
);
observation
.
getBooleanValue
().
ifPresent
(
value
->
{
stringBuilder
.
append
(
value
?
"Ja"
:
"Nein"
);
});
if
(
observation
.
getComment
().
isPresent
())
{
stringBuilder
.
append
(
" ["
+
observation
.
getComment
().
get
()
+
"]"
);
}
}
else
if
(
ObservationType
.
DATE
.
equals
(
observation
.
getObservationType
()))
{
stringBuilder
.
append
(
title
);
stringBuilder
.
append
(
" "
);
observation
.
getDateTimeValue
().
ifPresent
(
value
->
{
stringBuilder
.
append
(
new
SimpleDateFormat
(
"dd.MM.yyyy"
).
format
(
value
));
});
if
(
observation
.
getComment
().
isPresent
())
{
stringBuilder
.
append
(
" ["
+
observation
.
getComment
().
get
()
+
"]"
);
}
}
else
if
(
ObservationType
.
COMP
.
equals
(
observation
.
getObservationType
()))
{
stringBuilder
.
append
(
title
+
" "
);
...
...
bundles/ch.elexis.core.findings.util/src/ch/elexis/core/findings/util/fhir/accessor/ObservationAccessor.java
View file @
015b4ff2
...
...
@@ -287,7 +287,27 @@ public class ObservationAccessor extends AbstractFindingsAccessor {
org
.
hl7
.
fhir
.
dstu3
.
model
.
Observation
fhirObservation
=
(
org
.
hl7
.
fhir
.
dstu3
.
model
.
Observation
)
resource
;
if
(
fhirObservation
.
hasValueBooleanType
())
{
BooleanType
value
=
(
BooleanType
)
fhirObservation
.
getValue
();
BooleanType
value
=
fhirObservation
.
getValueBooleanType
();
if
(
value
.
getValue
()
!=
null
)
{
return
Optional
.
of
(
value
.
getValue
());
}
}
return
Optional
.
empty
();
}
public
void
setDateTimeValue
(
DomainResource
resource
,
Date
value
){
org
.
hl7
.
fhir
.
dstu3
.
model
.
Observation
fhirObservation
=
(
org
.
hl7
.
fhir
.
dstu3
.
model
.
Observation
)
resource
;
DateTimeType
q
=
new
DateTimeType
();
q
.
setValue
(
value
);
fhirObservation
.
setValue
(
q
);
}
public
Optional
<
Date
>
getDateTimeValue
(
DomainResource
resource
){
org
.
hl7
.
fhir
.
dstu3
.
model
.
Observation
fhirObservation
=
(
org
.
hl7
.
fhir
.
dstu3
.
model
.
Observation
)
resource
;
if
(
fhirObservation
.
hasValueDateTimeType
())
{
DateTimeType
value
=
(
DateTimeType
)
fhirObservation
.
getValueDateTimeType
();
if
(
value
.
getValue
()
!=
null
)
{
return
Optional
.
of
(
value
.
getValue
());
}
...
...
bundles/ch.elexis.core.findings/src/ch/elexis/core/findings/IObservation.java
View file @
015b4ff2
...
...
@@ -12,6 +12,7 @@ package ch.elexis.core.findings;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.MissingResourceException
;
import
java.util.Optional
;
...
...
@@ -246,6 +247,20 @@ public interface IObservation extends IFinding {
*/
public
Optional
<
Boolean
>
getBooleanValue
();
/**
* Set the dateTimeValue of the observation.
*
* @return
*/
public
void
setDateTimeValue
(
Date
value
);
/**
* Get the dateTimeValue
*
* @return
*/
public
Optional
<
Date
>
getDateTimeValue
();
/**
* Get the Unit
*
...
...
bundles/ch.elexis.core.findings/src/ch/elexis/core/findings/ObservationComponent.java
View file @
015b4ff2
...
...
@@ -2,6 +2,7 @@ package ch.elexis.core.findings;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -16,6 +17,7 @@ public class ObservationComponent {
private
String
numericValueUnit
;
private
String
stringValue
;
private
Boolean
booleanValue
;
private
Date
dateTimeValue
;
private
final
String
id
;
private
Map
<
String
,
String
>
extensions
=
new
HashMap
<>();
...
...
@@ -84,6 +86,16 @@ public class ObservationComponent {
ObservationType
.
BOOLEAN
.
name
());
}
public
Optional
<
Date
>
getDateTimeValue
(){
return
Optional
.
ofNullable
(
dateTimeValue
);
}
public
void
setDateTimeValue
(
Date
dateTimeValue
){
this
.
dateTimeValue
=
dateTimeValue
;
getExtensions
().
put
(
ObservationComponent
.
EXTENSION_OBSERVATION_TYPE_URL
,
ObservationType
.
DATE
.
name
());
}
public
void
setExtensions
(
Map
<
String
,
String
>
extensions
){
this
.
extensions
=
extensions
;
}
...
...
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