Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/v1.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
subigre committed May 4, 2021
2 parents b96f5df + 11718a1 commit d8b057a
Show file tree
Hide file tree
Showing 113 changed files with 33,664 additions and 672 deletions.
9 changes: 5 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ commands:
name: WAIT FOR EHRBASE SERVER TO BE READY
command: |
ls -la
timeout=180
timeout=600
while [ ! -f ehrbase/log ];
do
echo "Waiting for file ehrbase/log ..."
Expand All @@ -546,11 +546,12 @@ commands:
sleep 1
((timeout--))
done
echo "REMAINING TIMEOUT: $timeout"
while ! (cat ehrbase/log | grep -m 1 "Started EhrBase in");
do
echo "waiting for EHRbase to be ready ...";
if [ "$timeout" == 0 ]; then
echo "WARNING: Did not see a startup message even after waiting 180s"
echo "WARNING: Did not see a startup message even after waiting 600s"
cat ehrbase/log
exit 1
fi
Expand Down Expand Up @@ -585,7 +586,7 @@ commands:
name: WAIT FOR FHIRBRIDE TO BE READY
command: |
ls -la
timeout=180
timeout=600
while [ ! -f fhirbride_log ];
do
echo "Waiting for file fhirbride_log ..."
Expand All @@ -600,7 +601,7 @@ commands:
do
echo "waiting for FHIR-Bridge to be ready ...";
if [ "$timeout" == 0 ]; then
echo "WARNING: Did not see a startup message even after waiting 180s"
echo "WARNING: Did not see a startup message even after waiting 600s"
cat fhirbride_log
exit 1
fi
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ The implementation is based on [Apache Camel](https://camel.apache.org/) and [Op

## Releases

##### 2021, May 04
v1.1.1 - Add system scope for SMART on FHIR.

##### 2021, April 27
v1.1.0 - Final release 1.1.0 including the fix for SMART on FHIR.

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<groupId>org.ehrbase.fhirbridge</groupId>
<artifactId>fhir-bridge</artifactId>
<version>1.1.0</version>
<version>1.1.1</version>

<name>FHIR Bridge</name>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright 2020-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.ehrbase.fhirbridge.camel.component.fhir.medicationstatement;

import org.ehrbase.fhirbridge.fhir.medicationstatement.CreateMedicationStatementTransaction;
import org.openehealth.ipf.commons.ihe.fhir.audit.GenericFhirAuditDataset;
import org.openehealth.ipf.platform.camel.ihe.fhir.core.custom.CustomFhirComponent;

/**
* Camel {@link org.apache.camel.Component Component} that handles 'Create Medication Statement' transaction.
*
* @since 1.0.0
*/
@SuppressWarnings({"java:S110"})
public class CreateMedicationStatementComponent extends CustomFhirComponent<GenericFhirAuditDataset> {

public CreateMedicationStatementComponent() {
super(new CreateMedicationStatementTransaction());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright 2020-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.ehrbase.fhirbridge.camel.component.fhir.medicationstatement;

import org.ehrbase.fhirbridge.fhir.observation.FindObservationTransaction;
import org.openehealth.ipf.commons.ihe.fhir.audit.FhirQueryAuditDataset;
import org.openehealth.ipf.platform.camel.ihe.fhir.core.custom.CustomFhirComponent;

/**
* Camel {@link org.apache.camel.Component Component} that handles 'Find MedicationStatement' transaction.
*
* @since 1.0.0
*/
@SuppressWarnings({"java:S110"})
public class FindMedicationStatementComponent extends CustomFhirComponent<FhirQueryAuditDataset> {

public FindMedicationStatementComponent() {
super(new FindObservationTransaction());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright 2020-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.ehrbase.fhirbridge.camel.route;

import org.apache.camel.builder.RouteBuilder;
import org.ehrbase.fhirbridge.camel.FhirBridgeConstants;
import org.springframework.stereotype.Component;

/**
* Implementation of {@link RouteBuilder} that provides route definitions for transactions
* linked to {@link org.hl7.fhir.r4.model.MedicationStatement MedicationStatement} resource.
*
* @since 1.0.0
*/
@Component
public class MedicationStatementRoutes extends AbstractRouteBuilder {

@Override
public void configure() throws Exception {
// @formatter:off
super.configure();

// 'Create Medication Statement' route definition
from("medication-statement-create:consumer?fhirContext=#fhirContext")
.onCompletion()
.process("auditCreateResourceProcessor")
.end()
.process("resourceProfileValidator")
.setHeader(FhirBridgeConstants.METHOD_OUTCOME, method("medicationStatementDao", "create(${body}, ${headers.FhirRequestDetails})"))
.process("ehrIdLookupProcessor")
.to("bean:fhirResourceConversionService?method=convert(${headers.FhirBridgeProfile}, ${body})")
.to("ehr-composition:compositionProducer?operation=mergeCompositionEntity")
.process("resourceResponseProcessor");

// 'Find Medication Statement' route definition
from("medication-statement-find:consumer?fhirContext=#fhirContext&lazyLoadBundles=true")
.choice()
.when(isSearchOperation())
.to("bean:medicationStatementDao?method=search(${body}, ${headers.FhirRequestDetails})")
.process("bundleProviderResponseProcessor")
.otherwise()
.to("bean:medicationStatementDao?method=read(${body}, ${headers.FhirRequestDetails})");

// @formatter:on
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
import org.ehrbase.fhirbridge.ehr.converter.specific.bodyheight.BodyHeightCompositionConverter;
import org.ehrbase.fhirbridge.ehr.converter.specific.bodytemperature.BodyTemperatureCompositionConverter;
import org.ehrbase.fhirbridge.ehr.converter.specific.bodyweight.BodyWeightCompositionConverter;
import org.ehrbase.fhirbridge.ehr.converter.specific.clinicalFrailty.ClinicalFrailtyScaleScoreCompositionConverter;
import org.ehrbase.fhirbridge.ehr.converter.specific.clinicalfrailty.ClinicalFrailtyScaleScoreCompositionConverter;
import org.ehrbase.fhirbridge.ehr.converter.specific.coronavirusnachweistest.CoronavirusNachweisTestCompositionConverter;
import org.ehrbase.fhirbridge.ehr.converter.specific.d4lquestionnaire.D4lQuestionnaireCompositionConverter;
import org.ehrbase.fhirbridge.ehr.converter.specific.diagnose.DiagnoseCompositionConverter;
import org.ehrbase.fhirbridge.ehr.converter.specific.diagnosticreportlab.DiagnosticReportLabCompositionConverter;
import org.ehrbase.fhirbridge.ehr.converter.specific.fio2.FiO2CompositionConverter;
import org.ehrbase.fhirbridge.ehr.converter.specific.geccoDiagnose.GECCODiagnoseCompositionConverter;
import org.ehrbase.fhirbridge.ehr.converter.specific.heartrate.HeartRateCompositionConverter;
import org.ehrbase.fhirbridge.ehr.converter.specific.historyoftravel.HistoryOfTravelConverter;
import org.ehrbase.fhirbridge.ehr.converter.specific.historyoftravel.HistoryOfTravelCompositionConverter;
import org.ehrbase.fhirbridge.ehr.converter.specific.knownexposure.SarsCov2KnownExposureCompositionConverter;
import org.ehrbase.fhirbridge.ehr.converter.specific.medication.GECCOMedikationCompositionConverter;
import org.ehrbase.fhirbridge.ehr.converter.specific.observationlab.ObservationLabCompositionConverter;
import org.ehrbase.fhirbridge.ehr.converter.specific.patient.PatientCompositionConverter;
import org.ehrbase.fhirbridge.ehr.converter.specific.patientinicu.PatientInIcuCompositionConverter;
Expand Down Expand Up @@ -49,6 +50,7 @@ public ConversionService conversionService() {
registerPatientConverters(conversionService);
registerProcedureConverters(conversionService);
registerQuestionnaireResponseConverter(conversionService);
registerMedicationStatementConverter(conversionService);

return conversionService;
}
Expand Down Expand Up @@ -102,7 +104,7 @@ private void registerObservationConverters(ConversionService conversionService)
conversionService.registerConverter(Profile.SOFA_SCORE, new SofaScoreCompositionConverter());
conversionService.registerConverter(Profile.SMOKING_STATUS, new SmokingStatusCompositionConverter());

conversionService.registerConverter(Profile.TRAVEL_HISTORY, new HistoryOfTravelConverter());
conversionService.registerConverter(Profile.TRAVEL_HISTORY, new HistoryOfTravelCompositionConverter());
conversionService.registerConverter(Profile.OXYGEN_SATURATION, new PulseOximetryCompositionConverter());
}

Expand All @@ -125,4 +127,12 @@ private void registerProcedureConverters(ConversionService conversionService) {
private void registerQuestionnaireResponseConverter(ConversionService conversionService) {
conversionService.registerConverter(Profile.DEFAULT_QUESTIONNAIRE_RESPONSE, new D4lQuestionnaireCompositionConverter());
}

private void registerMedicationStatementConverter(ConversionService conversionService) {
GECCOMedikationCompositionConverter converter = new GECCOMedikationCompositionConverter();
conversionService.registerConverter(Profile.PHARMACOLOGICAL_THERAPY, converter);
conversionService.registerConverter(Profile.PHARMACOLOGICAL_THERAPY_ACE_INHIBITORS, converter);
conversionService.registerConverter(Profile.PHARMACOLOGICAL_THERAPY_ANTICOAGULANTS, converter);
conversionService.registerConverter(Profile.PHARMACOLOGICAL_THERAPY_IMMUNOGLOBULINS, converter);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.hl7.fhir.r4.model.DiagnosticReport;
import org.hl7.fhir.r4.model.Group;
import org.hl7.fhir.r4.model.Location;
import org.hl7.fhir.r4.model.MedicationStatement;
import org.hl7.fhir.r4.model.Observation;
import org.hl7.fhir.r4.model.Patient;
import org.hl7.fhir.r4.model.Procedure;
Expand Down Expand Up @@ -180,6 +181,14 @@ public IFhirResourceDao<Location> locationDao() {
return resourceDao;
}

@Bean
public IFhirResourceDao<MedicationStatement> medicationStatementDao() {
JpaResourceDao<MedicationStatement> resourceDao = new JpaResourceDao<>();
resourceDao.setResourceType(MedicationStatement.class);
resourceDao.setContext(fhirContext());
return resourceDao;
}

@Bean
public IFhirResourceDao<Observation> observationDao() {
JpaResourceDao<Observation> resourceDao = new JpaResourceDao<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.ehrbase.fhirbridge.ehr.converter.generic;

import org.ehrbase.client.classgenerator.interfaces.CompositionEntity;
import org.hl7.fhir.r4.model.MedicationStatement;
import org.springframework.lang.NonNull;

public abstract class MedicationStatementToCompositionConverter<C extends CompositionEntity> extends CompositionConverter<MedicationStatement, C>{
@Override
public C convert(@NonNull MedicationStatement resource) {
C composition = super.convert(resource);
composition.setStartTimeValue(TimeConverter.convertMedicationStatmentTime(resource)); // StartTimeValue
TimeConverter.convertMedicationStatementEndTime(resource).ifPresent(composition::setEndTimeValue);
return composition;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.ehrbase.fhirbridge.ehr.converter.generic;

import org.ehrbase.client.classgenerator.interfaces.EntryEntity;
import org.hl7.fhir.r4.model.MedicationStatement;
import org.springframework.lang.NonNull;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.time.temporal.TemporalAccessor;

public abstract class MedicationStatementToObservationConverter<E extends EntryEntity> extends EntryEntityConverter<MedicationStatement, E> {

@Override
public E convert(@NonNull MedicationStatement resource) {
E entryEntity = super.convert(resource);
invokeTimeValues(entryEntity, resource);
return entryEntity;
}

public void invokeTimeValues(E entryEntity, MedicationStatement resource) {
invokeOriginValue(entryEntity, resource);
invokeSetTimeValue(entryEntity, resource);
}

public void invokeSetTimeValue(E entryEntity, MedicationStatement resource){
try {
Method setOriginValue = entryEntity.getClass().getMethod("setOriginValue", TemporalAccessor.class);
setOriginValue.invoke(entryEntity, TimeConverter.convertMedicationStatmentTime(resource));
} catch (IllegalAccessException | InvocationTargetException exception) {
exception.printStackTrace();
} catch (NoSuchMethodException ignored){
//ignored
}
}

public void invokeOriginValue(E entryEntity, MedicationStatement resource){
try {
Method setTimeValue = entryEntity.getClass().getMethod("setTimeValue", TemporalAccessor.class);
setTimeValue.invoke(entryEntity, TimeConverter.convertMedicationStatmentTime(resource));
} catch ( IllegalAccessException | InvocationTargetException exception) {
exception.printStackTrace();
}catch (NoSuchMethodException ignored){
//ignored
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.ehrbase.fhirbridge.ehr.converter.generic;

import org.springframework.lang.NonNull;
import org.ehrbase.client.classgenerator.interfaces.PointEventEntity;
import org.hl7.fhir.r4.model.MedicationStatement;


public abstract class MedicationStatementToPointEventConverter <P extends PointEventEntity> extends EventEntityConverter<MedicationStatement, P> {

@Override
public P convert(@NonNull MedicationStatement resource) {
P pointEvent = super.convert(resource);
pointEvent.setTimeValue(TimeConverter.convertMedicationStatmentTime(resource));
return pointEvent;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.hl7.fhir.r4.model.Condition;
import org.hl7.fhir.r4.model.DiagnosticReport;
import org.hl7.fhir.r4.model.MedicationStatement;
import org.hl7.fhir.r4.model.Observation;
import org.hl7.fhir.r4.model.Procedure;
import org.hl7.fhir.r4.model.QuestionnaireResponse;
Expand Down Expand Up @@ -102,4 +103,22 @@ public static Optional<TemporalAccessor> convertProcedureEndTime(Procedure resou
return Optional.empty();
}
}

public static TemporalAccessor convertMedicationStatmentTime(MedicationStatement medicationStatement){
if (medicationStatement.hasEffectiveDateTimeType()) { // EffectiveDateTime
return medicationStatement.getEffectiveDateTimeType().getValueAsCalendar().toZonedDateTime();
} else if (medicationStatement.hasEffectivePeriod() && medicationStatement.getEffectivePeriod().hasStart()) { // EffectivePeriod
return medicationStatement.getEffectivePeriod().getStartElement().getValueAsCalendar().toZonedDateTime();
}else{
return ZonedDateTime.now();
}
}

public static Optional<TemporalAccessor> convertMedicationStatementEndTime(MedicationStatement medicationStatement){
if (medicationStatement.hasEffectivePeriod() && medicationStatement.getEffectivePeriod().hasEnd()) { // EffectivePeriod
return Optional.of(medicationStatement.getEffectivePeriod().getStartElement().getValueAsCalendar().toZonedDateTime());
} else {
return Optional.empty();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ public enum CodeSystem {

SNOMED("http://snomed.info/sct"),

HL7_DATA_ABSENT_REASON("http://terminology.hl7.org/CodeSystem/data-absent-reason");
HL7_DATA_ABSENT_REASON("http://terminology.hl7.org/CodeSystem/data-absent-reason"),

DIMDI_ATC("http://fhir.de/CodeSystem/dimdi/atc");

private final String url;

Expand Down
Loading

0 comments on commit d8b057a

Please sign in to comment.