health.hl7v2.utils.v2tofhirr4
Module health.hl7v2.utils.v2tofhirr4
API
ballerinax/health.hl7v2.utils.v2tofhirr4 Ballerina library
Module for HL7v2.x to FHIR R4 pre-built mapping functionalities.
HL7v2 to FHIR Package
Module Overview
This module implements the HL7 version 2 to FHIR implementation guide (https://build.fhir.org/ig/HL7/v2-to-fhir/branches/master/datatype_maps.html).
Usage
To use the package add following import to your Ballerina program.
import ballerinax/health.hl7v2.utils.v2tofhirr4
Sample: This sample showcase how you can pass a HL7 version 2 message and get a FHIR R4 Bundle in return. In addition to that, we are demonstrating how you could use the library to transform HL7 segments to FHIR.
import ballerina/io; import ballerinax/health.hl7v2.utils.v2tofhirr4; import ballerinax/health.hl7v2 as hl7; import ballerinax/health.hl7v23; import ballerinax/health.fhir.r4 as r4; final string msg = "MSH|^~\\&|ADT1|GOOD HEALTH HOSPITAL|GHH LAB, INC.|GOOD HEALTH" + "HOSPITAL|198808181126|SECURITY|ADT^A01^ADT_A01|MSG00001|P|2.3||\rEVN|A01|" + "200708181123||\rPID|1||PATID1234^5^M11^ADT1^MR^GOOD HEALTH"+ "HOSPITAL~123456789^^^USSSA^SS||" + "BATMAN^ADAM^A^III||19610615|M||C|2222 HOME STREET^^GREENSBORO^NC^27401-1020|GL|" + "(555)555-2004|(555)555-2004||S||PATID12345001^2^M10^ADT1^AN^A|444333333|987654^NC|" + "\rNK1|1|NUCLEAR^NELDA^W|SPO^SPOUSE||||NK^NEXT OF KIN$\rPV1|1|I|2000^2012^01||||" + "004777^ATTEND^AARON^A|||SUR||||ADM|A0|"; public function main() returns error? { // Transform HL7v2 message to FHIR R4. // You can pass a HL7v2 message and get a FHIR R4 Bundle based on // the mappings defined at // https://build.fhir.org/ig/HL7/v2-to-fhir/branches/master/datatype_maps.html. json v2tofhirResult = check v2tofhirr4:v2ToFhir(msg); io:println("Transformed FHIR message: ", v2tofhirResult.toString()); io:println("------------------------------------------------------------------"); hl7:Message hl7msg = check v2tofhirr4:stringToHl7(msg); if (hl7msg is hl7v23:ADT_A01) { // v2tofhirr4 library exposes these low level functions as well, // if you want to work with HL7v2 segments directly. // Transform HL7v2 PID to FHIR R4 Patient Name. r4:HumanName[] patientName = v2tofhirr4:pidToPatientName(hl7msg.pid.pid5, hl7msg.pid.pid9); io:println("HL7v23 PID Patient Name: ", patientName[0].toString()); } }
Functions
al1ToAllerygyIntolerance
function al1ToAllerygyIntolerance(Al1 al1) returns AllergyIntolerance
Parameters
- al1 Al1 -
ceToCode
Parameters
- ce Ce -
ceToCodeableConcept
function ceToCodeableConcept(Ce ce) returns CodeableConcept
Parameters
- ce Ce -
ceToCodeableConcepts
function ceToCodeableConcepts(Ce|CWE ce) returns CodeableConcept[]
ceToCoding
Parameters
- ce Ce -
ceToCodings
Parameters
- ce Ce -
ceToUri
Parameters
- ce Ce -
cweToCode
Parameters
- cwe Cwe -
cweToCodeableConcept
function cweToCodeableConcept(Cwe cwe) returns CodeableConcept
Parameters
- cwe Cwe -
cweToCoding
Parameters
- cwe Cwe -
cweToCodings
Parameters
- ce Cwe -
cweToUri
Parameters
- cwe Cwe -
dg1ToCondition
Parameters
- dg1 Dg1 -
dtmToDateTime
Parameters
- ts Dtm -
dtmToInstant
Parameters
- ts Dtm -
eiToCoding
Parameters
- ei Ei -
eiToIdentifier
function eiToIdentifier(Ei ei) returns Identifier
Parameters
- ei Ei -
evnToProvenance
function evnToProvenance(Evn evn) returns Provenance
Parameters
- evn Evn -
hdToMessageHeaderDestination
function hdToMessageHeaderDestination(Hd hd) returns MessageHeaderDestination
Parameters
- hd Hd -
hdToMessageHeaderSource
function hdToMessageHeaderSource(Hd hd) returns MessageHeaderSource
Parameters
- hd Hd -
idToAddressType
function idToAddressType(Id id) returns AddressType
Parameters
- id Id -
idToAddressUse
function idToAddressUse(Id id) returns AddressUse?
Parameters
- id Id -
idToCodeableConcept
function idToCodeableConcept(ID id) returns CodeableConcept
Parameters
- id ID -
idToCodeableConceptArray
function idToCodeableConceptArray(Id id) returns CodeableConcept[]
Parameters
- id Id -
idToCoding
Parameters
- id ID -
idToContactPointSystem
function idToContactPointSystem(Id id) returns ContactPointSystem
Parameters
- id Id -
idToContactPointUse
function idToContactPointUse(Id id) returns ContactPointUse
Parameters
- id Id -
idToDiagnosticReportStatus
function idToDiagnosticReportStatus(ID id) returns DiagnosticReportStatus
Parameters
- id ID -
idToHumanNameUse
function idToHumanNameUse(Id id) returns HumanNameUse
Parameters
- id Id -
idToServiceRequestPriority
function idToServiceRequestPriority(ID id) returns ServiceRequestPriority
Parameters
- id ID -
isToAllergyIntoleranceCategory
function isToAllergyIntoleranceCategory(Is 'is) returns AllergyIntoleranceCategory
Parameters
- 'is Is -
isToAllergyIntoleranceCriticality
function isToAllergyIntoleranceCriticality(Is 'is) returns AllergyIntoleranceCriticality
Parameters
- 'is Is -
isToAllergyIntoleranceType
function isToAllergyIntoleranceType(string 'is) returns AllergyIntoleranceType
Parameters
- 'is string -
msgToCoding
Parameters
- msg CM_MSG -
mshToMessageHeader
function mshToMessageHeader(Msh msh) returns MessageHeader
Parameters
- msh Msh -
nameToServiceRequestIntent
function nameToServiceRequestIntent(string name) returns ServiceRequestIntent
Parameters
- name string -
nk1ToContact
nk1ToPatient
Parameters
- nk1 Nk1 -
obrToDiagnosticReport
function obrToDiagnosticReport(Obr obr) returns DiagnosticReport
Parameters
- obr Obr -
obrToServiceRequest
function obrToServiceRequest(Obr obr) returns ServiceRequest
Parameters
- obr Obr -
obxToObservation
function obxToObservation(Obx obx) returns Observation
Parameters
- obx Obx -
orcToDiagnosticReport
function orcToDiagnosticReport(Orc orc) returns DiagnosticReport
Parameters
- orc Orc -
orcToImmunization
function orcToImmunization(Orc orc) returns Immunization
Parameters
- orc Orc -
pd1ToExtension
Parameters
- pd16 string -
pd1ToGeneralPractitioner
pd1ToPatient
Parameters
- pd1 Pd1 -
pidToAddress
pidToAdministrativeSex
function pidToAdministrativeSex(string pid8) returns PatientGender
Parameters
- pid8 string -
pidToBirthOrder
pidToBirthPlace
Parameters
- pid23 string -
pidToMaritalStatus
Parameters
- pid16 Pid16 -
pidToMultipleBirthIndicator
Parameters
- pid24 string -
pidToPatient
Parameters
- pid Pid -
pidToPatientDeathIndicator
Parameters
- pid30 string -
pidToPatientName
pidToPhoneNumber
function pidToPhoneNumber(Pid13 pid13, Pid14 pid14) returns ContactPoint[]
pidToPrimaryLanguage
function pidToPrimaryLanguage(Pid15 pid15) returns PatientCommunication[]
Parameters
- pid15 Pid15 -
pidToSsnNumberIdentifier
function pidToSsnNumberIdentifier(string pid19) returns Identifier[]
Parameters
- pid19 string -
ptToMeta
Parameters
- pt Pt -
pv1ToEncounter
Parameters
- pv1 Pv1 -
pv1ToExtension
Parameters
- pv116 string -
pv1ToPatient
Parameters
- pv1 Pv1 -
pv2ToEncounter
Parameters
- pv2 Pv2 -
segmentToFhir
function segmentToFhir(string segmentName, Segment segment) returns BundleEntry[]
Transform an HL7 segment to FHIR.
Return Type
- BundleEntry[] - FHIR Bundle
stringToHl7
Parse a string to an HL7 message.
Parameters
- msg string - HL7 message as a string
tsToDateTime
Parameters
- ts Ts -
tsToInstant
Parameters
- ts Ts -
v2ToFhir
Transform an HL7 message to FHIR.
Return Type
- json|error - FHIR Bundle as a json
xadToAddress
Parameters
- xad Xad -
xcnToCodeableConcept
function xcnToCodeableConcept(Xcn xcn) returns CodeableConcept
Parameters
- xcn Xcn -
xcnToReference
Parameters
- xcn Xcn -
xonToOrganization
function xonToOrganization(Xon xon) returns Organization
Parameters
- xon Xon -
xpnToHumanName
Parameters
- xpn Xpn -
xtnToContactPoint
function xtnToContactPoint(Xtn xtn) returns ContactPoint
Parameters
- xtn Xtn -
Union types
health.hl7v2.utils.v2tofhirr4: Al1
Al1
Union type for holding patient allergy information segment for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Ce
Ce
Union type for CE data type for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Cwe
Cwe
Union type for CWE data type for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Dg1
Dg1
Union type for holding patient visit segment for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Dtm
Dtm
Union type for DTM data type for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Ei
Ei
Union type for EI data type for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Evn
Evn
Union type for holding event type segment for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Hd
Hd
Union type for HD data type for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Id
Id
Union type for ID data type for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Is
Is
Union type for IS data type for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Msh
Msh
Union types for holding hl7 segments for supported hl7 versions.
######################################################################## Union type for holding message header segment for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Nk1
Nk1
Union type for holding next of kin segment for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Nk113
Nk113
Union type for patient's extended person's organization name for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Nk115
Nk115
Union type for patient's extended person's gender for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Nk12
Nk12
Union type for patient's extended person's name for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Nk130
Nk130
Union type for patient's extended person's contact person name for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Nk131
Nk131
Union type for patient's extended person's contact person phone number for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Nk132
Nk132
Union type for patient's extended person's contact person address for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Nk14
Nk14
Union type for patient's extended person's address for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Nk15
Nk15
Union type for patient's extended person's home phone number for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Nk16
Nk16
Union type for patient's extended person's business phone number for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Nk17
Nk17
Union type for patient's extended person's contact role for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Nk18
Nk18
Union type for patient's extended person's start date for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Nk19
Nk19
Union type for patient's extended person's end date for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Obr
Obr
Union type for holding observation request segment for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Obx
Obx
Union type for holding observation segment for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Orc
Orc
Union type for holding common order segment for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Pd1
Pd1
Union type for holding patient identification segment for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Pd13
Pd13
Union type for patient primary facility for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Pd14
Pd14
Union type for patient primary care provider for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Pid
Pid
Union type for holding patient identification segment for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Pid11
Pid11
Union type for holding patient address for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Pid13
Pid13
Union type for holding patient home phone number for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Pid14
Pid14
Union type for holding patient business phone number for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Pid15
Pid15
Union type for holding patient primary language for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Pid16
Pid16
Union type for holding patient marital status for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Pid5
Pid5
Union types defined for data types for supported hl7 versions.
###################################################################### Union type for holding patient name for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Pid9
Pid9
Union type for holding patient alias name for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Pt
Pt
Union type for PT data type for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Pv1
Pv1
Union type for holding patient visit segment for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Pv2
Pv2
Union type for holding patient visit additional information segment for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Ts
Ts
Union type for TS data type for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Xad
Xad
Union type for XAD data type for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Xcn
Xcn
Union type for XCN data type for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Xon
Xon
Union type for XON data type for all supported hl7 versions.
Import
import ballerinax/health.hl7v2.utils.v2tofhirr4;
Metadata
Released date: over 1 year ago
Version: 1.0.2
Compatibility
Platform: any
Ballerina version: 2201.5.0
GraalVM compatible: Yes
Pull count
Total: 868
Current verison: 36
Weekly downloads
Keywords
Healthcare
HL7
FHIR
Contributors
Dependencies