{"_id":"hl7-standard","_rev":"4-aa443d914cf3f0b3a5c5745c54c8f34e","name":"hl7-standard","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.0":{"name":"hl7-standard","version":"1.0.0","description":"Simple, Lightweight HL7 module for tranforming, manipulating, or creating HL7 messages.","main":"index.js","scripts":{"test":"tap tests","build":"babel src/api.js --out-file builds/._.mirth.js; node bin/build.js;"},"author":{"name":"Jesse Reynolds","email":"jreynolds@ironbridgecorp.com"},"contributors":[{"name":"Jesse Reynolds","email":"jreynolds@ironbridgecorp.com"},{"name":"Adam Farabaugh","email":"afarabaugh@ironbridgecorp.com"}],"license":"ISC","devDependencies":{"@babel/cli":"^7.5.5","@babel/core":"^7.5.5","@babel/preset-env":"^7.5.5","babel-preset-minify":"^0.5.1","minifier":"^0.8.1","rimraf":"^3.0.0","tap":"^10.1.0"},"gitHead":"642464bfc3ce6e3986cea5912c8aadff8115c6e4","_id":"hl7-standard@1.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"ironbridgecorp","email":"engineering@ironbridgecorp.com"},"dist":{"integrity":"sha512-J/m9TdnPNcrGZPbkbmUKVQkQwjXIuFC2eJTzU3XiLr46MiUdHS71aM2gY0uKj/KZQGYFbJoGw5I8dkCmnIvHTw==","shasum":"0027c8ade7399629225d0e8cdbf2faf4784e01a4","tarball":"https://registry.npmjs.org/hl7-standard/-/hl7-standard-1.0.0.tgz","fileCount":35,"unpackedSize":124343,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdk5RRCRA9TVsSAnZWagAAvTkP/0rV/ZTqgn3joDI0v8fK\n7zJpMRDF+o4cje9zkHq8PSVL/TzTs4RXKQR2+dhrbHBYqljNhJ4GHszInhb0\nQ0MPhdu624RulUCTzLBYmhhF/8oLLE6ZMVMUBXiFdA3VghDNTv0Dul8ARhtf\nBWI+xJKowdZ7nutJnN3vdAgw3tVEby92KDQ3vW2K2CTo4FsVFBj70Y7Nq/GW\n5R+E/c0VB5sUHakDrapKbRxn6/5C4ShoUFOS3HVXNQl3+mQMEvsiTSriEwgd\n+cebYkRuJPTbihwt872vYkEzHuM54FroPNyfMJuCrz4Y7byqg/ra6BmMGLei\nRwluk53wee0y2C74vcwUJagiC8W8JJaZF9RD+1lvaVN4IxpaYjmcx5Ezwdlr\nxLoSVEc1iiuceqhYO6qHmw7eW/7KJ/AmskuU7BWneD3Siq1rQw+rpAmpsz8O\n2iuQQ4hTGwW3tE4TGXopL+SbF8eaQQAdw6c7sb7Rsyie31WjM145TN38T9pB\nk9Sx4kPeVuPJQwi9v+VfIO/Gtxm6knC+qYZDhPpkIZfYWkVzoOc3cVfEhwaB\nC9M80FhuzTMObBivTcUyqzae/vWKO/DSTqa0VhyVScUXYStkwvJwLP+zj9Gz\n7OY4om0wEeXZ7vK79Nu7CfKmfF97BqwEelhLGLVVeg0RbHvcxzksiUSQrLjH\nHTo2\r\n=iPkg\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBKixwjG469e3L84oyPJ/B8GVcURs/+cRkNybnxQqFrFAiANEM848r13saeCNykYTS+lPPiexb83Wquv03avMVHENw=="}]},"maintainers":[{"name":"ironbridgecorp","email":"engineering@ironbridgecorp.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hl7-standard_1.0.0_1569952848978_0.7369615884376115"},"_hasShrinkwrap":false},"1.0.2":{"name":"hl7-standard","version":"1.0.2","description":"Simple, Lightweight HL7 module for tranforming, manipulating, or creating HL7 messages.","main":"index.js","scripts":{"test":"tap tests","build":"babel src/api.js --out-file builds/._.mirth.js; node bin/build.js;"},"author":{"name":"Jesse Reynolds","email":"jreynolds@ironbridgecorp.com"},"contributors":[{"name":"Jesse Reynolds","email":"jreynolds@ironbridgecorp.com"},{"name":"Adam Farabaugh","email":"afarabaugh@ironbridgecorp.com"}],"license":"Apache-2.0","keywords":["hl7","parse","format"],"devDependencies":{"@babel/cli":"^7.5.5","@babel/core":"^7.5.5","@babel/preset-env":"^7.5.5","babel-preset-minify":"^0.5.1","minifier":"^0.8.1","rimraf":"^3.0.0","tap":"^10.1.0"},"gitHead":"b4e0ee9c6aa06994ac0bc9af68c00b2814a0cb20","_id":"hl7-standard@1.0.2","_nodeVersion":"10.18.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-keftyS4asXEFSyKr1a9yaxuHyG1ExovXSNrvE4Br/gVzCoD3wQLRXJ4olxnqE73zYgtaY90tbB66WZ9yEszoUA==","shasum":"e3edf2d1ac30814ce94ceb67881bb2bfe54ae7dd","tarball":"https://registry.npmjs.org/hl7-standard/-/hl7-standard-1.0.2.tgz","fileCount":35,"unpackedSize":124467,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeaU06CRA9TVsSAnZWagAAhY4P/2LP2zkJNoQmw9Xup5yJ\nPOwFR+K8QOCd2XDZoNHrlDbK1f7IhVOr1kqcE/44YptINwD4fNmNszOO5Mft\n7eYjvq29d7KgC5nCuieQioMy5j7vqZG7XS2l6F+4qbe2N2HnJlb1gcYwM4nl\n1/qN3YSt4/7WInN2GLzilmPP3bMqB+FSi6k+hx493hk+HwW1PWIP2TLwYJT+\nSg5foIKfxmVXzDM7lVuizoVeNAbRQI8aUeel8yPGnHGVlv+54pIZmJ1L5VUO\nDTDeDcyt1y/9TCBW6UUxdzReNZAU/hK8QNwKzceDU8sbxxpUTGxr47iUBk1T\n6gu34Ydal2UmDhYFqltRbqgmMc9DZ+y3s/63AArAcGdF4Apf1iTLjJCVFrNu\nc77/dl1VfU6F8xQbhP/ru3jTR1IXMHyoW2izr0+tTJ6yV2sq2Yr03RBIUsTK\nAxrWS/vTsVSo6z4KCPZ3P6dTNPHuv0kgQwbtyHaIhiBExvsX0rLDQS7WEs3g\nKBvLzOZYCldGNZcHKlIuDSolRapLNNlgxWMCpRwleHubUs5LlyuwK/3UTDoq\nZ7qAzbfka9ISS0a8Mdy4fWhwiU8fXk/6gBKtAKSmamcsGFUtEDgjHMa5RCw4\n1pUjMfRjZF7YomRS5ykkT6qUMvp/KSljTgOK64E5crXo/ZpvWOhTBi+zp+lb\nWi1v\r\n=7Jbs\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEniedEln1Duobq8TIQ8eVF81uCt0xAsPtUUrk9fyco9AiEArG0PqB/eBEr5v1HrqiCdxR8iK0PqQ0XTOf2+IXNu1uE="}]},"maintainers":[{"name":"ironbridgecorp","email":"engineering@ironbridgecorp.com"}],"_npmUser":{"name":"ironbridgecorp","email":"engineering@ironbridgecorp.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hl7-standard_1.0.2_1583959353803_0.9426161342776975"},"_hasShrinkwrap":false},"1.0.3":{"name":"hl7-standard","version":"1.0.3","description":"Simple, Lightweight HL7 module for tranforming, manipulating, or creating HL7 messages.","main":"index.js","scripts":{"test":"tap tests","build":"babel src/api.js --out-file builds/._.mirth.js; node bin/build.js;"},"author":{"name":"Jesse Reynolds","email":"jreynolds@ironbridgecorp.com"},"contributors":[{"name":"Jesse Reynolds","email":"jreynolds@ironbridgecorp.com"},{"name":"Adam Farabaugh","email":"afarabaugh@ironbridgecorp.com"}],"license":"Apache-2.0","keywords":["hl7","parse","format"],"devDependencies":{"@babel/cli":"^7.5.5","@babel/core":"^7.5.5","@babel/preset-env":"^7.5.5","babel-preset-minify":"^0.5.1","minifier":"^0.8.1","rimraf":"^3.0.0","tap":"^10.1.0"},"gitHead":"11d111f16c26c263e36402af498df0a44687162e","_id":"hl7-standard@1.0.3","_nodeVersion":"12.18.4","_npmVersion":"6.14.6","dist":{"integrity":"sha512-WUiINNB8CWpP06OuPHoyAbiq2ZpKepYrlLFbTVquQWEmw72qwyft5bChjfkrHmM9ds0r95Oo7Ux7fDCzpUrh2A==","shasum":"4d77a1fc8e1b7504c8d98631dc82998be2afc90c","tarball":"https://registry.npmjs.org/hl7-standard/-/hl7-standard-1.0.3.tgz","fileCount":35,"unpackedSize":125297,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDJA/eSIzsKzJf7jCPjCsdhDALaO0r94M94qVUrK26BNQIhAPsSn5ZZjk/sUbvouDWB8CtzEtFAM7pmu/NXuWVYgyCS"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJie/nSACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp9KQ//WdB7LVCoTE++liHgpr5omL9GDLhJATyxF114DjsXbjCEnFRC\r\ntWkfsJrDl3xaChubwiq2Mbh+B2eIqhynYv/0eHhfdlnDHb2i/2OEnMq0kFUX\r\nwOrEc3WXf+4mKRNTjP8tNEIGN9Us3TvHa0Ob3ybdFUwhZMijbpgC03ikGIdJ\r\n6GunuDVADeXnEUpb4TGjKPbprhuNeFcJaHwUgMGqSV7XdLBcQjHrzQ5mfmyJ\r\n0db1vWgVamiMDmdk9um2lX/XDUQUNClt+R8EG1F5WWpxEqXSK4z/uAas6JqQ\r\ngnNZHrjKMMxp3X2mvHP7iWnbz94mZfr5qgGxm7PZblV+K6siR1FVyFoy2Nfk\r\n85vtSgNToOryyvAumvBTrW+OcPZAo4hv3IynEiUU5vG6P5me9QtA/RMbU/Hs\r\nQChTujLCzFZsctpDiCJmyW9zbww6XdT8IVX4UuohWeuODAU7J18ip8Jmlscf\r\n2Jedmo/vknjZO35kFaYHBfMu473s0wpveQkdl2As4Qt2tRYJYhti4ccTYnLv\r\ncqm28vNY3cfhHFMjRz6xfTcJEeieqTbqd+9HgqC1A77a8wUQxoKzSZOLVOKu\r\nBXnWkzIz384yMbrJuiDt+YD9lzJ8dWDyGelsjWxl7Z9yy+wzzrlKmUJBtfb9\r\nuNyH8qZosmd0zI/3eJBR/fLrpKrHxBZWwEU=\r\n=r7Hd\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"ironbridgecorp","email":"engineering@ironbridgecorp.com"},"directories":{},"maintainers":[{"name":"ironbridgecorp","email":"engineering@ironbridgecorp.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hl7-standard_1.0.3_1652292050159_0.32730994694616355"},"_hasShrinkwrap":false},"1.0.4":{"name":"hl7-standard","version":"1.0.4","description":"Simple, Lightweight HL7 module for tranforming, manipulating, or creating HL7 messages.","main":"index.js","scripts":{"test":"tap tests","build":"babel src/api.js --out-file builds/._.mirth.js; node bin/build.js;"},"author":{"name":"Jesse Reynolds","email":"jreynolds@ironbridgecorp.com"},"contributors":[{"name":"Jesse Reynolds","email":"jreynolds@ironbridgecorp.com"},{"name":"Adam Farabaugh","email":"afarabaugh@ironbridgecorp.com"}],"license":"Apache-2.0","keywords":["hl7","parse","format"],"devDependencies":{"@babel/cli":"^7.5.5","@babel/core":"^7.5.5","@babel/preset-env":"^7.5.5","babel-preset-minify":"^0.5.1","minifier":"^0.8.1","rimraf":"^3.0.0","tap":"^10.1.0"},"gitHead":"e303cc6068f614cf1742a0023a6695ba4a65ae5a","_id":"hl7-standard@1.0.4","_nodeVersion":"12.18.4","_npmVersion":"6.14.6","dist":{"integrity":"sha512-Dk8U0Q84HrQ5HCS3VXcay3ILrKOqQ1pprHHIxPaq/byi2zrTUwdP+tIv0sF+SI/l4bkET3EnN8yuGuQmOdHvuw==","shasum":"b5858814e18d3b3af71844ee68366ee7d52d8a30","tarball":"https://registry.npmjs.org/hl7-standard/-/hl7-standard-1.0.4.tgz","fileCount":35,"unpackedSize":125298,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCFDlYBmI39liEHZ6WPPff5u+GAN3tHLp7vpXSuoAC4LwIhAKSD2pgDtlk2SUckYGUT5gFWxn+5JyHEdjyRCVT3c3QX"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJie/tfACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrclA/+JUWV7i0AoQLn/m43M4cz7rcSoBg5BgErbI9gtN2yHF5BG1Xo\r\n04hMOAFQpyRq8NLxxIhwZjIF1cbn8X0X7X6Y1sgGkUrZ7Prx5ii3aB4huBt1\r\n0RUmfYIeaYvaDLKi1ZqbX5FpQ3ggY748WjMqBc+fOcP8A++o5CYjVGdf0fKm\r\n+rXo5ND5LVOXIZtw1/3zPHZRhvfBelxi6rVxdA56Kq8fRDOa6t9w8BRWP7cZ\r\nPzayWYIktUnqbpx+cdmEgzQ8tDPVmTbhuj58ULutFaFC+3ttIRkw1bpIDhqH\r\nRK4t9/Km9LnR0oxpWiPH6h9NaRWSxTkjfiKwOwPoOquneANeF/wVJSeZ3+Xm\r\nwxLXp07DqPaq+/oDrqj9ov+tSfXIbDiMdMEkWhDL8cmUeVQKMekJvfAriTsA\r\nG9tgt6m9hviMYaWc5pwrU8UseBsTaGVFvnz+/md6SQj7KQoGZf+J1s3OvGH6\r\n6CZeV6zqrSn0FUWFtu8pAP/Nv+KIdQrWcQcf9rcs8nhvNrEni16E9dUNVfhJ\r\nakTdU8SxFMA7SCBNaKP35cDQtEiAHdrV80Ct7SuaNrGUmQJeWGmMfmiNmY1X\r\nhnOH7ij+3AyUEL477wNvezeIUU0/fLP1ziyAgpvsbNKOyS3RbN/FPPLdQ8cs\r\n0B2iA0fQH+SrBy8P+CO+GM+vuBQ0dC0GMwY=\r\n=fOea\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"ironbridgecorp","email":"engineering@ironbridgecorp.com"},"directories":{},"maintainers":[{"name":"ironbridgecorp","email":"engineering@ironbridgecorp.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hl7-standard_1.0.4_1652292447577_0.2219147948357989"},"_hasShrinkwrap":false}},"time":{"created":"2019-10-01T18:00:48.977Z","1.0.0":"2019-10-01T18:00:49.094Z","modified":"2022-05-11T18:07:27.844Z","1.0.2":"2020-03-11T20:42:33.957Z","1.0.3":"2022-05-11T18:00:50.370Z","1.0.4":"2022-05-11T18:07:27.770Z"},"maintainers":[{"name":"ironbridgecorp","email":"engineering@ironbridgecorp.com"}],"description":"Simple, Lightweight HL7 module for tranforming, manipulating, or creating HL7 messages.","contributors":[{"name":"Jesse Reynolds","email":"jreynolds@ironbridgecorp.com"},{"name":"Adam Farabaugh","email":"afarabaugh@ironbridgecorp.com"}],"author":{"name":"Jesse Reynolds","email":"jreynolds@ironbridgecorp.com"},"license":"Apache-2.0","readme":"<h1 align=\"center\">\n  <br>\n  <a href=\"https://ironbridgecorp.com\"><img src=\"https://hl7-standard-images.s3.amazonaws.com/hl7-standard-logo-stamp.svg\" alt=\"HL7 Standard\" width=\"300\"></a>\n  <br>\n  hl7-standard\n  <br>\n</h1>\n\n*A simple, lightweight HL7 module for transforming, manipulating, or creating HL7 messages*\n\n## Description & Features\n\nHL7-Standard is a javascript based library that aims to make handling HL7 data simpler.  This lightweight library was written and open sourced by [Iron Bridge](https://www.ironbridgecorp.com/), a healthcare technology company. HL7-Standard is able to be used as a stand-alone js scripting module or dropped into an application like mirth to aid in difficult transformations.\n\n- [Mirth Compatibility](#mirth-usage)\n\n---\n\n## Usage\n\n### Install\n\nTo install 'hl7-standard' for use in node via `require('hl7-standard')`, run:\n\n```bash\nnpm install hl7-standard\n```\n\n## Support\n\nWe wish to collaborate with like-minded individuals in the healthcare ecosystem who share our vision and goal. Please join us on our ['hl7-standard' gitter.im channel](https://gitter.im/hl7-standard/community).\n\n## API Methods\n\nHL7-Standard enables users to quickly manipulate HL7 data using JSON. It consists of the following methods:\n\n- [transform](#transform)\n- [build](#build)\n- [get](#get)\n- [getSegment](#getsegment)\n- [getSegments](#getsegments)\n- [getSegmentsAfter](#getsegmentsafter)\n- [set](#set)\n- [createSegment](#createsegment)\n- [createSegmentAfter](#createsegmentafter)\n- [createSegmentBefore](#createsegmentbefore)\n- [deleteSegment](#deletesegment)\n- [deleteSegments](#deletesegments)\n- [moveSegmentAfter](#movesegmentafter)\n- [moveSegmentBefore](#movesegmentbefore)\n\n### parseOptions\n\nSet up a custom line ending (ie. \\n) for your build method.\n\n```js\nlet hl7 = new HL7(data, { lineEndings: '\\n' });\nconsole.log(hl7.build());\n```\n\n### transform\n\nTransforms raw HL7 data to 'hl7-standard' constructor format for message manipulation\n\n| Parameter | Type | Description |\n| :--- | :--- | :--- |\n| `callback` | `Function` | Optional. callback function used to control transformation errors, if not used, a try/catch is recommended |\n| `batch` | `Boolean` | Optional. boolean specifying if message should be treated as a batch message |\n\n```js\n\nlet hl7 = new HL7(rawData);\nhl7.transform(err => {\n  if (err) throw err;\n  // code here\n});\n\n// callback optional\ntry {\n let hl7 = new HL7(rawData);\n hl7.transform();\n // code here\n} catch (e) {\n  console.error(e);\n}\n\n```\n\n### build\n\nBuilds a new HL7 message from transformed data\n\n```js\n\nconst finalizedHL7 = hl7.build(); // MSH|^~\\&|Example|General Hospital|ADT||20070510092626|411|ADT^A01|24553|P|2.4|||....\nfs.writeFileSync(`${__dirname}/data/hl7_message_${uuid}.hl7`, finalizedHL7, 'utf8');\n\n```\n\n### get\n\nGets a value from a transformed segment returning an array, object, or string\n\n| Parameter | Type | Description |\n| :--- | :--- | :--- |\n| `field` | `String` | **Required**. name of field being requested using dot notation |\n| `index` | `Number` | Optional. index of segment relative to other segments of same type |\n| `sectionIndex` | `Number` | Optional. index of section within segment being requested |\n| `subSectionIndex` | `Number` | Optional. index of value in repeating section and field |\n\n```js\n\nlet familyName = hl7.get('PID.5.1'); //Reynolds\n\nlet patientLanguage = hl7.get('PID.15'); // { 'PID.15.1':'en', 'PID.15.2':'English' }\n\n```\n\n### getSegment\n\nGets a single segment constructor, if multiple exist, it will return the first one\n\n| Parameter | Type | Description |\n| :--- | :--- | :--- |\n| `segment` | `String` | **Required**. name of segment, must be 3 char |\n\n```js\n\nlet pidSegment = hl7.getSegment('PID');\npidSegment.get('PID.3.1'); //123456\n\n```\n\n### getSegments\n\nGets all segment constructors by segment type, if no segment is specified, method will return all segments in the message\n\n| Parameter | Type | Description |\n| :--- | :--- | :--- |\n| `segment` | `String` | Optional. name of segment, must be 3 char, if empty, method will return all segments |\n\n```js\nconst children = hl7.getSegments();\nfor (let i = 0; i < children.length; i++) {\n  if (children[i].type === 'NTE') {\n    // loop through every segment in the HL7 message and check for segment type\n  }\n}\n\nfor (let nte of hl7.getSegments('NTE')) {\n  // loop through only the NTE segments using getSegments\n}\n\n```\n\n### getSegmentsAfter\n\nReturns all requested 'Segment' constructors at occur in the HL7 message after a specified start point\n\n| Parameter | Type | Description |\n| :--- | :--- | :--- |\n| `start` | `Object` | **Required**. 'Segment' constructor that marks the starting point for the retrieval of segments |\n| `name` | `String` | **Required**. name of segment that you wish to retrieve, must be 3 char |\n| `consecutive` | `Boolean` | Optional. boolean telling the method to only grab segments that are consecutive or back to back in the HL7 message |\n| `stop` | `String or Array` | Optional. segment name or list of segment names that would trigger the method to stop collecting matching segments |\n\n```js\n\nfor (let obr of hl7.getSegment('OBR')) {\n  if (obr.get('OBR.4.1') === '1234x') {\n    let nteGroup = hl7.getSegmentsAfter(obr, 'NTE', false, ['ORC', 'OBR']);\n    // nteGroup contains all NTE segments after the OBR segment and before the next OBR or ORC segment\n  }\n}\n\n```\n\n### set\n\nSets a value on a transformed segment\n\n| Parameter | Type | Description |\n| :--- | :--- | :--- |\n| `field` | `String` | **Required**. name of field being set using the dot notation |\n| `value` | `String` | **Required**. value being set on field |\n| `index` | `Number` | Optional. index of segment relative to other segments of same type |\n| `sectionIndex` | `Number` | Optional. index of section within segment being set |\n| `subSectionIndex` | `Number` | Optional. index of value in repeating section and field |\n\n```js\n\nhl7.set('PID.5.1', 'Reynolds');\n\nhl7.set('PID.15', { 'PID.15.1':'en', 'PID.15.2':'English' });\n\nhl7.set('PID.11', [{\n  'PID.11.1': '123 Example Rd',\n  'PID.11.2': '',\n  'PID.11.3': 'Pittsburgh',\n  'PID.11.4': 'PA',\n  'PID.11.4': '15226',\n  'PID.11.5': 'USA'\n}, {\n  'PID.11.1': '321 Sample St',\n  'PID.11.2': '',\n  'PID.11.3': 'Pittsburgh',\n  'PID.11.4': 'PA',\n  'PID.11.4': '15317',\n  'PID.11.5': 'USA'\n}]);\n\n```\n\n### createSegment\n\nCreates a single segment at the end of the hl7 message\n\n| Parameter | Type | Description |\n| :--- | :--- | :--- |\n| `segment` | `String` | **Required**. name of segment being created, must be 3 char |\n\n```js\n\nlet hl7 = new HL7();\nhl7.createSegment('MSH');\nhl7.set('MSH', {\n  'MSH.2': '^~\\\\&',\n  'MSH.3': 'Example',\n  'MSH.4': '123456',\n  'MSH.5': '',\n  'MSH.6': '',\n  'MSH.7': timestamp,\n  'MSH.8': '',\n  'MSH.9': {\n    'MSH.9.1': 'ADT',\n    'MSH.9.2': 'A08'\n  },\n  'MSH.10': '',\n  'MSH.11': 'T',\n  'MSH.12': '2.3'\n});\n\n```\n\n### createSegmentAfter\n\nCreates a single segment after an already existing, specified segment\n\n| Parameter | Type | Description |\n| :--- | :--- | :--- |\n| `segment` | `String` | **Required**. name of segment being created, must be 3 char |\n| `afterSegment` | `Object` | **Required**. 'Segment' constructor of existing segment which the new segment will be positioned after |\n\n```js\n\nlet pv1Segment = hl7.createSegmentAfter('PV1', hl7.getSegment('PID'));\npv1Segment.set(...);\n\n```\n\n### createSegmentBefore\n\nCreates a single segment before an already existing, specified segment\n\n| Parameter | Type | Description |\n| :--- | :--- | :--- |\n| `segment` | `String` | **Required**. name of segment being created, must be 3 char |\n| `beforeSegment` | `Object` | **Required**. 'Segment' constructor of existing segment which the new segment will be positioned before |\n\n```js\n\nlet evnSegment = hl7.createSegmentAfter('EVN', hl7.getSegment('PID'));\nevnSegment.set(...);\n\n```\n\n### deleteSegment\n\nDeletes a single segment from the HL7 message\n\n| Parameter | Type | Description |\n| :--- | :--- | :--- |\n| `segment` | `Object` | **Required**. 'Segment' constructor to be deleted |\n\n```js\n\nfor (let segment of hl7.getSegments()) {\n  if (segment.type === 'ZIB') hl7.deleteSegment(segment);\n}\n\n```\n\n### deleteSegments\n\nDeletes multiple segments from the HL7 message\n\n| Parameter | Type | Description |\n| :--- | :--- | :--- |\n| `segment` | `Array` | **Required**. list of 'Segment' constructors to be deleted |\n\n```js\n\n// conditionally delete a block of NTE segments from a message\nfor (let obr of hl7.getSegments('OBR')) {\n  if (obr.get('OBR.4.1') === '681X') {\n    let nteGroup = hl7.getSegmentsAfter(obr, 'NTE', true, 'OBR');\n    hl7.deleteSegments(nteGroup);\n  }\n}\n\n//delete all NTE segments from message\nhl7.deleteSegments(hl7.getSegments('NTE'))\n  \n```\n\n### moveSegmentAfter\n\nMoves existing segment after another existing segment\n\n| Parameter | Type | Description |\n| :--- | :--- | :--- |\n| `segment` | `Object` | **Required**. 'Segment' constructor that is being moved |\n| `afterSegment` | `Object` | **Required**. 'Segment' constructor that marks where the segment is being moved after |\n\n```js\n\nlet hl7 = new HL7(...);\nlet evnSegment = hl7.createSegment('EVN');\nevnSegment.set('EVN.1.1', 'A08');\nhl7.moveSegmentAfter(evnSegment, hl7.getSegment('MSH'));\n\n```\n\n### moveSegmentBefore\n\nMoves existing segment before another existing segment\n\n| Parameter | Type | Description |\n| :--- | :--- | :--- |\n| `segment` | `Object` | **Required**. 'Segment' constructor that is being moved |\n| `beforeSegment` | `Object` | **Required**. 'Segment' constructor that marks where the segment is being moved before |\n\n```js\n\nlet hl7 = new HL7(...);\nlet evnSegment = hl7.createSegment('EVN');\nevnSegment.set('EVN.1.1', 'A08');\nhl7.moveSegmentBefore(evnSegment, hl7.getSegment('PID'));\n\n```\n---\n\n## Mirth Usage\n\nAdding 'hl7-standard' to Mirth opens up more possibilities for data tranformations. This 20KB library can make some of the advanced mirth transformations much simplier and can aid in readability and ease of use. Can you get by in Mirth without using 'hl7-standard', absolutely; however, we find this library to be very intuitive and easier for a novice to pick up and run with.\n\n### Configuring 'hl7-standard' in Mirth\n\nTo use the library in mirth, you will need to copy the `mirth.min.js` file out of the `builds/` directory and import it into your mirth code templates. On newer versions of mirth make sure you give the template the context of source connector and destination connector and make sure the 'Library' that houses the code template is set to add the lib to any new channel. Alternatively, you can control what channels have access to the library individually using the code template options.\n\n### Setting the Data Types to Raw on a Mirth Channel\n\nThere are many ways to incorporate 'hl7-standard' into your channels workflow, but the simplest method would be to set the source data type to `raw` allowing the raw `msg` to be a string.  Channel inbound and outbound data type settings can be found under the `Summary` tab of your Mirth channel. \n\n*This is not a requirement and many implementations involve the default hl7v2 datatypes for inbound and outbound. An example of this can be seen [here](#hl7v2datatype).*\n\n<img src=\"https://hl7-standard-images.s3.amazonaws.com/channel-datatypes.png\" alt=\"HL7 Standard\" width=\"800\">\n\n### Setting the Dependencies on a Channel\n\nIf you set the code template options to auto-set the channel dependencies you can skip this step, but you can always check the channel dependencies to ensure the library is accessible by your channel. Channel dependencies can be found under the `Summary` tab of your Mirth channel.\n\n<img src=\"https://hl7-standard-images.s3.amazonaws.com/channel-dependencies.png\" alt=\"HL7 Standard\" width=\"400\">\n\n### Example Mirth Transformers Using 'hl7-standard'\n\nThere are many ways to transform HL7 data with 'hl7-standard'. Below is a sample destination transformer with a HL7 transformation that involves conditionally deleting unwanted NTE segments.\n\n<img src=\"https://hl7-standard-images.s3.amazonaws.com/example-transformation-raw-datatypes.png\" alt=\"HL7 Standard\" width=\"800\">\n\nIf you want to incorporate 'hl7-standard' into a Mirth channel that is already established, using the typical channel datatypes of HL7v2, you can do that by serializing the message from XML to HL7. Below is a high-level example of a Destination Transformer that combines the built in Mirth functionality with 'hl7-standard'.\n\n<img src=\"https://hl7-standard-images.s3.amazonaws.com/example-transformation-hl7v2-datatypes.png\" alt=\"HL7 Standard\" width=\"800\" id=\"hl7v2datatype\">\n\nMore examples like this can be found in the `examples/` directory and on the Iron Bridge Developer Site. \n\n### Example Preprocessor Using 'hl7-standard'\n\nA common use case for utilizing 'hl7-standard' in mirth outside of channel transformations is evaluating an incoming message within the preprocessor. Sometimes, interface feeds receive unwanted messages that are not HL7 and they tend to cause errors and issues in the interface workflow. By adding 'hl7-standard', we can evaluate the message in the pre-processor, prior to the message being parsed by mirth.\n\n<img src=\"https://hl7-standard-images.s3.amazonaws.com/preprocessor-flagging.png\" alt=\"HL7 Standard\" width=\"800\">\n\n---\n\n## LICENSE\n\nCopyright 2019 Iron Bridge Corp.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n","readmeFilename":"README.md","keywords":["hl7","parse","format"]}