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
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,31 @@ public static String getNarrativeDiv(String text) {
return String.format(divText, StringEscapeUtils.escapeHtml4(text).replace("~", "<br />"));
}

public static Integer getDurationInMinutes(Integer duration, String unit) {
if (duration == null) {
return null;
}

if (unit == null) {
return duration / 60; // Convert seconds to minutes
}

switch (unit.toLowerCase().trim()) {
case "":
case "s":
case "sec":
return duration / 60; // Convert seconds to minutes
case "h":
case "hr":
return duration * 60; // Convert hours to minutes
case "d":
case "day":
return duration * 24 * 60; // Convert days to minutes
default:
return duration; // Assume already in minutes
}
}

// Private method to split and format the 7 digit local telecom number
private static String formatLocalNumber(String localNumber) {
// Split after the 3rd digit, add a space, add the rest of the number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public enum SimpleDataTypeMapper {
DIAGNOSTIC_REPORT_STATUS(SimpleDataValueResolver.DIAGNOSTIC_REPORT_STATUS_CODES),
ARRAY(SimpleDataValueResolver.ARRAY),
OBSERVATION_STATUS(SimpleDataValueResolver.OBSERVATION_STATUS_CODE_FHIR),
SERVICE_REQUEST_STATUS(SimpleDataValueResolver.SERVICE_REQUEST_STATUS),
APPOINTMENT_STATUS_CODE_FHIR(SimpleDataValueResolver.APPOINTMENT_STATUS_CODE_FHIR),
SERVICE_REQUEST_STATUS(SimpleDataValueResolver.SERVICE_REQUEST_STATUS),
RELATIVE_REFERENCE(SimpleDataValueResolver.RELATIVE_REFERENCE),
MESSAGE_REASON_ENCOUNTER(SimpleDataValueResolver.MESSAGE_REASON_ENCOUNTER),
SPECIMEN_STATUS(SimpleDataValueResolver.SPECIMEN_STATUS_CODE_FHIR),
Expand Down Expand Up @@ -78,7 +79,8 @@ public enum SimpleDataTypeMapper {
CLEAN_SSN(SimpleDataValueResolver.CLEAN_SSN),
ENCOUNTER_MODE_ARRIVAL_DISPLAY(SimpleDataValueResolver.ENCOUNTER_MODE_ARRIVAL_DISPLAY),
CONTACT_POINT_SYSTEM(SimpleDataValueResolver.CONTACT_POINT_SYSTEM),
CONTACT_POINT_USE(SimpleDataValueResolver.CONTACT_POINT_USE);
CONTACT_POINT_USE(SimpleDataValueResolver.CONTACT_POINT_USE),
ALLERGY_INTOLERANCE_SEVERITY(SimpleDataValueResolver.ALLERGY_INTOLERANCE_SEVERITY_CODE_FHIR);

private ValueExtractor<Object, ?> valueResolver;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.apache.commons.lang3.math.NumberUtils;
import org.hl7.fhir.dstu3.model.codesystems.MedicationRequestCategory;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.model.AllergyIntolerance;
import org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCategory;
import org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCriticality;
import org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus;
Expand All @@ -44,6 +45,7 @@
import org.hl7.fhir.r4.model.ServiceRequest.ServiceRequestStatus;
import org.hl7.fhir.r4.model.Specimen.SpecimenStatus;

import org.hl7.fhir.r4.model.codesystems.Appointmentstatus;
import org.hl7.fhir.r4.model.codesystems.V3ActCode;
import org.hl7.fhir.r4.model.codesystems.V3MaritalStatus;
import org.hl7.fhir.r4.model.codesystems.ConditionCategory;
Expand Down Expand Up @@ -209,6 +211,12 @@ public class SimpleDataValueResolver {
return getFHIRCode(val, ObservationStatus.class);
};


public static final ValueExtractor<Object, String> APPOINTMENT_STATUS_CODE_FHIR = (Object value) -> {
String val = Hl7DataHandlerUtil.getStringValue(value);
return getFHIRCode(val, Appointmentstatus.class);
};

// Handlers for searching Immunization.education siblings.
public static final ValueExtractor<Object, String> FIND_EDUCATION_REFERENCE_TEXT = (Object value) -> {
return getSelectedSiblingObservationTEXTfromObxGroup(value, "30956-7");
Expand Down Expand Up @@ -942,4 +950,9 @@ public static String getFHIRCode(String hl7Value, String fhirMappingConceptName)
}
return null;
};

public static final ValueExtractor<Object, String> ALLERGY_INTOLERANCE_SEVERITY_CODE_FHIR = (Object value) -> {
String val = Hl7DataHandlerUtil.getStringValue(value);
return getFHIRCode(val, AllergyIntolerance.AllergyIntoleranceSeverity.class);
};
}
23 changes: 22 additions & 1 deletion src/main/resources/hl7/codesystem/v2ToFhirMapping.yml
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ RelatedPersonNeededIN272:
17: TRUE # Minor dependent of a minor dependant input (grandchild dependent) : Grandparent
18: TRUE # Parent : Child
19: TRUE # Grandparent : Grandchild

ContactPointSystem:
PH: phone
FX: fax
Expand All @@ -567,9 +568,29 @@ ContactPointSystem:
TDD: other
TTY: other
SAT: other

ContactPointUse:
PRN: home
VHN: home
NET: home
WPN: work
PRS: mobile
PRS: mobile

Appointmentstatus:
PROPOSED: proposed
PENDING: pending
WAITLIST: waitlist
BOOKED: booked
STARTED: checked-in
COMPLETE: fulfilled
CANCELLED: cancelled
DC: cancelled
DISCONTINUED: cancelled
DELETED: entered-in-error
OVERBOOK: booked
NOSHOW: noshow

AllergyIntoleranceSeverity:
MI: mild
MO: moderate
SV: severe
Original file line number Diff line number Diff line change
Expand Up @@ -458,4 +458,25 @@ void testContactPointUse(String hl7Code) throws DataTypeException {
break;
}
}

@ParameterizedTest
@ValueSource(strings = { "MI", "MO", "SV"})
void testAllergyIntoleranceSeverity(String hl7Code) {
String severity = SimpleDataValueResolver.ALLERGY_INTOLERANCE_SEVERITY_CODE_FHIR.apply(hl7Code);
switch (hl7Code) {
case "MI":
assertThat(severity).isEqualTo("mild");
break;
case "MO":
assertThat(severity).isEqualTo("moderate");
break;
case "SV":
assertThat(severity).isEqualTo("severe");
break;
default:
assertThat(severity).isNull();
break;
}

}
}
Loading