diff --git a/packages/fhir-location-management/src/components/LocationForm/utils.ts b/packages/fhir-location-management/src/components/LocationForm/utils.ts index d805d5e4b..26e85d623 100644 --- a/packages/fhir-location-management/src/components/LocationForm/utils.ts +++ b/packages/fhir-location-management/src/components/LocationForm/utils.ts @@ -64,40 +64,48 @@ export const getLocationFormFields = ( location?: ILocation, parentId?: string ): LocationFormFields => { - if(location){ + if (location) { const { position, extension, physicalType, name, status, type } = location; - // TODO - magic string - const geoJsonExtension = getObjLike(extension, 'url', locationGeoJsonExtensionUrl)[0] as Extension | undefined; + + const geoJsonExtension = getObjLike( + extension, + 'url', + locationGeoJsonExtensionUrl + )[0] as Extension | undefined; const geoJsonAttachment = geoJsonExtension?.valueAttachment?.data; let geometryGeoJSon; if (geoJsonAttachment) { // try and parse into an object. geometryGeoJSon = atob(geoJsonAttachment); } - + const physicalTypeCoding = getObjLike( physicalType?.coding ?? [], 'system', physicalTypeValueSetSystem )[0] as Coding | undefined; - const servicePointTypeCodings = type?.flatMap(concept => concept.coding ?? []) - const serviceTypeCode = getObjLike(servicePointTypeCodings, "system", eusmServicePointCodeSystemUri)?.[0] - + const servicePointTypeCodings = type?.flatMap((concept) => concept.coding ?? []); + const serviceTypeCode = getObjLike( + servicePointTypeCodings, + 'system', + eusmServicePointCodeSystemUri + )[0] as Coding | undefined; + return { ...defaultFormFields, initObj: location, - isJurisdiction: physicalTypeCoding?.code !== "bu", + isJurisdiction: physicalTypeCoding?.code !== 'bu', name, status, geometry: geometryGeoJSon, - parentId: parentId ?? location?.partOf?.reference, + parentId: parentId ?? location.partOf?.reference, latitude: position?.latitude, longitude: position?.longitude, serviceType: serviceTypeCode ? JSON.stringify(servicePointTypeCodings) : undefined, } as LocationFormFields; } - return defaultFormFields + return defaultFormFields; }; // TODO - dry out fhir-helpers diff --git a/packages/fhir-location-management/src/components/ViewDetails/DetailsTabs/Inventory.tsx b/packages/fhir-location-management/src/components/ViewDetails/DetailsTabs/Inventory.tsx index 8dc0e98ea..4c97bf0a3 100644 --- a/packages/fhir-location-management/src/components/ViewDetails/DetailsTabs/Inventory.tsx +++ b/packages/fhir-location-management/src/components/ViewDetails/DetailsTabs/Inventory.tsx @@ -80,12 +80,12 @@ function parseInventoryGroup(group: IGroup) { return { id, productReference, - quantity: quantityCharacteristic.valueQuantity?.value, + quantity: quantityCharacteristic?.valueQuantity?.value, poNumber: poNumberIdentifier?.[0]?.value, deliveryDate: sanitizeDate(startDate), accountabilityEndDate: sanitizeDate(endDate), - unicefSection: sectionCharacteristic.valueCodeableConcept?.text, - donor: donorCharacteristic.valueCodeableConcept?.text, + unicefSection: sectionCharacteristic?.valueCodeableConcept?.text, + donor: donorCharacteristic?.valueCodeableConcept?.text, serialNumber: serialNumberIdentifier?.[0]?.value, }; }