You are using an unsupported browser. Please update your browser to the latest version on or before July 31, 2020.
Welcome to the CAREWare FAQ Page
announcement close button
Home > CAREWare > HL7 Lab Import Specification
HL7 Lab Import Specification
print icon

The CAREWare HL7 Lab format is a simple standard for electronic import of laboratory data into CAREWare.  This format only includes the absolute minimum necessary to import lab data into a CAREWare client record.  By doing this, it helps healthcare providers that just want to import their data without having to process unneeded fields.  This format is used by CAREWare’s CWLAB tab-delimited file processor, which reformats the data into HL7 files that can be imported into CAREWare.  The reason we are publishing this format is to provide a simple vehicle for labs that prefer to provide their data in the HL7 format rather than a tab delimited format.

Message Segment Hierarchy

The bare minimum requirements that CAREWare needs to format an HL7 file is as follows:


  • MSH Message Header
  • PID Patient Identifier                
  • OBR Observation Request
  • OBX Observation Result
  • NTE Notes and Comments

Segment Hierarchy Rules

There are certain rules to the message segment hierarchy. To create a parseable HL7 file that CAREWare can process, these rules must be followed. These rules are:


  1. The MSH segment needs to be the first line segment in the file.   
  2. The PID segment must precede all OBR, OBX and NTE segments.
  3. The OBR segment must precede OBX and NTE segments. In multiple OBR segment cases, the other OBR segments may follow either a PID, OBX, or NTE segment(s).  They may also follow optional ORC and ZPS segments, but CAREWare does not process ORC or ZPS segments.
  4. The OBX segment(s) must follow a corresponding OBR segment. There may be multiple OBX segments to one OBR segment. They may also follow NTE segments that correspond to other OBX segments.
  5. NTE segments must follow OBX segments. There may be multiple NTE segments.  Data from multiple NTE segments will be concatenated and placed in the comments field with the test represented by the previous OBX.

Translation of Tab Delimited Format into HL7 Format

CAREWare retrieves data from a tab-delimited file and tries to translate it into a parseable HL7 file.  When the reader reads the line, it will translate it to its corresponding HL7 segment.  


The following table represents the fields within the HL7 segments.  There types are defined here.



Data Type Data Type Name Comments
ST String Any ASCII characters besides the ones designated for the delimiter characters
TS Time Stamp Format is YYYYMMDD
CAREWare is able to process TS with 4 additional characters for the time, but does not use them for import.
SI Sequence ID Non negative integer.
ID Coded values for HL7 tables String value.

MSH - Message Header Segment

The MSH segment defines the source, destination, and syntax of the message.



Type Length Comments Required
MSH1 ST 4 Must be MSH Yes
MSH2 ST 4 ^~\&
Component, Repetition, Escape, and Sub component separators
MSH3 ST 15 ID of sending lab Yes
MSH6 ST 15 ID of receiving clinic Yes


An example of a simplified MSH segment is as follows:

MSH|^~\&| Sending Lab ID| | |Receiving Clinic ID


PID – Patient Identifier Segment


The PID specifies the patient’s demographic information.



Type Length Comments Required
PID1 ST 4 Must be PID Yes
PID2 SI 4 Allows the identification of multiple PID. This number is sequential and usually starts with 1. Yes
PID3 ST 30 The patient ID. No, See patient matching description
PID4 ST 20 The lab reference. (How the lab identifies the patient) No
PID6 ST 90 Patient Name. The patient name is subdivided into last name, first name, and middle name. They are separated by the component separator.
See patient matching description
PID8 TS 8 Patient’s date of birth. The date format is YYYYMMDD See patient matching description
PID9 ST 1 Patient’s gender (you can use your own coding structure) No


An example of a simplified PID segment is as follows:



OBR – Observation Request Segment


The OBR segment holds the test date of the lab results.



Type Length Comments Required
OBR1 ST 4 Must be OBR Yes
OBR2 SI 4 Allows the identification of multiple OBR. This number is sequential and usually starts with 1 Yes
OBR7 TS 8 Date of labs. The date format is


An example of a simplified OBR segment

OBR|1| | | | | |20080204


OBX – Observation Result Segment


The OBX segment holds the lab definitions and lab results.



Type Length Comments Required
OBX1 ST 4 Must be OBX Yes
OBX2 SI 4 Allows the identification of multiple OBX. This number is sequential and usually starts with 1 Yes
OBX3 ST 2 The Result value type. Valid types are:
CE = coded element
NM = numeric
TX = text
ST = string
*see how CW handles these types for more details
OBX4 ST 50 The Test Identifier. This field is subdivided into 2 sub fields by component separators. The first field is the test type id and the second is the test type name. Test type id^test type name Yes
OBX6 ST 28 Holds the test result Yes
OBX7 ST 100 Holds the unit of measure No


An example of a simplified OBX segment

OBX|1|NM|24680^BOGUSTEST| |5.5|mmol/L


NTE – Notes and Comments Segment


The NTE segment holds any comments that lab result contains.  NTE are grouped with OBX segments.   NTE segments are all optional.  See result value types for more details.


Type Length Comments Required
NTE1 ST 4 Must be NTE Yes
NTE2 SI 4 Allows the identification of multiple NTE. This number is sequential and usually starts with 1 Yes
NTE3 ID 8 Specifies the source of the comments. Valid values are:
L = laboratory as source for comments.
NTE4 ST 60 The comments. No


An example of a NTE segment

NTE|1|L|Desirable < 1500 mmol/L


An example of a parse able HL7 file

MSH|^~\&| Sending Lab ID| | |Receiving Clinic ID PID|1|CLIENTID|LABREF1||LASTNAME^FIRSTNAME^MIDDLENAME||19800101|


OBR|1| | | | | |20080204

OBX|1|NM|24680^BOGUSTEST| |5.5|mmol/L

NTE|1|L|Desirable < 1500 mmol/L


How CAREWare handles lab and provider matching


Since a single CAREWare installation can house multiple clinics/providers on a server, and a single clinic/provider can handle imports from multiple labs that may use different coding systems, CAREWare has established a process called provider mapping to ensure that data makes it to the correct provider and the correct result mappings are used.  To make this process work smoothly, it is important that you keep the MSH3 Lab ID and the MSH6 Provider ID consistent across exports.


How CAREWare handles patient matching


Matching IDs Agreeing on the ID


CAREWare can be configured to use the Central URN/Unique ID or the clinic's Clinic ID.  The only way to completely automate the import of the lab data is for the lab to supply a patient-identifying code that exactly matches a code in CAREWare.  If supplying a common patient ID is not possible, then you can still import lab records, but a CAREWare user will need to go through a manual matching processes with each client in the file.


How CAREWare finds the patient record the lab is intended for


CAREWare goes through a two-step matching process with incoming lab records. It first tries to match by finding a client associated with the intended provider with an ID matching the value in PID3 Match Patient ID.


What happens if there is a match


The demographic fields in the incoming record are compared to the existing client record and scored.  The score is compared to the threshold that is set with the incoming provider record, and if it is greater than or equal to the threshold then the lab record is marked to import.  If you want the lab records to be imported regardless of the score--for instance if the lab cannot provide demographic information--set the threshold to zero for the incoming provider map record.


What happens if there is not a match or the demographic check score is too low?


The incoming record is put in a queue to be matched manually by a user.


How CAREWare handles result value types


There are several result value types that CAREWare handles.  These values are CE, NM, TX, and ST.  For quantitative results, CAREWare uses NM and ST.  When a lab result uses the result value type ST, the results usually are in a form of an operator and a numeric value.  CAREWare parses everything before a numeric value to set the lab operator to that character.  For instance, if the result is “<=6.25”, CW parses the “<=” as an operator and “6.25” as the result.  For the NM result type, the operator is automatically set to “=” if no other operator is specified.  Accepted operators are <=, >=, <, > and =. When an HL7 result type is TX, there should not be a result in the OBX segment.  All results with the result type TX are stored in NTE segments and are displayed as comments.  For CE result types, they are used to specify qualitative results.


How CAREWare handles test type codes


This format does not impose a coding structure; instead you can use any coding structure that is constant over time and that the lab and CAREWare clinic can reach agreement on. 


CAREWare users will use user tools to map your lab codes to CAREWare labs. When the lab codes are imported in CAREWare, there is a check to see if the code has been mapped to a CAREWare lab.  If the code is already mapped, the lab will move to the next step in processing; otherwise the lab code from OBX4 Test Type ID and OBX4 Test Type Name will fall into a queue for user action.


How CAREWare maps qualitative results


If the OBX3 Result Value Type is CE (Coded Element), CAREWare will check an internal mapping table.  If the value has already been mapped to the CAREWare qualitative code, the correct CAREWare code will be inserted and the record will be imported; otherwise the new code will fall into a queue for user action.


How CAREWare handles duplicate, pending and corrected tests


The basic rule with the import is if a new lab comes in for the same provider for the same patient with the same lab code with the same specimen date, the existing record will be overwritten with the newer record.  To make this format easy to implement we did not put status flags.


If for some reason you need to correct the Provider ID, Lab Type Code or Specimen Date, you will need to handle that process outside the CWLAB lab file format.

0 out of 0 found this helpful


scroll to top icon