Skip to content

Instantly share code, notes, and snippets.

@denniskigen
Last active April 16, 2020 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save denniskigen/9239df1f92d813dc0f6c1e2fd4c46a78 to your computer and use it in GitHub Desktop.
Save denniskigen/9239df1f92d813dc0f6c1e2fd4c46a78 to your computer and use it in GitHub Desktop.
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