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

feat(#138): move polling to openhim channel config #139

Open
wants to merge 7 commits into
base: openmrs-mediator
Choose a base branch
from

Conversation

witash
Copy link
Contributor

@witash witash commented Oct 8, 2024

making PRs against openmrs_mediator instead of just pushing to openmrs_mediator directly, to make review easier

closes #138

Copy link

@njuguna-n njuguna-n left a comment

Choose a reason for hiding this comment

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

Left a few comments and questions

mediator/config/index.ts Outdated Show resolved Hide resolved
export const SYNC_INTERVAL = getEnvironmentVariable('SYNC_INTERVAL', '60000');
//export const SYNC_INTERVAL = getEnvironmentVariable('SYNC_INTERVAL', '60000');
// hard code sync interval to 1 minute because it is hard coded in mediator config
export const SYNC_INTERVAL = '60000';

Choose a reason for hiding this comment

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

Should they always be the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

with the current implementation, yes they should always be the same because the syn uses the sync interval as a workaround to #141

when that is fixed, the code likely won't reference sync interval anywhere

export async function sync() {
try {
const startTime = new Date();
startTime.setHours(startTime.getHours() - 1);

Choose a reason for hiding this comment

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

Why set start time to an hour ago?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One hour was supposed to be form how long ago the sync should look for new resources. But it should be configureable, I have added an environment vairable SYNC_PERIOD for this instead.

mediator/src/controllers/openmrs.ts Show resolved Hide resolved
Copy link
Contributor

@lorerod lorerod left a comment

Choose a reason for hiding this comment

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

Thanks, @witash, for this work. I left some suggestions inline.

Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about adding GET /sync route unit tests? While the code is simple, ensuring the route behaves as expected in both success and failure scenarios is a good idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added src/routes/test/openmrs.sync.test with simple success and failure tests, if/when the sync returns more data, we can add more test conditions.

mediator/src/controllers/openmrs.ts Show resolved Hide resolved
Copy link

@njuguna-n njuguna-n left a comment

Choose a reason for hiding this comment

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

Added a few suggestions. There is also a Sonar failure that should be fixed.

export const SYNC_INTERVAL = getEnvironmentVariable('SYNC_INTERVAL', '60000');
// hard code sync interval to 1 minute because it is hard coded in mediator config
export const SYNC_INTERVAL = '60';
// how far back shoudl the sync look for new resources

Choose a reason for hiding this comment

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

Adding the default sync period to the comment in a human-readable manner would be helpful. e.g. How far back should the sync look for new resources. Defaults to 1 hour.

@@ -21,11 +21,12 @@ const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));

/*

Choose a reason for hiding this comment

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

Remove this code rather than commenting it out.


//Create a patient using openMRS api

/*const retrieveFhirPatientIdResponse = await request(FHIR.url)

Choose a reason for hiding this comment

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

Let's replace this commented out code with a TODO.

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.

3 participants