Skip to content

Commit

Permalink
Merge branch 'develop' into ocrvs-993
Browse files Browse the repository at this point in the history
  • Loading branch information
noah-brunate authored Oct 8, 2024
2 parents 95964ee + 4480507 commit 94d0165
Show file tree
Hide file tree
Showing 17 changed files with 74 additions and 75 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/trigger-e2e-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ jobs:
.trim()
.replace(/\s+/g, '-')
.replace(/-+/g, '-')
.substr(0, 35);
.substr(0, 35)
.replace(/[^a-zA-Z0-9]+$/g, '');
}
const result = await github.rest.repos.createDispatchEvent({
owner: 'opencrvs',
Expand Down
44 changes: 13 additions & 31 deletions packages/client/src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,14 @@ import { constantsMessages } from '@client/i18n/messages'
import { messages } from '@client/i18n/messages/views/header'
import { Icon } from '@opencrvs/components/lib/Icon'
import {
goBack,
goForward,
goToEvents as goToEventsAction,
goToPerformanceHome,
goToSearch,
goToSearchResult,
goToSettings,
goToTeamSearch,
goToTeamUserList,
goToCreateNewUserWithLocationId,
goToCreateNewUser,
goToAdvancedSearch
} from '@client/navigation'
import { redirectToAuthentication } from '@client/profile/profileActions'
import { getUserDetails } from '@client/profile/profileSelectors'
import { IStoreState } from '@client/store'
import styled from 'styled-components'
Expand Down Expand Up @@ -68,19 +62,12 @@ type IStateProps = {
}

type IDispatchProps = {
redirectToAuthentication: typeof redirectToAuthentication
goToSearchResult: typeof goToSearchResult
goToEvents: typeof goToEventsAction
goToSearch: typeof goToSearch
goToSettings: typeof goToSettings
goBack: typeof goBack
goForward: typeof goForward
goToPerformanceHomeAction: typeof goToPerformanceHome
goToCreateNewUserWithLocationId: typeof goToCreateNewUserWithLocationId
goToCreateNewUser: typeof goToCreateNewUser
goToTeamSearchAction: typeof goToTeamSearch
goToTeamUserListAction: typeof goToTeamUserList
goToAdvancedSearch: typeof goToAdvancedSearch
goToSearchResult: typeof goToSearchResult
setAdvancedSearchParam: typeof setAdvancedSearchParam
}

Expand Down Expand Up @@ -147,20 +134,23 @@ const USERS_WITHOUT_SEARCH = SYS_ADMIN_ROLES.concat(
export const HeaderComponent = (props: IFullProps) => {
const {
location,
mapPerformanceClickHandler,
goToCreateNewUserWithLocationId,
changeTeamLocation,
goToCreateNewUser,
userDetails,
mobileSearchBar,
goToSearch,
offlineData,
className,
intl,
activeMenuItem,
title,
mobileRight,
goToEvents
goToSearch,
goToEvents,
goToCreateNewUserWithLocationId,
goToCreateNewUser,
goToAdvancedSearch,
goToSearchResult,
setAdvancedSearchParam,
mapPerformanceClickHandler,
changeTeamLocation
} = props

const getMobileHeaderActionProps = (activeMenuItem: ACTIVE_MENU_ITEM) => {
Expand Down Expand Up @@ -365,9 +355,7 @@ export const HeaderComponent = (props: IFullProps) => {
? undefined
: navigationList
}
searchHandler={(text, type) =>
props.goToSearchResult(text, type, isMobile)
}
searchHandler={(text, type) => goToSearchResult(text, type, isMobile)}
/>
)
}
Expand Down Expand Up @@ -492,20 +480,14 @@ export const Header = connect(
.map((field) => field.name)
}),
{
redirectToAuthentication,
goToSearchResult,
goToSearch,
goToSettings,
goBack,
goForward,
goToEvents: goToEventsAction,
goToPerformanceHomeAction: goToPerformanceHome,
goToCreateNewUserWithLocationId,
goToCreateNewUser,
goToTeamSearchAction: goToTeamSearch,
goToTeamUserListAction: goToTeamUserList,
goToAdvancedSearch: goToAdvancedSearch,
setAdvancedSearchParam: setAdvancedSearchParam
setAdvancedSearchParam: setAdvancedSearchParam,
goToSearchResult
}
)(injectIntl(withRouter(HeaderComponent)))

Expand Down
3 changes: 2 additions & 1 deletion packages/client/src/views/RegisterForm/RegisterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,8 @@ class RegisterFormView extends React.Component<FullProps, State> {
const { declaration } = this.props
const informantTypeChanged =
prevProps.declaration?.data?.informant?.informantType !==
declaration?.data?.informant?.informantType
declaration?.data?.informant?.informantType &&
Boolean(declaration?.data?.informant?.informantType)

// see https://github.com/opencrvs/opencrvs-core/issues/5820
if (informantTypeChanged) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ class ReviewSectionComp extends React.Component<FullProps, State> {
<RequiredField id={`required_label_${section.id}_${field.name}`}>
{field.ignoreFieldLabelOnErrorMessage ||
(field.previewGroup &&
this.props.intl.formatMessage(field.label) + ' ')}
this.props.intl.formatMessage(field.label, field.labelParam) + ' ')}
{this.props.intl.formatMessage(
errorsOnField.message,
errorsOnField.props
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async function getCompositionIdToStartedByMap(
if (startedByMap.has(compositionId)) return
startedByMap.set(
compositionId,
extractId(task.extension[0].valueReference.reference)
extractId(task.extension[0]?.valueReference.reference)
)
})
return startedByMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const up = async (db: Db, client: MongoClient) => {
const immediatePrevComp = compositionHistory[correctionIndex - 1]
const hasDocumentSection = immediatePrevComp?.section?.find(
(section: fhir.CompositionSection) =>
section?.code?.coding?.[0].code === 'supporting-documents'
section?.code?.coding?.[0]?.code === 'supporting-documents'
)
if (hasDocumentSection) {
await db
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async function migrateRegistrations(measurement: string, db: Db) {

await writePoints(updatedPoints)

const startTime = registrations[0].time?.getNanoTime()
const startTime = registrations[0]?.time?.getNanoTime()
const endTime = registrations[registrations.length - 1].time?.getNanoTime()

const deleteQuery = `DELETE FROM ${measurement} WHERE registrarPractitionerId = '' AND time >= ${startTime} AND time <= ${endTime}`
Expand Down Expand Up @@ -110,7 +110,7 @@ const getUpdatedPoints = async (
)
}

let id: string = ''
let id = ''
if (
practitionerExtension &&
practitionerExtension.valueReference &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const up = async (db: Db, client: MongoClient) => {
const body = {}
const compositionDoc =
(await compositionCursor.next()) as unknown as fhir.Composition

await setInformantDeceasedAndLocationDetails(db, body, compositionDoc)
}
skip += limit
Expand Down Expand Up @@ -157,16 +158,18 @@ async function setInformantDeceasedAndLocationDetails(
)

if (encounterDoc.length > 0) {
const locationId = encounterDoc[0].location[0].location.reference.replace(
'Location/',
''
)
const locationId =
encounterDoc[0]?.location?.[0]?.location?.reference?.replace(
'Location/',
''
)

const locationDoc = locationId
? await getCollectionDocuments(db, COLLECTION_NAMES.LOCATION, [
locationId
])
: []

const locationDoc = await getCollectionDocuments(
db,
COLLECTION_NAMES.LOCATION,
[locationId]
)
if (locationDoc.length > 0) {
const address: fhir.Address = locationDoc[0].address
if (address) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const up = async (db: Db, client: MongoClient) => {
)
while (await documentCursor.hasNext()) {
const document = await documentCursor.next()
const fileData = document?.content[0].attachment.data
const fileData = document?.content?.[0]?.attachment?.data
if (fileData && isBase64FileString(fileData)) {
const refUrl = await uploadBase64ToMinio(fileData)
if (refUrl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ export const up = async (db: Db, client: MongoClient) => {

if (hasSystemTypes) {
const typeCode = practitionerRole.code?.find(
(c) => c.coding?.[0].system === systemTypes
)?.coding?.[0].code
(c) => c.coding?.[0]?.system === systemTypes
)?.coding?.[0]?.code
await db
.collection('PractitionerRole')
.updateOne(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,9 @@ export const up = async (db: Db, client: MongoClient) => {
$project: {
_id: { $concat: [{ $toString: '$id' }, '_', '$daysInYear.date'] },
name: 1,
date: { $dateFromString: { dateString: '$daysInYear.date' } },
date: {
$dateFromString: { dateString: '$daysInYear.date' }
},
estimatedNumberOfBirths: '$daysInYear.estimatedNumberOfBirths',
event: 'Birth'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ export const up = async (db: Db, client: MongoClient) => {
const searchResult = await searchByCompositionId(compositionId)

const operationHistoriesData =
searchResult &&
searchResult.body.hits.hits.length > 0 &&
searchResult.body.hits.hits[0]._source?.operationHistories
searchResult?.body?.hits?.hits?.[0]?._source?.operationHistories
const lastOperationHistory =
operationHistoriesData &&
operationHistoriesData.length > 0 &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,22 +138,24 @@ async function updateEventLocationIdOrJurisdictionIds(db: Db, elasticDoc: any) {
)

if (encounterDoc.length > 0) {
const locationId = encounterDoc[0].location[0].location.reference.replace(
'Location/',
''
)
const locationId =
encounterDoc[0]?.location?.[0]?.location?.reference?.replace(
'Location/',
''
)

const locationDoc = await getCollectionDocuments(
db,
COLLECTION_NAMES.LOCATION,
[locationId]
)
const locationDoc = locationId
? await getCollectionDocuments(db, COLLECTION_NAMES.LOCATION, [
locationId
])
: []

if (locationDoc.length > 0) {
if (locationDoc[0].type.coding[0].code === 'HEALTH_FACILITY') {
body.eventLocationId = locationDoc[0].id
const firstLocationDoc = locationDoc[0]
if (firstLocationDoc.type?.coding?.[0]?.code === 'HEALTH_FACILITY') {
body.eventLocationId = firstLocationDoc.id
} else {
const address = locationDoc[0].address
const address = firstLocationDoc.address
if (address) {
const eventJurisdictionIds: string[] = []
address.state && eventJurisdictionIds.push(address.state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const up = async (db: Db, client: MongoClient) => {
})
let processed = 0
for await (const patient of patientIterator) {
const age = parseInt(patient.extension[0].valueString, 10)
const age = parseInt(patient.extension?.[0]?.valueString, 10)
const birthDate = subYears(new Date(patient.deceasedDateTime), age)
db.collection('Patient').updateOne(
{ id: patient.id },
Expand Down
7 changes: 5 additions & 2 deletions packages/notification/src/features/sentForUpdates/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { sendNotification } from '@notification/features/sms/utils'
import { messageKeys } from '@notification/i18n/messages'
import {
getOfficeName,
getPersonName,
getRegistrationLocation
} from '@notification/features/utils'
import {
Expand Down Expand Up @@ -41,7 +42,8 @@ export async function birthSentForUpdatesNotification(
trackingId: getTrackingId(rejectedRecord),
crvsOffice: getOfficeName(rejectedRecord),
registrationLocation: getRegistrationLocation(rejectedRecord),
informantName: getInformantName(rejectedRecord)
informantName: getInformantName(rejectedRecord),
name: getPersonName(rejectedRecord, 'child')
}
)
return h.response().code(200)
Expand All @@ -66,7 +68,8 @@ export async function deathSentForUpdatesNotification(
trackingId: getTrackingId(rejectedRecord),
crvsOffice: getOfficeName(rejectedRecord),
registrationLocation: getRegistrationLocation(rejectedRecord),
informantName: getInformantName(rejectedRecord)
informantName: getInformantName(rejectedRecord),
name: getPersonName(rejectedRecord, 'deceased')
}
)
return h.response().code(200)
Expand Down
7 changes: 4 additions & 3 deletions packages/notification/src/features/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function getContactEmail(
}

function error(
record: ReadyForReviewRecord | RegisteredRecord,
record: ReadyForReviewRecord | RegisteredRecord | RejectedRecord,
message: string
): never {
const task = getTaskFromSavedBundle(record)
Expand Down Expand Up @@ -97,7 +97,7 @@ export function getInformantName(
}

export function getPersonName(
record: ReadyForReviewRecord | RegisteredRecord,
record: ReadyForReviewRecord | RegisteredRecord | RejectedRecord,
personType: 'deceased' | 'child'
) {
const compositionCode: Extract<
Expand All @@ -117,7 +117,8 @@ export function getPersonName(
if (!name) {
error(record, `name not found in patient resource for ${compositionCode}`)
}
return [name.given?.join(' '), name.family].join(' ').trim()
// the trim used in given name handles the case when a country does not have middlename
return [name.given?.join(' ').trim(), name.family].join(' ').trim()
}

export function getRegistrationLocation(
Expand Down
12 changes: 9 additions & 3 deletions packages/search/src/features/reindex/reindex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export const reindex = async () => {
}
})

const droppedCompositionIds: string[] = []

await client.helpers.bulk(
{
retries: 3,
Expand All @@ -74,22 +76,26 @@ export const reindex = async () => {
}
}),
onDrop(doc) {
throw new Error(
`Document ${doc.document.compositionId} couldn't be inserted`
)
droppedCompositionIds.push(doc.document.compositionId)
}
},
{
meta: true
}
)

const t2 = performance.now()
logger.info(
`Finished reindexing to ${index} in ${((t2 - t1) / 1000).toFixed(
2
)} seconds`
)

if (droppedCompositionIds.length) {
logger.error(`Could not index ${droppedCompositionIds.length} document(s)`)
logger.error(droppedCompositionIds.join(', '))
}

return { index }
}

Expand Down

0 comments on commit 94d0165

Please sign in to comment.