From 220d659ca566c46b09e2b71d62d3ddff818fb7ef Mon Sep 17 00:00:00 2001 From: Pavel R Date: Tue, 28 Nov 2023 18:23:13 +0100 Subject: [PATCH] Add medication knowledge create form --- .../medication-knowledge-create-extract.yaml | 66 +++++++++ .../medication-knowledge-create.yaml | 133 ++++++++++++++++++ .../MedicationKnowledgeList.tsx | 42 +++++- 3 files changed, 238 insertions(+), 3 deletions(-) create mode 100644 resources/seeds/Mapping/medication-knowledge-create-extract.yaml create mode 100644 resources/seeds/Questionnaire/medication-knowledge-create.yaml diff --git a/resources/seeds/Mapping/medication-knowledge-create-extract.yaml b/resources/seeds/Mapping/medication-knowledge-create-extract.yaml new file mode 100644 index 00000000..9dc83554 --- /dev/null +++ b/resources/seeds/Mapping/medication-knowledge-create-extract.yaml @@ -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 diff --git a/resources/seeds/Questionnaire/medication-knowledge-create.yaml b/resources/seeds/Questionnaire/medication-knowledge-create.yaml new file mode 100644 index 00000000..0894ed9a --- /dev/null +++ b/resources/seeds/Questionnaire/medication-knowledge-create.yaml @@ -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 diff --git a/src/containers/MedicationManagement/MedicationKnowledgeList.tsx b/src/containers/MedicationManagement/MedicationKnowledgeList.tsx index 0d71ba49..6799a158 100644 --- a/src/containers/MedicationManagement/MedicationKnowledgeList.tsx +++ b/src/containers/MedicationManagement/MedicationKnowledgeList.tsx @@ -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'; 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 ( <> + ); } + +interface ModalNewMedicationKnowledgeProps { + onCreate: () => void; +} +export const ModalNewMedicationKnowledge = (props: ModalNewMedicationKnowledgeProps) => { + return ( + } type="primary"> + + Add medication knowledge + + + } + > + {({ closeModal }) => ( + { + closeModal(); + notification.success({ message: t`Medication knowledge successfully created` }); + props.onCreate(); + }} + onCancel={closeModal} + /> + )} + + ); +};