console.clear();
/**
* example of parsing icd10 codes from multiple fields. Also each field can contain multiple codes
*/
//a ==> is a field that can contain diag codes
//b ===> is a field that can contain symptom codes
const examples = [{
description : 'one field containing several entries',
a: `{ICD10}I47.0 Paroxysmal V-tach, I44.0 AV block, 1st degree, I47.2 Ventricular tachycardia,I47.9 Paroxysmal tachycardia, unsp., I48.3 Typical atrial flutter, I48.4 Atypical atrial flutter`,
b: ``
},
{
description : 'one field basic',
a: `{ICD10}I47.0 Paroxysmal V-tach`,
b: ''
},
//G code
{
description : 'one field basic',
a: `{ICD10}G45.9 Transient cerebral ischemic attack`,
b: ''
},
//code that is a bit longer
{
description : 'code with a 2-digit suffix',
a: `{ICD10}I45.89 Some description here`,
b: ''
},
//code with no decimal
{
description : 'code without a suffix',
a: `{ICD10}R42 a code to use`,
b: ''
},
{//5
description : 'both fields with codes',
a: `{ICD10}R42 a code to use`,
b: `{ICD10}G45.9 Transient cerebral ischemic attack`
}
];
let loader;
const rgx = {
icd10: /^{ICD10}/,
// embeddedCodes: /(\b[RIG]\d\d(?:[.]\d+)*\b)/g
//ref: https://www.johndcook.com/blog/2019/05/05/regex_icd_codes/
embeddedCodes: /(\b[A-TV-Z][0-9][0-9AB](?:[.][0-9A-TV-Z]{0,4})*\b)/g
}
//let codeField = examples[0];
examples.reduce((output, ex, i) => {
let {
a,
b,
description
} = ex;
let codes=[], descriptions=[], map;
console.log('_'.padEnd(80,'_'))
console.log(`iteration : examples[${i}]`,`${ex.description}`);
[a, b].reduce((sources, source, j) => {
let _codes, _descriptions;
//convert the diagnosis code into it's parts
let codeField;
//valid codes begin with a pattern
if (!rgx.icd10.test(source))
return;
else
//remove the IDC10 to continue working with the string
codeField =...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.