Blogs Home
Wednesday, April 18, 2018 12:00 PM

SQL Tip: Finding Lab Test LOINC Code Values

Written by Thomas Harlan, Jim McGrath; Reporting Services Team - iatricSystems


Like ICD-10 diagnosis and procedure codes, LOINC codes offer a platform-independent way to identify medical laboratory observations. Within MEDITECH’s LAB module, LOINC codes are set up as a “nomenclature” — a code describing another code — or in this case, a LOINC standard code is mapped to each LAB test in the appropriate dictionary.

This allows, for example, a laboratory test result sourced in MEDITECH to go outbound on an HL7 interface and report itself properly in another, non-MEDITECH, system. A vendor may also ask for LOINC codes as part of a scheduled extract of laboratory test data.

Or, it may be useful for internal analysis to group laboratory test results by their LOINC code, particularly if you have multiple facilities in your MEDITECH environment and each @.facility has a different set of LAB dictionaries.

The Codes Themselves…

…are stored in (for Client/Server and 6.x):


With a parent segment / dictionary of:


And in MAGIC, in:


With a parent dictionary/segment in:


So, if you want to get from the laboratory test and/or results to the codes, you can get at them this way:


And in MAGIC:


Extra Credit

Create a table valued FUNCTION (or a VIEW) to encapsulate this logic so you have a handy, re-usable database object to fetch yourself a LOINC code (or a SNOMED code or… whatever else in the nomenclature map table!) when you need it without having to cut and paste this JOIN structure.

If you need more help…

Our Report Writing team can help you fix reports, create new ones, make old ones run faster, and much more. Simply reach out to your Iatric Systems Account Executive, or our NPR report writing team at, or click the button below to contact us and learn how we can help support your team!