Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post-extraction mapper #199

Merged
merged 5 commits into from
Nov 13, 2023
Merged

Post-extraction mapper #199

merged 5 commits into from
Nov 13, 2023

Conversation

dmendelowitz
Copy link
Contributor

Summary

This PR adds post-extraction filtering by date, which can be enabled in the config file. The user does this by specifying start and end dates and which resource types to filter and the post-extraction filter will only include resources within that range for those resource types.

Currently WIP is adding all the date formats for each resource type since they vary resource to resource, in the current state you can filter Observations and Conditions by date and I can easily expand it for other resource types. In the current state, the date fields to be checked are hard-coded to be the style of date we produce with the CSV extractors, for example Observation could be any of the effectiveX dates, but I made it only check for effectiveDateTime since that is what we produce with the extractor. We could make a new task to create more robust date filtering that checks all possible date formats.

Testing guidance

Add the following to the config file:

"postExtraction": {
    "dateFilter": {
      "startDate": "2019-01-01",
      "endDate": "2019-12-31",
      "resourceTypes": ["Condition", "Observation"]
    }
  },

Running the extractor with this filter should result in the first patient output having no Conditions and only one Observation left

@dmendelowitz dmendelowitz force-pushed the fhir-mapper-filtering branch from a028278 to eab1319 Compare October 30, 2023 13:48
@dmendelowitz dmendelowitz changed the title WIP Post-extraction date filtering Post-extraction mapper Nov 2, 2023
@dmendelowitz
Copy link
Contributor Author

The latest commit changes how a mapper is included as a post-extraction process. Now, if the user includes a mapper.js file in their config folder that exports resourceMapping and variables then it will be included in the app and run as a new AggregateMapper post-extraction.
Here is an example mapper for testing purposes (should exclude patients named "Jane", which is the name of the patient in our first sample bundle output):

const fhirpath = require('fhirpath');
// eslint-disable-next-line camelcase
const fhirpath_r4_model = require('fhirpath/fhir-context/r4');

const resourceMapping = {
  filter: (r) => r.resource.resourceType === 'Patient',
  exclude: (r) => fhirpath.evaluate(r.resource, "name.given = 'Jane'", fhirpath_r4_model)[0],
  exec: (resource) => resource,
};

const variables = {};

module.exports = {
  resourceMapping,
  variables,
};

}
}
},
"dateFilter": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still relevant?

"title": "Post Extraction Processes",
"type": "object",
"properties": {
"dateFilter": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still relevant/correct?

@rdingwell rdingwell merged commit 939155f into main Nov 13, 2023
8 checks passed
@rdingwell rdingwell deleted the fhir-mapper-filtering branch November 13, 2023 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants