Skip to content

Commit

Permalink
Merge branch 'develop' into ocrvs-7055-hide-pre-postfix-with-no-value
Browse files Browse the repository at this point in the history
  • Loading branch information
tumbledwyer authored Sep 30, 2024
2 parents 9de65b6 + 41c7dac commit 14d3091
Show file tree
Hide file tree
Showing 13 changed files with 1,955 additions and 924 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/build-images-from-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ jobs:
cache-to: type=inline

- name: Run Trivy vulnerability scanner
uses: aquasecurity/[email protected]
# Skip temporarily for non-develop branches because of
# a TOOMANYREQUESTS error failing the check
# https://github.com/aquasecurity/trivy/discussions/7591
if: ${{ needs.base.outputs.branch == 'develop' }}
uses: aquasecurity/[email protected]
with:
image-ref: 'opencrvs/ocrvs-${{ matrix.service }}:${{ needs.base.outputs.version }}'
trivy-config: trivy.yaml
2 changes: 1 addition & 1 deletion .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner in fs mode
uses: aquasecurity/trivy-action@0.23.0
uses: aquasecurity/trivy-action@0.24.0
with:
scan-type: 'fs'
scan-ref: '.'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
.trivyignore.yaml
sparse-checkout-cone-mode: false
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@0.23.0
uses: aquasecurity/trivy-action@0.24.0
with:
image-ref: 'opencrvs/ocrvs-${{ matrix.service }}:${{ needs.base.outputs.version }}'
trivy-config: trivy.yaml
11 changes: 8 additions & 3 deletions .github/workflows/storybook-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,18 @@ jobs:
run: cd packages/components && yarn build-storybook

- name: Deploy Storybook to Cloudflare Pages
run: npx wrangler pages deploy ./packages/components/build --project-name opencrvs --branch ${{ env.PR_BRANCH }}
id: deploy_storybook
run: |
DEPLOY_OUTPUT=$(npx wrangler pages deploy ./packages/components/build --project-name opencrvs --branch ${{ env.PR_BRANCH }})
echo "$DEPLOY_OUTPUT"
DEPLOY_URL=$(echo "$DEPLOY_OUTPUT" | grep -o 'https://.*.dev' | tail -n 1)
echo "storybook_url=$DEPLOY_URL" >> $GITHUB_OUTPUT
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}

- name: Comment on PR with Storybook link
run: |
COMMENT="Storybook deployed: https://${{ env.PR_BRANCH }}.opencrvs.pages.dev"
COMMENT="Storybook deployed: ${{ steps.deploy_storybook.outputs.storybook_url }}"
gh pr comment ${{ github.event.issue.number }} --body "$COMMENT"
env:
GITHUB_TOKEN: ${{ secrets.OLLIE_BOT_GITHUB_TOKEN }}
10 changes: 10 additions & 0 deletions .trivyignore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,13 @@ vulnerabilities:
statement: Transitive dependency of lint-staged, jest and msw. Not running in production. Likely fixed by upgrading.
- id: CVE-2024-37890
statement: ws vulnerability, transitive dependency of jest, storybook, graphql-codegen, not running in production.
- id: CVE-2024-45296
statement: Transitive dependency of react-router 5.3.4. Only affects client-side code ocrvs-7682
- id: CVE-2024-47068
statement: Transitive dependency of Vite. Not run in production and there is currently no fix.
- id: CVE-2024-7254
statement: Metabase v0.46 vulnerability, fixed in Metabase v0.50 ocrvs-6607
- id: CVE-2024-41909
statement: Metabase v0.46 vulnerability, fixed in Metabase v0.50 ocrvs-6607
- id: CVE-2024-22871
statement: Metabase v0.46 vulnerability, fixed in Metabase v0.50 ocrvs-6607
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

## Bug fixes

- TBC
- Fix health facilities missing from dropdown after correcting a record address [#7528](https://github.com/opencrvs/opencrvs-core/issues/7528)

## 1.6.0 Release candidate

Expand Down
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"sanitize-html": "^2.4.0",
"styled-components": "^5.2.0",
"tsconfig-paths": "^3.13.0",
"vite": "^5.0.0",
"vite": "^5.4.8",
"vite-plugin-svgr": "^0.6.0",
"vite-tsconfig-paths": "^3.5.0",
"webfontloader": "^1.6.28",
Expand Down
4 changes: 4 additions & 0 deletions packages/commons/src/fhir/location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,7 @@ export function isHealthFacility(
): location is HealthFacility {
return location.type?.coding?.[0].code === 'HEALTH_FACILITY'
}

export function getLocationType(location: Location): string | undefined {
return location.type?.coding?.[0].code
}
131 changes: 130 additions & 1 deletion packages/commons/src/fhir/transformers/fhir-builders.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,19 @@ import {
findExtension,
isTask,
taskBundleWithExtension,
updateFHIRTaskBundle
updateFHIRTaskBundle,
updateFHIRBundle,
Bundle,
Location,
Encounter,
BundleEntry,
getLocationType
} from '..'

import * as fetchMock from 'jest-fetch-mock'

import { DeathRegistration } from './input'
import { UUID } from 'src/uuid'

const fetch = fetchMock as fetchMock.FetchMock

Expand Down Expand Up @@ -445,3 +452,125 @@ describe('taskBundleWithExtension()', () => {
)
})
})

describe('updateFhirBundle', () => {
describe('when the type of a location is changed from HEALTH_FACILITY to another type', () => {
const facilityId = 'TestFacility1'
const encounterId = 'Encounter1'

const bundle = {
resourceType: 'Bundle',
type: 'document',
entry: [
{
resource: {
resourceType: 'Composition',
title: 'Birth Declaration',
section: [
{
title: 'Birth encounter',
code: {
coding: [
{
system: 'http://opencrvs.org/specs/sections',
code: 'birth-encounter'
}
],
text: 'Birth encounter'
},
entry: [
{
reference: `Encounter/${encounterId}`
}
]
}
],
id: 'Composition1'
}
},
{
resource: {
resourceType: 'Encounter',
status: 'finished',
id: encounterId as UUID,
location: [
{
location: {
reference: `Location/${facilityId}` as ResourceIdentifier
}
}
]
}
} as BundleEntry<Encounter>,
{
resource: {
resourceType: 'Location',
name: 'My Test Facility',
type: {
coding: [
{
system: 'http://opencrvs.org/specs/location-type',
code: 'HEALTH_FACILITY'
}
]
},
id: facilityId
}
}
]
} as Bundle

const updatedBundle = updateFHIRBundle(
bundle,
{
eventLocation: {
address: {
country: 'FAR',
state: 'State1',
district: 'District1',
city: 'City1',
postalCode: 'Code1',
line: ['line1', 'line2', 'line3', 'line4'],
partOf: 'Dictrict1'
},
type: 'PRIVATE_HOME'
}
},
'BIRTH' as EVENT_TYPE
)

const encounter = updatedBundle.entry.find(
(e) => e.resource.resourceType === 'Encounter'
) as BundleEntry<Encounter>

const encounterLocationreference =
encounter.resource.location![0].location?.reference

const originalFacility = updatedBundle.entry.find(
(e) => e.resource.id === facilityId
)! as BundleEntry<Location>

const newLocation = updatedBundle.entry.find(
(e) =>
e.resource.resourceType === 'Location' && e.resource.id !== facilityId
) as BundleEntry<Location>

const locations = updatedBundle.entry.filter(
(entry) => entry.resource.resourceType === 'Location'
)

it('should create a new location', () => {
expect(locations.length).toEqual(2)
expect(encounterLocationreference).toEqual(newLocation.fullUrl)
expect(getLocationType(newLocation.resource)).toEqual('PRIVATE_HOME')
expect(newLocation.resource.address).not.toBeUndefined()
})

it('should not edit the original facility', () => {
expect(getLocationType(originalFacility.resource)).toEqual(
'HEALTH_FACILITY'
)
expect(originalFacility.resource.address).toBeUndefined()
})
})
})
31 changes: 22 additions & 9 deletions packages/commons/src/fhir/transformers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ import {
findEntryFromBundle
} from '..'

import { CompositionSectionTitleByCode, PartialBy } from '../../types'
import {
CompositionSectionTitleByCode,
isHealthFacility,
PartialBy
} from '../../types'
import {
DOWNLOADED_EXTENSION_URL,
EVENT_TYPE,
Expand Down Expand Up @@ -333,14 +337,7 @@ export function selectOrCreateLocationRefResource(

if (!encounter.location) {
// create location
const locationRef = getUUID()
const locationEntry = createLocationResource(locationRef)
fhirBundle.entry.push(locationEntry)
encounter.location = []
encounter.location.push({
location: { reference: `urn:uuid:${locationRef}` as URNReference }
})
return locationEntry.resource
return createNewLocation(fhirBundle, encounter)
}

if (!encounter.location || !encounter.location[0]) {
Expand All @@ -358,6 +355,22 @@ export function selectOrCreateLocationRefResource(
'Location referenced from encounter section not found in FHIR bundle'
)
}

if (isHealthFacility(locationEntry.resource)) {
return createNewLocation(fhirBundle, encounter)
}

return locationEntry.resource
}

function createNewLocation(fhirBundle: Bundle, encounter: Encounter): Location {
const locationRef = getUUID()
const locationEntry = createLocationResource(locationRef)
fhirBundle.entry.push(locationEntry)
encounter.location = []
encounter.location.push({
location: { reference: `urn:uuid:${locationRef}` as URNReference }
})
return locationEntry.resource
}

Expand Down
6 changes: 0 additions & 6 deletions packages/components/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ import type { StorybookConfig } from '@storybook/react-vite'
const viteFinal = async (config: Record<string, any>) => {
// return the customized config
return mergeConfig(config, {
// customize the Vite config here
resolve: {
alias: {
crypto: 'crypto-js'
}
},
build: {
minify: false,
sourcemap: false
Expand Down
24 changes: 12 additions & 12 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "MPL-2.0",
"private": true,
"dependencies": {
"@storybook/core-server": "^7.0.2",
"@storybook/core-server": "^7.6.17",
"css-animation": "^2.0.4",
"jest": "27.5.1",
"patch-package": "^6.1.2",
Expand Down Expand Up @@ -47,16 +47,16 @@
]
},
"devDependencies": {
"@storybook/addon-a11y": "^7.0.2",
"@storybook/addon-actions": "^7.0.2",
"@storybook/addon-docs": "^7.0.2",
"@storybook/addon-essentials": "^7.0.2",
"@storybook/addon-links": "^7.0.2",
"@storybook/manager-api": "^7.0.2",
"@storybook/node-logger": "^7.0.2",
"@storybook/react": "^7.0.2",
"@storybook/react-vite": "^7.0.2",
"@storybook/theming": "^7.0.2",
"@storybook/addon-a11y": "^7.6.17",
"@storybook/addon-actions": "^7.6.17",
"@storybook/addon-docs": "^7.6.17",
"@storybook/addon-essentials": "^7.6.17",
"@storybook/addon-links": "^7.6.17",
"@storybook/manager-api": "^7.6.17",
"@storybook/node-logger": "^7.6.17",
"@storybook/react": "^7.6.17",
"@storybook/react-vite": "^7.6.17",
"@storybook/theming": "^7.6.17",
"@types/jest": "^26.0.14",
"@types/lodash": "^4.14.126",
"@types/node": "^10.12.5",
Expand All @@ -76,7 +76,7 @@
"lint-staged": "^15.0.0",
"prettier": "2.8.8",
"rimraf": "^5.0.0",
"storybook": "^7.0.2",
"storybook": "^7.6.17",
"stylelint": "^14.11.0",
"stylelint-config-recommended": "^9.0.0",
"stylelint-config-styled-components": "^0.1.1",
Expand Down
Loading

0 comments on commit 14d3091

Please sign in to comment.