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

O3-3592 Packaging unit name for a drug item is translated from Englis… #26

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ public Map<Integer, String> getConceptNames(List<Integer> conceptIds) {

public List<ConceptNameDTO> getConceptNamesByConceptIds(List<Integer> ids) {
if (ids == null || ids.isEmpty()) return new ArrayList<>();
Query query = getSession().createQuery("select cc.concept.conceptId as conceptId, cc.name as name from ConceptName cc where cc.concept.conceptId in (:ids) and cc.conceptNameType = (:cnt)")
Query query = getSession().createQuery("select cc.concept.conceptId as conceptId, cc.name as name, cc.locale as locale from ConceptName cc where cc.concept.conceptId in (:ids) and cc.conceptNameType = (:cnt)")
.setParameterList("ids", ids)
.setParameter("cnt", ConceptNameType.FULLY_SPECIFIED);
query = query.setResultTransformer(new AliasToBeanResultTransformer(ConceptNameDTO.class));
Expand Down Expand Up @@ -1395,10 +1395,16 @@ public Result<StockItemPackagingUOMDTO> findStockItemPackagingUOMs(StockItemPack
}
List<ConceptNameDTO> conceptNameDTOs = getConceptNamesByConceptIds(conceptIdsToFetch);
for (StockItemPackagingUOMDTO stockItemPackagingUOMDTO : result.getData()) {
Optional<ConceptNameDTO> conceptNameDTO = conceptNameDTOs.stream().filter(p -> p.getConceptId().equals(stockItemPackagingUOMDTO.getPackagingUomId())).findFirst();
if (conceptNameDTO.isPresent()) {
Optional<ConceptNameDTO> conceptNameDTO = conceptNameDTOs.stream().filter(p -> p.getConceptId().equals(stockItemPackagingUOMDTO.getPackagingUomId())
&& p.getLocale().getDisplayName().equals(Context.getLocale().getDisplayName())).findFirst();
if (conceptNameDTO.isPresent()) {
stockItemPackagingUOMDTO.setPackagingUomName(conceptNameDTO.get().getName());
}
} else {
conceptNameDTO = conceptNameDTOs.stream().filter(p -> p.getConceptId().equals(stockItemPackagingUOMDTO.getPackagingUomId())).findFirst();
if(conceptNameDTO.isPresent()){
stockItemPackagingUOMDTO.setPackagingUomName(conceptNameDTO.get().getName());
}
}
if (filter.includingDispensingUnit() && stockItemPackagingUOMDTO.getStockItemDispensingUnitId() != null) {
conceptNameDTO = conceptNameDTOs.stream().filter(p -> p.getConceptId().equals(stockItemPackagingUOMDTO.getStockItemDispensingUnitId())).findFirst();
if (conceptNameDTO.isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package org.openmrs.module.stockmanagement.api.dto;

import java.util.Locale;

public class ConceptNameDTO {

private Integer conceptId;

private String name;


private Locale locale;

public Integer getConceptId() {
return conceptId;
}
Expand All @@ -21,4 +25,12 @@ public String getName() {
public void setName(String name) {
this.name = name;
}

public Locale getLocale() {
return locale;
}

public void setLocale(Locale locale) {
this.locale = locale;
}
}
Loading