Last active
April 16, 2020 14:28
-
-
Save denniskigen/9239df1f92d813dc0f6c1e2fd4c46a78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getDimensionsObservations(patientId: string) { | |
return openmrsObservableFetch( | |
`${fhirConfig.baseUrl}/Observation?subject:Patient=${patientId}&code=${WEIGHT_CONCEPT},${HEIGHT_CONCEPT}` | |
).pipe( | |
map(({ data }) => data["entry"]), | |
map(entries => { | |
if (entries) { | |
const dimensions = entries.map(entry => entry.resource); | |
return { | |
heights: dimensions.filter(dimension => | |
dimension.code.coding.some(sys => sys.code === HEIGHT_CONCEPT) | |
), | |
weights: dimensions.filter(dimension => | |
dimension.code.coding.some(sys => sys.code === WEIGHT_CONCEPT) | |
) | |
}; | |
} | |
}) | |
); | |
} | |
function getDimensionsObservations(patientId: string) { | |
return openmrsObservableFetch( | |
`${fhirConfig.baseUrl}/Observation?subject:Patient=${patientId}&code=${WEIGHT_CONCEPT},${HEIGHT_CONCEPT}` | |
).pipe( | |
map(({ data }) => data["entry"]), | |
map((entries: []) => entries.map(entry => entry.resource)), | |
map(dimensions => { | |
return { | |
heights: dimensions.filter(dimension => | |
dimension.code.coding.some(sys => sys.code === HEIGHT_CONCEPT) | |
), | |
weights: dimensions.filter(dimension => | |
dimension.code.coding.some(sys => sys.code === WEIGHT_CONCEPT) | |
) | |
}; | |
}) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment