Skip to content

Commit

Permalink
Merge develop into master (#244)
Browse files Browse the repository at this point in the history
* Add Identifier field for the Practitioner and Organization resources (#240)

* bump up the version

* Formulary data resources - React components (#243)

* Add list resource with Davinci PDex profile

* Add dstu2 and stu3 stories to the storybook

* Add propTypes to the DrugTierDefinitionExtension helper resoruce

* fix html structure

* Add MedicationKnowledge component

* Add daVinci PDex profile to Med Knowledge

* Update readme, export components to be globally available

* Add tests

* Bump up the version
  • Loading branch information
KonradNojman authored Jul 23, 2021
1 parent abaaa83 commit d0117ec
Show file tree
Hide file tree
Showing 28 changed files with 2,914 additions and 38 deletions.
77 changes: 40 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const MyComponent = () => {
| `fhirResource`\* | Object | - | The FHIR resource to be rendered |
| `fhirVersion`\* | `fhirVersions.DSTU2`, `fhirVersions.STU3, fhirVersions.R4` | - | FHIR resource version |
| `withCarinBBProfile` | Boolean | `false` | Use Carin BB profile extension on top of the HL7 default FHIR specification https://build.fhir.org/ig/HL7/carin-bb/index.html |
| `withDaVinciPDex` | Boolean | `false` | Use DaVinci Payer Data Exchange (PDex) profile extension on top of the HL7 default FHIR specification https://hl7.org/fhir/us/davinci-drug-formulary/index.html |
| `thorough` | Boolean | `false` | If this is set to `true`, or if it is absent, all array items and supported attributes will be displayed. Otherwise if this is `false` then only the first or otherwise important items will be displayed |

\* required props
Expand All @@ -53,43 +54,45 @@ const MyComponent = () => {

### Available resources

| Resource | DSTU2 | STU3 | R4 | Carin BB Profile |
| -------------------------- | :---: | :--: | :---: | :--------------: |
| `AdverseEvent` | _N/A_ |||
| `AllergyIntolerance` ||||
| `AdverseEvent` | _N/A_ |||
| `AllergyIntolerance` ||||
| `Appointment` ||||
| `Bundle` ||||
| `CarePlan` ||||
| `CareTeam` | _N/A_ |||
| `Claim` ||||
| `ClaimResponse` ||||
| `Condition` ||||
| `Coverage` ||||
| `Device` ||||
| `DiagnosticReport` ||||
| `DocumentReference` ||||
| `Encounter` ||||
| `ExplanationOfBenefit` |||||
| `Goal` ||||
| `Immunization` ||||
| `Location` ||||
| `Medication` ||||
| `MedicationAdministration` ||||
| `MedicationDispense` ||||
| `MedicationRequest` | _N/A_ |||
| `MedicationStatement` ||||
| `Observation` ||||
| `Organization` ||||
| `Patient` ||||
| `Practitioner` ||||
| `PractitionerRole` | _N/A_ |||
| `Procedure` ||||
| `Questionnaire` ||||
| `QuestionnaireResponse` ||||
| `ReferralRequest` ||| _N/A_ |
| `ResearchStudy` | _N/A_ |||
| Resource | DSTU2 | STU3 | R4 | Carin BB Profile | DaVinci PDex |
| -------------------------- | :---: | :---: | :---: | :--------------: | ------------ |
| `AdverseEvent` | _N/A_ |||
| `AllergyIntolerance` ||||
| `AdverseEvent` | _N/A_ |||
| `AllergyIntolerance` ||||
| `Appointment` ||||
| `Bundle` ||||
| `CarePlan` ||||
| `CareTeam` | _N/A_ |||
| `Claim` ||||
| `ClaimResponse` ||||
| `Condition` ||||
| `Coverage` ||||
| `Device` ||||
| `DiagnosticReport` ||||
| `DocumentReference` ||||
| `Encounter` ||||
| `ExplanationOfBenefit` |||||
| `Goal` ||||
| `Immunization` ||||
| `List` |||| ||
| `Location` ||||
| `Medication` ||||
| `MedicationAdministration` ||||
| `MedicationDispense` ||||
| `MedicationKnowledge` | _N/A_ | _N/A_ || ||
| `MedicationRequest` | _N/A_ |||
| `MedicationStatement` ||||
| `Observation` ||||
| `Organization` ||||
| `Patient` ||||
| `Practitioner` ||||
| `PractitionerRole` | _N/A_ |||
| `Procedure` ||||
| `Questionnaire` ||||
| `QuestionnaireResponse` ||||
| `ReferralRequest` ||| _N/A_ |
| `ResearchStudy` | _N/A_ |||

### Styles

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fhir-react",
"version": "0.2.1",
"version": "0.2.2",
"description": "React component library for displaying FHIR Resources ",
"main": "build/index.js",
"peerDependencies": {
Expand Down
139 changes: 139 additions & 0 deletions src/components/resources/List/DrugTierDefinitionExtension.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import React from 'react';
import PropTypes from 'prop-types';
import _get from 'lodash/get';
import { getExtension } from './utils';
import { ValueSection, Value } from '../../ui';
import CodeableConcept from '../../datatypes/CodeableConcept';
import Money from '../../datatypes/Money';

const DrugTierDefinitionExtension = props => {
const dto = drugTierDefinitionExtension => {
const extensions = _get(drugTierDefinitionExtension, 'extension', []);
const hasExtensions = extensions.length >= 1;

const drugTierID = _get(
getExtension('drugTierID', extensions),
'valueCodeableConcept',
);
const mailOrder = _get(
getExtension('mailOrder', extensions),
'valueBoolean',
);
const costSharing = _get(
getExtension('costSharing', extensions),
'extension',
null,
);

const hasConstSharing = costSharing !== null;
if (hasConstSharing) {
const pharmacyType = _get(
getExtension('pharmacyType', costSharing),
'valueCodeableConcept',
);
const copayAmount = _get(
getExtension('copayAmount', costSharing),
'valueMoney',
);
const copayOption = _get(
getExtension('copayOption', costSharing),
'valueCodeableConcept',
);
const coinsuranceRate = _get(
getExtension('coinsuranceRate', costSharing),
'valueDecimal',
);
const coinsuranceOption = _get(
getExtension('coinsuranceOption', costSharing),
'valueCodeableConcept',
);

return {
hasExtensions,
drugTierID,
mailOrder,
hasConstSharing,
pharmacyType,
copayAmount,
copayOption,
coinsuranceRate,
coinsuranceOption,
};
}

return {
hasExtensions,
drugTierID,
mailOrder,
hasConstSharing,
};
};

const { drugTierDefinitionExtension } = props;
const {
hasExtensions,
drugTierID,
mailOrder,
hasConstSharing,
pharmacyType,
copayAmount,
copayOption,
coinsuranceRate,
coinsuranceOption,
} = dto(drugTierDefinitionExtension);

return (
hasExtensions && (
<ValueSection
label="Drug Tier Definition"
data-testid="drugTierDefinition"
>
{drugTierID && (
<Value label="Drug Tier ID" data-testid="drugTierID">
<CodeableConcept fhirData={drugTierID} />
</Value>
)}
{mailOrder && (
<Value label="Mail order" data-testid="mailOrder">
{mailOrder ? 'yes' : 'no'}
</Value>
)}
{hasConstSharing && (
<ValueSection label="Cost sharing" data-testid="costSharing">
{pharmacyType && (
<Value label="Pharmacy Type" data-testid="pharmacyType">
<CodeableConcept fhirData={pharmacyType} />
</Value>
)}
{copayAmount && (
<Value label="Copay Amount" data-testid="copayAmount">
<Money fhirData={copayAmount} />
</Value>
)}
{copayOption && (
<Value label="Copay Option" data-testid="copayOption">
<CodeableConcept fhirData={copayOption} />
</Value>
)}
{(coinsuranceRate === 0 || coinsuranceRate) && (
<Value label="Coinsurance Rate" data-testid="coinsuranceRate">
{coinsuranceRate}
</Value>
)}
{coinsuranceOption && (
<Value label="Coinsurance Option" data-testid="coinsuranceOption">
<CodeableConcept fhirData={coinsuranceOption} />
</Value>
)}
</ValueSection>
)}
</ValueSection>
)
);
};

DrugTierDefinitionExtension.propTypes = {
drugTierDefinitionExtension: PropTypes.shape({}).isRequired,
};

export default DrugTierDefinitionExtension;
66 changes: 66 additions & 0 deletions src/components/resources/List/Entries.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import React from 'react';
import _get from 'lodash/get';

import {
ValueSection,
Table,
TableRow,
TableHeader,
TableCell,
MissingValue,
} from '../../ui/index';
import Date from '../../datatypes/Date';
import CodeableConcept from '../../datatypes/CodeableConcept';
import Reference from '../../datatypes/Reference';

const Entries = ({ fhirData: items = [] }) => {
if (items.length === 0) return null;
return (
<ValueSection label="Entries" data-testid="entries">
<Table>
<thead>
<TableRow>
<TableHeader>Item</TableHeader>
<TableHeader>Date</TableHeader>
<TableHeader>Is deleted</TableHeader>
<TableHeader>Status</TableHeader>
</TableRow>
</thead>
<tbody>
{items.map((item, idx) => (
<Entry key={idx} item={item} />
))}
</tbody>
</Table>
</ValueSection>
);
};

const Entry = props => {
const { item } = props;
const flag = _get(item, 'flag');
const deleted = _get(item, 'deleted');
const date = _get(item, 'date');
const entry = _get(item, 'item');

return (
<>
<TableRow>
<TableCell data-testid="items.entry">
<Reference fhirData={entry} />
</TableCell>
<TableCell data-testid="items.date">
{date ? <Date fhirData={date} /> : <MissingValue />}
</TableCell>
<TableCell data-testid="items.isDeleted">
{deleted === true ? 'yes' : 'no'}
</TableCell>
<TableCell data-testid="items.flag">
{flag ? <CodeableConcept fhirData={flag} /> : <MissingValue />}
</TableCell>
</TableRow>
</>
);
};

export default Entries;
Loading

0 comments on commit d0117ec

Please sign in to comment.