From 57a8bb34bc9e5d2181ba69d2240dbb8513dad0cf Mon Sep 17 00:00:00 2001 From: Buvaneswari Arun Date: Fri, 25 Sep 2020 01:35:06 +0530 Subject: [PATCH] Buvaneswari - BAH 988 - Internationalization of Clinical module - Java changes. Disposition, Drug Order and Lab Order pages --- .../contract/BahmniDisposition.java | 16 +++++++--- .../mapper/BahmniDispositionMapper.java | 12 +++++-- .../service/BahmniDispositionService.java | 6 ++-- .../service/BahmniDispositionServiceImpl.java | 17 +++++----- .../mapper/BahmniDrugOrderMapper.java | 8 +++-- .../laborder/contract/LabOrderResult.java | 32 ++++++++++++++++++- 6 files changed, 71 insertions(+), 20 deletions(-) diff --git a/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/disposition/contract/BahmniDisposition.java b/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/disposition/contract/BahmniDisposition.java index 5e77003ac9..a0a8cbd61e 100644 --- a/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/disposition/contract/BahmniDisposition.java +++ b/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/disposition/contract/BahmniDisposition.java @@ -1,11 +1,9 @@ package org.openmrs.module.bahmniemrapi.disposition.contract; +import org.openmrs.ConceptName; import org.openmrs.module.emrapi.encounter.domain.EncounterTransaction; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; public class BahmniDisposition { private String code; @@ -18,6 +16,16 @@ public class BahmniDisposition { private Date dispositionDateTime; private Set providers = new HashSet<>(); + public String getPreferredName() { + return preferredName; + } + + public void setPreferredName(String preferredName) { + this.preferredName = preferredName; + } + + private String preferredName; + public String getCode() { return code; } diff --git a/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/disposition/mapper/BahmniDispositionMapper.java b/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/disposition/mapper/BahmniDispositionMapper.java index a6af4734c5..7869253992 100644 --- a/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/disposition/mapper/BahmniDispositionMapper.java +++ b/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/disposition/mapper/BahmniDispositionMapper.java @@ -1,16 +1,21 @@ package org.openmrs.module.bahmniemrapi.disposition.mapper; +import org.openmrs.Concept; import org.openmrs.User; +import org.openmrs.api.ConceptService; import org.openmrs.module.bahmniemrapi.disposition.contract.BahmniDisposition; import org.openmrs.module.emrapi.encounter.domain.EncounterTransaction; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.Set; +import java.util.Locale; @Component public class BahmniDispositionMapper { - - public BahmniDisposition map(EncounterTransaction.Disposition disposition, Set providers, User user){ + @Autowired + private ConceptService conceptService; + public BahmniDisposition map(EncounterTransaction.Disposition disposition, Set providers, User user , Locale locale){ BahmniDisposition bahmniDisposition = new BahmniDisposition(); bahmniDisposition.setAdditionalObs(disposition.getAdditionalObs()); bahmniDisposition.setCode(disposition.getCode()); @@ -21,7 +26,8 @@ public BahmniDisposition map(EncounterTransaction.Disposition disposition, Set getDispositionByVisitUuid(String visitUuid); - List getDispositionByVisits(List visits); + List getDispositionByVisitUuid(String visitUuid , Locale locale); + // List getDispositionByVisits(List visits); + List getDispositionByVisits(List visits , Locale locale); } diff --git a/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/disposition/service/BahmniDispositionServiceImpl.java b/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/disposition/service/BahmniDispositionServiceImpl.java index af677d5b7c..fc20add950 100644 --- a/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/disposition/service/BahmniDispositionServiceImpl.java +++ b/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/disposition/service/BahmniDispositionServiceImpl.java @@ -16,6 +16,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.Set; @Service @@ -43,7 +44,7 @@ public BahmniDispositionServiceImpl(VisitService visitService, DispositionMapper } @Override - public List getDispositionByVisitUuid(String visitUuid) { + public List getDispositionByVisitUuid(String visitUuid , Locale locale) { Assert.notNull(visitUuid); Visit visit = visitService.getVisitByUuid(visitUuid); @@ -52,20 +53,20 @@ public List getDispositionByVisitUuid(String visitUuid) { return new ArrayList<>(); } - return getDispositionByVisit(visit); + return getDispositionByVisit(visit, locale); } - public List getDispositionByVisits(List visits){ + public List getDispositionByVisits(List visits , Locale locale){ List dispositions = new ArrayList<>(); for(Visit visit: visits){ - dispositions.addAll(getDispositionByVisit(visit)); + dispositions.addAll(getDispositionByVisit(visit , locale)); } return dispositions; } - private List getDispositionByVisit(Visit visit) { + private List getDispositionByVisit(Visit visit , Locale locale) { List dispositions = new ArrayList<>(); for (Encounter encounter : visit.getEncounters()) { Set observations = encounter.getObsAtTopLevel(false); @@ -73,17 +74,17 @@ private List getDispositionByVisit(Visit visit) { for (Obs observation : observations) { if(ObservationTypeMatcher.ObservationType.DISPOSITION.equals(observationTypeMatcher.getObservationType(observation))){ - addBahmniDisposition(dispositions, eTProvider, observation); + addBahmniDisposition(dispositions, eTProvider, observation , locale); } } } return dispositions; } - private void addBahmniDisposition(List dispositions, Set eTProvider, Obs observation) { + private void addBahmniDisposition(List dispositions, Set eTProvider, Obs observation , Locale locale) { EncounterTransaction.Disposition eTDisposition = dispositionMapper.getDisposition(observation); if(eTDisposition!=null){ - dispositions.add(bahmniDispositionMapper.map(eTDisposition, eTProvider, observation.getCreator())); + dispositions.add(bahmniDispositionMapper.map(eTDisposition, eTProvider, observation.getCreator(),locale)); } } } diff --git a/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/drugorder/mapper/BahmniDrugOrderMapper.java b/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/drugorder/mapper/BahmniDrugOrderMapper.java index 4541a35893..762af763be 100644 --- a/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/drugorder/mapper/BahmniDrugOrderMapper.java +++ b/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/drugorder/mapper/BahmniDrugOrderMapper.java @@ -13,7 +13,7 @@ import java.util.Collection; import java.util.List; import java.util.Map; - +import java.util.Locale; public class BahmniDrugOrderMapper { private BahmniProviderMapper providerMapper; @@ -28,7 +28,8 @@ public BahmniDrugOrderMapper() { public List mapToResponse(List activeDrugOrders, Collection orderAttributeObs, - Map discontinuedOrderMap) throws IOException { + Map discontinuedOrderMap, + String locale) throws IOException { OrderMapper drugOrderMapper = new OrderMapper1_12(); @@ -37,6 +38,9 @@ public List mapToResponse(List activeDrugOrders, for (DrugOrder openMRSDrugOrder : activeDrugOrders) { BahmniDrugOrder bahmniDrugOrder = new BahmniDrugOrder(); bahmniDrugOrder.setDrugOrder(drugOrderMapper.mapDrugOrder(openMRSDrugOrder)); + if(locale != null) { + bahmniDrugOrder.getDrugOrder().getDosingInstructions().setFrequency(openMRSDrugOrder.getFrequency().getConcept().getPreferredName(new Locale((locale))).getName()); + } bahmniDrugOrder.setVisit(openMRSDrugOrder.getEncounter().getVisit()); bahmniDrugOrder.setProvider(providerMapper.map(openMRSDrugOrder.getOrderer())); if(openMRSDrugOrder.getDrug() != null){ diff --git a/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/laborder/contract/LabOrderResult.java b/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/laborder/contract/LabOrderResult.java index 118a85795c..d9eac918bb 100644 --- a/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/laborder/contract/LabOrderResult.java +++ b/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/laborder/contract/LabOrderResult.java @@ -27,6 +27,8 @@ public class LabOrderResult { private Boolean referredOut; private Date resultDateTime; private String uploadedFileName; + private String preferredNameForTestLocale; + private String preferredNameForPanelLocale; public LabOrderResult() { } @@ -46,7 +48,22 @@ public LabOrderResult(String orderUuid, String action, String accessionUuid, Dat this.uploadedFileName = uploadedFileName; this.accessionNotes = accessionNotes; } - + public LabOrderResult(String orderUuid, String action, String accessionUuid, Date accessionDateTime, String testName, String testUnitOfMeasurement, Double minNormal, Double maxNormal, String result, Boolean abnormal, Boolean referredOut, String uploadedFileName, List accessionNotes ,String preferredNameByLocale) { + this.orderUuid = orderUuid; + this.action = action; + this.accessionUuid = accessionUuid; + this.testName = testName; + this.testUnitOfMeasurement = testUnitOfMeasurement; + this.minNormal = minNormal; + this.maxNormal = maxNormal; + this.accessionDateTime = accessionDateTime; + this.result = result; + this.abnormal = abnormal; + this.referredOut = referredOut; + this.uploadedFileName = uploadedFileName; + this.accessionNotes = accessionNotes; + this.preferredNameForTestLocale = preferredNameByLocale; + } public String getOrderUuid() { return orderUuid; } @@ -214,4 +231,17 @@ public String getUploadedFileName() { public void setUploadedFileName(String uploadedFileName) { this.uploadedFileName = uploadedFileName; } + + public String getPreferredNameForTestLocale() { return preferredNameForTestLocale; } + + public void setPreferredNameForTestLocale(String preferredNameForTestLocale) { this.preferredNameForTestLocale = preferredNameForTestLocale; } + + public String getPreferredNameForPanelLocale() { + return preferredNameForPanelLocale; + } + + public void setPreferredNameForPanelLocale(String preferredNameForPanelLocale) { + this.preferredNameForPanelLocale = preferredNameForPanelLocale; + } + }