Skip to content

Commit 39b0a6d

Browse files
authored
Merge pull request #190 from mcode/multiple-conditions-whitespace
Trimming whitespace and handling empty values for additional condition codes
2 parents 8d7c3eb + 25b28e5 commit 39b0a6d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/extractors/CSVConditionExtractor.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,16 @@ function formatData(conditionData, patientId) {
2727
if (!(conditionId && codeSystem && code && category)) {
2828
throw new Error('The condition is missing an expected attribute. Condition id, code system, code, and category are all required.');
2929
}
30+
const codes = code.split('|').map((c) => c.trim()).filter((c) => c && c !== '');
31+
if (codes.length < code.split('|').length) {
32+
logger.warn('Delimiter (|) used to indicate multiple condition codes but no additional code provided');
33+
}
3034
return {
3135
id: conditionId,
3236
subject: {
3337
id: patientId,
3438
},
35-
code: code.split('|').map((c) => ({
39+
code: codes.map((c) => ({
3640
code: c,
3741
system: codeSystem,
3842
display: displayName,

0 commit comments

Comments
 (0)