Skip to content

Commit f96f504

Browse files
authored
Refactor characteristic code system to smartregister (#1334)
* 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
1 parent 2f590a0 commit f96f504

File tree

5 files changed

+64
-52
lines changed

5 files changed

+64
-52
lines changed

packages/fhir-group-management/src/components/CommodityAddEdit/Eusm/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const CommodityAddEdit = (props: GroupAddEditProps) => {
3838
const { groupQuery, binaryQuery } = useGetGroupAndBinary(fhirBaseUrl, resourceId);
3939

4040
// TODO - Had to include binaryQuery loading status since the antd form upload widget
41-
// does not update when the component updates initial values.
41+
// does not update when we pass new set of initial values to commodityForm.
4242
if (
4343
(!groupQuery.isIdle && groupQuery.isLoading) ||
4444
(!binaryQuery.isIdle && binaryQuery.isLoading)

packages/fhir-group-management/src/components/CommodityAddEdit/Eusm/tests/fixtures.ts

+37-29
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const commodity1 = {
3131
code: {
3232
coding: [
3333
{
34-
system: 'http://snomed.info/sct',
34+
system: 'http://smartregister.org/',
3535
code: '23435363',
3636
display: 'Attractive Item code',
3737
},
@@ -43,7 +43,7 @@ export const commodity1 = {
4343
code: {
4444
coding: [
4545
{
46-
system: 'http://snomed.info/sct',
46+
system: 'http://smartregister.org/',
4747
code: '34536373',
4848
display: 'Is it there code',
4949
},
@@ -52,7 +52,7 @@ export const commodity1 = {
5252
valueCodeableConcept: {
5353
coding: [
5454
{
55-
system: 'http://snomed.info/sct',
55+
system: 'http://smartregister.org/',
5656
code: '34536373-1',
5757
display: 'Value entered on the It is there code',
5858
},
@@ -64,7 +64,7 @@ export const commodity1 = {
6464
code: {
6565
coding: [
6666
{
67-
system: 'http://snomed.info/sct',
67+
system: 'http://smartregister.org/',
6868
code: '45647484',
6969
display: 'Is it in good condition? (optional)',
7070
},
@@ -73,7 +73,7 @@ export const commodity1 = {
7373
valueCodeableConcept: {
7474
coding: [
7575
{
76-
system: 'http://snomed.info/sct',
76+
system: 'http://smartregister.org/',
7777
code: '45647484-1',
7878
display: 'Value entered on the Is it in good condition? (optional)',
7979
},
@@ -85,7 +85,7 @@ export const commodity1 = {
8585
code: {
8686
coding: [
8787
{
88-
system: 'http://snomed.info/sct',
88+
system: 'http://smartregister.org/',
8989
code: '56758595',
9090
display: 'Is it being used appropriately? (optional)',
9191
},
@@ -94,7 +94,7 @@ export const commodity1 = {
9494
valueCodeableConcept: {
9595
coding: [
9696
{
97-
system: 'http://snomed.info/sct',
97+
system: 'http://smartregister.org/',
9898
code: '56758595-1',
9999
display: 'Value entered on the Is it being used appropriately? (optional)',
100100
},
@@ -106,7 +106,7 @@ export const commodity1 = {
106106
code: {
107107
coding: [
108108
{
109-
system: 'http://snomed.info/sct',
109+
system: 'http://smartregister.org/',
110110
code: '67869606',
111111
display: 'Accountability period (in months)',
112112
},
@@ -120,7 +120,7 @@ export const commodity1 = {
120120
code: {
121121
coding: [
122122
{
123-
system: 'http://snomed.info/sct',
123+
system: 'http://smartregister.org/',
124124
code: '1231415',
125125
display: 'Product Image code',
126126
},
@@ -151,21 +151,25 @@ export const editedCommodity1 = {
151151
{
152152
code: {
153153
coding: [
154-
{ system: 'http://snomed.info/sct', code: '23435363', display: 'Attractive Item code' },
154+
{
155+
system: 'http://smartregister.org/',
156+
code: '23435363',
157+
display: 'Attractive Item code',
158+
},
155159
],
156160
},
157161
valueBoolean: true,
158162
},
159163
{
160164
code: {
161165
coding: [
162-
{ system: 'http://snomed.info/sct', code: '34536373', display: 'Is it there code' },
166+
{ system: 'http://smartregister.org/', code: '34536373', display: 'Is it there code' },
163167
],
164168
},
165169
valueCodeableConcept: {
166170
coding: [
167171
{
168-
system: 'http://snomed.info/sct',
172+
system: 'http://smartregister.org/',
169173
code: '34536373-1',
170174
display: 'Value entered on the It is there code',
171175
},
@@ -177,7 +181,7 @@ export const editedCommodity1 = {
177181
code: {
178182
coding: [
179183
{
180-
system: 'http://snomed.info/sct',
184+
system: 'http://smartregister.org/',
181185
code: '45647484',
182186
display: 'Is it in good condition? (optional)',
183187
},
@@ -186,7 +190,7 @@ export const editedCommodity1 = {
186190
valueCodeableConcept: {
187191
coding: [
188192
{
189-
system: 'http://snomed.info/sct',
193+
system: 'http://smartregister.org/',
190194
code: '45647484-1',
191195
display: 'Value entered on the Is it in good condition? (optional)',
192196
},
@@ -198,7 +202,7 @@ export const editedCommodity1 = {
198202
code: {
199203
coding: [
200204
{
201-
system: 'http://snomed.info/sct',
205+
system: 'http://smartregister.org/',
202206
code: '56758595',
203207
display: 'Is it being used appropriately? (optional)',
204208
},
@@ -207,7 +211,7 @@ export const editedCommodity1 = {
207211
valueCodeableConcept: {
208212
coding: [
209213
{
210-
system: 'http://snomed.info/sct',
214+
system: 'http://smartregister.org/',
211215
code: '56758595-1',
212216
display: 'Value entered on the Is it being used appropriately? (optional)',
213217
},
@@ -219,7 +223,7 @@ export const editedCommodity1 = {
219223
code: {
220224
coding: [
221225
{
222-
system: 'http://snomed.info/sct',
226+
system: 'http://smartregister.org/',
223227
code: '67869606',
224228
display: 'Accountability period (in months)',
225229
},
@@ -230,7 +234,7 @@ export const editedCommodity1 = {
230234
{
231235
code: {
232236
coding: [
233-
{ system: 'http://snomed.info/sct', code: '1231415', display: 'Product Image code' },
237+
{ system: 'http://smartregister.org/', code: '1231415', display: 'Product Image code' },
234238
],
235239
},
236240
valueReference: { reference: 'Binary/9b782015-8392-4847-b48c-50c11638656b' },
@@ -267,11 +271,11 @@ export const editedCommodity = {
267271
{
268272
code: {
269273
coding: [
270-
{ system: 'http://snomed.info/sct', code: '767524001', display: 'Unit of measure' },
274+
{ system: 'http://smartregister.org/', code: '767524001', display: 'Unit of measure' },
271275
],
272276
},
273277
valueCodeableConcept: {
274-
coding: [{ system: 'http://snomed.info/sct', code: '767525000', display: 'Unit' }],
278+
coding: [{ system: 'http://smartregister.org/', code: '767525000', display: 'Unit' }],
275279
text: 'Strips',
276280
},
277281
},
@@ -342,7 +346,7 @@ export const createdCommodity = {
342346
code: {
343347
coding: [
344348
{
345-
system: 'http://snomed.info/sct',
349+
system: 'http://smartregister.org/',
346350
code: '67869606',
347351
display: 'Accountability period (in months)',
348352
},
@@ -354,7 +358,7 @@ export const createdCommodity = {
354358
code: {
355359
coding: [
356360
{
357-
system: 'http://snomed.info/sct',
361+
system: 'http://smartregister.org/',
358362
code: '56758595',
359363
display: 'Is it being used appropriately? (optional)',
360364
},
@@ -363,7 +367,7 @@ export const createdCommodity = {
363367
valueCodeableConcept: {
364368
coding: [
365369
{
366-
system: 'http://snomed.info/sct',
370+
system: 'http://smartregister.org/',
367371
code: '56758595-1',
368372
display: 'Value entered on the Is it being used appropriately? (optional)',
369373
},
@@ -375,7 +379,7 @@ export const createdCommodity = {
375379
code: {
376380
coding: [
377381
{
378-
system: 'http://snomed.info/sct',
382+
system: 'http://smartregister.org/',
379383
code: '45647484',
380384
display: 'Is it in good condition? (optional)',
381385
},
@@ -384,7 +388,7 @@ export const createdCommodity = {
384388
valueCodeableConcept: {
385389
coding: [
386390
{
387-
system: 'http://snomed.info/sct',
391+
system: 'http://smartregister.org/',
388392
code: '45647484-1',
389393
display: 'Value entered on the Is it in good condition? (optional)',
390394
},
@@ -395,13 +399,13 @@ export const createdCommodity = {
395399
{
396400
code: {
397401
coding: [
398-
{ system: 'http://snomed.info/sct', code: '34536373', display: 'Is it there code' },
402+
{ system: 'http://smartregister.org/', code: '34536373', display: 'Is it there code' },
399403
],
400404
},
401405
valueCodeableConcept: {
402406
coding: [
403407
{
404-
system: 'http://snomed.info/sct',
408+
system: 'http://smartregister.org/',
405409
code: '34536373-1',
406410
display: 'Value entered on the It is there code',
407411
},
@@ -412,15 +416,19 @@ export const createdCommodity = {
412416
{
413417
code: {
414418
coding: [
415-
{ system: 'http://snomed.info/sct', code: '23435363', display: 'Attractive Item code' },
419+
{
420+
system: 'http://smartregister.org/',
421+
code: '23435363',
422+
display: 'Attractive Item code',
423+
},
416424
],
417425
},
418426
valueBoolean: true,
419427
},
420428
{
421429
code: {
422430
coding: [
423-
{ system: 'http://snomed.info/sct', code: '1231415', display: 'Product Image code' },
431+
{ system: 'http://smartregister.org/', code: '1231415', display: 'Product Image code' },
424432
],
425433
},
426434
valueReference: { reference: 'Binary/9b782015-8392-4847-b48c-50c11638656b' },

packages/fhir-group-management/src/components/CommodityAddEdit/Eusm/utils.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import {
4646
supplyMgSnomedCode,
4747
unitOfMeasureCharacteristicCoding,
4848
unitOfMeasureCharacteristic,
49+
smartRegisterCodeSystem,
4950
} from '../../../helpers/utils';
5051
import { TypeOfGroup } from '../../ProductForm/utils';
5152
import { GroupFormFields } from '../../ProductForm/types';
@@ -350,6 +351,8 @@ export const getGroupFormFields = (obj?: IGroup, binary?: IBinary): EusmGroupFor
350351
const val = getValueFromCharacteristic(characteristic);
351352
formFieldsFromCharacteristics[unitOfMeasure] = val;
352353
}
354+
}
355+
if (codingSystem === smartRegisterCodeSystem) {
353356
if (codingCode === accountabilityCharacteristicCode) {
354357
const val = getValueFromCharacteristic(characteristic);
355358
formFieldsFromCharacteristics[accountabilityPeriod] = val;
@@ -492,8 +495,8 @@ export const generateGroupPayload = async (
492495
code: {
493496
coding: [
494497
{
495-
system: 'http://snomed.info/sct',
496-
code: '1231415',
498+
system: smartRegisterCodeSystem,
499+
code: photoUploadCharacteristicCode,
497500
display: 'Product Image code',
498501
},
499502
],

packages/fhir-group-management/src/components/CommodityList/Eusm/tests/fixtures.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const firstTwentyEusmCommodities = {
5252
code: {
5353
coding: [
5454
{
55-
system: 'http://snomed.info/sct',
55+
system: 'http://smartregister.org/',
5656
code: '23435363',
5757
display: 'Attractive Item code',
5858
},
@@ -64,7 +64,7 @@ export const firstTwentyEusmCommodities = {
6464
code: {
6565
coding: [
6666
{
67-
system: 'http://snomed.info/sct',
67+
system: 'http://smartregister.org/',
6868
code: '34536373',
6969
display: 'Is it there code',
7070
},
@@ -73,7 +73,7 @@ export const firstTwentyEusmCommodities = {
7373
valueCodeableConcept: {
7474
coding: [
7575
{
76-
system: 'http://snomed.info/sct',
76+
system: 'http://smartregister.org/',
7777
code: '34536373-1',
7878
display: 'Value entered on the It is there code',
7979
},
@@ -85,7 +85,7 @@ export const firstTwentyEusmCommodities = {
8585
code: {
8686
coding: [
8787
{
88-
system: 'http://snomed.info/sct',
88+
system: 'http://smartregister.org/',
8989
code: '45647484',
9090
display: 'Is it in good condition? (optional)',
9191
},
@@ -94,7 +94,7 @@ export const firstTwentyEusmCommodities = {
9494
valueCodeableConcept: {
9595
coding: [
9696
{
97-
system: 'http://snomed.info/sct',
97+
system: 'http://smartregister.org/',
9898
code: '45647484-1',
9999
display: 'Value entered on the Is it in good condition? (optional)',
100100
},
@@ -106,7 +106,7 @@ export const firstTwentyEusmCommodities = {
106106
code: {
107107
coding: [
108108
{
109-
system: 'http://snomed.info/sct',
109+
system: 'http://smartregister.org/',
110110
code: '56758595',
111111
display: 'Is it being used appropriately? (optional)',
112112
},
@@ -115,7 +115,7 @@ export const firstTwentyEusmCommodities = {
115115
valueCodeableConcept: {
116116
coding: [
117117
{
118-
system: 'http://snomed.info/sct',
118+
system: 'http://smartregister.org/',
119119
code: '56758595-1',
120120
display: 'Value entered on the Is it being used appropriately? (optional)',
121121
},
@@ -127,7 +127,7 @@ export const firstTwentyEusmCommodities = {
127127
code: {
128128
coding: [
129129
{
130-
system: 'http://snomed.info/sct',
130+
system: 'http://smartregister.org/',
131131
code: '67869606',
132132
display: 'Accountability period (in months)',
133133
},
@@ -141,7 +141,7 @@ export const firstTwentyEusmCommodities = {
141141
code: {
142142
coding: [
143143
{
144-
system: 'http://snomed.info/sct',
144+
system: 'http://smartregister.org/',
145145
code: '1231415',
146146
display: 'Product Image code',
147147
},

0 commit comments

Comments
 (0)