Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .mvn/jvm.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--add-opens=java.base/java.util=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED
Copy link
Member

@sherrif10 sherrif10 Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need mvn configurations. ?

--add-opens=java.base/java.lang.reflect=ALL-UNNAMED
--add-opens=java.base/java.io=ALL-UNNAMED
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
*
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
* graphic logo is a trademark of OpenMRS Inc.
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Organize this comments . Ensure they are on the same line.

/*
* Rights Reserved, Unlicensed
*/
package org.openmrs.module.fhir2.api.util;

import org.hl7.fhir.r4.model.CodeableConcept;
import org.hl7.fhir.r4.model.Coding;

public class FhirNormalizationUtils {

/**
* Normalize a CodeableConcept by trimming code/system/display and decoding HL7 v2 escape sequences.
*/
public static void normalize(CodeableConcept concept) {
if (concept == null) {
return;
}
for (Coding coding : concept.getCoding()) {
if (coding.hasCode()) {
coding.setCode(clean(coding.getCode()));
}
if (coding.hasSystem()) {
coding.setSystem(clean(coding.getSystem()));
}
if (coding.hasDisplay()) {
coding.setDisplay(clean(coding.getDisplay()));
}
}
}

private static String clean(String input) {
if (input == null) {
return null;
}
String trimmed = input.trim();
return decodeHl7Escapes(trimmed);
}

/**
* Simplified HL7 v2 escape decoding (handles \F\ | \S\ | \T\ | \R\ | \E\).
*/
private static String decodeHl7Escapes(String value) {
return value.replace("\\F\\", "|").replace("\\S\\", "^").replace("\\T\\", "&").replace("\\R\\", "~").replace("\\E\\",
"\\");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
*
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
* graphic logo is a trademark of OpenMRS Inc.
*/
/*
* Rights Reserved, Unlicensed
*/
package org.openmrs.module.fhir2.api.util;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.hl7.fhir.r4.model.CodeableConcept;
import org.hl7.fhir.r4.model.Coding;
import org.junit.jupiter.api.Test;

public class FhirNormalizationUtilsTest {

@Test
public void shouldTrimAndDecodeCodings() {
CodeableConcept concept = new CodeableConcept();
concept.addCoding(
new Coding().setSystem(" http://loinc.org ").setCode(" 1234-5 ").setDisplay("Blood Test \\F\\ Panel"));

FhirNormalizationUtils.normalize(concept);

Coding coding = concept.getCodingFirstRep();
assertEquals("http://loinc.org", coding.getSystem());
assertEquals("1234-5", coding.getCode());
assertEquals("Blood Test | Panel", coding.getDisplay());
}
}