Skip to content

Commit

Permalink
merge latest updates on develop 2.x branch
Browse files Browse the repository at this point in the history
  • Loading branch information
ralych committed Oct 25, 2024
2 parents 39ec3c8 + 74c6e66 commit 4311292
Show file tree
Hide file tree
Showing 100 changed files with 5,914 additions and 382 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
package org.projecthusky.communication.ch.camel.chpharm1.requests.query;

import org.checkerframework.checker.nullness.qual.Nullable;
import org.openehealth.ipf.commons.ihe.xds.core.metadata.Code;
import org.openehealth.ipf.commons.ihe.xds.core.metadata.DocumentEntryType;
import org.openehealth.ipf.commons.ihe.xds.core.metadata.TimeRange;

Expand Down Expand Up @@ -44,6 +45,11 @@ public class ChFindMedicationCardQuery extends ChPharmacyDocumentsQuery {
*/
@Nullable
private Boolean includeNonActive;
/**
* Specific paper/print format for the PMLC PDF (original representation).
*/
@Nullable
private Code paperFormat;

/**
* Constructs the query.
Expand Down Expand Up @@ -87,6 +93,10 @@ public void setLanguageCode(@Nullable final String languageCode) {
public Boolean getIncludeNonActive() { return includeNonActive; }
public void setIncludeNonActive(@Nullable final Boolean includeNonActive) {this.includeNonActive = includeNonActive;}

@Nullable
public Code getPaperFormat() { return paperFormat; }
public void setPaperFormat(@Nullable final Code paperFormat) {this.paperFormat = paperFormat;}

@Override
public boolean equals(final Object o) {
if (this == o) return true;
Expand All @@ -95,12 +105,13 @@ public boolean equals(final Object o) {
&& Objects.equals(serviceStart, that.serviceStart)
&& Objects.equals(serviceEnd, that.serviceEnd)
&& Objects.equals(languageCode, that.languageCode)
&& Objects.equals(includeNonActive, that.includeNonActive);
&& Objects.equals(includeNonActive, that.includeNonActive)
&& Objects.equals(paperFormat, that.paperFormat);
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), documentEntryTypes, serviceStart, serviceEnd, languageCode, includeNonActive);
return Objects.hash(super.hashCode(), documentEntryTypes, serviceStart, serviceEnd, languageCode, includeNonActive, paperFormat);
}

@Override
Expand All @@ -111,6 +122,7 @@ public String toString() {
", serviceEnd=" + this.serviceEnd +
", languageCode='" + this.languageCode + '\'' +
", includeNonActive='" + this.includeNonActive + '\'' +
", paperFormat='" + this.paperFormat + '\'' +
", type=" + this.type +
", homeCommunityId='" + this.homeCommunityId + '\'' +
", extraParameters=" + this.extraParameters +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
package org.projecthusky.communication.ch.camel.chpharm1.transform.requests.query;

import org.checkerframework.checker.nullness.qual.Nullable;
import org.openehealth.ipf.commons.ihe.xds.core.metadata.Code;
import org.openehealth.ipf.commons.ihe.xds.core.metadata.Hl7v2Based;
import org.projecthusky.communication.ch.camel.chpharm1.requests.query.ChFindMedicationCardQuery;
import org.openehealth.ipf.commons.ihe.xds.core.ebxml.EbXMLAdhocQueryRequest;
import org.openehealth.ipf.commons.ihe.xds.core.transform.requests.query.QuerySlotHelper;
Expand All @@ -29,6 +31,7 @@ public class ChFindMedicationCardQueryTransformer extends ChPharmacyDocumentsQue
*/
public static final String DOC_ENTRY_LANGUAGE_CODE = "$XDSDocumentEntryLanguageCode";
public static final String PMLC_QUERY_INCLUDE_NON_ACTIVE = "$PMLCIncludeNonActive";
public static final String PMLC_QUERY_PAPER_FORMAT = "$PMLCPaperFormat";

/**
* Transforms the query into its EbXML representation.
Expand Down Expand Up @@ -64,6 +67,11 @@ public void toEbXML(@Nullable final ChFindMedicationCardQuery query,
if (query.getIncludeNonActive() != null) {
ebXML.addSlot(PMLC_QUERY_INCLUDE_NON_ACTIVE, QuerySlotHelper.encodeAsString(query.getIncludeNonActive().toString()));
}

if (query.getPaperFormat() != null) {

ebXML.addSlot(PMLC_QUERY_PAPER_FORMAT, QuerySlotHelper.encodeAsString(Hl7v2Based.render(query.getPaperFormat())));
}
}

/**
Expand Down Expand Up @@ -95,5 +103,6 @@ public void fromEbXML(@Nullable final ChFindMedicationCardQuery query,

query.setLanguageCode(QuerySlotHelper.decodeString(ebXML.getSingleSlotValue(DOC_ENTRY_LANGUAGE_CODE)));
query.setIncludeNonActive(Boolean.valueOf(QuerySlotHelper.decodeString(ebXML.getSingleSlotValue(PMLC_QUERY_INCLUDE_NON_ACTIVE))));
query.setPaperFormat(Hl7v2Based.parse(QuerySlotHelper.decodeString(ebXML.getSingleSlotValue(PMLC_QUERY_PAPER_FORMAT)), Code.class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.Extension;
import ca.uhn.fhir.model.api.annotation.ResourceDef;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.hl7.fhir.r4.model.*;
import org.projecthusky.fhir.emed.ch.common.annotation.ExpectsValidResource;
import org.projecthusky.fhir.emed.ch.common.enums.ReligiousAffiliation;
import org.projecthusky.fhir.emed.ch.common.error.InvalidEmedContentException;
import org.projecthusky.fhir.emed.ch.common.util.FhirDateTimes;

import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

Expand Down Expand Up @@ -187,6 +191,101 @@ public Identifier addIdentifier(final String system,
.setValue(value);
}

/**
* Resolves the language of correspondence (i.e. preferred communication language) of the patient.
* @return the preferred patient component with the language of correspondence.
*/
public @Nullable PatientCommunicationComponent resolveLanguageOfCorrespondence() {
return getCommunication().stream().filter( com -> com != null && com.getPreferred()).findAny().orElse(null);
}

/**
* Fetches the list of contact points which are an email address.
* @return The list of contact points.
*/
public List<@NonNull ContactPoint> resolveEmailAddresses() {
return resolveTelecom(ContactPoint.ContactPointSystem.EMAIL);
}

/**
* Fetches the list of email addresses values. It does not check their period.
* @return The list of email addresses values.
*/
public List<@NonNull String> resolveEmailAddressesAsStrings() {
return resolveEmailAddressesAsStrings(false);
}

/**
* Fetches the list of email address values, optionally checking if the period is valid at the moment.
* @param activeOnly If true, the method will filter out email address for which the current timestamp is not within
* the period boundaries, if defined.
* @return The list of matching email addresses, as strings.
*/
public List<@NonNull String> resolveEmailAddressesAsStrings(boolean activeOnly) {
return resolveTelecomAsStrings(ContactPoint.ContactPointSystem.EMAIL, activeOnly);
}

/**
* Fetches the list of contact points which are a phone number.
* @return The list of contact points.
*/
public List<@NonNull ContactPoint> resolvePhoneNumbers() {
return resolveTelecom(ContactPoint.ContactPointSystem.PHONE);
}

/**
* Fetches the list of phone number values. It does not check their period.
* @return The list of phone number values as strings.
*/
public List<@NonNull String> resolvePhoneNumbersAsStrings() {
return resolvePhoneNumbersAsStrings(false);
}

/**
* Fetches the list of email address values, optionally checking if the period is valid at the moment.
* @param activeOnly If true, the method will filter out phone numbers for which the current timestamp is not within
* the period boundaries, if defined.
* @return The list of matching email addresses, as strings.
*/
public List<@NonNull String> resolvePhoneNumbersAsStrings(boolean activeOnly) {
return resolveTelecomAsStrings(ContactPoint.ContactPointSystem.PHONE, activeOnly);
}

/**
* Fetches the list of telecom contact point values for the specified system and optionally checking whether they
* are valid at the current time.
*
* @param system The contact point system that must match.
* @param activeOnly Whether to return only contact points for which the current timestamp is within the specified
* boundaries (if any).
* @return The list of strings with the matching contact points values.
*/
private List<@NonNull String> resolveTelecomAsStrings(final ContactPoint.ContactPointSystem system,
boolean activeOnly) {
return resolveTelecom(system).stream().filter(telecom -> {
if (telecom.hasValue()) {
if (activeOnly) {
if (telecom.hasPeriod() && (telecom.getPeriod().hasStart() || telecom.getPeriod().hasEnd())) {
if (telecom.getPeriod().hasStart() && telecom.getPeriod().getStartElement().getValueAsCalendar().after(Calendar.getInstance()))
return false;
if (telecom.getPeriod().hasEnd() && FhirDateTimes.completeToLatestInstant(telecom.getPeriod().getEndElement()).isBefore(Instant.now()))
return false;
} else return true;
} else return true;
}
return false;
}).map(ContactPoint::getValue).toList();
}

/**
* Gets the list of telecom contact points that match the specified system.
* @param system The specific system for which to fetch all the contact points.
* @return The list of contact points.
*/
private List<@NonNull ContactPoint> resolveTelecom(final ContactPoint.ContactPointSystem system) {
return getTelecom().stream().filter(telecom -> telecom.getSystem() == system).toList();
}

@Override
public ChCorePatientEpr copy() {
final var copy = new ChCorePatientEpr();
Expand Down
155 changes: 86 additions & 69 deletions husky-fhir/husky-fhir-emed-ch/husky-fhir-emed-ch-epr-narrative/pom.xml
Original file line number Diff line number Diff line change
@@ -1,79 +1,96 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>husky-fhir-emed-ch</artifactId>
<groupId>org.projecthusky.fhir.emed.ch</groupId>
<version>3.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>
husky-fhir-emed-ch-epr-narrative</artifactId>
<name>Husky FHIR eMedication
Switzerland EPR Narrative</name>
<parent>
<artifactId>husky-fhir-emed-ch</artifactId>
<groupId>org.projecthusky.fhir.emed.ch</groupId>
<version>3.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.projecthusky.fhir.emed.ch</groupId>
<artifactId>husky-fhir-emed-ch-common</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.projecthusky.fhir.emed.ch</groupId>
<artifactId>husky-fhir-emed-ch-epr</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.projecthusky.validation.service</groupId>
<artifactId>husky-validation-service</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>

<artifactId>husky-fhir-emed-ch-epr-narrative</artifactId>
<name>Husky FHIR eMedication Switzerland EPR Narrative</name>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation</artifactId>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-r4</artifactId>
</dependency>

<properties>
<openhtmltopdf-version>1.0.10</openhtmltopdf-version>
</properties>
<!-- HTML to PDF conversion -->
<dependency>
<groupId>io.github.openhtmltopdf</groupId>
<artifactId>openhtmltopdf-core</artifactId> <!-- LGPL -->
</dependency>
<dependency>
<groupId>io.github.openhtmltopdf</groupId>
<artifactId>openhtmltopdf-pdfbox</artifactId> <!-- LGPL -->
</dependency>
<dependency>
<groupId>io.github.openhtmltopdf</groupId>
<artifactId>openhtmltopdf-slf4j</artifactId>
</dependency>
<dependency>
<!-- SVG support plugin. -->
<groupId>io.github.openhtmltopdf</groupId>
<artifactId>openhtmltopdf-svg-support</artifactId>
</dependency>

<dependencies>
<dependency>
<groupId>org.projecthusky.fhir.emed.ch</groupId>
<artifactId>husky-fhir-emed-ch-common</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.projecthusky.fhir.emed.ch</groupId>
<artifactId>husky-fhir-emed-ch-epr</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
</dependency>

<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation</artifactId>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-r4</artifactId>
</dependency>
<dependency>
<!-- The Checker Framework enhances Java's type system to make it
more powerful and useful. -->
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId> <!-- MIT -->
</dependency>

<!-- HTML to PDF conversion -->
<dependency>
<groupId>com.openhtmltopdf</groupId>
<artifactId>openhtmltopdf-core</artifactId> <!-- LGPL -->
<version>${openhtmltopdf-version}</version>
</dependency>
<dependency>
<groupId>com.openhtmltopdf</groupId>
<artifactId>openhtmltopdf-pdfbox</artifactId> <!-- LGPL -->
<version>${openhtmltopdf-version}</version>
</dependency>
<dependency>
<groupId>com.openhtmltopdf</groupId>
<artifactId>openhtmltopdf-slf4j</artifactId>
<version>${openhtmltopdf-version}</version>
</dependency>
<!-- QR code generator -->
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
</dependency>
<!-- Tests (EPL 2.0) -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<!-- The Checker Framework enhances Java's type system to make it more powerful and useful. -->
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId> <!-- MIT -->
</dependency>

<!-- Tests (EPL 2.0) -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>

</dependencies>
</dependencies>

</project>
Loading

0 comments on commit 4311292

Please sign in to comment.