-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
1 parent
abaaa83
commit d0117ec
Showing
28 changed files
with
2,914 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 139 additions & 0 deletions
139
src/components/resources/List/DrugTierDefinitionExtension.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.