Skip to content

Commit

Permalink
Generate Diagnosis Extension on Specimen #14
Browse files Browse the repository at this point in the history
  • Loading branch information
kairosmike committed Dec 6, 2021
1 parent 83f9489 commit df9b23c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 23 deletions.
36 changes: 21 additions & 15 deletions src/main/groovy/projects/bbmri/specimen.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package projects.bbmri

import static de.kairos.fhir.centraxx.metamodel.RootEntities.sample

/**
* Represented by a CXX AbstractSample
* Specified by https://simplifier.net/bbmri.de/specimen
Expand Down Expand Up @@ -106,6 +108,18 @@ specimen {
}
}

if (context.source[sample().diagnosis()]) {
extension {
url = "https://fhir.bbmri.de/StructureDefinition/SampleDiagnosis"
valueCodeableConcept {
coding {
system = "http://hl7.org/fhir/sid/icd-10"
code = context.source[sample().diagnosis().diagnosisCode()]
}
}
}
}

final def temperature = toTemperature(context)
if (temperature) {
extension {
Expand All @@ -118,34 +132,26 @@ specimen {
}
}
}

}

static def toTemperature(final ctx) {
final def temp = ctx.source["sampleLocation.temperature"]

if (null != temp) {
switch (temp) {
case { it >= 2.0 && it <= 10 }:
return "temperature2to10"
case { it <= -18.0 && it >= -35.0 }:
return "temperature-18to-35"
case { it <= -60.0 && it >= -85.0 }:
return "temperature-60to-85"
case { it >= 2.0 && it <= 10 }: return "temperature2to10"
case { it <= -18.0 && it >= -35.0 }: return "temperature-18to-35"
case { it <= -60.0 && it >= -85.0 }: return "temperature-60to-85"
}
}

final def sprec = ctx.source["receptable.sprecCode"]
if (null != sprec) {
switch (sprec) {
case ['C', 'F', 'O', 'Q']:
return "temperatureLN"
case ['A', 'D', 'J', 'L', 'N', 'O', 'S']:
return "temperature-60to-85"
case ['B', 'H', 'K', 'M', 'T']:
return "temperature-18to-35"
default:
return "temperatureOther"
case ['C', 'F', 'O', 'Q']: return "temperatureLN"
case ['A', 'D', 'J', 'L', 'N', 'O', 'S']: return "temperature-60to-85"
case ['B', 'H', 'K', 'M', 'T']: return "temperature-18to-35"
default: return "temperatureOther"
}
}

Expand Down
24 changes: 16 additions & 8 deletions src/main/groovy/projects/dktk/v2/specimen.groovy
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package projects.dktk.v2


import static de.kairos.fhir.centraxx.metamodel.AbstractCode.CODE
import static de.kairos.fhir.centraxx.metamodel.AbstractIdContainer.ID_CONTAINER_TYPE
import static de.kairos.fhir.centraxx.metamodel.AbstractIdContainer.PSN
import static de.kairos.fhir.centraxx.metamodel.RootEntities.abstractSample
import static de.kairos.fhir.centraxx.metamodel.RootEntities.sample

/**
* Represented by a CXX AbstractSample
Expand Down Expand Up @@ -114,6 +114,18 @@ specimen {
// }
// }

if (context.source[abstractSample().diagnosis()]) {
extension {
url = "https://fhir.bbmri.de/StructureDefinition/SampleDiagnosis"
valueCodeableConcept {
coding {
system = "http://hl7.org/fhir/sid/icd-10"
code = context.source[sample().diagnosis().diagnosisCode()]
}
}
}
}

final def temperature = toTemperature(context)
if (temperature) {
extension {
Expand All @@ -131,15 +143,11 @@ specimen {

static def toTemperature(final ctx) {
final def temp = ctx.source[abstractSample().sampleLocation().temperature()]

if (null != temp) {
switch (temp) {
case { it >= 2.0 && it <= 10 }:
return "temperature2to10"
case { it <= -18.0 && it >= -35.0 }:
return "temperature-18to-35"
case { it <= -60.0 && it >= -85.0 }:
return "temperature-60to-85"
case { it >= 2.0 && it <= 10 }: return "temperature2to10"
case { it <= -18.0 && it >= -35.0 }: return "temperature-18to-35"
case { it <= -60.0 && it >= -85.0 }: return "temperature-60to-85"
}
}

Expand Down

0 comments on commit df9b23c

Please sign in to comment.