health.hl7v2.utils.v2tofhirr4
Module health.hl7v2.utils.v2tofhirr4
API
Definitions
ballerinax/health.hl7v2.utils.v2tofhirr4 Ballerina library
HL7v2 to FHIR Package
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[]
Parameters
- ce Ce|CWE -
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
function dg1ToCondition(Dg1 dg1) returns Condition
Parameters
- dg1 Dg1 -
dg1ToEncounter
dg1ToEpisodeOfCare
function dg1ToEpisodeOfCare(Dg1 dg1, string? conditionId, string? patientId) returns EpisodeOfCare
dtmToDateTime
Parameters
- ts Dtm -
dtmToInstant
Parameters
- ts Dtm -
eiToCoding
Parameters
- ei Ei -
eiToIdentifier
function eiToIdentifier(Ei ei) returns Identifier
Parameters
- ei Ei -
eiToReferenceWithType
evnToProvenance
function evnToProvenance(Evn evn) returns Provenance
Parameters
- evn Evn -
generateFhirResourceId
function generateFhirResourceId() returns string
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
function idToCoding(ID id) returns Coding
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
function msgToCoding(CM_MSG msg) returns Coding
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
function nk1ToContact(Nk12 nk12, Nk14 nk14, Nk15 nk15, Nk16 nk16, Nk17 nk17, Nk18 nk18, Nk19 nk19, Nk113 nk113, Nk115 nk115, Nk130 nk130, Nk131 nk131, Nk132 nk132) returns PatientContact[]
Parameters
- nk12 Nk12 -
- nk14 Nk14 -
- nk15 Nk15 -
- nk16 Nk16 -
- nk17 Nk17 -
- nk18 Nk18 -
- nk19 Nk19 -
- nk113 Nk113 -
- nk115 Nk115 -
- nk130 Nk130 -
- nk131 Nk131 -
- nk132 Nk132 -
nk1ToPatient
function nk1ToPatient(Nk1 nk1) returns Patient
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
function pd1ToGeneralPractitioner(Pd13 pd13, Pd14 pd14) returns Reference[]?
Parameters
- pd13 Pd13 -
- pd14 Pd14 -
pd1ToPatient
function pd1ToPatient(Pd1 pd1) returns Patient
Parameters
- pd1 Pd1 -
pidToAddress
pidToAdministrativeSex
function pidToAdministrativeSex(string pid8) returns PatientGender?
Parameters
- pid8 string -
pidToBirthOrder
pidToBirthPlace
Parameters
- pid23 string -
pidToMaritalStatus
function pidToMaritalStatus(Pid16 pid16) returns CodeableConcept?
Parameters
- pid16 Pid16 -
pidToMultipleBirthIndicator
Parameters
- pid24 string -
pidToPatient
function pidToPatient(Pid pid) returns Patient
Parameters
- pid Pid -
pidToPatientDeathIndicator
Parameters
- pid30 string -
pidToPatientName
function pidToPatientName(Pid5 pid5, Pid9 pid9) returns HumanName[]?
Parameters
- pid5 Pid5 -
- pid9 Pid9 -
pidToPhoneNumber
function pidToPhoneNumber(Pid13 pid13, Pid14 pid14) returns ContactPoint[]?
Parameters
- pid13 Pid13 -
- pid14 Pid14 -
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
function pv1ToEncounter(Pv1 pv1) returns Encounter
Parameters
- pv1 Pv1 -
pv1ToExtension
Parameters
- pv116 string -
pv1ToPatient
function pv1ToPatient(Pv1 pv1) returns Patient
Parameters
- pv1 Pv1 -
pv2ToEncounter
function pv2ToEncounter(Pv2 pv2) returns Encounter
Parameters
- pv2 Pv2 -
segmentToFhir
function segmentToFhir(string segmentName, Segment segment, V2SegmentToFhirMapper? customMapper, V2ToFhirCustomMapperServiceConfig? serviceconf) returns BundleEntry[]|error
Transform an HL7 segment to FHIR Bundle.
Parameters
- segmentName string - Name of the HL7 segment
- segment Segment - HL7 segment
- customMapper V2SegmentToFhirMapper? - Custom mapper implementation
- serviceconf V2ToFhirCustomMapperServiceConfig? - Custom mapping service configuration
Return Type
- BundleEntry[]|error - FHIR Bundle
stringToHl7
Parse a string to an HL7 message.
Parameters
- msg string - HL7 message as a string
Return Type
- Message|error - hl7v2:Message
tsToDateTime
Parameters
- ts Ts -
tsToInstant
Parameters
- ts Ts -
v2ToFhir
function v2ToFhir(string|Message hl7, V2SegmentToFhirMapper? customMapper, V2ToFhirCustomMapperServiceConfig? mapperServiceConf) returns json|error
Transform an HL7 message to FHIR.
Parameters
- hl7 string|Message - HL7 message as a string or an hl7v2:Message
- customMapper V2SegmentToFhirMapper? (default ()) - Custom mapper implementation
- mapperServiceConf V2ToFhirCustomMapperServiceConfig? (default ()) - Custom mapping service configuration
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 -
xcnToReferenceWithType
xonToOrganization
function xonToOrganization(Xon xon) returns Organization
Parameters
- xon Xon -
xonToReference
Parameters
- xon Xon -
xpnToHumanName
Parameters
- xpn Xpn -
xtnToContactPoint
function xtnToContactPoint(Xtn xtn) returns ContactPoint?
Parameters
- xtn Xtn -
Records
health.hl7v2.utils.v2tofhirr4: V2SegmentToFhirMapper
V2toFHIR Mapper function implementation holder record.
Fields
- pv1ToPatient Pv1ToPatient? - PV1 segment to Patient FHIR resource mapping function
- pv1ToEncounter Pv1ToEncounter? - PV1 segment to Encounter FHIR resource mapping function
- nk1ToPatient Nk1ToPatient? - NK1 segment to Patient FHIR resource mapping function
- pd1ToPatient Pd1ToPatient? - PD1 segment to Patient FHIR resource mapping function
- pidToPatient PidToPatient? - PID segment to Patient FHIR resource mapping function
- dg1ToCondition Dg1ToCondition? - DG1 segment to Condition FHIR resource mapping function
- dg1ToEncounter Dg1ToEncounter? - DG1 segment to Encounter FHIR resource mapping function
- dg1ToEpisodeOfCare Dg1ToEpisodeOfCare? - DG1 segment to EpisodeOfCare FHIR resource mapping function
- obxToObservation ObxToObservation? - OBX segment to Observation FHIR resource mapping function
- obrToDiagnosticReport ObrToDiagnosticReport? - OBR segment to DiagnosticReport FHIR resource mapping function
- al1ToAllerygyIntolerance Al1ToAllerygyIntolerance? - AL1 segment to AllergyIntolerance FHIR resource mapping function
- evnToProvenance EvnToProvenance? - EVN segment to Provenance FHIR resource mapping function
- mshToMessageHeader MshToMessageHeader? - MSH segment to MessageHeader FHIR resource mapping function
- pv2ToEncounter Pv2ToEncounter? - PV2 segment to Encounter FHIR resource mapping function
- orcToImmunization OrcToImmunization? - ORC segment to Immunization FHIR resource mapping function
health.hl7v2.utils.v2tofhirr4: V2ToFhirCustomMapperServiceConfig
Fields
- baseUrl string -
Union types
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: Xad
Xad
Union type for XAD data type for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Xon
Xon
Union type for XON data type for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Xpn
Xpn
Union type for XPN data type for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Xtn
Xtn
Union type for XTN data type 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: Pt
Pt
Union type for PT 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: Id
Id
Union type for ID 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: Dtm
Dtm
Union type for DTM data type 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: Is
Is
Union type for IS data type for all supported hl7 versions.
health.hl7v2.utils.v2tofhirr4: Msh
DeprecatedMsh
Union types for holding hl7 segments for supported hl7 versions.
######################################################################## Union type for holding message header segment for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Al1
DeprecatedAl1
Union type for holding patient allergy information segment for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Evn
DeprecatedEvn
Union type for holding event type segment for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Dg1
DeprecatedDg1
Union type for holding patient visit segment for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Nk1
DeprecatedNk1
Union type for holding next of kin segment for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Pd1
DeprecatedPd1
Union type for holding patient identification segment for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Pid
DeprecatedPid
Union type for holding patient identification segment for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Pv1
DeprecatedPv1
Union type for holding patient visit segment for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Pv2
DeprecatedPv2
Union type for holding patient visit additional information segment for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Obx
DeprecatedObx
Union type for holding observation segment for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Orc
DeprecatedOrc
Union type for holding common order segment for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Obr
DeprecatedObr
Union type for holding observation request segment for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Pid5
DeprecatedPid5
Union types defined for data types for supported hl7 versions.
###################################################################### Union type for holding patient name for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Pid9
DeprecatedPid9
Union type for holding patient alias name for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Pid11
DeprecatedPid11
Union type for holding patient address for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Pid13
DeprecatedPid13
Union type for holding patient home phone number for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Pid14
DeprecatedPid14
Union type for holding patient business phone number for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Pid15
DeprecatedPid15
Union type for holding patient primary language for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Pid16
DeprecatedPid16
Union type for holding patient marital status for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Pd13
DeprecatedPd13
Union type for patient primary facility for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Pd14
DeprecatedPd14
Union type for patient primary care provider for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Nk12
DeprecatedNk12
Union type for patient's extended person's name for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Nk14
DeprecatedNk14
Union type for patient's extended person's address for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Nk15
DeprecatedNk15
Union type for patient's extended person's home phone number for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Nk16
DeprecatedNk16
Union type for patient's extended person's business phone number for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Nk17
DeprecatedNk17
Union type for patient's extended person's contact role for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Nk18
DeprecatedNk18
Union type for patient's extended person's start date for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Nk19
DeprecatedNk19
Union type for patient's extended person's end date for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Nk113
DeprecatedNk113
Union type for patient's extended person's organization name for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Nk115
DeprecatedNk115
Union type for patient's extended person's gender for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Nk130
DeprecatedNk130
Union type for patient's extended person's contact person name for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Nk131
DeprecatedNk131
Union type for patient's extended person's contact person phone number for all supported hl7 versions.
Deprecated
health.hl7v2.utils.v2tofhirr4: Nk132
DeprecatedNk132
Union type for patient's extended person's contact person address for all supported hl7 versions.
Deprecated
Function types
health.hl7v2.utils.v2tofhirr4: Pv1ToPatient
function(Pv1) returns (Patient)
Pv1ToPatient
#################################################################################################### Mapping function definitions for V2 to FHIR #################################################################################################### Mapping function type for PV1 segment to Patient FHIR resource.
health.hl7v2.utils.v2tofhirr4: Pv1ToEncounter
function(Pv1) returns (Encounter)
Pv1ToEncounter
Mapping function type for PV1 segment to Encounter FHIR resource.
health.hl7v2.utils.v2tofhirr4: Nk1ToPatient
function(Nk1) returns (Patient)
Nk1ToPatient
Mapping function type for NK1 segment to Patient FHIR resource.
health.hl7v2.utils.v2tofhirr4: Pd1ToPatient
function(Pd1) returns (Patient)
Pd1ToPatient
Mapping function type for PD1 segment to Patient FHIR resource.
health.hl7v2.utils.v2tofhirr4: PidToPatient
function(Pid) returns (Patient)
PidToPatient
Mapping function type for PID segment to Patient FHIR resource.
health.hl7v2.utils.v2tofhirr4: Dg1ToCondition
function(Dg1) returns (Condition)
Dg1ToCondition
Mapping function type for DG1 segment to Condition FHIR resource.
health.hl7v2.utils.v2tofhirr4: Dg1ToEncounter
function(Dg1, string?) returns (Encounter)
Dg1ToEncounter
Mapping function type for DG1 segment to Encounter FHIR resource.
health.hl7v2.utils.v2tofhirr4: Dg1ToEpisodeOfCare
function(Dg1, string?, string?) returns (EpisodeOfCare)
Dg1ToEpisodeOfCare
Mapping function type for DG1 segment to EpisodeOfCare FHIR resource.
health.hl7v2.utils.v2tofhirr4: ObxToObservation
function(Obx) returns (Observation)
ObxToObservation
Mapping function type for OBX segment to Observation FHIR resource.
health.hl7v2.utils.v2tofhirr4: ObrToDiagnosticReport
function(Obr) returns (DiagnosticReport)
ObrToDiagnosticReport
Mapping function type for OBR segment to DiagnosticReport FHIR resource.
health.hl7v2.utils.v2tofhirr4: Al1ToAllerygyIntolerance
function(Al1) returns (AllergyIntolerance)
Al1ToAllerygyIntolerance
Mapping function type for AL1 segment to AllergyIntolerance FHIR resource.
health.hl7v2.utils.v2tofhirr4: EvnToProvenance
function(Evn) returns (Provenance)
EvnToProvenance
Mapping function type for EVN segment to Provenance FHIR resource.
health.hl7v2.utils.v2tofhirr4: MshToMessageHeader
function(Msh) returns (MessageHeader)
MshToMessageHeader
Mapping function type for MSH segment to MessageHeader FHIR resource.
health.hl7v2.utils.v2tofhirr4: Pv2ToEncounter
function(Pv2) returns (Encounter)
Pv2ToEncounter
Mapping function type for PV2 segment to Encounter FHIR resource.
health.hl7v2.utils.v2tofhirr4: OrcToImmunization
function(Orc) returns (Immunization)
OrcToImmunization
Mapping function type for ORC segment to Immunization FHIR resource.
Import
import ballerinax/health.hl7v2.utils.v2tofhirr4;
Metadata
Released date: 5 months ago
Version: 2.2.3
Compatibility
Platform: any
Ballerina version: 2201.8.5
GraalVM compatible: Yes
Pull count
Total: 868
Current verison: 71
Weekly downloads
Keywords
Healthcare
HL7
FHIR
Contributors