Skip to content

Commit

Permalink
Add medication knowledge create form
Browse files Browse the repository at this point in the history
  • Loading branch information
projkov committed Nov 28, 2023
1 parent 9225456 commit 220d659
Show file tree
Hide file tree
Showing 3 changed files with 238 additions and 3 deletions.
66 changes: 66 additions & 0 deletions resources/seeds/Mapping/medication-knowledge-create-extract.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
body:
$let:
name: $ fhirpath("QuestionnaireResponse.repeat(item).where(linkId='name').answer.valueString").0
code: $ fhirpath("QuestionnaireResponse.repeat(item).where(linkId='code').answer.valueString").0
doseForm: $ fhirpath("QuestionnaireResponse.repeat(item).where(linkId='dose-form').answer.valueCoding").0
amountUnit: $ fhirpath("QuestionnaireResponse.repeat(item).where(linkId='amount-unit').answer.valueCoding").0
amountValue: $ fhirpath("QuestionnaireResponse.repeat(item).where(linkId='amount-value').answer.valueInteger").0
ingredients: $ fhirpath("QuestionnaireResponse.repeat(item).where(linkId='ingredients')")
$body:
type: transaction
entry:
- request:
url: /MedicationKnowledge
method: POST
fullUrl: urn:uuid:medication-knowledge-id
resource:
code:
coding:
- code: $ code
display: $ name
system: http://beda.software/custom-medication-list
doseForm:
coding:
- $ doseForm
amount:
code: $ amountUnit.code
unit: $ amountUnit.display
value: $ amountValue
system: http://unitsofmeasure.org
ingredient:
$map: $ ingredients
$as: ingredientData
$body:
$let:
itemCode: $ fhirpath("%context.item.where(linkId='ingredientsIngredient').answer.valueCoding.code", ingredientData).0
itemDisplay: $ fhirpath("%context.item.where(linkId='ingredientsIngredient').answer.valueCoding.display", ingredientData).0
numeratorCode: $ fhirpath("%context.item.where(linkId='numerator-unit').answer.valueCoding.code", ingredientData).0
numeratorUnit: $ fhirpath("%context.item.where(linkId='numerator-unit').answer.valueCoding.display", ingredientData).0
numeratorValue: $ fhirpath("%context.item.where(linkId='numerator-value').answer.valueDecimal", ingredientData).0
denominatorCode: $ fhirpath("%context.item.where(linkId='denominator-unit').answer.valueCoding.code", ingredientData).0
denominatorUnit: $ fhirpath("%context.item.where(linkId='denominator-unit').answer.valueCoding.display", ingredientData).0
denominatorValue: $ fhirpath("%context.item.where(linkId='denominator-value').answer.valueDecimal", ingredientData).0
$body:
item:
CodeableConcept:
coding:
- code: $ itemCode
system: http://www.nlm.nih.gov/research/umls/rxnorm
display: $ itemDisplay
isActive: true
strength:
numerator:
code: $ numeratorCode
unit: $ numeratorUnit
value: $ numeratorValue
system: http://unitsofmeasure.org
denominator:
code: $ denominatorCode
unit: $ denominatorUnit
value: $ denominatorValue
system: http://unitsofmeasure.org
status: active
resourceType: MedicationKnowledge
resourceType: Bundle
id: medication-knowledge-create-extract
resourceType: Mapping
133 changes: 133 additions & 0 deletions resources/seeds/Questionnaire/medication-knowledge-create.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
id: medication-knowledge-create
resourceType: Questionnaire
name: medication-knowledge-create
title: medication-knowledge create
status: active
mapping:
- id: medication-knowledge-create-extract
resourceType: Mapping
item:
- text: Name
type: string
linkId: name
- text: Code
type: string
linkId: code
- text: Dose form
type: choice
linkId: dose-form
answerOption:
- value:
Coding:
code: '7946007'
display: Drug suspension
system: http://snomed.info/sct
- value:
Coding:
code: '11190007'
display: Drug stick
system: http://snomed.info/sct
- value:
Coding:
code: '17519006'
display: Lotion
system: http://snomed.info/sct
- text: Amount unit
type: choice
linkId: amount-unit
answerOption:
- value:
Coding:
code: '7946007'
display: Drug suspension
system: http://snomed.info/sct
- value:
Coding:
code: '11190007'
display: Drug stick
system: http://snomed.info/sct
- text: Amount value
type: integer
linkId: amount-value
- item:
- text: Ingredient
type: choice
linkId: ingredientsIngredient
answerOption:
- value:
Coding:
code: '1091643'
display: azilsartan
system: https://mor.nlm.nih.gov/
- value:
Coding:
code: '1191'
display: aspirin
system: https://mor.nlm.nih.gov/
- text: Numerator unit
type: choice
linkId: numerator-unit
answerOption:
- value:
Coding:
code: kg
display: kilogram
system: http://unitsofmeasure.org
- value:
Coding:
code: mg
display: milligram
system: http://unitsofmeasure.org
- value:
Coding:
code: tablet
display: tablet
system: http://unitsofmeasure.org
- text: Numerator value
type: decimal
linkId: numerator-value
- text: Denominator unit
type: choice
linkId: denominator-unit
answerOption:
- value:
Coding:
code: kg
display: kilogram
system: http://unitsofmeasure.org
- value:
Coding:
code: mg
display: milligram
system: http://unitsofmeasure.org
- value:
Coding:
code: tablet
display: tablet
system: http://unitsofmeasure.org
- text: Denominator value
type: decimal
linkId: denominator-value
text: Ingredients
type: group
linkId: ingredients
repeats: true
- text: Price base
type: decimal
linkId: priceBase
unit:
code: usd
system: http://unitsofmeasure.org
display: USD
- text: Price tax
type: decimal
linkId: priceTax
unit:
code: usd
system: http://unitsofmeasure.org
display: USD

meta:
profile:
- https://beda.software/beda-emr-questionnaire
url: https://aidbox.emr.beda.software/ui/console#/entities/Questionnaire/healthcare-service-create
42 changes: 39 additions & 3 deletions src/containers/MedicationManagement/MedicationKnowledgeList.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
import { Trans } from '@lingui/macro';
import { Table } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
import { t, Trans } from '@lingui/macro';
import { Table, Button, notification } from 'antd';
import { Medication, MedicationKnowledge } from 'fhir/r4b';

Check failure on line 4 in src/containers/MedicationManagement/MedicationKnowledgeList.tsx

View workflow job for this annotation

GitHub Actions / Tests

'Medication' is declared but its value is never read.

import { isLoading, isSuccess } from 'fhir-react/lib/libs/remoteData';

import { questionnaireIdLoader } from 'shared/src/hooks/questionnaire-response-form-data';

import { ModalTrigger } from 'src/components/ModalTrigger';
import { QuestionnaireResponseForm } from 'src/components/QuestionnaireResponseForm';
import { SpinIndicator } from 'src/components/Spinner';

import { useMedicationKnowledge } from './hooks';
import { RenderStrength } from './MedicationList';

export function MedicationKnowledgeList() {
const { medicationKnowledgeResponse, pagination, handleTableChange } = useMedicationKnowledge();
const { medicationKnowledgeResponse, pagination, handleTableChange, pagerManager } = useMedicationKnowledge();

return (
<>
<ModalNewMedicationKnowledge onCreate={pagerManager.reload} />
<Table
pagination={pagination}
onChange={handleTableChange}
Expand Down Expand Up @@ -60,3 +66,33 @@ function OtherDetails({ medicationKnowledge }: { medicationKnowledge: Medication
</ul>
);
}

interface ModalNewMedicationKnowledgeProps {
onCreate: () => void;
}
export const ModalNewMedicationKnowledge = (props: ModalNewMedicationKnowledgeProps) => {
return (
<ModalTrigger
title={t`Add Medication Knowledge`}
trigger={
<Button icon={<PlusOutlined />} type="primary">
<span>
<Trans>Add medication knowledge</Trans>
</span>
</Button>
}
>
{({ closeModal }) => (
<QuestionnaireResponseForm
questionnaireLoader={questionnaireIdLoader('medication-knowledge-create')}
onSuccess={() => {
closeModal();
notification.success({ message: t`Medication knowledge successfully created` });
props.onCreate();
}}
onCancel={closeModal}
/>
)}
</ModalTrigger>
);
};

0 comments on commit 220d659

Please sign in to comment.