Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
hhund committed Jun 7, 2022
2 parents 9c015fd + 706aee1 commit 08883dc
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.hl7.fhir.r4.model.Procedure;
import org.hl7.fhir.r4.model.Reference;
import org.hl7.fhir.r4.model.Resource;
import org.hl7.fhir.r4.model.ResourceType;
import org.hl7.fhir.r4.model.Task;
import org.hl7.fhir.r4.model.Type;
import org.slf4j.Logger;
Expand Down Expand Up @@ -241,19 +242,33 @@ else if (resource instanceof Procedure)

protected String getConditionalUpdateUrl(String pseudonym, DomainResource resource)
{
String patientIdentifier = ConstantsDataTransfer.NAMING_SYSTEM_NUM_CODEX_DIC_PSEUDONYM + "|" + pseudonym;

if (resource instanceof Patient)
{
return "Patient?identifier=" + ConstantsDataTransfer.NAMING_SYSTEM_NUM_CODEX_DIC_PSEUDONYM + "|"
+ pseudonym;
return "Patient?identifier=" + patientIdentifier;
}
else if (resource instanceof Condition)
{
Condition c = (Condition) resource;
String profileUrl = getProfileUrl(resource, v -> v.startsWith(NUM_CODEX_STRUCTURE_DEFINITION_PREFIX));

return "Condition?_profile=" + profileUrl + "&recorded-date="
+ c.getRecordedDateElement().getValueAsString() + "&patient:identifier="
+ ConstantsDataTransfer.NAMING_SYSTEM_NUM_CODEX_DIC_PSEUDONYM + "|" + pseudonym;
String updateUrl = getBaseConditionalUpdateUrl(ResourceType.Condition.name(), profileUrl,
patientIdentifier);

if (c.hasRecordedDateElement() && c.getRecordedDateElement().getValueAsString() != null)
updateUrl = updateUrl + "&recorded-date=" + c.getRecordedDateElement().getValueAsString();

if (c.hasCategory() && c.getCategoryFirstRep().hasCoding())
updateUrl = updateUrl + "&category=" + getCodingUpdateUrl(c.getCategoryFirstRep().getCodingFirstRep());

if (c.hasCode() && c.getCode().hasCoding())
updateUrl = updateUrl + "&code=" + getCodingUpdateUrl(c.getCode().getCodingFirstRep());

if (c.hasBodySite() && c.getBodySiteFirstRep().hasCoding())
updateUrl = updateUrl + "&body-site=" + getCodingUpdateUrl(c.getBodySiteFirstRep().getCodingFirstRep());

return updateUrl;
}
else if (resource instanceof Consent)
{
Expand All @@ -262,21 +277,20 @@ else if (resource instanceof Consent)

if (NUM_CODEX_DO_NOT_RESUSCITAT_ORDER.equals(profileUrl))
{
boolean scopePresent = c.getScope().getCoding().stream().filter(co -> co.hasSystem())
boolean scopePresent = c.getScope().getCoding().stream().filter(Coding::hasSystem)
.filter(co -> "http://terminology.hl7.org/CodeSystem/consentscope".equals(co.getSystem()))
.filter(co -> co.hasCode()).filter(co -> "adr".equals(co.getCode())).findAny().isPresent();
.filter(Coding::hasCode).anyMatch(co -> "adr".equals(co.getCode()));
boolean categoryPresent = c.getCategory().stream().flatMap(coc -> coc.getCoding().stream())
.filter(co -> co.hasSystem())
.filter(Coding::hasSystem)
.filter(co -> "http://terminology.hl7.org/CodeSystem/consentcategorycodes"
.equals(co.getSystem()))
.filter(co -> co.hasCode()).filter(co -> "dnr".equals(co.getCode())).findAny().isPresent();
.filter(Coding::hasCode).anyMatch(co -> "dnr".equals(co.getCode()));

if (scopePresent && categoryPresent)
return "Consent?_profile=" + profileUrl
return getBaseConditionalUpdateUrl(ResourceType.Consent.name(), profileUrl, patientIdentifier)
+ "&scope=http://terminology.hl7.org/CodeSystem/consentscope|adr"
+ "&category=http://terminology.hl7.org/CodeSystem/consentcategorycodes|dnr"
+ "&patient:identifier=" + ConstantsDataTransfer.NAMING_SYSTEM_NUM_CODEX_DIC_PSEUDONYM + "|"
+ pseudonym;
+ "&category=http://terminology.hl7.org/CodeSystem/consentcategorycodes|dnr";

else
throw new RuntimeException("Resource of type Consent with profile " + profileUrl
+ " is missing scope: http://terminology.hl7.org/CodeSystem/consentscope|adr and/or category: http://terminology.hl7.org/CodeSystem/consentcategorycodes|dnr");
Expand All @@ -289,61 +303,92 @@ else if (resource instanceof DiagnosticReport)
DiagnosticReport dr = (DiagnosticReport) resource;
String profileUrl = getProfileUrl(resource, v -> v.startsWith(NUM_CODEX_STRUCTURE_DEFINITION_PREFIX));

return "DiagnosticReport?_profile=" + profileUrl + "&date="
+ dr.getEffectiveDateTimeType().getValueAsString() + "&patient:identifier="
+ ConstantsDataTransfer.NAMING_SYSTEM_NUM_CODEX_DIC_PSEUDONYM + "|" + pseudonym;
String updateUrl = getBaseConditionalUpdateUrl(ResourceType.DiagnosticReport.name(), profileUrl,
patientIdentifier);

if (dr.hasEffectiveDateTimeType() && dr.getEffectiveDateTimeType().getValueAsString() != null)
updateUrl = updateUrl + "&date=" + dr.getEffectiveDateTimeType().getValueAsString();

if (dr.hasCategory() && dr.getCategoryFirstRep().hasCoding())
updateUrl = updateUrl + "&category=" + getCodingUpdateUrl(dr.getCategoryFirstRep().getCodingFirstRep());

if (dr.hasCode() && dr.getCode().hasCoding())
updateUrl = updateUrl + "&code=" + getCodingUpdateUrl(dr.getCode().getCodingFirstRep());

return updateUrl;
}
else if (resource instanceof Immunization)
{
Immunization i = (Immunization) resource;
String profileUrl = getProfileUrl(resource, v -> v.startsWith(NUM_CODEX_STRUCTURE_DEFINITION_PREFIX));

return "Immunization?_profile=" + profileUrl + "&date=" + i.getOccurrenceDateTimeType().getValueAsString()
+ "&patient:identifier=" + ConstantsDataTransfer.NAMING_SYSTEM_NUM_CODEX_DIC_PSEUDONYM + "|"
+ pseudonym;
String updateUrl = getBaseConditionalUpdateUrl(ResourceType.Immunization.name(), profileUrl,
patientIdentifier);

if (i.hasOccurrenceDateTimeType() && i.getOccurrenceDateTimeType().getValueAsString() != null)
updateUrl = updateUrl + "&date=" + i.getOccurrenceDateTimeType().getValueAsString();

if (i.hasVaccineCode() && i.getVaccineCode().hasCoding())
updateUrl = updateUrl + "&vaccine-code=" + i.getVaccineCode().getCodingFirstRep();

return updateUrl;
}
else if (resource instanceof MedicationStatement)
{
MedicationStatement ms = (MedicationStatement) resource;
String profileUrl = getProfileUrl(resource, v -> v.startsWith(NUM_CODEX_STRUCTURE_DEFINITION_PREFIX));

return "MedicationStatement?_profile=" + profileUrl + "&effective="
+ ms.getEffectiveDateTimeType().getValueAsString() + "&patient:identifier="
+ ConstantsDataTransfer.NAMING_SYSTEM_NUM_CODEX_DIC_PSEUDONYM + "|" + pseudonym;
}
String updateUrl = getBaseConditionalUpdateUrl(ResourceType.MedicationStatement.name(), profileUrl,
patientIdentifier);

if (ms.hasEffectiveDateTimeType() && ms.getEffectiveDateTimeType().getValueAsString() != null)
updateUrl = updateUrl + "&effective=" + ms.getEffectiveDateTimeType();

if (ms.hasMedicationCodeableConcept() && ms.getMedicationCodeableConcept().hasCoding())
updateUrl = updateUrl + "&code="
+ getCodingUpdateUrl(ms.getMedicationCodeableConcept().getCodingFirstRep());

return updateUrl;
}
else if (resource instanceof Observation)
{
Observation o = (Observation) resource;
String profileUrl = getProfileUrl(resource, v -> v.startsWith(NUM_CODEX_STRUCTURE_DEFINITION_PREFIX)
|| MII_LAB_STRUCTURED_DEFINITION.equals(v));

if (MII_LAB_STRUCTURED_DEFINITION.equals(profileUrl))
{
Coding loincCode = o.getCode().getCoding().stream()
.filter(c -> "http://loinc.org".equals(c.getSystem())).findFirst()
.orElseThrow(() -> new RuntimeException("Observation (" + MII_LAB_STRUCTURED_DEFINITION
+ ") not supported, missing LOINC code"));

return "Observation?_profile=" + profileUrl + "&date=" + o.getEffectiveDateTimeType().getValueAsString()
+ "&code=" + loincCode.getSystem() + "|" + loincCode.getCode() + "&patient:identifier="
+ ConstantsDataTransfer.NAMING_SYSTEM_NUM_CODEX_DIC_PSEUDONYM + "|" + pseudonym;
}
else
{
return "Observation?_profile=" + profileUrl + "&date=" + o.getEffectiveDateTimeType().getValueAsString()
+ "&patient:identifier=" + ConstantsDataTransfer.NAMING_SYSTEM_NUM_CODEX_DIC_PSEUDONYM + "|"
+ pseudonym;
}
String updateUrl = getBaseConditionalUpdateUrl(ResourceType.Observation.name(), profileUrl,
patientIdentifier);

if (o.hasEffectiveDateTimeType() && o.getEffectiveDateTimeType().getValueAsString() != null)
updateUrl = updateUrl + "&date=" + o.getEffectiveDateTimeType().getValueAsString();

if (o.hasCategory() && o.getCategoryFirstRep().hasCoding())
updateUrl = updateUrl + "&category=" + getCodingUpdateUrl(o.getCategoryFirstRep().getCodingFirstRep());

if (o.hasCode() && o.getCode().hasCoding())
updateUrl = updateUrl + "&code=" + getCodingUpdateUrl(o.getCode().getCodingFirstRep());

return updateUrl;
}
else if (resource instanceof Procedure)
{
Procedure p = (Procedure) resource;
String profileUrl = getProfileUrl(resource, v -> v.startsWith(NUM_CODEX_STRUCTURE_DEFINITION_PREFIX));

return "Procedure?_profile=" + profileUrl + "&date=" + p.getPerformedDateTimeType().getValueAsString()
+ "&patient:identifier=" + ConstantsDataTransfer.NAMING_SYSTEM_NUM_CODEX_DIC_PSEUDONYM + "|"
+ pseudonym;
String updateUrl = getBaseConditionalUpdateUrl(ResourceType.Procedure.name(), profileUrl,
patientIdentifier);

if (p.hasPerformedDateTimeType() && p.getPerformedDateTimeType().getValueAsString() != null)
updateUrl = updateUrl + "&date=" + p.getPerformedDateTimeType().getValueAsString();

if (p.hasCategory() && p.getCategory().hasCoding())
updateUrl = updateUrl + "&category=" + getCodingUpdateUrl(p.getCategory().getCodingFirstRep());

if (p.hasCode() && p.getCode().hasCoding())
updateUrl = updateUrl + "&code=" + getCodingUpdateUrl(p.getCode().getCodingFirstRep());

return updateUrl;

}
else
throw new RuntimeException("Resource of type " + resource.getResourceType().name() + " not supported");
Expand All @@ -355,4 +400,14 @@ private String getProfileUrl(DomainResource resource, Predicate<String> filter)
.orElseThrow(() -> new RuntimeException("Resource of type " + resource.getResourceType().name()
+ " not supported, missing NUM or MII profile"));
}

private String getBaseConditionalUpdateUrl(String resourceName, String profileUrl, String patientIdentifier)
{
return resourceName + "?_profile=" + profileUrl + "&patient:identifier=" + patientIdentifier;
}

private String getCodingUpdateUrl(Coding coding)
{
return coding.getSystem() + "|" + coding.getCode();
}
}
18 changes: 9 additions & 9 deletions codex-processes-ap1-docker-test-setup/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ services:


dic-fhir:
image: ghcr.io/highmed/fhir:0.6.0-RC3
image: ghcr.io/highmed/fhir:0.6.0
restart: on-failure
ports:
- 127.0.0.1:5000:5000
Expand Down Expand Up @@ -113,7 +113,7 @@ services:
- db
- proxy
dic-bpe:
image: ghcr.io/highmed/bpe:0.6.0-RC3
image: ghcr.io/highmed/bpe:0.6.0
restart: on-failure
ports:
- 127.0.0.1:5003:5003
Expand Down Expand Up @@ -194,7 +194,7 @@ services:


gth-fhir:
image: ghcr.io/highmed/fhir:0.6.0-RC3
image: ghcr.io/highmed/fhir:0.6.0
restart: on-failure
ports:
- 127.0.0.1:5001:5001
Expand Down Expand Up @@ -241,7 +241,7 @@ services:
- db
- proxy
gth-bpe:
image: ghcr.io/highmed/bpe:0.6.0-RC3
image: ghcr.io/highmed/bpe:0.6.0
restart: on-failure
ports:
- 127.0.0.1:5004:5004
Expand Down Expand Up @@ -298,7 +298,7 @@ services:


crr-fhir:
image: ghcr.io/highmed/fhir:0.6.0-RC3
image: ghcr.io/highmed/fhir:0.6.0
restart: on-failure
ports:
- 127.0.0.1:5002:5002
Expand Down Expand Up @@ -345,7 +345,7 @@ services:
- db
- proxy
crr-bpe:
image: ghcr.io/highmed/bpe:0.6.0-RC3
image: ghcr.io/highmed/bpe:0.6.0
restart: on-failure
ports:
- 127.0.0.1:5005:5005
Expand Down Expand Up @@ -404,7 +404,7 @@ services:
- crr-fhir
# - crr-fhir-bridge not defining a dependency here, crr-fhir-bridge* needs to be started manually
crr-ehrbase-db:
image: ehrbase/ehrbase-postgres:latest
image: ehrbase/ehrbase-postgres
networks:
- crr-ehrbase-network
environment:
Expand All @@ -414,7 +414,7 @@ services:
EHRBASE_PASSWORD: ehrbase
TZ: Europe/Berlin
crr-ehrbase:
image: ehrbase/ehrbase:latest
image: ehrbase/ehrbase
networks:
- crr-ehrbase-network
environment:
Expand All @@ -433,7 +433,7 @@ services:
depends_on:
- crr-ehrbase-db
crr-fhir-bridge:
image: ehrbase/fhir-bridge:latest
image: ehrbase/fhir-bridge
ports:
- 127.0.0.1:8888:8888
- 127.0.0.1:5006:5006
Expand Down

0 comments on commit 08883dc

Please sign in to comment.