fhir-react 0.3.6 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/index.js +7 -7
- package/build/style.css +2 -1
- package/package.json +1 -1
- package/src/assets/containers/Coverage/coverage.svg +4 -0
- package/src/assets/containers/Medication/medication.svg +5 -0
- package/src/assets/containers/Organization/organization.svg +5 -0
- package/src/components/datatypes/Attachment/Attachment.css +5 -0
- package/src/components/datatypes/Attachment/Attachment.js +7 -2
- package/src/components/datatypes/Identifier/Identifier.js +7 -3
- package/src/components/datatypes/Reference/Reference.js +5 -1
- package/src/components/resources/Claim/CareTeam.js +55 -0
- package/src/components/resources/Claim/Claim.css +2 -11
- package/src/components/resources/Claim/Claim.js +157 -309
- package/src/components/resources/Claim/Claim.stories.js +37 -5
- package/src/components/resources/Claim/Claim.test.js +72 -0
- package/src/components/resources/Claim/Diagnosis.js +61 -0
- package/src/components/resources/Claim/Insurance.js +58 -0
- package/src/components/resources/Claim/Item.js +79 -0
- package/src/components/resources/Claim/Items.js +29 -0
- package/src/components/resources/Coverage/Coverage.js +96 -69
- package/src/components/resources/Coverage/Coverage.stories.js +31 -5
- package/src/components/resources/Coverage/Coverage.test.js +75 -3
- package/src/components/resources/Medication/Medication.js +90 -51
- package/src/components/resources/Medication/Medication.stories.js +37 -7
- package/src/components/resources/Medication/Medication.test.js +78 -4
- package/src/components/resources/Organization/Organization.js +55 -37
- package/src/components/resources/Organization/Organization.stories.js +15 -2
- package/src/components/resources/Organization/Organization.test.js +73 -0
- package/src/components/ui/index.js +11 -4
- package/src/fixtures/example-icons.jsx +21 -0
|
@@ -14,18 +14,18 @@ import './Claim.css';
|
|
|
14
14
|
import {
|
|
15
15
|
Root,
|
|
16
16
|
Header,
|
|
17
|
-
Title,
|
|
18
17
|
Badge,
|
|
19
|
-
BadgeSecondary,
|
|
20
18
|
Body,
|
|
21
19
|
MissingValue,
|
|
22
20
|
Value,
|
|
23
21
|
ValueSection,
|
|
24
|
-
|
|
25
|
-
TableCell,
|
|
26
|
-
TableHeader,
|
|
27
|
-
TableRow,
|
|
22
|
+
ValueSectionItem,
|
|
28
23
|
} from '../../ui';
|
|
24
|
+
import Accordion from '../../containers/Accordion';
|
|
25
|
+
import CareTeam from './CareTeam';
|
|
26
|
+
import Diagnosis from './Diagnosis';
|
|
27
|
+
import Insurance from './Insurance';
|
|
28
|
+
import Items from './Items';
|
|
29
29
|
|
|
30
30
|
const commonDTO = fhirResource => {
|
|
31
31
|
const id = _get(fhirResource, 'id');
|
|
@@ -298,215 +298,7 @@ const resourceDTO = (fhirVersion, fhirResource) => {
|
|
|
298
298
|
}
|
|
299
299
|
};
|
|
300
300
|
|
|
301
|
-
const
|
|
302
|
-
const { careTeam } = props;
|
|
303
|
-
|
|
304
|
-
return (
|
|
305
|
-
<ValueSection label="Care Team" data-testid="careTeam">
|
|
306
|
-
<Table>
|
|
307
|
-
<thead>
|
|
308
|
-
<TableRow>
|
|
309
|
-
<TableHeader>Provider</TableHeader>
|
|
310
|
-
<TableHeader>Role</TableHeader>
|
|
311
|
-
<TableHeader>Qualification</TableHeader>
|
|
312
|
-
</TableRow>
|
|
313
|
-
</thead>
|
|
314
|
-
<tbody>
|
|
315
|
-
{careTeam.map((member, idx) => (
|
|
316
|
-
<TableRow key={idx}>
|
|
317
|
-
<TableCell data-testid="careTeam.provider">
|
|
318
|
-
<Reference fhirData={member.provider} />
|
|
319
|
-
</TableCell>
|
|
320
|
-
<TableCell data-testid="careTeam.role">
|
|
321
|
-
{member.role ? (
|
|
322
|
-
<Coding fhirData={member.role} />
|
|
323
|
-
) : (
|
|
324
|
-
<MissingValue />
|
|
325
|
-
)}
|
|
326
|
-
</TableCell>
|
|
327
|
-
<TableCell data-testid="careTeam.qualification">
|
|
328
|
-
{careTeam.qualification ? (
|
|
329
|
-
<Coding fhirData={member.qualification} />
|
|
330
|
-
) : (
|
|
331
|
-
<MissingValue />
|
|
332
|
-
)}
|
|
333
|
-
</TableCell>
|
|
334
|
-
</TableRow>
|
|
335
|
-
))}
|
|
336
|
-
</tbody>
|
|
337
|
-
</Table>
|
|
338
|
-
</ValueSection>
|
|
339
|
-
);
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
const Diagnosis = props => {
|
|
343
|
-
const { diagnosis } = props;
|
|
344
|
-
|
|
345
|
-
return (
|
|
346
|
-
<ValueSection label="Diagnosis" data-testid="diagnosis">
|
|
347
|
-
<Table>
|
|
348
|
-
<thead>
|
|
349
|
-
<TableRow>
|
|
350
|
-
<TableHeader>Diagnosis</TableHeader>
|
|
351
|
-
<TableHeader>Type</TableHeader>
|
|
352
|
-
<TableHeader>Package code</TableHeader>
|
|
353
|
-
</TableRow>
|
|
354
|
-
</thead>
|
|
355
|
-
<tbody>
|
|
356
|
-
{diagnosis.map((diagnosis, idx) => (
|
|
357
|
-
<TableRow key={idx}>
|
|
358
|
-
<TableCell data-testid="diagnosis.diagnosis">
|
|
359
|
-
{diagnosis.coding ? (
|
|
360
|
-
<Coding fhirData={diagnosis.coding} />
|
|
361
|
-
) : diagnosis.refrence ? (
|
|
362
|
-
<Reference fhirData={diagnosis.reference} />
|
|
363
|
-
) : (
|
|
364
|
-
<MissingValue />
|
|
365
|
-
)}
|
|
366
|
-
</TableCell>
|
|
367
|
-
<TableCell data-testid="diagnosis.type">
|
|
368
|
-
{diagnosis.typeCoding ? (
|
|
369
|
-
<Coding fhirData={diagnosis.typeCoding} />
|
|
370
|
-
) : (
|
|
371
|
-
<MissingValue />
|
|
372
|
-
)}
|
|
373
|
-
</TableCell>
|
|
374
|
-
<TableCell data-testid="diagnosis.packageCode">
|
|
375
|
-
{diagnosis.packageCodeCoding ? (
|
|
376
|
-
<Coding fhirData={diagnosis.packageCodeCoding} />
|
|
377
|
-
) : (
|
|
378
|
-
<MissingValue />
|
|
379
|
-
)}
|
|
380
|
-
</TableCell>
|
|
381
|
-
</TableRow>
|
|
382
|
-
))}
|
|
383
|
-
</tbody>
|
|
384
|
-
</Table>
|
|
385
|
-
</ValueSection>
|
|
386
|
-
);
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
const Insurance = props => {
|
|
390
|
-
const { insurance } = props;
|
|
391
|
-
|
|
392
|
-
return (
|
|
393
|
-
<ValueSection label="Insurance" data-testid="insurance">
|
|
394
|
-
<Table>
|
|
395
|
-
<thead>
|
|
396
|
-
<TableRow>
|
|
397
|
-
<TableHeader>Coverage</TableHeader>
|
|
398
|
-
<TableHeader>Business Arrangement</TableHeader>
|
|
399
|
-
<TableHeader>Claim Response</TableHeader>
|
|
400
|
-
</TableRow>
|
|
401
|
-
</thead>
|
|
402
|
-
<tbody>
|
|
403
|
-
{insurance.map((insurance, idx) => (
|
|
404
|
-
<TableRow key={idx}>
|
|
405
|
-
<TableCell data-testid="insurance.coverage">
|
|
406
|
-
<Reference fhirData={insurance.coverage} />
|
|
407
|
-
{insurance.focal && ' (focal)'}
|
|
408
|
-
</TableCell>
|
|
409
|
-
<TableCell data-testid="insurance.businessArrangement">
|
|
410
|
-
{insurance.businessArrangement ? (
|
|
411
|
-
insurance.businessArrangement
|
|
412
|
-
) : (
|
|
413
|
-
<MissingValue />
|
|
414
|
-
)}
|
|
415
|
-
</TableCell>
|
|
416
|
-
<TableCell data-testid="insurance.claimResponse">
|
|
417
|
-
{insurance.claimResponse ? (
|
|
418
|
-
<Reference fhirData={insurance.claimResponse} />
|
|
419
|
-
) : (
|
|
420
|
-
<MissingValue />
|
|
421
|
-
)}
|
|
422
|
-
</TableCell>
|
|
423
|
-
</TableRow>
|
|
424
|
-
))}
|
|
425
|
-
</tbody>
|
|
426
|
-
</Table>
|
|
427
|
-
</ValueSection>
|
|
428
|
-
);
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
const Item = props => {
|
|
432
|
-
const { item, parentSequences, level } = props;
|
|
433
|
-
|
|
434
|
-
const fill = Array(level)
|
|
435
|
-
.fill(null)
|
|
436
|
-
.map((_, idx) => (
|
|
437
|
-
<div key={idx} className="fhir-resource__Claim__item-level-fill"></div>
|
|
438
|
-
));
|
|
439
|
-
|
|
440
|
-
const itemSequences = [...parentSequences, item.sequence];
|
|
441
|
-
const id = itemSequences.join('.');
|
|
442
|
-
|
|
443
|
-
return (
|
|
444
|
-
<>
|
|
445
|
-
<TableRow>
|
|
446
|
-
<TableCell data-testid="items.level">
|
|
447
|
-
<div className="fhir-resource__Claim__item-level">{fill}</div>
|
|
448
|
-
</TableCell>
|
|
449
|
-
<TableCell data-testid="items.sequence">{id}</TableCell>
|
|
450
|
-
<TableCell data-testid="items.service">
|
|
451
|
-
<Coding fhirData={item.service} />
|
|
452
|
-
</TableCell>
|
|
453
|
-
<TableCell data-testid="items.unitPrice">
|
|
454
|
-
{item.unitPrice ? (
|
|
455
|
-
<Money fhirData={item.unitPrice} />
|
|
456
|
-
) : (
|
|
457
|
-
<MissingValue />
|
|
458
|
-
)}
|
|
459
|
-
{item.factor != null ? (
|
|
460
|
-
<span> × {item.factor}</span>
|
|
461
|
-
) : null}
|
|
462
|
-
</TableCell>
|
|
463
|
-
<TableCell data-testid="items.quantity">
|
|
464
|
-
{item.quantity != null ? item.quantity : <MissingValue />}
|
|
465
|
-
</TableCell>
|
|
466
|
-
<TableCell data-testid="items.net">
|
|
467
|
-
{item.net ? <Money fhirData={item.net} /> : <MissingValue />}
|
|
468
|
-
</TableCell>
|
|
469
|
-
</TableRow>
|
|
470
|
-
{item.subItems.map((subItem, idx) => (
|
|
471
|
-
<Item
|
|
472
|
-
key={idx}
|
|
473
|
-
item={subItem}
|
|
474
|
-
level={level + 1}
|
|
475
|
-
parentSequences={itemSequences}
|
|
476
|
-
/>
|
|
477
|
-
))}
|
|
478
|
-
</>
|
|
479
|
-
);
|
|
480
|
-
};
|
|
481
|
-
|
|
482
|
-
const Items = props => {
|
|
483
|
-
const { items } = props;
|
|
484
|
-
|
|
485
|
-
return (
|
|
486
|
-
<ValueSection label="Items" data-testid="items">
|
|
487
|
-
<Table>
|
|
488
|
-
<thead>
|
|
489
|
-
<TableRow>
|
|
490
|
-
<TableHeader />
|
|
491
|
-
<TableHeader>ID</TableHeader>
|
|
492
|
-
<TableHeader expand>Service</TableHeader>
|
|
493
|
-
<TableHeader>Unit price</TableHeader>
|
|
494
|
-
<TableHeader>Quantity</TableHeader>
|
|
495
|
-
<TableHeader>Total</TableHeader>
|
|
496
|
-
</TableRow>
|
|
497
|
-
</thead>
|
|
498
|
-
<tbody>
|
|
499
|
-
{items.map((item, idx) => (
|
|
500
|
-
<Item key={idx} item={item} level={0} parentSequences={[]} />
|
|
501
|
-
))}
|
|
502
|
-
</tbody>
|
|
503
|
-
</Table>
|
|
504
|
-
</ValueSection>
|
|
505
|
-
);
|
|
506
|
-
};
|
|
507
|
-
|
|
508
|
-
const Claim = props => {
|
|
509
|
-
const { fhirResource, fhirVersion } = props;
|
|
301
|
+
const Claim = ({ fhirResource, fhirVersion, fhirIcons }) => {
|
|
510
302
|
let fhirResourceData = {};
|
|
511
303
|
try {
|
|
512
304
|
fhirResourceData = resourceDTO(fhirVersion, fhirResource);
|
|
@@ -537,103 +329,159 @@ const Claim = props => {
|
|
|
537
329
|
const hasDiagnosis = diagnosis.length > 0;
|
|
538
330
|
const hasInsurance = insurance.length > 0;
|
|
539
331
|
|
|
332
|
+
const tableData1 = [
|
|
333
|
+
{
|
|
334
|
+
label: 'Type',
|
|
335
|
+
testId: 'type',
|
|
336
|
+
data: <Coding fhirData={typeCoding} />,
|
|
337
|
+
status: true,
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
label: 'Created at',
|
|
341
|
+
testId: 'created',
|
|
342
|
+
data: created && <DateType fhirData={created} />,
|
|
343
|
+
status: created,
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
label: 'Accident',
|
|
347
|
+
testId: 'accident',
|
|
348
|
+
data: accident && (
|
|
349
|
+
<>
|
|
350
|
+
{accident.date && (
|
|
351
|
+
<Value label="Date" data-testid="accident.date">
|
|
352
|
+
<DateType fhirData={accident.date} />
|
|
353
|
+
</Value>
|
|
354
|
+
)}
|
|
355
|
+
{accident.coding && (
|
|
356
|
+
<Value label="Type" data-testid="accident.type">
|
|
357
|
+
<Coding fhirData={accident.coding} />
|
|
358
|
+
</Value>
|
|
359
|
+
)}
|
|
360
|
+
</>
|
|
361
|
+
),
|
|
362
|
+
status: accident,
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
label: 'Employment impacted',
|
|
366
|
+
testId: 'employmentImpacted',
|
|
367
|
+
data: employmentImpacted && (
|
|
368
|
+
<>
|
|
369
|
+
{employmentImpacted.start ? (
|
|
370
|
+
<DateType fhirData={employmentImpacted.start} />
|
|
371
|
+
) : (
|
|
372
|
+
<MissingValue />
|
|
373
|
+
)}
|
|
374
|
+
{' - '}
|
|
375
|
+
{employmentImpacted.end ? (
|
|
376
|
+
<DateType fhirData={employmentImpacted.end} />
|
|
377
|
+
) : (
|
|
378
|
+
<MissingValue />
|
|
379
|
+
)}
|
|
380
|
+
</>
|
|
381
|
+
),
|
|
382
|
+
status: employmentImpacted,
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
label: 'Hospitalization',
|
|
386
|
+
testId: 'hospitalization',
|
|
387
|
+
data: hospitalization && (
|
|
388
|
+
<>
|
|
389
|
+
{hospitalization.start ? (
|
|
390
|
+
<DateType fhirData={hospitalization.start} />
|
|
391
|
+
) : (
|
|
392
|
+
<MissingValue />
|
|
393
|
+
)}
|
|
394
|
+
{' - '}
|
|
395
|
+
{hospitalization.end ? (
|
|
396
|
+
<DateType fhirData={hospitalization.end} />
|
|
397
|
+
) : (
|
|
398
|
+
<MissingValue />
|
|
399
|
+
)}
|
|
400
|
+
</>
|
|
401
|
+
),
|
|
402
|
+
status: hospitalization,
|
|
403
|
+
},
|
|
404
|
+
];
|
|
405
|
+
|
|
406
|
+
const tableData2 = [
|
|
407
|
+
{
|
|
408
|
+
label: 'Insurer',
|
|
409
|
+
testId: 'insurer',
|
|
410
|
+
data: insurer && <Reference fhirData={insurer} />,
|
|
411
|
+
status: insurer,
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
label: 'Organization',
|
|
415
|
+
testId: 'organization',
|
|
416
|
+
data: organization && <Reference fhirData={organization} />,
|
|
417
|
+
status: organization,
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
label: 'Payee',
|
|
421
|
+
testId: 'payee.type',
|
|
422
|
+
data: payee.coding && <Coding fhirData={payee.coding} />,
|
|
423
|
+
status: payee.coding,
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
label: 'Payee party',
|
|
427
|
+
testId: 'payee.party',
|
|
428
|
+
data: payee.party && <Reference fhirData={payee.party} />,
|
|
429
|
+
status: payee.party,
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
label: 'Priority',
|
|
433
|
+
testId: 'priority',
|
|
434
|
+
data: priorityCoding && <Coding fhirData={priorityCoding} />,
|
|
435
|
+
status: priorityCoding,
|
|
436
|
+
},
|
|
437
|
+
];
|
|
438
|
+
|
|
540
439
|
return (
|
|
541
440
|
<Root name="Claim">
|
|
542
|
-
<
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
{
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
<DateType fhirData={employmentImpacted.end} />
|
|
582
|
-
) : (
|
|
583
|
-
<MissingValue />
|
|
584
|
-
)}
|
|
585
|
-
</Value>
|
|
586
|
-
)}
|
|
587
|
-
{hospitalization && (
|
|
588
|
-
<Value label="Hospitalization" data-testid="hospitalization">
|
|
589
|
-
{hospitalization.start ? (
|
|
590
|
-
<DateType fhirData={hospitalization.start} />
|
|
591
|
-
) : (
|
|
592
|
-
<MissingValue />
|
|
593
|
-
)}
|
|
594
|
-
{' - '}
|
|
595
|
-
{hospitalization.end ? (
|
|
596
|
-
<DateType fhirData={hospitalization.end} />
|
|
597
|
-
) : (
|
|
598
|
-
<MissingValue />
|
|
441
|
+
<Accordion
|
|
442
|
+
headerContent={
|
|
443
|
+
<Header
|
|
444
|
+
resourceName="Claim"
|
|
445
|
+
title={`Claim #${id}`}
|
|
446
|
+
badges={
|
|
447
|
+
<>
|
|
448
|
+
{use && <Badge data-testid="use">{use}</Badge>}
|
|
449
|
+
{status && <Badge data-testid="status">{status}</Badge>}
|
|
450
|
+
</>
|
|
451
|
+
}
|
|
452
|
+
icon={fhirIcons}
|
|
453
|
+
/>
|
|
454
|
+
}
|
|
455
|
+
bodyContent={
|
|
456
|
+
<Body tableData={tableData1}>
|
|
457
|
+
{hasCareTeam && <CareTeam careTeam={careTeam} />}
|
|
458
|
+
{hasDiagnosis && <Diagnosis diagnosis={diagnosis} />}
|
|
459
|
+
<ValueSection>
|
|
460
|
+
{tableData2.map(
|
|
461
|
+
(item, index) =>
|
|
462
|
+
item.status && (
|
|
463
|
+
<ValueSectionItem
|
|
464
|
+
key={`claim-item-${index}`}
|
|
465
|
+
label={item.label}
|
|
466
|
+
data-testid={item.testId}
|
|
467
|
+
>
|
|
468
|
+
{item.data}
|
|
469
|
+
</ValueSectionItem>
|
|
470
|
+
),
|
|
471
|
+
)}
|
|
472
|
+
</ValueSection>
|
|
473
|
+
{hasInsurance && <Insurance insurance={insurance} />}
|
|
474
|
+
{total && (
|
|
475
|
+
<ValueSection>
|
|
476
|
+
<ValueSectionItem label="Total amount" data-testid="total">
|
|
477
|
+
<Money fhirData={total} />
|
|
478
|
+
</ValueSectionItem>
|
|
479
|
+
</ValueSection>
|
|
599
480
|
)}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
{insurer && (
|
|
605
|
-
<Value label="Insurer" data-testid="insurer">
|
|
606
|
-
<Reference fhirData={insurer} />
|
|
607
|
-
</Value>
|
|
608
|
-
)}
|
|
609
|
-
{organization && (
|
|
610
|
-
<Value label="Organization" data-testid="organization">
|
|
611
|
-
<Reference fhirData={organization} />
|
|
612
|
-
</Value>
|
|
613
|
-
)}
|
|
614
|
-
{payee.coding && (
|
|
615
|
-
<Value label="Payee" data-testid="payee.type">
|
|
616
|
-
<Coding fhirData={payee.coding} />
|
|
617
|
-
</Value>
|
|
618
|
-
)}
|
|
619
|
-
{payee.party && (
|
|
620
|
-
<Value label="Payee party" data-testid="payee.party">
|
|
621
|
-
<Reference fhirData={payee.party} />
|
|
622
|
-
</Value>
|
|
623
|
-
)}
|
|
624
|
-
{priorityCoding && (
|
|
625
|
-
<Value label="Priority" data-testid="priority">
|
|
626
|
-
<Coding fhirData={priorityCoding} />
|
|
627
|
-
</Value>
|
|
628
|
-
)}
|
|
629
|
-
{hasInsurance && <Insurance insurance={insurance} />}
|
|
630
|
-
{total && (
|
|
631
|
-
<Value label="Total amount" data-testid="total">
|
|
632
|
-
<Money fhirData={total} />
|
|
633
|
-
</Value>
|
|
634
|
-
)}
|
|
635
|
-
{items && <Items items={items} />}
|
|
636
|
-
</Body>
|
|
481
|
+
{items && <Items items={items} />}
|
|
482
|
+
</Body>
|
|
483
|
+
}
|
|
484
|
+
/>
|
|
637
485
|
</Root>
|
|
638
486
|
);
|
|
639
487
|
};
|
|
@@ -11,6 +11,8 @@ import stu3Example3 from '../../../fixtures/stu3/resources/claim/example-3.json'
|
|
|
11
11
|
|
|
12
12
|
import r4Example1 from '../../../fixtures/r4/resources/claim/example1.json';
|
|
13
13
|
import r4Example2 from '../../../fixtures/r4/resources/claim/example2.json';
|
|
14
|
+
import ClaimIcon from '../../../assets/containers/Claim/claim.svg';
|
|
15
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
14
16
|
|
|
15
17
|
export default {
|
|
16
18
|
title: 'Claim',
|
|
@@ -18,27 +20,57 @@ export default {
|
|
|
18
20
|
|
|
19
21
|
export const ExampleOfDSTU2 = () => {
|
|
20
22
|
const fhirResource = object('Resource', dstu2Example1);
|
|
21
|
-
return
|
|
23
|
+
return (
|
|
24
|
+
<Claim
|
|
25
|
+
fhirVersion={fhirVersions.DSTU2}
|
|
26
|
+
fhirResource={fhirResource}
|
|
27
|
+
fhirIcons={require('../../../assets/containers/Claim/claim.svg')}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
22
30
|
};
|
|
23
31
|
|
|
24
32
|
export const ExampleOfSTU3 = () => {
|
|
25
33
|
const fhirResource = object('Resource', stu3Example1);
|
|
26
|
-
return
|
|
34
|
+
return (
|
|
35
|
+
<Claim
|
|
36
|
+
fhirVersion={fhirVersions.STU3}
|
|
37
|
+
fhirResource={fhirResource}
|
|
38
|
+
fhirIcons={ClaimIcon}
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
27
41
|
};
|
|
28
42
|
|
|
29
43
|
export const Example2OfSTU3 = () => {
|
|
30
44
|
const fhirResource = object('Resource', stu3Example2);
|
|
31
|
-
return
|
|
45
|
+
return (
|
|
46
|
+
<Claim
|
|
47
|
+
fhirVersion={fhirVersions.STU3}
|
|
48
|
+
fhirResource={fhirResource}
|
|
49
|
+
fhirIcons={fhirIcons}
|
|
50
|
+
/>
|
|
51
|
+
);
|
|
32
52
|
};
|
|
33
53
|
|
|
34
54
|
export const Example3OfSTU3 = () => {
|
|
35
55
|
const fhirResource = object('Resource', stu3Example3);
|
|
36
|
-
return
|
|
56
|
+
return (
|
|
57
|
+
<Claim
|
|
58
|
+
fhirVersion={fhirVersions.STU3}
|
|
59
|
+
fhirResource={fhirResource}
|
|
60
|
+
fhirIcons={false}
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
37
63
|
};
|
|
38
64
|
|
|
39
65
|
export const Example1OfR4 = () => {
|
|
40
66
|
const fhirResource = object('Resource', r4Example1);
|
|
41
|
-
return
|
|
67
|
+
return (
|
|
68
|
+
<Claim
|
|
69
|
+
fhirVersion={fhirVersions.R4}
|
|
70
|
+
fhirResource={fhirResource}
|
|
71
|
+
fhirIcons={'random text'}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
42
74
|
};
|
|
43
75
|
|
|
44
76
|
export const Example2OfR4 = () => {
|
|
@@ -9,8 +9,80 @@ import stu3Example1 from '../../../fixtures/stu3/resources/claim/example-1.json'
|
|
|
9
9
|
import stu3Example2 from '../../../fixtures/stu3/resources/claim/example-2.json';
|
|
10
10
|
import stu3Example3 from '../../../fixtures/stu3/resources/claim/example-3.json';
|
|
11
11
|
import r4Example1 from '../../../fixtures/r4/resources/claim/example1.json';
|
|
12
|
+
import fhirIcons from '../../../fixtures/example-icons';
|
|
12
13
|
|
|
13
14
|
describe('should render the Claim component properly', () => {
|
|
15
|
+
it('component without a fhirIcons props should render a default icon', () => {
|
|
16
|
+
const defaultProps = {
|
|
17
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
18
|
+
fhirResource: dstu2Example1,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const { getByAltText } = render(<Claim {...defaultProps} />);
|
|
22
|
+
const headerIcon = getByAltText('claim');
|
|
23
|
+
|
|
24
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('component with a false as a fhirIcons props should render a placeholder', () => {
|
|
28
|
+
const defaultProps = {
|
|
29
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
30
|
+
fhirResource: dstu2Example1,
|
|
31
|
+
fhirIcons: false,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const { getByTestId } = render(<Claim {...defaultProps} />);
|
|
35
|
+
const headerIcon = getByTestId('placeholder');
|
|
36
|
+
|
|
37
|
+
expect(headerIcon).toBeTruthy();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('component with the img as a fhirIcons props should render an img', () => {
|
|
41
|
+
const defaultProps = {
|
|
42
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
43
|
+
fhirResource: dstu2Example1,
|
|
44
|
+
fhirIcons: (
|
|
45
|
+
<img
|
|
46
|
+
src={require('../assets/containers/Claim/claim.svg')}
|
|
47
|
+
alt="claim"
|
|
48
|
+
/>
|
|
49
|
+
),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const { getByAltText } = render(<Claim {...defaultProps} />);
|
|
53
|
+
const headerIcon = getByAltText('claim');
|
|
54
|
+
|
|
55
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('component with the resources object as a fhirIcons props should render an img', () => {
|
|
59
|
+
const defaultProps = {
|
|
60
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
61
|
+
fhirResource: dstu2Example1,
|
|
62
|
+
fhirIcons: fhirIcons,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const { getByAltText } = render(<Claim {...defaultProps} />);
|
|
66
|
+
const headerIcon = getByAltText('clipboard with a symmetrical cross');
|
|
67
|
+
|
|
68
|
+
expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('component with the url as a fhirIcons props should render an img', () => {
|
|
72
|
+
const avatarSrc =
|
|
73
|
+
'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
|
|
74
|
+
const defaultProps = {
|
|
75
|
+
fhirVersion: fhirVersions.DSTU2,
|
|
76
|
+
fhirResource: dstu2Example1,
|
|
77
|
+
fhirIcons: avatarSrc,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const { getByAltText } = render(<Claim {...defaultProps} />);
|
|
81
|
+
const headerIcon = getByAltText('header icon');
|
|
82
|
+
|
|
83
|
+
expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
|
|
84
|
+
});
|
|
85
|
+
|
|
14
86
|
it('with DSTU2 source data', () => {
|
|
15
87
|
const defaultProps = {
|
|
16
88
|
fhirResource: dstu2Example1,
|