Skip to content

Commit

Permalink
Refactor characteristic code system to smartregister (#1334)
Browse files Browse the repository at this point in the history
* Update group-management dependencies

* Extract general re-usable productForm

* Define a way to dynamically provide vlaidationRules

* Make it possible to configure hiddenfilds and validationRUles

* Make the whole Group details section configurable

* Move current commodity list implementation to DEfault

* Add Eusm centric commodity list

* Configurable view details section for group list view

* Conditionally render list view wrt to project code

* Update utils

* Install jest-canvas-mock, mocks canvas for antd upload

* Create a mock for window.URL.createObjectURL

* Create Eusm edit

* Fix lint issues

* Update snapshot tests

* Show error banner if list id is not configured

* Replace fallback image with skeleton image

* Link material number to the identifier dataindex

* Add material number to view details section

* Fix test regressions

* Wrap commodity edit in rbaccheck

* Refactor lexicalities on variable unitOfMeasure

* Cleaning up the code

* Wrap commodity edit in rbaccheck

* Update mock envs to fix test regression

* Update snapshot in commodity list view

* Fix missing material number

* Wait for binary Query to render form view

* Fix binary payload generation and append to list

* Disable caching on binary query

* Update docstring for helper fun toArrayBuffer

* Fix bug where attractive item did not have correct value

* Refctor characteristic code system to smartregister
  • Loading branch information
peterMuriuki authored Feb 28, 2024
1 parent 2f590a0 commit f96f504
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const CommodityAddEdit = (props: GroupAddEditProps) => {
const { groupQuery, binaryQuery } = useGetGroupAndBinary(fhirBaseUrl, resourceId);

// TODO - Had to include binaryQuery loading status since the antd form upload widget
// does not update when the component updates initial values.
// does not update when we pass new set of initial values to commodityForm.
if (
(!groupQuery.isIdle && groupQuery.isLoading) ||
(!binaryQuery.isIdle && binaryQuery.isLoading)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const commodity1 = {
code: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '23435363',
display: 'Attractive Item code',
},
Expand All @@ -43,7 +43,7 @@ export const commodity1 = {
code: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '34536373',
display: 'Is it there code',
},
Expand All @@ -52,7 +52,7 @@ export const commodity1 = {
valueCodeableConcept: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '34536373-1',
display: 'Value entered on the It is there code',
},
Expand All @@ -64,7 +64,7 @@ export const commodity1 = {
code: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '45647484',
display: 'Is it in good condition? (optional)',
},
Expand All @@ -73,7 +73,7 @@ export const commodity1 = {
valueCodeableConcept: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '45647484-1',
display: 'Value entered on the Is it in good condition? (optional)',
},
Expand All @@ -85,7 +85,7 @@ export const commodity1 = {
code: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '56758595',
display: 'Is it being used appropriately? (optional)',
},
Expand All @@ -94,7 +94,7 @@ export const commodity1 = {
valueCodeableConcept: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '56758595-1',
display: 'Value entered on the Is it being used appropriately? (optional)',
},
Expand All @@ -106,7 +106,7 @@ export const commodity1 = {
code: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '67869606',
display: 'Accountability period (in months)',
},
Expand All @@ -120,7 +120,7 @@ export const commodity1 = {
code: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '1231415',
display: 'Product Image code',
},
Expand Down Expand Up @@ -151,21 +151,25 @@ export const editedCommodity1 = {
{
code: {
coding: [
{ system: 'http://snomed.info/sct', code: '23435363', display: 'Attractive Item code' },
{
system: 'http://smartregister.org/',
code: '23435363',
display: 'Attractive Item code',
},
],
},
valueBoolean: true,
},
{
code: {
coding: [
{ system: 'http://snomed.info/sct', code: '34536373', display: 'Is it there code' },
{ system: 'http://smartregister.org/', code: '34536373', display: 'Is it there code' },
],
},
valueCodeableConcept: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '34536373-1',
display: 'Value entered on the It is there code',
},
Expand All @@ -177,7 +181,7 @@ export const editedCommodity1 = {
code: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '45647484',
display: 'Is it in good condition? (optional)',
},
Expand All @@ -186,7 +190,7 @@ export const editedCommodity1 = {
valueCodeableConcept: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '45647484-1',
display: 'Value entered on the Is it in good condition? (optional)',
},
Expand All @@ -198,7 +202,7 @@ export const editedCommodity1 = {
code: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '56758595',
display: 'Is it being used appropriately? (optional)',
},
Expand All @@ -207,7 +211,7 @@ export const editedCommodity1 = {
valueCodeableConcept: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '56758595-1',
display: 'Value entered on the Is it being used appropriately? (optional)',
},
Expand All @@ -219,7 +223,7 @@ export const editedCommodity1 = {
code: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '67869606',
display: 'Accountability period (in months)',
},
Expand All @@ -230,7 +234,7 @@ export const editedCommodity1 = {
{
code: {
coding: [
{ system: 'http://snomed.info/sct', code: '1231415', display: 'Product Image code' },
{ system: 'http://smartregister.org/', code: '1231415', display: 'Product Image code' },
],
},
valueReference: { reference: 'Binary/9b782015-8392-4847-b48c-50c11638656b' },
Expand Down Expand Up @@ -267,11 +271,11 @@ export const editedCommodity = {
{
code: {
coding: [
{ system: 'http://snomed.info/sct', code: '767524001', display: 'Unit of measure' },
{ system: 'http://smartregister.org/', code: '767524001', display: 'Unit of measure' },
],
},
valueCodeableConcept: {
coding: [{ system: 'http://snomed.info/sct', code: '767525000', display: 'Unit' }],
coding: [{ system: 'http://smartregister.org/', code: '767525000', display: 'Unit' }],
text: 'Strips',
},
},
Expand Down Expand Up @@ -342,7 +346,7 @@ export const createdCommodity = {
code: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '67869606',
display: 'Accountability period (in months)',
},
Expand All @@ -354,7 +358,7 @@ export const createdCommodity = {
code: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '56758595',
display: 'Is it being used appropriately? (optional)',
},
Expand All @@ -363,7 +367,7 @@ export const createdCommodity = {
valueCodeableConcept: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '56758595-1',
display: 'Value entered on the Is it being used appropriately? (optional)',
},
Expand All @@ -375,7 +379,7 @@ export const createdCommodity = {
code: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '45647484',
display: 'Is it in good condition? (optional)',
},
Expand All @@ -384,7 +388,7 @@ export const createdCommodity = {
valueCodeableConcept: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '45647484-1',
display: 'Value entered on the Is it in good condition? (optional)',
},
Expand All @@ -395,13 +399,13 @@ export const createdCommodity = {
{
code: {
coding: [
{ system: 'http://snomed.info/sct', code: '34536373', display: 'Is it there code' },
{ system: 'http://smartregister.org/', code: '34536373', display: 'Is it there code' },
],
},
valueCodeableConcept: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '34536373-1',
display: 'Value entered on the It is there code',
},
Expand All @@ -412,15 +416,19 @@ export const createdCommodity = {
{
code: {
coding: [
{ system: 'http://snomed.info/sct', code: '23435363', display: 'Attractive Item code' },
{
system: 'http://smartregister.org/',
code: '23435363',
display: 'Attractive Item code',
},
],
},
valueBoolean: true,
},
{
code: {
coding: [
{ system: 'http://snomed.info/sct', code: '1231415', display: 'Product Image code' },
{ system: 'http://smartregister.org/', code: '1231415', display: 'Product Image code' },
],
},
valueReference: { reference: 'Binary/9b782015-8392-4847-b48c-50c11638656b' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {
supplyMgSnomedCode,
unitOfMeasureCharacteristicCoding,
unitOfMeasureCharacteristic,
smartRegisterCodeSystem,
} from '../../../helpers/utils';
import { TypeOfGroup } from '../../ProductForm/utils';
import { GroupFormFields } from '../../ProductForm/types';
Expand Down Expand Up @@ -350,6 +351,8 @@ export const getGroupFormFields = (obj?: IGroup, binary?: IBinary): EusmGroupFor
const val = getValueFromCharacteristic(characteristic);
formFieldsFromCharacteristics[unitOfMeasure] = val;
}
}
if (codingSystem === smartRegisterCodeSystem) {
if (codingCode === accountabilityCharacteristicCode) {
const val = getValueFromCharacteristic(characteristic);
formFieldsFromCharacteristics[accountabilityPeriod] = val;
Expand Down Expand Up @@ -492,8 +495,8 @@ export const generateGroupPayload = async (
code: {
coding: [
{
system: 'http://snomed.info/sct',
code: '1231415',
system: smartRegisterCodeSystem,
code: photoUploadCharacteristicCode,
display: 'Product Image code',
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const firstTwentyEusmCommodities = {
code: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '23435363',
display: 'Attractive Item code',
},
Expand All @@ -64,7 +64,7 @@ export const firstTwentyEusmCommodities = {
code: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '34536373',
display: 'Is it there code',
},
Expand All @@ -73,7 +73,7 @@ export const firstTwentyEusmCommodities = {
valueCodeableConcept: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '34536373-1',
display: 'Value entered on the It is there code',
},
Expand All @@ -85,7 +85,7 @@ export const firstTwentyEusmCommodities = {
code: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '45647484',
display: 'Is it in good condition? (optional)',
},
Expand All @@ -94,7 +94,7 @@ export const firstTwentyEusmCommodities = {
valueCodeableConcept: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '45647484-1',
display: 'Value entered on the Is it in good condition? (optional)',
},
Expand All @@ -106,7 +106,7 @@ export const firstTwentyEusmCommodities = {
code: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '56758595',
display: 'Is it being used appropriately? (optional)',
},
Expand All @@ -115,7 +115,7 @@ export const firstTwentyEusmCommodities = {
valueCodeableConcept: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '56758595-1',
display: 'Value entered on the Is it being used appropriately? (optional)',
},
Expand All @@ -127,7 +127,7 @@ export const firstTwentyEusmCommodities = {
code: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '67869606',
display: 'Accountability period (in months)',
},
Expand All @@ -141,7 +141,7 @@ export const firstTwentyEusmCommodities = {
code: {
coding: [
{
system: 'http://snomed.info/sct',
system: 'http://smartregister.org/',
code: '1231415',
display: 'Product Image code',
},
Expand Down
Loading

0 comments on commit f96f504

Please sign in to comment.