Top Banner
23

HL7 for Busy Professionals · 2019-10-30 · HL7 for Busy Professionals Your No Sweat Guide to Understanding HL7 Rahul Bhagat Illustration By Calvin Hui Anchiove 2015. Table of Contents

Jun 07, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: HL7 for Busy Professionals · 2019-10-30 · HL7 for Busy Professionals Your No Sweat Guide to Understanding HL7 Rahul Bhagat Illustration By Calvin Hui Anchiove 2015. Table of Contents
Page 2: HL7 for Busy Professionals · 2019-10-30 · HL7 for Busy Professionals Your No Sweat Guide to Understanding HL7 Rahul Bhagat Illustration By Calvin Hui Anchiove 2015. Table of Contents

HL7forBusyProfessionals

YourNoSweatGuidetoUnderstandingHL7

RahulBhagat

IllustrationByCalvinHui

Anchiove2015

Page 3: HL7 for Busy Professionals · 2019-10-30 · HL7 for Busy Professionals Your No Sweat Guide to Understanding HL7 Rahul Bhagat Illustration By Calvin Hui Anchiove 2015. Table of Contents

TableofContentsPreface

PartIScratchingthesurface

1.Introduction2.WhatisHL7?3.IntegrationConcepts4.EvolutionofHL7

PartIIDiggingDeeper

5.BasicConcepts6.MessageBuildingBlocks7.WorkingwithaMessage8.ControlSegments9.DataSegments10.OtherImportantTopics

Page 4: HL7 for Busy Professionals · 2019-10-30 · HL7 for Busy Professionals Your No Sweat Guide to Understanding HL7 Rahul Bhagat Illustration By Calvin Hui Anchiove 2015. Table of Contents

PrefaceAfteruniversity,Igotajobwithabusy,Torontobased,healthcareconsultingcompany.Ondaytwoatwork,Iwashandedaprintoutwithcryptictextonit,andadocumentcalledinterfacespec,toreadandunderstand.

ThiswasmyintroductiontoHL7.Atthattime,Ididnotrealizethatthisobscuremessagingprotocolwouldbecomemytickettofaroffplaces,andthereasontomeetandworkwithalotofpeople.

Itdidn'ttakemelongtolearnHL7,myprogrammingbackgroundhelped.Later,IrealizedthatmyskillisinhighdemandandIbecameaconsultant.ItraveledtodifferentcitiesandworkedonvariousHL7projects.

Ialsostartedrunningintopeoplefromnon-technicalbackgroundwhowantedmetoexplainHL7intheelevatororwhilechattingintheircubicle.Therewasn’tanyintroductorybookIcouldsuggest,sotheideaofwritingonemyself.

I'mgladIcollaboratedwithCalvinHuiinwritingthisbook.HenotonlytookcareofillustrationanddesignbutalsonudgedmewhenIwasslackingafterthefirstdraft.MyfriendErikWestermannwasagreatsoundingboardandhelpedmerefinemyideas.Andthankstomanycolleagueswhohelpedmedevelopmyskills.Inparticular,DerrickLeung,whomentoredmewhenIwasjuststartingout.

Sohereitis.MyideaofanintroductorybookonHL7.Ihopeyouenjoyreadingit.

Page 5: HL7 for Busy Professionals · 2019-10-30 · HL7 for Busy Professionals Your No Sweat Guide to Understanding HL7 Rahul Bhagat Illustration By Calvin Hui Anchiove 2015. Table of Contents

PartIScratchingthesurface

Page 6: HL7 for Busy Professionals · 2019-10-30 · HL7 for Busy Professionals Your No Sweat Guide to Understanding HL7 Rahul Bhagat Illustration By Calvin Hui Anchiove 2015. Table of Contents

1.IntroductionAtechnicalbookusuallyimpliesadrysubject.Soitsnosurpriseauthorshaveahardtimefiguringoutwaystomakethebookinterestingtothereader.HL7isonesuchsubject.Itisasubjectthatissohighonthescaleofdrynessandnoonecomestoitwillingly.TheonlyreasonsomeonewouldreadabookonHL7isbecauseofhisorherjob.Andifyouarehere,readingthisbook,thenIassumeyouworkinhealthcareITorintendtojointheindustrysoon.

Ihavemadeeveryefforttotakeoutthedrynessofthesubjectandmakethisbookinteresting.Therearenoneedlessjargonsoresotericconceptsthrowncasuallytotripyou.Infact,youwillseeaheavyrelianceoneverydayexamplesandinclusionofbackgroundinformationtopaintacompletepicture.ButHL7andhealthcaresystemintegrationarecomplexsubjectssotherewillbetopicsthatdon'tmakesenserightaway.Pleasepersevere.Tieaknotandhanginthere.Graduallythingswillmakesense.

ThisintroductorybookonHL7goesindetailtoexplainwhatHL7is.Itgivesyouthebasicconcepts,tellsyouabouttheorganizationbehinditandhelpsyoucreateamentalmapofthevoluminousHL7specificationdocument.And,ittakesyouthroughawhirlwindtourofsomeofthemostcommonlyusedHL7messages,allinashortspanoftime.

EarlyRailroadsHL7wascreatedtosolvetheproblemsofclinicalsystemintegration.Buttotrulyunderstandtheproblemsofsystemintegration,let’sstartwithanotherintegrationproblemwesolvedcenturiesago.

The1800’swereatimewhenrailwayswerecomingofageinAmerica–justlikebatterydrivencars,dronesandothernewtechnologiesarecomingofagetoday.

Therewereliterallyhundredsofcompaniescompetingforapieceoftherailwaypie.Enterprisingcompanieswouldbuyupland,laydowntracksandrunatransportservicebetweencitieswhichhadnoothermeansoftransportationexceptforhorse-drawnwagonsor,ifonewasfortunate,steamships.

Page 7: HL7 for Busy Professionals · 2019-10-30 · HL7 for Busy Professionals Your No Sweat Guide to Understanding HL7 Rahul Bhagat Illustration By Calvin Hui Anchiove 2015. Table of Contents

BythetimeAmericancivilwarstarted(1861),vaststretchesofthecontinentwerealreadyconnectedthroughrailandworkwaswellunderwayontheconstructionofthetranscontinentalrailroadtoconnectCaliforniawiththerestofthecountry.

However,therewasoneproblem.Youcouldnotjusthoponatrainandgetoffatyourdestination,likeyoucantoday.Becausetheserailroadswerebuiltandrunbydifferentcompanies,theyuseddifferenttrackgauges(horizontaldistancebetweentworailsofthetrack).Thismeantyouhadtogetoffandchangetrainswheneveryouhitajunctionwithtwodifferentgaugewidths.Therewerewellovertwentydifferenttrackgaugesbeingusedatthetimeofthecivilwar.Thearmyhadtoconstantlyloadandunloadcargoinitsefforttogetsuppliestothetroops.Thiswasaseriousproblem!

AnditwasthereasonthatfinallymadetheAmericangovernmenttopushfortheconversionofallrailwaytrackstoastandardgauge—4feetand8.5inches,themostcommonlyusedgaugewidth.Morethanhalfoftheexistingtrackswerebuilttothiswidthsoitwaseasiesttoconverttheremainingtrackstothiswidthandachievestandardization.

Standardizationofrailtrackswasthefirststeptowardscreatinganintegratedsystemwheregoodsandpeoplecouldmovefreelyacrossthewholenetwork.Itwasfollowedbythedevelopmentofacommonsignalsystem,timezones,harmonizedtrainschedule,fixedcoachheight,astandardcoalandwatersupplysystemandonandon.

Itwasevidentthatanintegratedsystemneededastandardwayofdoingthings.

EvolutionofHealthcareITSystemsToday,weareina(somewhat)similarsituationwiththemovementofhealthcareinformation.Itcannotseamlesslyflowfromonesystemtothenext.Eachorganizationhasitsownwayofstoringandsharinginformation.Wheneverhealthinformationneedstomoveacrossorganizationboundaries,ithitstheincompatiblestandardsroadblock.Someonehastounloadandreloadtheinformation.

HealthcareITsystemshaveevolvedsimilartorailroads.Initially,hardwarecosts(thinkmulti-milliondollarmainframes)werethebiggestfactor,soonlyafewteachinghospitalswithdeeppocketshadthemeanstobuildasystem.Thesewereprimarilystand-alonesystemsmeanttoserveaspecificpurpose.Forexample,tomanagepatientpopulationinalargehospital.

Thenthehardwarecostcamedownandminicomputersarrivedonthescene.Acomputercouldbehadforlessthan$25,000anddidn’tneeda

Page 8: HL7 for Busy Professionals · 2019-10-30 · HL7 for Busy Professionals Your No Sweat Guide to Understanding HL7 Rahul Bhagat Illustration By Calvin Hui Anchiove 2015. Table of Contents

roomtohouseit.Thisallowedsmallerplayersandevendepartmentswithinahospitaltopurchasesystemsoftheirown.Pharmaciesinstalledsystemstotrackprescriptionsanddispensedmedicationwhilelaboratoriessetupsystemstotrackrequestsfortestsandtheirresults.

Thisledtodramaticimprovementinproductivityfortheseorganizationsbuttherewasnofreeflowofinformationbetweentheclinicalsystems.Theproblemwaslackofstandardization.Informationfromonesystemhadtobeunloadedtopaperandtransportedtowheretheothersystemwas.Thenahumanoperatorwouldreloadtheinformationtotheothersystembymanuallytypingitin.

Ofcoursethiswastheworsecasescenario.Improvementsweremade.Informationwasloadedonfloppydisksandelectronicallymovedtotheothersystem.Still,therewasnofreeflowofinformationbetweensystems.Thispreventedusfromrealizingthetruepotentialofelectronicsystems.

ThensomeITvendorscameupwithasolution.Replacestand-alonesystemswithanintegratedproduct-anEHR(electronichealthrecord).IfyouarefamiliarwithCerner,EpicorMeditechthenyouknowwhatIamtalkingabout.Alargesystemwithmodulesforeverydepartment.

Thiseliminatedtheneedforhealthinformationtocrosssystemboundaries.Withinthesystem,themoduleswoulduseastandardwayofstoringandsharinginformationandthiswouldallowtheinformationtoflowseamlesslywithintheorganization.

Thisapproachworkedwell.EHRshavebeenverysuccessfulineliminatingtheproblemofintegratingsystemswithinanorganizationandtheycontinuetobeoneofthecornerstonesofthehealthcareITstructure.

Butwhataboutsharinginformationoutsidetheorganization?Healthcareorganizationsdon’tworkinisolation.Theyneedtoshareinformationwithinsurancecompaniesandsendpatientcareinformationtothegovernment.Theyhavetoconstantlycommunicatewiththeoutsideworld.

Touseourrailwayanalogy,thiswassimilartothesituationwhereeachstatecouldsetitsownstandardgauge.Youcouldtravelalloverastatewithouttheneedtoswitchtrainsbutwhenyouwantedtocrossthestateboundary,youwouldneedtodisembarkandgetonatrainthatranontheotherstate’sstandardgauge.

Clearly,EHRswereonlyalimitedsolution.Therewasalsothequestionofwhattodowithexistingstandalone

clinicalsystems.Thesesystemswerebuiltovermanyyearsthroughsubstantialmonetaryinvestment.Anorganizationwouldbeloathtoscrapallthatinvestment&hardworkandreplaceitwithanEHR.

Healthcareneededabettersolution.Itneededastandardgaugeto

Page 9: HL7 for Busy Professionals · 2019-10-30 · HL7 for Busy Professionals Your No Sweat Guide to Understanding HL7 Rahul Bhagat Illustration By Calvin Hui Anchiove 2015. Table of Contents

connecttheseEHRs,standalonesystems,externalsystemsandsystemsthatwereyettobebuilt.Itneededtomoveawayfromconstantlyloadingandunloadinginformation.

ThesolutionwasHL7.

Page 10: HL7 for Busy Professionals · 2019-10-30 · HL7 for Busy Professionals Your No Sweat Guide to Understanding HL7 Rahul Bhagat Illustration By Calvin Hui Anchiove 2015. Table of Contents

2.WhatisHL7?HL7isanANSIaccredited,OSIlevel7,applicationlayerprotocolforexchangingclinicalandadministrativedatabetweenhealthcaresystems.

Chancesare,ifyouarenotanetworkengineerordidnotstudycomputerscience,then“OSIlevel7,applicationlayerprotocol”probablymeansnothingtoyou.

Inlayterms,youcansaythatHL7isalanguagethatclinicalsystemsusetoexchangeinformationwitheachother.Buteventhatdoesn’ttellyouanything.WhenIwaslearningHL7,thedefinitionraiseditsownquestionsandleftmewithavaguesenseofunease.IttookafairbitofresearchtofigureoutwhatHL7is.

Soinsteadofleavingwithasenseofunease,whydon’twetakethetimeandfigureoutwhatHL7reallyis?

ApplicationLayerProtocolHL7isanapplicationlayerprotocol.Thismeansthatitdefinestherulesforexchangingdata(clinicalandadministrative)betweenapplications.

Weoftenusethewordsystemandapplicationinaninformalway,whichcloudsthedistinctionbetweenthetwo.Historicallyanapplicationwasthesameasasystem.Anoldaccountingsystem,withitshardwareandprintersandmonitorshadonlyonejoborapplication–preparingandmaintainingfinancialrecords.

Thingschangedwhensystemsbecamemorepowerfulandstartedtakingonmultipleroles.Agreatexampleisyoursmartphone.It’snotjustaphoneanymore.Makingaphonecallisjustoneofthemanyfunctionsofthedevice.Ithasnumerous“apps”orapplicationsforallsortsofthings.

Similarly,moderncomputersystemsorserversrunmultipleapplications,includingclinicalapplications.Whenapplicationscommunicatewitheachother,theyhavetodosothroughtheirsystem.Basically,applicationscreateamessageinalanguagethatisunderstoodbytheircounterpartapplications–inourcaseHL7–andhanditovertotheirsystemfordelivery.Thesystemdoesn’tunderstandthemessage.Itsjobistoreliablydeliverthemessagetothedestinationsystem.

Page 11: HL7 for Busy Professionals · 2019-10-30 · HL7 for Busy Professionals Your No Sweat Guide to Understanding HL7 Rahul Bhagat Illustration By Calvin Hui Anchiove 2015. Table of Contents

HL7isonesuchspecializedapplication-to-applicationlanguage/messagingrulebook/protocol–whateveryoucallit–forcommunicationbetweenclinicalapplications.

OSILevel7HL7isalsoanOSI(OpenSystemInterconnection)Level7protocol.Thisisjustaformalwayofsayingthatitisanapplicationlayerprotocol.

Now,wearegoingtodiscussOSIanditslevelsandthatmeanssplashingthroughpacketbased,networkcommunication.Ifyouarenotinterestedinit,Iwouldsuggestskippingovertothenextchapter.

OSIisareferencemodelthatnetworkingguysusetomakesenseofthenetworkcommunicationmodelandhowthingsreallyhappenatthebitandbytelevel.

ItisnotdifficulttounderstandtheOSImodel.Thesecretisproperbackgroundknowledgeandanunderstandingofthekeyconcepts.Let’sseeifwecandothatinafewshortpageshere.

HistoricalBackgroundUsingelectricityforcommunicationstartedwithSamuelMorse,theinventorofthetelegraph.Hecreatedasimplecircuitwithabattery,abowlofmercuryandtwolongwiresgroundedatends.

Ifhedippedawireinthebowlofmercury,itcompletedthecircuitandcurrentflowedthroughit.Tosendashortburstofelectricity,hewoulddipthewireandpullitoutquickly.Thiswaslikesendingelectric“smokepuffs”totheotherend.

ThisbasicideawasrefinedintothetelegraphandMorsecode.Thecodehadtwoletters–adotandadash.Adotwasashortpuffofelectricityandadashwasalongerpuff(about3timesthedurationofadot).Dotsanddasheswerecombinedtorepresentlettersandvoila!Wehadelectroniccommunication.

.....Thisisapreview.RestoftheChapterisnotshown.....

Page 12: HL7 for Busy Professionals · 2019-10-30 · HL7 for Busy Professionals Your No Sweat Guide to Understanding HL7 Rahul Bhagat Illustration By Calvin Hui Anchiove 2015. Table of Contents

4.EvolutionofHL7Weliveinaworldofstandards.Asnewtechnologiesemerge,anecessaryconditionfortheirwideadoptionisstandardization.Wenoticeitwhenthereisaproblemwiththestandard.Asmustbeevidenttoanyoneinaforeigncountrynotabletopluginalaptopbecausethepoweroutletisdifferent.

Standardsemergefromdifferentsources.Astandardcouldbeimposedbythegovernment,aswasthecasewiththeconversionfromtheimperialtothemetricsystemofmeasurement.BoththeUSAandCanadastartedtheconversionbutintheStates,thegovernmentdefundedtheMetricBoard,stallingtheirconversion.InCanadahowever,theconversionwascompletedandwestartedmeasuringdistanceinkilometersandtemperatureinCelsius.

Anothersourceofstandardistheindustryitself.Companiesattheforefrontofanewtechnologyvieforcompetitiveadvantagebypromotingadoptionoftheirtechnology.WehaveallheardaboutthefamousvideotapestandardsbattlebetweenBetamaxandVHS.Sony’sBetamaxwasasuperiortechnologybutVHSbecamethestandardbecauseJVCwasrelentlessinpromotingittoelectronicsmanufacturers.

Athirdsourceofstandardismarketforces,whichleadstoade-factostandard.ThiswasthecasewithTCP/IP.Itbecamethedominant,andultimatelystandard,network-communicationprotocolasaresultofgradualadoptionbyuniversitiesandbusinesses.BythetimetheISOmodelwasdeveloped,itwastoolateforaswitchover.TCP/IPwasalreadybakedin.

Andfinally,thereisthedeliberateapproachwhereexpertsgettogetherwiththespecificintentofcreatingastandard.ThisishowtheHL7standardcameintobeing.

.....Thisisapreview.RestoftheChapterisnotshown.....

Page 13: HL7 for Busy Professionals · 2019-10-30 · HL7 for Busy Professionals Your No Sweat Guide to Understanding HL7 Rahul Bhagat Illustration By Calvin Hui Anchiove 2015. Table of Contents

PARTIIDiggingDeeper

Page 14: HL7 for Busy Professionals · 2019-10-30 · HL7 for Busy Professionals Your No Sweat Guide to Understanding HL7 Rahul Bhagat Illustration By Calvin Hui Anchiove 2015. Table of Contents

6.MessageBuildingBlocksTotheuninitiated,thesightofanHL7messageisoftenintimidating.Abrewofsymbolsandcharacters,itlookslikesomethingoutoftheMatrixthatisbeyondthecomprehensionofmeremortals.Buttobehonest,HL7reallyisquietsimpleandstraightforward,onceyouknowhowtoreadit.Andforthat,youwillneedtolearnaboutthebuildingblocksofanHL7message.

Let’staketheexampleofregisteringanewpatient.Whenthestaffatthefrontdeskcompletesthepatientregistrationandhitsenter,ittriggersanevent:A04(Registerpatient).ThiscausesthesystemtogenerateanewADT^A04HL7message,whichlookssomethinglikethis.MSH|^~\&|SENDER_APP|SENT_BY|RECEIVER_APP|RCVD_BY|201310201500||ADT^A04|MSG_ID001|P|2.5|||AL

EVN|A04|201310201500|||ID221^Dude@Terminal

PID|1||PAT416^^^HEALTH_ID||SEBELUS^KANSAS||194801150600|M|||123SESAME.ST^^TORONTO^ON^A1A2B2^CANADA||(416)888-8088||ENGLISH|M||PAT_AC_721914

NK1|1|SEBELUS^MARY|SPOUSE|||(416)888-9999|(647)123-1234|C|20131020

PV1|1|O|ROOM10^BED12^OUTPATIENT|ELECTIVE|||S21195^DRIKOFF^FRANCIS^^^DR^MD||C90023^PAYNE^TRACY^^^DR^MD|SUR||||1|||S21195^DRIKOFF^FRANCIS^^^DR^MD||37323|SELF||||||||||||||||||||||||201310201500

PV2|||DAYSURGERY

AL1|1|FA^PEANUT||PRODUCESMILDRASH

SeewhatImean?Makesnosense.Butsoonitwill.

SegmentTheprimarybuildingblockofamessageisasegment.Asegmentissimplyarowofdatainthemessage.So,forthemessageabove,thefirstsegmentstartswithMSHandendsonlinetwowithAL.Itisactuallyjustonerowofdata,whichwaswrappedovertothesecondline.ThereisalinebreakafterALandthatmeansendofthesegment.ThesecondsegmentstartswithEVNonlinethreeandendsat“Terminal”onthesameline,followedbyalinebreakandsoon.Anewsegmentalwaysstartsonanewline.

ThefirstthreecharactersofeachsegmentisthesegmentID.ThesegmentIDisanacronymorthenametagofthesegment.

Onceweknowthesegmentname,weknowtheinformationinthat

Page 15: HL7 for Busy Professionals · 2019-10-30 · HL7 for Busy Professionals Your No Sweat Guide to Understanding HL7 Rahul Bhagat Illustration By Calvin Hui Anchiove 2015. Table of Contents

segment.Thisisbecausethemainpurposeofasegmentistogrouprelatedinformationtogether.

Inourexamplehere,therearesevensegments(IDsbolded).MSHistheMessageHeadersegment,EVNistheEventsegment,PIDisthePatientIdentificationsegmentandsoon.WithoutevenlookingatthecontentofthePIDsegment,Icantellyouitcontainsthenameofthepatient,hishealthID,dateofbirth,phonenumber,address-basicallyalltheinformationthatcanbeusedtoidentifythepatient.Hencethenameofthesegment-PatientIdentification.MSH|^~\&|SENDER_APP|SENT_BY|RECEIVER_APP|RCVD_BY|201310201500||ADT^A04|MSG_ID001|P|2.5|||AL

EVN|A04|201310201500|||ID221^Dude@Terminal

PID|1||PAT416^^^HEALTH_ID||SEBELUS^KANSAS||194801150600|M|||123SESAME.ST^^TORONTO^ON^A1A2B2^CANADA||(416)888-8088||ENGLISH|M||PAT_AC_721914

NK1|1|SEBELUS^MARY|SPOUSE|||(416)888-9999|(647)123-1234|C|20131020

PV1|1|O|ROOM10^BED12^OUTPATIENT|ELECTIVE|||S21195^DRIKOFF^FRANCIS^^^DR^MD||C90023^PAYNE^TRACY^^^DR^MD|SUR||||1|||S21195^DRIKOFF^FRANCIS^^^DR^MD||37323|SELF||||||||||||||||||||||||201310201500

PV2|||DAYSURGERY

AL1|1|FA^PEANUT||PRODUCESMILDRASH

MessageStructureSegmentsinamessagearealwaysorganizedinaspecificorder.Thisorderiscalledthemessagestructure.Differentmessagetypeshavedifferentmessagestructuresbutsomethingsarealwaysthesame.Forexample,everymessagestartswithanMSHsegment.

Iftheorderofsegmentsinamessageisnotexactlylikeitsmessagestructure,thenthatmessagewillbecomeinvalid.Itwillberejectedbythereceivingsystem.

YoucangettheabstractmessagestructureofanymessageintheHL7specificationdocument.TheabstractmessagestructureofanADT^A04messageisinChapter3oftheHL7specificationdocumentwhereeventA04isdiscussed.

HereisapartialabstractmessagestructureofanADT^A04message.Itisjustatablewiththreecolumns:segmentID,segmentnameandthechapterwherethatsegmentisexplained.

Page 16: HL7 for Busy Professionals · 2019-10-30 · HL7 for Busy Professionals Your No Sweat Guide to Understanding HL7 Rahul Bhagat Illustration By Calvin Hui Anchiove 2015. Table of Contents

Ifyoucomparetheexamplemessagetoitsabstractmessagestructure,thesegmentorderdoesnotmatchbetweenthetwo.Intheexamplemessage,theSFTsegmentismissingafterMSH;PD1&ROLaremissingtoo.

Doesthatmeantheexamplemessageisinvalid?No,it’snotbecausethe[]and{}bracketsaroundthosesegmentsmakethemeitheroptionalorrepeatable.

Optional/Repeatable/MandatoryTherearetwokindsofbrackets:square[]andcurly{}.IfasegmentIDisenclosedwithin[squarebrackets],itmeansthesegmentisoptional.Wecanchoosewhethertoincludethatsegmentinthemessageornot.Thesesegmentsaregenerallyforoptionalinformation,suchasPD1(additionalpatientinformation).

IfthesegmentIDisenclosedwithin{curlybrackets},thenthatsegmentisrepeatable.Wecanhavemorethanoneinstanceofthatsegmentinarealmessage.CurlybracketsareforsegmentslikeNK1(NextofKin).Ifapatienthasgivencontactinformationfortwonextofkin(spouseandsister),thentheinformationforeachnextofkinwillneedaseparateNK1segmentinthemessage.

IfasegmentIDisenclosedinboth[{squareandcurly}]bracketsthenthatmeansthesegmentisbothoptionalandrepeatable.IfasegmentIDisnotsurroundedbyanybracketthenthatmeansitisamandatorysegment.Thatsegmenthastobepresentinthemessage.SosegmentslikeMSH,EVN,PID,PV1,withnobrackets,havetobepresentinarealmessage.

Basedonthisknowledgewecanseewhytheexampleisavalidmessage.Allthemissingsegments,SFT,PD1andROLaresurroundedbysquarebrackets.Andthatmeansthosesegmentsareoptional.Wecanchoosetoleavethemout.

.....Thisisapreview.RestoftheChapterisnotshown.....

Page 17: HL7 for Busy Professionals · 2019-10-30 · HL7 for Busy Professionals Your No Sweat Guide to Understanding HL7 Rahul Bhagat Illustration By Calvin Hui Anchiove 2015. Table of Contents
Page 18: HL7 for Busy Professionals · 2019-10-30 · HL7 for Busy Professionals Your No Sweat Guide to Understanding HL7 Rahul Bhagat Illustration By Calvin Hui Anchiove 2015. Table of Contents

8.ControlSegmentsFromthelastchapter,ifyourememberthediscussionabouttheanatomyofamessage,controlsegmentsarethesegmentsintheheadofamessage.Theyonlycarrymeta-datainformationaboutamessage.

ThereareaboutadozencontrolsegmentsdefinedbyHL7.Theyareallexplainedinchapter2oftheHL7spec.Fortunately,weonlyneedtoknowaboutafewofthemtoaccountforthevastmajorityofcases.Forexample,therearecontrolsegmentsforbreakingaverylargemessageintosmallerpiecesandcontrolsegmentsforbatchingtogetheralargenumberofmessages.Thesecontrolsegmentsarenotusedthatfrequentlyandforageneralunderstanding,youcanskipthem.

Therearefivecontrolsegmentsthatyoureallyshouldknowabout–MSH,EVN,NTE,MSA&ERR.WewillstartwithMSH,theubiquitouscontrolsegmentthateverymessagebeginswith.Itisthemostimportantcontrolsegment.Ifyoudecidefiveistoomanyforyourprecioustimeandyouareonlygoingtoreadaboutone,thenletthisbetheone.

MessageHeaderSegment(MSH)Themessageheadersegment(MSH)isthemostimportantcontrolsegment.EveryHL7messagestartswiththissegment.WhenanHL7messageisreceivedbyasystem,itistheMSHthattellsthereceivingsystemwherethismessagecamefrom,theinformationitcontainsandhowitissupposedtobeacknowledged.

Thisisasegmentyouwanttoknowwell.Togetabetterunderstandingofthecontentsofthissegment,let’suse

theMSHsegmentfromourexampleA04messageandexploreitscontents.MSH|^~\&|SENDER_APP|SENT_BY|RECEIVER_APP|RCVD_BY|201310201500||ADT^A04|MSG_ID001|P|2.5|||AL

Ifyoubreakthesegmentdownintoitsseparatefields,itgetseasiertofigureoutthecontent.Remember|isusedtoseparatefields.

MSH-1:|(FieldSeparator)

Page 19: HL7 for Busy Professionals · 2019-10-30 · HL7 for Busy Professionals Your No Sweat Guide to Understanding HL7 Rahul Bhagat Illustration By Calvin Hui Anchiove 2015. Table of Contents

MSH-2:^~\&(EncodingCharacters)MSH-3:SENDER_APP(SendingApplication)

MSH-4:SENT_BY(SendingFacility)

MSH-5:RECEIVER_APP(ReceivingApplication)

MSH-6:RCVD_BY(ReceivingFacility)

MSH-7:201310201500(Date/TimeofMessage)

MSH-8:

MSH-9:ADT^A04(MessageType)

MSH-10:MSG_ID001(MessageControlID)

MSH-11:P(ProcessingID)

MSH-12:2.5(VersionID)

MSH-13:

MSH-14:

MSH-15:AL(AcceptAcknowledgementType)

Notethatsomeofthefieldsareempty(e.g.MSH-8).Thisisperfectlyfine.Remember,noteveryfieldinasegmentisrequiredtohaveavalue.IfyourefertothesegmentattributetableofMSH,youcanconfirmthatallmissingfieldsareoptional.

Now,hereisalittleinsiderinformation.Thereareonlyafewfieldsineachsegmentthatarereallyimportantandregularlyused.Thatiswhyyouseetheusualpipepattern(||||)inHL7messages.Theconsecutivepipesarenothingbutemptyfields.

Sokeepingwithourtradition,andsavingyouprecioustime,wearegoingtodiscussonlythemostimportantfieldsinasegment.

IntheMSHsegment,owingtothefactthatitcontainsmostofthemeta-datainformation,therearemanyimportantfields.Itistheheaviestcontrolsegment.Someoftheseimportantfieldsarerequiredandothersareoptional,buttheyalmostalwayshaveavalue.

IfyourefertothesegmentattributetableoftheMSHsegment,HL7requiresthatthefollowingfieldsalwayshaveavalue.MSH-1:FieldSeparator

MSH-2:EncodingCharacters

MSH-7:Date/TimeOfMessage

MSH-9:MessageType

MSH-10:MessageControlID

MSH-11:ProcessingID

Page 20: HL7 for Busy Professionals · 2019-10-30 · HL7 for Busy Professionals Your No Sweat Guide to Understanding HL7 Rahul Bhagat Illustration By Calvin Hui Anchiove 2015. Table of Contents

MSH-12:VersionID

Itiseasytofindoutwhichfieldsarerequiredinasegment.JustgotothesegmentattributetableandlookfortheletterRintheoptionality(OPT)column.

Besidestheserequiredfields,therearesomeotherfields(below)inMSH,whichareoptionalbutregularlyused.TheyareimportantandIthinkyoushouldknowaboutthem.MSH-3:SendingApplication

MSH-4:SendingFacility

MSH-5:ReceivingApplication

MSH-6:ReceivingFacility

MSH-15:AcceptAcknowledgementType

MSH-16:ApplicationAcknowledgementType

Keepinmindthoughthatthisisonlymypersonalopinion.Otherscanarguethatthereareotheroptionalfieldsthatareimportantandsomeherearenot.I’mnotdenyingit.Butfrommyexperience,IbelievethesearetheimportantfieldsintheMSHsegment.

Nowlet’sgetfamiliarwiththesefieldsbecausethenameofthefielddoesn’ttellyouevenonetenthofthestory.

MSH-1:FieldSeparatorUsually,thefirstfieldinasegmentisthefieldthatfollowsthesegmentID.Sotechnically“encodingcharacters”shouldbethefirstfieldofMSHsegment.ButwithMSH,thereisananomaly.Thefirstfield(MSH-1)alwaysdefinesthesymbolthatwillbethefieldseparator(delimiter)fortheentiremessage.IfyourememberthediscussionaboutpipedelimitersinChapter6,|isthefieldseparatorinHL7messagesandtherefore,thefirstfieldofMSH.Butitdoesn’thavetobe.Youcanchoosetohaveacomma(,)oranyothersymbolastheseparator.Ifyouchoosetouseacomma,thesegmentwilllooksomethinglikethis.MSH,^~\&,SENDER_APP,SENT_BY,RECEIVER_APP,RCVD_BY,201310201500,,ADT^A04,MSG_ID001,P,2.5,,,AL

ThiswouldbeaperfectlylegitimateHL7segment.However,|hasbecomesuchadefactostandardthatnoonereallyusesanythingbut|asthefielddelimiter.Butit’sgoodtoknowthatwehavethepowertochangeit.

MSH-2:EncodingCharactersEncodingCharactersarethefoursymbols^~\&thatHL7reservesformessageconstruction.

Page 21: HL7 for Busy Professionals · 2019-10-30 · HL7 for Busy Professionals Your No Sweat Guide to Understanding HL7 Rahul Bhagat Illustration By Calvin Hui Anchiove 2015. Table of Contents

Thesecharactershavespecialmeaning,whichallowsapplicationsreadinganHL7messagetodistinguishbetweencomponentsandsubcomponentsofafield,readrepeatingfields,andtranslatesymbols.

Theencodingcharacters,inorder,are-ComponentSeparator(^),RepetitionSeparator(~),EscapeCharacter(\)andSubComponentSeparator(&).Thepositionofeachcharacterisfixedinthefield.Firstthecomponentseparatorthentherepetitionseparatorandsoon.

ByhavingthesesymbolsinMSH-2,wearebasicallysayingthatinthisHL7message,^willbeusedtoseparatecomponents,~willbeusedtoseparatemultipleoccurrencesofafield,\willbeusedforspecialcharactersand&willbeusedtoseparatesubcomponents.

Butshouldn’tthisbehardcodedinsystemsthatreadHL7messages,insteadofincludingitineverymessage?

Goodpoint.ThereasonencodingcharactersareincludedineveryHL7messageisbecausethesecharactersarecustomizabletoo,justlikethefieldseparator|.

HL7givesyoutheoptionofselectingyourownencodingcharacters.Ifyoudon’tlike^andwouldratherhave#asthecomponentseparatorinyourmessagesthenallyouhavetodoisreplace^with#inMSH-2.Asaresult,yourencodingcharacterswouldbe#~\&.The#symbolwillnowbethecomponentseparator.

Butthiswholediscussionispointless!Overtheyears,thesesymbolshavebecomeadefactostandard.I’llbet,manyfolkswhohavebeenworkingwithHL7foryears,don’tknowthatyoucanchangethesesymbols.Ihavenevercomeacrossamessagewhereadifferentsetofsymbolswereused.

Beforewemovetothenextfield,youneedtoknowmoreabouttheothertwoencodingcharacters–theRepetitionSeparator(~)andtheEscapeCharacter(\).

RepetitionSeparator(~):Thisisthesymbolthatseparatesmultiplevaluesinafield.Rememberthesectiononsegmentattributetableinchapter7?Somefieldsarerepeatableandtheycanhavemultiplevalues.~isthesymbolthatisusedtoseparatethosevaluesinafield.

IntheMSHsegment,fieldMSH-18andfieldMSH-21arerepeatable.Thismeans,wheneverthosefieldshavetwoormorevalues,thevalueswillbeseparatedbythe~symbol.Ifasystemreadingthemessagecomesacrossthe~symbol,itwillknowrightawaythatwhatfollowsisthenextvalueofthefield.

EscapeCharacter(\):HL7reservesencodingcharactersformessageconstructionandtheyhaveaspecialmeaninginthemessage.Whathappensifyouneedtouseoneofthosespecialcharactersaspartofthedata?The

Page 22: HL7 for Busy Professionals · 2019-10-30 · HL7 for Busy Professionals Your No Sweat Guide to Understanding HL7 Rahul Bhagat Illustration By Calvin Hui Anchiove 2015. Table of Contents

applicationreadingthemessageisgoingtobeallconfused!!Inrealworldapplications,themosttroublesomeofthesespecial

charactersistheampersandsymbol(&).Itisusedfor“and”(asinBen&Jerry’s)andisalsoacommonlyusedsymbolinprogramminglanguageslikeHTML(whichcouldbeembeddedinanHL7message).So,soonerorlater,youareboundtocomeacrossthe&symbolinthebodyofanHL7message.

Whathappensifthesecharactersarepartofthedata?Let’sconsideranexample.

Ben&Jerry’sDiagnosticCentersendstheresultofatestasanHL7messagetotheorderinghospital.Thehospitalsystemreceivesthemessageandstartsreadingittoparsethedata(pulloutfieldvalues)andsaveittoadatabase.WhenthesystemgetstotheSendingFacilityfield(MSH-4),itwillread“Ben”andthenrunintothe&symbol.Atthatpoint,thesystemisbeingtoldthatthenameofthefacilityhasasub-component.Facilitynamesdon’thavesub-components(ifyoucheckthesegmentattributetable),soinalllikelihoodthesystemdoesn’thaveacorrespondingfieldinthedatabasetosavethevalue“Jerry’sDiagnosticCenter”.

Thisisarecipeforapplicationfailure.Let’sassumethisisafuturistic,can-handle-anythingkindofsystem,buteventhenthesystemisonlysaving“Ben”asthenameofthesendingfacility,whichisincorrect.Thedoctorreadingthelabreportwillseethat“Ben”sentthetestresult.Idon’tknowhowmuchfaithshewillhaveinthereport.

Sowhatdowedo?Wecan’taskBen&Jerry’sDiagnosticCentertochangeitsname.

Thisiswheretheescapecharactercomestotherescue.Ifcharacters,whichhavespecialmeaninginHL7,needtobetransmittedaspartofthedata,thenalloneneedstodoisreplacethecharacterwithitscorrespondingescapesequence.Thesystemreadingitwillreadtheescapesequenceandreplaceitwiththatspecialcharacterbeforesavingit.

Anescapesequenceisnothingmorethanoneormorecharacterssurroundedbytheescapecharacter(\).EveryspecialcharacterinHL7hasacorrespondingescapesequence.Therearemanyescapesequencesforformattingandhighlightingtext,andyoucanevencreatecustomescapesequences.

Herearetheescapesequencesforthesymbolswehavealreadydiscussed:

Page 23: HL7 for Busy Professionals · 2019-10-30 · HL7 for Busy Professionals Your No Sweat Guide to Understanding HL7 Rahul Bhagat Illustration By Calvin Hui Anchiove 2015. Table of Contents

GuesshowBen&Jerry’sDiagnosticCenterwillbeencodedinanHL7message.Youwillreplacetheencodingcharacter&withitscorrespondingescapesequencesothatyouwillhave“Ben\T\Jerry’sDiagnosticCenter”encodedinthemessage.Thereceivingsystemwillrecognize\T\asanescapesequenceandreplaceitwiththe&symbolwhenthedataissavedlocally.

.....Thisisapreview.RestoftheChapterisnotshown.....