Skip to content

Commit

Permalink
fix(migration): fetch location when id is found during population. Cl…
Browse files Browse the repository at this point in the history
…ean conditions
  • Loading branch information
makelicious committed Oct 8, 2024
1 parent 70abbbc commit e5321e9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
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 @@ -144,14 +144,14 @@ async function updateEventLocationIdOrJurisdictionIds(db: Db, elasticDoc: any) {
''
)

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') {
if (locationDoc[0].type?.coding?.[0]?.code === 'HEALTH_FACILITY') {
body.eventLocationId = locationDoc[0]?.id
} else {
const address = locationDoc[0]?.address
Expand Down

0 comments on commit e5321e9

Please sign in to comment.