diff --git a/build.gradle b/build.gradle index ffbc45c6..8e03e0c4 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,8 @@ plugins { id 'signing' } -group = 'io.github.linuxforhealth' +// group = 'io.github.linuxforhealth' +group = 'net.fhirfactory.pegacorn' version = (findProperty('version') == 'unspecified') ? '1.0.1-SNAPSHOT' : version ext.isReleaseVersion = !version.endsWith("SNAPSHOT") diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 12d38de6..a5f05cc7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip +distributionUrl=https\://downloads.gradle-dn.com/distributions/gradle-6.6.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000..07d6bf78 --- /dev/null +++ b/pom.xml @@ -0,0 +1,263 @@ + + + + + + + + + + + + + + + 4.0.0 + + + + + + + + + net.fhirfactory.pegacorn + pegacorn + 1.5.0-SNAPSHOT + ../pegacorn + + + pegacorn-hl7v2-fhir-converter + jar + 1.0.1-SNAPSHOT + + Pegacorn :: HL7-FHIR-Converter + Converter of HL7 to FHIR JSON + + + + + + + + + + + + org.apache.commons + commons-lang3 + 3.9 + + + org.apache.commons + commons-math3 + 3.6.1 + + + com.fasterxml.jackson.core + jackson-databind + 2.10.1 + + + com.google.guava + guava + 23.0 + + + commons-io + commons-io + 2.6 + + + ca.uhn.hapi + hapi-base + 2.3 + + + ca.uhn.hapi + hapi-structures-v26 + 2.3 + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + 2.10.1 + + + com.fasterxml.jackson.datatype + jackson-datatype-jdk8 + 2.10.1 + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + 2.10.1 + + + org.apache.commons + commons-text + 1.8 + + + ca.uhn.hapi.fhir + hapi-fhir-structures-r4 + 5.1.0 + + + ca.uhn.hapi.fhir + hapi-fhir-structures-r5 + 5.1.0 + + + ca.uhn.hapi.fhir + hapi-fhir-validation + 5.1.0 + + + ca.uhn.hapi.fhir + hapi-fhir-validation-resources-r4 + 5.1.0 + + + org.apache.commons + commons-jexl3 + 3.1 + + + org.apache.commons + commons-configuration2 + 2.7 + + + org.apache.commons + commons-collections4 + 4.4 + + + com.ibm.fhir + fhir-registry + 4.9.0 + + + com.ibm.fhir + fhir-term + 4.9.0 + + + commons-beanutils + commons-beanutils + 1.9.4 + + + ch.qos.logback + logback-classic + 1.2.3 + test + + + org.assertj + assertj-core + 3.9.0 + test + + + jakarta.json + jakarta.json-api + 2.0.1 + test + + + org.junit.jupiter + junit-jupiter-api + 5.7.2 + test + + + org.junit.jupiter + junit-jupiter-params + 5.7.2 + test + + + + + + + + ch.qos.logback + logback-classic + ${version-ch.qos.logback-classic} + compile + + + + ch.qos.logback + logback-core + ${version-ch.qos.logback-classic} + compile + + + + + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${version-org.apache.maven-compiler-plugin} + + ${maven.compiler.source} + ${maven.compiler.target} + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${version-org.apache.maven-surefire-plugin} + + + org.apache.maven.plugins + maven-failsafe-plugin + ${version-org.apache.maven-failsafe-plugin} + + + + + + + + + + + + + + + default + + true + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${version-org.apache.maven-surefire-plugin} + + true + + + + + + + + diff --git a/src/main/java/io/github/linuxforhealth/hl7/HL7ToFHIRConverter.java b/src/main/java/io/github/linuxforhealth/hl7/HL7ToFHIRConverter.java index 23f4c3c8..1d164c31 100644 --- a/src/main/java/io/github/linuxforhealth/hl7/HL7ToFHIRConverter.java +++ b/src/main/java/io/github/linuxforhealth/hl7/HL7ToFHIRConverter.java @@ -40,6 +40,7 @@ public class HL7ToFHIRConverter { private static HL7HapiParser hparser = new HL7HapiParser(); private static final Logger LOGGER = LoggerFactory.getLogger(HL7ToFHIRConverter.class); + private static final String FALLBACK_BASE = "Fallback_Base"; // fallback configuration file to use when Trigger Event does not match anything (only used if enabled in supported.hl7.messages) private Map messagetemplates = new HashMap<>(); /** @@ -130,7 +131,15 @@ public String convert(String hl7MessageData, ConverterOptions options) { if (hl7MessageTemplateModel != null) { return hl7MessageTemplateModel.convert(hl7message, engine); } else { - throw new UnsupportedOperationException("Message type not yet supported " + messageType); + // try to get the our fallback template + hl7MessageTemplateModel = messagetemplates.get(FALLBACK_BASE); + if (hl7MessageTemplateModel != null) { + // fallback template is enabled so use it just like a normal message template model + return hl7MessageTemplateModel.convert(hl7message, engine); + } else { + // it is not enabled by being in the supported.hl7.messages + throw new UnsupportedOperationException("Message type not yet supported " + messageType); + } } } else { throw new IllegalArgumentException("Parsed HL7 message was null."); diff --git a/src/main/java/io/github/linuxforhealth/hl7/data/SimpleDataTypeMapper.java b/src/main/java/io/github/linuxforhealth/hl7/data/SimpleDataTypeMapper.java index 9238d7c8..27736051 100644 --- a/src/main/java/io/github/linuxforhealth/hl7/data/SimpleDataTypeMapper.java +++ b/src/main/java/io/github/linuxforhealth/hl7/data/SimpleDataTypeMapper.java @@ -44,6 +44,7 @@ public enum SimpleDataTypeMapper { ALLERGY_INTOLERANCE_CATEGORY(SimpleDataValueResolver.ALLERGY_INTOLERANCE_CATEGORY_CODE_FHIR), ALLERGY_INTOLERANCE_CRITICALITY( SimpleDataValueResolver.ALLERGY_INTOLERANCE_CRITICALITY_CODE_FHIR), + ALLERGY_INTOLERANCE_TYPE(SimpleDataValueResolver.ALLERGY_INTOLERANCE_TYPE_CODE_FHIR), ADMINISTRATIVE_GENDER(SimpleDataValueResolver.ADMINISTRATIVE_GENDER_CODE_FHIR), CONDITION_CATEGORY_CODES(SimpleDataValueResolver.CONDITION_CATEGORY_CODES), DIAGNOSTIC_REPORT_STATUS(SimpleDataValueResolver.DIAGNOSTIC_REPORT_STATUS_CODES), diff --git a/src/main/java/io/github/linuxforhealth/hl7/data/SimpleDataValueResolver.java b/src/main/java/io/github/linuxforhealth/hl7/data/SimpleDataValueResolver.java index eed27cf1..87e20d49 100644 --- a/src/main/java/io/github/linuxforhealth/hl7/data/SimpleDataValueResolver.java +++ b/src/main/java/io/github/linuxforhealth/hl7/data/SimpleDataValueResolver.java @@ -32,6 +32,7 @@ import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCategory; import org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCriticality; +import org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceType; import org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus; import org.hl7.fhir.r4.model.Enumerations.AdministrativeGender; import org.hl7.fhir.r4.model.Immunization.ImmunizationStatus; @@ -577,6 +578,11 @@ private static final SimpleCode commonCodingSystemV2 (String table, String code, String val = Hl7DataHandlerUtil.getStringValue(value); return getFHIRCode(val, AllergyIntoleranceCategory.class); }; + + public static final ValueExtractor ALLERGY_INTOLERANCE_TYPE_CODE_FHIR = (Object value) -> { + String val = Hl7DataHandlerUtil.getStringValue(value); + return getFHIRCode(val, AllergyIntoleranceType.class); + }; public static final ValueExtractor DOSE_SYSTEM = (Object value) -> { String val = Hl7DataHandlerUtil.getStringValue(value); diff --git a/src/main/resources/config.properties b/src/main/resources/config.properties index 151b2e73..83000fe2 100644 --- a/src/main/resources/config.properties +++ b/src/main/resources/config.properties @@ -1,4 +1,4 @@ base.path.resource= -supported.hl7.messages=ADT_A01, ADT_A08, ADT_A34, ADT_A40, MDM_T02, MDM_T06, ORM_O01, OMP_O09, ORU_R01, PPR_PC1, RDE_O11, RDE_O25, VXU_V04 -default.zoneid=+08:00 +supported.hl7.messages=Fallback_Base, ADT_A01, ADT_A04, ADT_A05, ADT_A08, ADT_A31, ADT_A34, ADT_A40, ADT_A60, MDM_T02, MDM_T06, ORM_O01, OMP_O09, ORU_R01, PPR_PC1, RDE_O11, RDE_O25, VXU_V04 +default.zoneid=+11:00 additional.conceptmap.file= \ No newline at end of file diff --git a/src/main/resources/fhir/resourcemapping.yml b/src/main/resources/fhir/resourcemapping.yml index 673b365e..fe9ec11c 100644 --- a/src/main/resources/fhir/resourcemapping.yml +++ b/src/main/resources/fhir/resourcemapping.yml @@ -12,6 +12,7 @@ Condition: org.hl7.fhir.r4.model.Condition Practitioner: org.hl7.fhir.r4.model.Practitioner DiagnosticReport: org.hl7.fhir.r4.model.DiagnosticReport Immunization: org.hl7.fhir.r4.model.Immunization +Location: org.hl7.fhir.r4.model.Location Organization: org.hl7.fhir.r4.model.Organization MessageHeader: org.hl7.fhir.r4.model.MessageHeader Medication: org.hl7.fhir.r4.model.Medication diff --git a/src/main/resources/hl7/codesystem/v2ToFhirMapping.yml b/src/main/resources/hl7/codesystem/v2ToFhirMapping.yml index 96e2c6d8..f7f071f1 100644 --- a/src/main/resources/hl7/codesystem/v2ToFhirMapping.yml +++ b/src/main/resources/hl7/codesystem/v2ToFhirMapping.yml @@ -7,14 +7,19 @@ AllergyIntoleranceCategory: AA: environment DA: medication + DRUG: medication EA: environment FA: food + FOOD: food LA: environment PA: environment AllergyIntoleranceCriticality: MI: low SV: high U: unable-to-assess +AllergyIntoleranceType: + AL: allergy + IN: intolerance ObservationStatus: C: corrected D: cancelled diff --git a/src/main/resources/hl7/message/ADT_A05.yml b/src/main/resources/hl7/message/ADT_A05.yml new file mode 100644 index 00000000..d1d161a0 --- /dev/null +++ b/src/main/resources/hl7/message/ADT_A05.yml @@ -0,0 +1,52 @@ +# FHIR Resources to extract from ADT_A60 message +--- +resources: + - resourceName: MessageHeader + segment: MSH + resourcePath: resource/MessageHeader + repeats: false + isReferenced: false + additionalSegments: + - EVN + + - resourceName: Patient + segment: PID + resourcePath: resource/Patient + repeats: false + isReferenced: true + additionalSegments: + - PD1 + - MSH + + - resourceName: Encounter + segment: PV1 + resourcePath: resource/Encounter + repeats: false + isReferenced: true + additionalSegments: + - PV2 + - EVN + - MSH + - OBX + + - resourceName: Observation + segment: OBX + resourcePath: resource/Observation + repeats: true + isReferenced: true + additionalSegments: + - MSH + + - resourceName: AllergyIntolerance + segment: AL1 + resourcePath: resource/AllergyIntolerance + repeats: true + additionalSegments: + - MSH + + - resourceName: Condition + segment: DG1 + resourcePath: resource/Condition + repeats: true + additionalSegments: + - MSH \ No newline at end of file diff --git a/src/main/resources/hl7/message/ADT_A60.yml b/src/main/resources/hl7/message/ADT_A60.yml new file mode 100644 index 00000000..bae96d47 --- /dev/null +++ b/src/main/resources/hl7/message/ADT_A60.yml @@ -0,0 +1,37 @@ +# FHIR Resources to extract from ADT_A60 message +--- +resources: + - resourceName: MessageHeader + segment: MSH + resourcePath: resource/MessageHeader + repeats: false + isReferenced: false + additionalSegments: + - EVN + + - resourceName: Patient + segment: PID + resourcePath: resource/Patient + repeats: false + isReferenced: true + additionalSegments: + - MSH + + + - resourceName: Encounter + segment: PV1 + resourcePath: resource/Encounter + repeats: false + isReferenced: true + additionalSegments: + - PV2 + - EVN + - MSH + + - resourceName: AllergyIntolerance + segment: IAM + resourcePath: resource/AllergyIntolerance + repeats: true + additionalSegments: + - MSH + - PID \ No newline at end of file diff --git a/src/main/resources/hl7/message/Fallback_Base.yml b/src/main/resources/hl7/message/Fallback_Base.yml new file mode 100644 index 00000000..15d2097e --- /dev/null +++ b/src/main/resources/hl7/message/Fallback_Base.yml @@ -0,0 +1,32 @@ +# FHIR Resources to extract from an unknown base as a fallback +# tries to get out patient and encounter data only +# to return to normal functionality without this fallback processing simply +# remove Fallback_Base from the supported.hl7.messages in config.properties +--- +resources: + - resourceName: MessageHeader + segment: MSH + resourcePath: resource/MessageHeader + repeats: false + isReferenced: false + additionalSegments: + - EVN + + - resourceName: Patient + segment: PID + resourcePath: resource/Patient + repeats: false + isReferenced: true + additionalSegments: + - MSH + + + - resourceName: Encounter + segment: PV1 + resourcePath: resource/Encounter + repeats: false + isReferenced: true + additionalSegments: + - PV2 + - EVN + - MSH diff --git a/src/main/resources/hl7/resource/AllergyIntolerance.yml b/src/main/resources/hl7/resource/AllergyIntolerance.yml index 3f0b1b5e..4f6e88da 100644 --- a/src/main/resources/hl7/resource/AllergyIntolerance.yml +++ b/src/main/resources/hl7/resource/AllergyIntolerance.yml @@ -10,7 +10,7 @@ id: valueOf: 'UUID.randomUUID()' expressionType: JEXL -identifier: +identifier_1: valueOf: datatype/Identifier generateList: true expressionType: resource @@ -20,6 +20,16 @@ identifier: constants: sys: "urn:id:extID" +identifier_2: + valueOf: datatype/Identifier + generateList: true + expressionType: resource + vars: + system: SYSTEM_URL, $sys + value: IAM.7 + constants: + sys: "urn:id:extID" + clinicalStatus: valueOf: datatype/CodeableConcept_var generateList: true @@ -38,10 +48,15 @@ verificationStatus: code: 'confirmed' display: 'Confirmed' +type: + type: ALLERGY_INTOLERANCE_TYPE + valueOf: IAM.9 + expressionType: HL7Spec + category: type: ALLERGY_INTOLERANCE_CATEGORY generateList: true - valueOf: AL1.2 + valueOf: AL1.2 | IAM.2 expressionType: HL7Spec criticality: @@ -53,13 +68,35 @@ code: valueOf: datatype/CodeableConcept generateList: true expressionType: resource - specs: AL1.3 + specs: AL1.3 | IAM.3 onsetDateTime: type: DATE_TIME valueOf: AL1.6 expressionType: HL7Spec +recordedDate: + type: DATE_TIME + valueOf: IAM.13 + expressionType: HL7Spec + +asserter_1: + condition: $iam18 NOT_NULL + valueOf: resource/Practitioner + expressionType: reference + specs: IAM.18 + vars: + iam18: IAM.18 + +asserter_2: + condition: $iam18 NULL && $iam14 NOT_NULL + valueOf: resource/Patient + expressionType: reference + specs: IAM.14 + vars: + iam14: IAM.14 + iam18: IAM.18 + patient: valueOf: datatype/Reference expressionType: resource diff --git a/src/main/resources/hl7/resource/Encounter.yml b/src/main/resources/hl7/resource/Encounter.yml index 6542fd5e..825a3896 100644 --- a/src/main/resources/hl7/resource/Encounter.yml +++ b/src/main/resources/hl7/resource/Encounter.yml @@ -202,6 +202,12 @@ participant_4: codeableConceptCode: 'ADM' codeableConceptText: 'admitter' +location: + valueOf: secondary/EncounterLocation + generateList: true + expressionType: resource + specs: PV1.3 | PV1.6 | PV1.11 | PV1.42 | PV1.43 + extension_1: generateList: true expressionType: nested diff --git a/src/main/resources/hl7/resource/Location.yml b/src/main/resources/hl7/resource/Location.yml new file mode 100644 index 00000000..694dd585 --- /dev/null +++ b/src/main/resources/hl7/resource/Location.yml @@ -0,0 +1,215 @@ +# A location tree based on HL7 Person Location (PL) for bed or more general based on this order: +# Bed (PL.3) > Room (PL.2) > Point of Care (PL.1) > Floor (PL.8) > Building (PL.7) > Facility (PL.4) +--- +resourceType: Location +id: + type: STRING + valueOf: UUID.randomUUID() + expressionType: JEXL + +name_1: + condition: $bed NOT_NULL + type: STRING + valueOf: PL.3 + expressionType: HL7Spec + vars: + bed: PL.3 + +name_2: + condition: $bed NULL && $room NOT_NULL + type: STRING + valueOf: PL.2 + expressionType: HL7Spec + vars: + bed: PL.3 + room: PL.2 + +name_3: + condition: $bed NULL && $room NULL && $pointofcare NOT_NULL + type: STRING + valueOf: PL.1 + expressionType: HL7Spec + vars: + bed: PL.3 + room: PL.2 + pointofcare: PL.1 + +name_4: + condition: $bed NULL && $room NULL && $pointofcare NULL && $floor NOT_NULL + type: STRING + valueOf: PL.8 + expressionType: HL7Spec + vars: + bed: PL.3 + room: PL.2 + pointofcare: PL.1 + floor: PL.8 + +name_5: + condition: $bed NULL && $room NULL && $pointofcare NULL && $floor NULL && $building NOT_NULL + type: STRING + valueOf: PL.7 + expressionType: HL7Spec + vars: + bed: PL.3 + room: PL.2 + pointofcare: PL.1 + floor: PL.8 + building: PL.7 + +name_6: + condition: $bed NULL && $room NULL && $pointofcare NULL && $floor NULL && $building NULL && $facility NOT_NULL + type: STRING + valueOf: PL.4 + expressionType: HL7Spec + vars: + bed: PL.3 + room: PL.2 + pointofcare: PL.1 + floor: PL.8 + building: PL.7 + facility: PL.4 + +partOf_1: + condition: $bed NOT_NULL + valueOf: resource/Location_Room + expressionType: reference + specs: PL + vars: + bed: PL.3 + +partOf_2: + condition: $bed NULL && $room NOT_NULL + valueOf: resource/Location_PointOfCare + expressionType: reference + specs: PL + vars: + bed: PL.3 + room: PL.2 + +partOf_3: + condition: $bed NULL && $room NULL && $pointofcare NOT_NULL + valueOf: resource/Location_Floor + expressionType: reference + specs: PL + vars: + bed: PL.3 + room: PL.2 + pointofcare: PL.1 + +partOf_4: + condition: $bed NULL && $room NULL && $pointofcare NULL && $floor NOT_NULL + valueOf: resource/Location_Building + expressionType: reference + specs: PL + vars: + bed: PL.3 + room: PL.2 + pointofcare: PL.1 + floor: PL.8 + +partOf_5: + condition: $bed NULL && $room NULL && $pointofcare NULL && $floor NULL && $building NOT_NULL + valueOf: resource/Location_Facility + expressionType: reference + specs: PL + vars: + bed: PL.3 + room: PL.2 + pointofcare: PL.1 + floor: PL.8 + building: PL.7 + +physicalType_1: + condition: $bed NOT_NULL + valueOf: datatype/CodeableConcept_var + expressionType: resource + constants: + system: 'http://hl7.org/fhir/ValueSet/location-physical-type' + code: 'bd' + text: 'Bed' + vars: + bed: PL.3 + +physicalType_2: + condition: $bed NULL && $room NOT_NULL + valueOf: datatype/CodeableConcept_var + expressionType: resource + constants: + system: 'http://hl7.org/fhir/ValueSet/location-physical-type' + code: 'ro' + text: 'Room' + vars: + bed: PL.3 + room: PL.2 + +physicalType_3: + condition: $bed NULL && $room NULL && $pointofcare NOT_NULL + valueOf: datatype/CodeableConcept_var + expressionType: resource + constants: + system: 'http://hl7.org/fhir/ValueSet/location-physical-type' + code: 'wa' + text: 'Ward' + vars: + bed: PL.3 + room: PL.2 + pointofcare: PL.1 + +physicalType_4: + condition: $bed NULL && $room NULL && $pointofcare NULL && $floor NOT_NULL + valueOf: datatype/CodeableConcept_var + expressionType: resource + constants: + system: 'http://hl7.org/fhir/ValueSet/location-physical-type' + code: 'lvl' + text: 'Level' + vars: + bed: PL.3 + room: PL.2 + pointofcare: PL.1 + floor: PL.8 + +physicalType_5: + condition: $bed NULL && $room NULL && $pointofcare NULL && $floor NULL && $building NOT_NULL + valueOf: datatype/CodeableConcept_var + expressionType: resource + constants: + system: 'http://hl7.org/fhir/ValueSet/location-physical-type' + code: 'bu' + text: 'Building' + vars: + bed: PL.3 + room: PL.2 + pointofcare: PL.1 + floor: PL.8 + building: PL.7 + +physicalType_6: + condition: $bed NULL && $room NULL && $pointofcare NULL && $floor NULL && $building NULL && $facility NOT_NULL + valueOf: datatype/CodeableConcept_var + expressionType: resource + constants: + system: 'http://hl7.org/fhir/ValueSet/location-physical-type' + code: 'si' + text: 'Site' + vars: + bed: PL.3 + room: PL.2 + pointofcare: PL.1 + floor: PL.8 + building: PL.7 + facility: PL.4 + +mode: + type: STRING + value: 'instance' + +description: + type: STRING + valueOf: PL.9 + expressionType: HL7Spec + +# ToDo map PL.6 (Person Location Type) to type (just for this file; not in sub-locations) + +# ToDo check if PL.5 (Location Status) can be mapped to status \ No newline at end of file diff --git a/src/main/resources/hl7/resource/Location_Building.yml b/src/main/resources/hl7/resource/Location_Building.yml new file mode 100644 index 00000000..60fc1a2e --- /dev/null +++ b/src/main/resources/hl7/resource/Location_Building.yml @@ -0,0 +1,62 @@ +# Do not reference directly: use resource/Location +# A sub-location for under a floor. Much like resource/Location but ignoring +# the bed (PL.3), room (PL.2), point of care (PL.1) and floor (PL.8) for name +# and partOf +--- +resourceType: Location +id: + type: STRING + valueOf: UUID.randomUUID() + expressionType: JEXL + +name_1: + condition: $building NOT_NULL + type: STRING + valueOf: PL.7 + expressionType: HL7Spec + vars: + building: PL.7 + +name_2: + condition: $building NULL && $facility NOT_NULL + type: STRING + valueOf: PL.4 + expressionType: HL7Spec + vars: + building: PL.7 + facility: PL.4 + +partOf_1: + condition: $building NOT_NULL + valueOf: resource/Location_Facility + expressionType: reference + specs: PL + vars: + building: PL.7 + +physicalType_1: + condition: $building NOT_NULL + valueOf: datatype/CodeableConcept_var + expressionType: resource + constants: + system: 'http://hl7.org/fhir/ValueSet/location-physical-type' + code: 'bu' + text: 'Building' + vars: + building: PL.7 + +physicalType_2: + condition: $building NULL && $facility NOT_NULL + valueOf: datatype/CodeableConcept_var + expressionType: resource + constants: + system: 'http://hl7.org/fhir/ValueSet/location-physical-type' + code: 'si' + text: 'Site' + vars: + building: PL.7 + facility: PL.4 + +mode: + type: STRING + value: 'instance' \ No newline at end of file diff --git a/src/main/resources/hl7/resource/Location_Facility.yml b/src/main/resources/hl7/resource/Location_Facility.yml new file mode 100644 index 00000000..18facf88 --- /dev/null +++ b/src/main/resources/hl7/resource/Location_Facility.yml @@ -0,0 +1,26 @@ +# Do not reference directly: use resource/Location +# A sub-location for under a building. Much like resource/Location only using +# facility (PL.4) for name (as this is the top level location in PL) +--- +resourceType: Location +id: + type: STRING + valueOf: UUID.randomUUID() + expressionType: JEXL + +name: + type: STRING + valueOf: PL.4 + expressionType: HL7Spec + +physicalType: + valueOf: datatype/CodeableConcept_var + expressionType: resource + constants: + system: 'http://hl7.org/fhir/ValueSet/location-physical-type' + code: 'si' + text: 'Site' + +mode: + type: STRING + value: 'instance' \ No newline at end of file diff --git a/src/main/resources/hl7/resource/Location_Floor.yml b/src/main/resources/hl7/resource/Location_Floor.yml new file mode 100644 index 00000000..7c47b8a5 --- /dev/null +++ b/src/main/resources/hl7/resource/Location_Floor.yml @@ -0,0 +1,94 @@ +# Do not reference directly: use resource/Location +# A sub-location for under a point of care. Much like resource/Location but +# ignoring the bed (PL.3), room (PL.2) and point of care (PL.1) for name and +# partOf +--- +resourceType: Location +id: + type: STRING + valueOf: UUID.randomUUID() + expressionType: JEXL + +name_1: + condition: $floor NOT_NULL + type: STRING + valueOf: PL.8 + expressionType: HL7Spec + vars: + floor: PL.8 + +name_2: + condition: $floor NULL && $building NOT_NULL + type: STRING + valueOf: PL.7 + expressionType: HL7Spec + vars: + floor: PL.8 + building: PL.7 + +name_3: + condition: $floor NULL && $building NULL && $facility NOT_NULL + type: STRING + valueOf: PL.4 + expressionType: HL7Spec + vars: + floor: PL.8 + building: PL.7 + facility: PL.4 + +partOf_1: + condition: $floor NOT_NULL + valueOf: resource/Location_Building + expressionType: reference + specs: PL + vars: + floor: PL.8 + +partOf_2: + condition: $floor NULL && $building NOT_NULL + valueOf: resource/Location_Facility + expressionType: reference + specs: PL + vars: + floor: PL.8 + building: PL.7 + +physicalType_1: + condition: $floor NOT_NULL + valueOf: datatype/CodeableConcept_var + expressionType: resource + constants: + system: 'http://hl7.org/fhir/ValueSet/location-physical-type' + code: 'lvl' + text: 'Level' + vars: + floor: PL.8 + +physicalType_2: + condition: $floor NULL && $building NOT_NULL + valueOf: datatype/CodeableConcept_var + expressionType: resource + constants: + system: 'http://hl7.org/fhir/ValueSet/location-physical-type' + code: 'bu' + text: 'Building' + vars: + floor: PL.8 + building: PL.7 + +physicalType_3: + condition: $floor NULL && $building NULL && $facility NOT_NULL + valueOf: datatype/CodeableConcept_var + expressionType: resource + constants: + system: 'http://hl7.org/fhir/ValueSet/location-physical-type' + code: 'si' + text: 'Site' + vars: + floor: PL.8 + building: PL.7 + facility: PL.4 + +mode: + type: STRING + value: 'instance' \ No newline at end of file diff --git a/src/main/resources/hl7/resource/Location_PointOfCare.yml b/src/main/resources/hl7/resource/Location_PointOfCare.yml new file mode 100644 index 00000000..4989e1a8 --- /dev/null +++ b/src/main/resources/hl7/resource/Location_PointOfCare.yml @@ -0,0 +1,128 @@ +# Do not reference directly: use resource/Location +# A sub-location for under a room. Much like resource/Location but ignoring the +# bed (PL.3) and room (PL.2) for name and partOf +--- +resourceType: Location +id: + type: STRING + valueOf: UUID.randomUUID() + expressionType: JEXL + +name_1: + condition: $pointofcare NOT_NULL + type: STRING + valueOf: PL.1 + expressionType: HL7Spec + vars: + pointofcare: PL.1 + +name_2: + condition: $pointofcare NULL && $floor NOT_NULL + type: STRING + valueOf: PL.8 + expressionType: HL7Spec + vars: + pointofcare: PL.1 + floor: PL.8 + +name_3: + condition: $pointofcare NULL && $floor NULL && $building NOT_NULL + type: STRING + valueOf: PL.7 + expressionType: HL7Spec + vars: + pointofcare: PL.1 + floor: PL.8 + building: PL.7 + +name_4: + condition: $pointofcare NULL && $floor NULL && $building NULL && $facility NOT_NULL + type: STRING + valueOf: PL.4 + expressionType: HL7Spec + vars: + pointofcare: PL.1 + floor: PL.8 + building: PL.7 + facility: PL.4 + +partOf_1: + condition: $pointofcare NOT_NULL + valueOf: resource/Location_Floor + expressionType: reference + specs: PL + vars: + pointofcare: PL.1 + +partOf_2: + condition: $pointofcare NULL && $floor NOT_NULL + valueOf: resource/Location_Building + expressionType: reference + specs: PL + vars: + pointofcare: PL.1 + floor: PL.8 + +partOf_3: + condition: $pointofcare NULL && $floor NULL && $building NOT_NULL + valueOf: resource/Location_Facility + expressionType: reference + specs: PL + vars: + pointofcare: PL.1 + floor: PL.8 + building: PL.7 + +physicalType_1: + condition: $pointofcare NOT_NULL + valueOf: datatype/CodeableConcept_var + expressionType: resource + constants: + system: 'http://hl7.org/fhir/ValueSet/location-physical-type' + code: 'wa' + text: 'Ward' + vars: + pointofcare: PL.1 + +physicalType_2: + condition: $pointofcare NULL && $floor NOT_NULL + valueOf: datatype/CodeableConcept_var + expressionType: resource + constants: + system: 'http://hl7.org/fhir/ValueSet/location-physical-type' + code: 'lvl' + text: 'Level' + vars: + pointofcare: PL.1 + floor: PL.8 + +physicalType_3: + condition: $pointofcare NULL && $floor NULL && $building NOT_NULL + valueOf: datatype/CodeableConcept_var + expressionType: resource + constants: + system: 'http://hl7.org/fhir/ValueSet/location-physical-type' + code: 'bu' + text: 'Building' + vars: + pointofcare: PL.1 + floor: PL.8 + building: PL.7 + +physicalType_4: + condition: $pointofcare NULL && $floor NULL && $building NULL && $facility NOT_NULL + valueOf: datatype/CodeableConcept_var + expressionType: resource + constants: + system: 'http://hl7.org/fhir/ValueSet/location-physical-type' + code: 'si' + text: 'Site' + vars: + pointofcare: PL.1 + floor: PL.8 + building: PL.7 + facility: PL.4 + +mode: + type: STRING + value: 'instance' \ No newline at end of file diff --git a/src/main/resources/hl7/resource/Location_Room.yml b/src/main/resources/hl7/resource/Location_Room.yml new file mode 100644 index 00000000..47b59b10 --- /dev/null +++ b/src/main/resources/hl7/resource/Location_Room.yml @@ -0,0 +1,166 @@ +# Do not reference directly: use resource/Location +# A sub-location for under a bed. Much like resource/Location but ignoring the +# bed (PL.3) for name and partOf +--- +resourceType: Location +id: + type: STRING + valueOf: UUID.randomUUID() + expressionType: JEXL + +name_1: + condition: $room NOT_NULL + type: STRING + valueOf: PL.2 + expressionType: HL7Spec + vars: + room: PL.2 + +name_2: + condition: $room NULL && $pointofcare NOT_NULL + type: STRING + valueOf: PL.1 + expressionType: HL7Spec + vars: + room: PL.2 + pointofcare: PL.1 + +name_3: + condition: $room NULL && $pointofcare NULL && $floor NOT_NULL + type: STRING + valueOf: PL.8 + expressionType: HL7Spec + vars: + room: PL.2 + pointofcare: PL.1 + floor: PL.8 + +name_4: + condition: $room NULL && $pointofcare NULL && $floor NULL && $building NOT_NULL + type: STRING + valueOf: PL.7 + expressionType: HL7Spec + vars: + room: PL.2 + pointofcare: PL.1 + floor: PL.8 + building: PL.7 + +name_5: + condition: $room NULL && $pointofcare NULL && $floor NULL && $building NULL && $facility NOT_NULL + type: STRING + valueOf: PL.4 + expressionType: HL7Spec + vars: + room: PL.2 + pointofcare: PL.1 + floor: PL.8 + building: PL.7 + facility: PL.4 + +partOf_1: + condition: $room NOT_NULL + valueOf: resource/Location_PointOfCare + expressionType: reference + specs: PL + vars: + room: PL.2 + +partOf_2: + condition: $room NULL && $pointofcare NOT_NULL + valueOf: resource/Location_Floor + expressionType: reference + specs: PL + vars: + room: PL.2 + pointofcare: PL.1 + +partOf_3: + condition: $room NULL && $pointofcare NULL && $floor NOT_NULL + valueOf: resource/Location_Building + expressionType: reference + specs: PL + vars: + room: PL.2 + pointofcare: PL.1 + floor: PL.8 + +partOf_4: + condition: $room NULL && $pointofcare NULL && $floor NULL && $building NOT_NULL + valueOf: resource/Location_Facility + expressionType: reference + specs: PL + vars: + room: PL.2 + pointofcare: PL.1 + floor: PL.8 + building: PL.7 + +physicalType_1: + condition: $room NOT_NULL + valueOf: datatype/CodeableConcept_var + expressionType: resource + constants: + system: 'http://hl7.org/fhir/ValueSet/location-physical-type' + code: 'ro' + text: 'Room' + vars: + room: PL.2 + +physicalType_2: + condition: $room NULL && $pointofcare NOT_NULL + valueOf: datatype/CodeableConcept_var + expressionType: resource + constants: + system: 'http://hl7.org/fhir/ValueSet/location-physical-type' + code: 'wa' + text: 'Ward' + vars: + room: PL.2 + pointofcare: PL.1 + +physicalType_3: + condition: $room NULL && $pointofcare NULL && $floor NOT_NULL + valueOf: datatype/CodeableConcept_var + expressionType: resource + constants: + system: 'http://hl7.org/fhir/ValueSet/location-physical-type' + code: 'lvl' + text: 'Level' + vars: + room: PL.2 + pointofcare: PL.1 + floor: PL.8 + +physicalType_4: + condition: $room NULL && $pointofcare NULL && $floor NULL && $building NOT_NULL + valueOf: datatype/CodeableConcept_var + expressionType: resource + constants: + system: 'http://hl7.org/fhir/ValueSet/location-physical-type' + code: 'bu' + text: 'Building' + vars: + room: PL.2 + pointofcare: PL.1 + floor: PL.8 + building: PL.7 + +physicalType_5: + condition: $room NULL && $pointofcare NULL && $floor NULL && $building NULL && $facility NOT_NULL + valueOf: datatype/CodeableConcept_var + expressionType: resource + constants: + system: 'http://hl7.org/fhir/ValueSet/location-physical-type' + code: 'si' + text: 'Site' + vars: + room: PL.2 + pointofcare: PL.1 + floor: PL.8 + building: PL.7 + facility: PL.4 + +mode: + type: STRING + value: 'instance' \ No newline at end of file diff --git a/src/main/resources/hl7/resource/Patient.yml b/src/main/resources/hl7/resource/Patient.yml index 9fc5fe12..52b1bd32 100644 --- a/src/main/resources/hl7/resource/Patient.yml +++ b/src/main/resources/hl7/resource/Patient.yml @@ -54,6 +54,18 @@ identifier_4: use: old mrgIdentifier: MRG.1 # Add the old MR # from the MRG segment +identifier_5: + condition: $valueIn NOT_NULL + valueOf: datatype/Identifier_var + generateList: true + expressionType: resource + specs: PID.2 + vars: + valueIn: String, PID.2.1 + constants: + system: http://terminology.hl7.org/CodeSystem/v2-0203 + code: MR + display: Medical Record Number name: valueOf: datatype/HumanName diff --git a/src/main/resources/hl7/secondary/EncounterLocation.yml b/src/main/resources/hl7/secondary/EncounterLocation.yml new file mode 100644 index 00000000..9cda414f --- /dev/null +++ b/src/main/resources/hl7/secondary/EncounterLocation.yml @@ -0,0 +1,6 @@ +# A location under an encounter (references an actual Location type) +--- +location: + valueOf: resource/Location + expressionType: reference + specs: PL