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

TRUNK-4144 #546

Closed
wants to merge 13 commits into from
Closed

TRUNK-4144 #546

wants to merge 13 commits into from

Conversation

ningosi
Copy link
Contributor

@ningosi ningosi commented Jan 17, 2014

Initial work done on TRUNK-4144

@dkayiwa
Copy link
Member

dkayiwa commented Jan 20, 2014

Can you also add some unit tests?

* @param conceptSource
* @param withAnyOfTheseTypes
* @param includeRetired
* @since 1.10.x
Copy link
Member

Choose a reason for hiding this comment

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

should be 1.10

@wluyima
Copy link
Member

wluyima commented Jan 21, 2014

/**
* @see org.openmrs.api.ConceptService#getDrugByMapping(String, ConceptSource, Collection, boolean)
*/
public Drug getDrugByMapping(String code, ConceptSource conceptSource, Collection<ConceptMapType> withAnyOfTheseTypesOrOrderOfPreference, boolean includeRetired) throws DAOException;
Copy link
Member

Choose a reason for hiding this comment

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

I think you should typically have one DAO method that returns multiple and then let the code in the ConceptServiceImpl filter out and return a single drug

Copy link
Member

Choose a reason for hiding this comment

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

Having a single DAO method will avoid code duplication in both methods

//get only the ones with these types by looping through the collection of conceptMapTypes
for(ConceptMapType conceptMapType : withAnyOfTheseTypes) {
if(conceptMapType != null) {
searchCriteria.add(Restrictions.eq("conceptMapType", conceptMapType));
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is correct, can you please add unit tests to show that this code is correct? I.e. you can find a drug given a code, source and map types

return null;
}

private Criteria createSearchDrugByMappingCriteria(String code, ConceptSource conceptSource, Collection<ConceptMapType> withAnyOfTheseTypesOrOrderOfPreference, boolean includeRetired) {
Copy link
Member

Choose a reason for hiding this comment

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

The withAnyOfTheseTypesOrOrderOfPreference parameter is never used in this method, probably you should remove it

searchCriteria.createAlias("drugReferenceMaps", "map");
// join to the conceptReferenceTerm table
searchCriteria.createAlias("map.conceptReferenceTerm", "term");
// match the source code to the passed code
Copy link
Member

Choose a reason for hiding this comment

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

you need to check that code is not null

@@ -1193,12 +1197,6 @@ public void changeConceptFromBooleanToCoded_shouldConvertTheDatatypeOfABooleanCo
/**
* @see {@link ConceptService#getConcept(Integer)}
*/
@Test(expected = APIException.class)
Copy link
Member

Choose a reason for hiding this comment

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

Why did you remove this test, i will add it back

@wluyima
Copy link
Member

wluyima commented Feb 7, 2014

Merged at 08c9bc3

@wluyima wluyima closed this Feb 7, 2014
RandilaP pushed a commit to RandilaP/openmrs-core that referenced this pull request Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants