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

AF-59: Extensions should support 'requiredProgram' property #47

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

samuelmale
Copy link
Member

ret.setProgram(programs.get(0));
} else if (programs.size() > 1) {
ret.setProgram(programWithBestWorflowAndStateCombination(programs));
}
Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't do this if statement, I would just keep the shortlist of programs for now.

}
}
if (StringUtils.isNotBlank(workflowRef)) {
List<ProgramWorkflow> workflows = getAllPossibleWorkflows();
Copy link
Member

Choose a reason for hiding this comment

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

Then I would do:

List<ProgramWorkflow> workflows = getAllPossibleWorkflows(programs);

That would give the shortlist of workflows that can work with the shortlist of programs.

Copy link
Member Author

@samuelmale samuelmale Feb 26, 2020

Choose a reason for hiding this comment

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

Hi @mks-d,

Did you intend to pass the programs shortlist as a parameter to the getAllPossibleWorkflows(..) method? If so, I think we had talked about this a couple of months back. Our conclusion was: First of all try getting all the metadata(program, workflow, state) independently. If we encounter an issue, then we fail.

In other-words, we want to look at what was provided as the "workflowRef", try to retrieve whatever object(s) the reference points to from the DB.

We do this for:

  1. Program
  2. Workflow
  3. State

If that operation yields many values for each ie. many programs, we try to get what we called ResolvedConfiguration by trying to get the best program-workflow-state tree. Otherwise we fail.

ret.setWorkflow(workflows.get(0));
} else if (workflows.size() > 1) {
ret.setWorkflow(workflowWithBestProgramAndStateCombination(workflows, ret.getProgram()));
}
Copy link
Member

Choose a reason for hiding this comment

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

So this if would not be needed either, you would just keep going with the shortlist of workflows.

}
}
if (StringUtils.isNotBlank(stateRef)) {
List<ProgramWorkflowState> states = getAllPossibleStates();
Copy link
Member

Choose a reason for hiding this comment

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

Same story:

List<ProgramWorkflowState> states = getAllPossibleStates(workflows);

That would give the shortlist of states that can work with the shortlist of workflows already established.

Copy link
Member Author

Choose a reason for hiding this comment

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

Same case here, getAllPossibleStates(...) should retrieve all possible states independent of the workflows.

Copy link
Member Author

Choose a reason for hiding this comment

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

That would give the shortlist of states that can work with the shortlist of workflows already established.

Actually that was my initial design which we changed. It makes things less complicated

} else if (states.size() > 1) {
ret.setState(stateWithBestProgramAndWorkflowCombination(states, ret.getProgram(), ret.getWorkflow()));
}
}
Copy link
Member

Choose a reason for hiding this comment

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

At this point you have three shortlists:

  • programs
  • workflows (that are working with programs)
  • states (that are working with workflows)

And this is where you need a specialized routine that will take the three shortlists and reduce them to a single final triplet program/workflow/state or throw an IllegalArgumentException if that is not possible from the provided references.

Probably this existing stateWithBestProgramAndWorkflowCombination to be renamed findProgramWorkflowStateTriplet.

@mks-d mks-d self-requested a review March 11, 2020 10:45
if (programs.size() == 1) {
ret.setProgram(programs.get(0));
} else {
throw new APIException("Failed to figure out the intended program identified by: " + programRef);
Copy link
Member

Choose a reason for hiding this comment

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

APIException("Failed to single out one program identified by: " + programRef);

Same kind of message for other entities.

Comment on lines +384 to +399
protected String getPatientUuid(AppContextModel contextModel) {
Bindings bindings = new SimpleBindings();
for (Map.Entry<String, Object> e : contextModel.entrySet()) {
bindings.put(e.getKey(), e.getValue());
}
javascriptEngine.setBindings(bindings, ScriptContext.ENGINE_SCOPE);
try {
String uuid = (String) javascriptEngine.eval("patient.uuid;");
if (StringUtils.isBlank(uuid)) {
throw new APIException("Patient uuid cannot be empty");
}
return uuid;
} catch (ScriptException e) {
throw new APIException("Failed to get patient uuid", e);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Looks like the context model holds direct references to the patient programs. See here. Wouldn't that be enough?

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