Skip to content

Commit 8cc76be

Browse files
authored
Merge pull request #188 from mcode/multiple-condition-codes
Modifying conditions to allow multiple codes
2 parents 1bd1c18 + 3739e75 commit 8cc76be

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

src/extractors/CSVConditionExtractor.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ function formatData(conditionData, patientId) {
3232
subject: {
3333
id: patientId,
3434
},
35-
code: {
36-
code,
35+
code: code.split('|').map((c) => ({
36+
code: c,
3737
system: codeSystem,
3838
display: displayName,
39-
},
39+
})),
4040
category: category.split('|'),
4141
dateOfDiagnosis: !dateOfDiagnosis ? null : formatDateTime(dateOfDiagnosis),
4242
clinicalStatus,

src/templates/ConditionTemplate.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ function categoryArrayTemplate(array) {
4848
function codingTemplate({ code }) {
4949
return {
5050
code: {
51-
coding: [coding(code),
52-
],
51+
coding: code.map((c) => coding(c)),
5352
},
5453
};
5554
}
@@ -100,7 +99,7 @@ function subjectTemplate({ subject }) {
10099
function conditionTemplate({
101100
subject, id, code, category, dateOfDiagnosis, clinicalStatus, verificationStatus, bodySite, laterality, histology,
102101
}) {
103-
if (!(id && subject && code.system && code.code && category)) {
102+
if (!(id && subject && code.every((c) => c.system && c.code) && category)) {
104103
throw Error('Trying to render a ConditionTemplate, but a required argument is missing; ensure that id, mrn, code, codesystem, and category are all present');
105104
}
106105

test/templates/condition.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ const CONDITION_VALID_DATA = {
99
subject: {
1010
id: 'example-subject-id',
1111
},
12-
code: {
12+
code: [{
1313
system: 'example-system',
1414
code: 'example-code',
1515
display: 'exampleDisplayName',
16-
},
16+
}],
1717
category: [
1818
'example-code',
1919
],
@@ -33,10 +33,10 @@ const CONDITION_MINIMAL_DATA = {
3333
subject: {
3434
id: 'example-subject-id',
3535
},
36-
code: {
36+
code: [{
3737
system: 'example-system',
3838
code: 'example-code',
39-
},
39+
}],
4040
category: [
4141
'example-code',
4242
],
@@ -97,11 +97,11 @@ describe('test Condition template', () => {
9797
subject: {
9898
id: 'example-subject-id',
9999
},
100-
code: {
100+
code: [{
101101
system: 'example-system',
102102
code: 'example-code',
103103
display: 'exampleDisplayName',
104-
},
104+
}],
105105
category: [
106106
'example-code',
107107
],

0 commit comments

Comments
 (0)