Skip to content

Commit

Permalink
Merge master into ipd branch and add disposition locale support
Browse files Browse the repository at this point in the history
  • Loading branch information
kavitha-sundararajan committed Oct 8, 2024
2 parents 8adf760 + a2a062a commit 9254963
Show file tree
Hide file tree
Showing 118 changed files with 2,331 additions and 301 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/build_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ jobs:
run: |
sudo gem install compass -v 1.0.3
- name: Build and deploy with Maven
run: ./mvnw --no-transfer-progress clean -U deploy
run: |
PROJECT_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
if [[ "$PROJECT_VERSION" == *"-SNAPSHOT" ]]; then
./mvnw --no-transfer-progress clean -U deploy
else
echo "❌ The current push is for release. So skipping build."
fi
env:
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
44 changes: 44 additions & 0 deletions .github/workflows/release_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build and Release package
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'

jobs:
build-release-package:
name: Build and Release package
runs-on: macos-14
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
server-id: nexus-sonatype
server-username: NEXUS_USERNAME
server-password: NEXUS_PASSWORD
gpg-private-key: ${{ secrets.BAHMNI_INFRA_GPG_KEY }}
- name: Compare Git tag with Maven version
run: |
export GIT_TAG=${GITHUB_REF#refs/tags/}
PROJECT_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
if [ "$PROJECT_VERSION" != "$GIT_TAG" ]; then
echo "❌ The Git tag ($GIT_TAG) does not match the Maven version ($PROJECT_VERSION)."
exit 1
else
echo "✅ The Git tag matches the Maven version."
fi
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
bundler-cache: true
- name: Install compass
run: |
sudo gem install compass -v 1.0.3
- name: Build and deploy with Maven
run: ./mvnw --no-transfer-progress clean -U deploy -DperformRelease=true
env:
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.BAHMNI_INFRA_GPG_PASSPHRASE }}
2 changes: 1 addition & 1 deletion .github/workflows/validate_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
jobs:
build:
name: Build
runs-on: macos-11
runs-on: macos-14
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ classes/
sass-external
bahmnicore-omod/src/main/webapp/resources/styles/bahmnicore.css
.mvn/wrapper/*.jar
.vscode


# Eclipse project files
.settings
Expand Down
2 changes: 1 addition & 1 deletion admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bahmni</artifactId>
<groupId>org.bahmni.module</groupId>
<version>1.1.0.ipd-SNAPSHOT</version>
<version>1.3.0.ipd-SNAPSHOT</version>
</parent>

<artifactId>admin</artifactId>
Expand Down
8 changes: 7 additions & 1 deletion bahmni-emr-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bahmni</artifactId>
<groupId>org.bahmni.module</groupId>
<version>1.1.0.ipd-SNAPSHOT</version>
<version>1.3.0.ipd-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -68,6 +68,12 @@
<groupId>org.bahmni.module</groupId>
<artifactId>bahmni-commons-api</artifactId>
</dependency>
<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>webservices.rest-omod-common</artifactId>
<version>${openMRSWebServicesVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openmrs.web</groupId>
<artifactId>openmrs-web</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;

import static java.util.stream.Collectors.toList;
Expand All @@ -37,16 +38,21 @@ public class BahmniDiagnosisMetadata {

private EncounterTransactionMapper encounterTransactionMapper;

private Concept getConceptsByNameAndLocale(String name, Locale locale) {
List<Concept> conceptList = conceptService.getConceptsByName(name, locale, false);
return conceptList.isEmpty() ? null : conceptList.get(0);
}

public Concept getBahmniInitialDiagnosisConcept() {
return conceptService.getConceptByName(BAHMNI_INITIAL_DIAGNOSIS);
return getConceptsByNameAndLocale(BAHMNI_INITIAL_DIAGNOSIS, Locale.ENGLISH);
}

public Concept getBahmniDiagnosisRevisedConcept() {
return conceptService.getConceptByName(BAHMNI_DIAGNOSIS_REVISED);
return getConceptsByNameAndLocale(BAHMNI_DIAGNOSIS_REVISED, Locale.ENGLISH);
}

public Concept getBahmniDiagnosisStatusConcept() {
return conceptService.getConceptByName(BAHMNI_DIAGNOSIS_STATUS);
return getConceptsByNameAndLocale(BAHMNI_DIAGNOSIS_STATUS, Locale.ENGLISH);
}

@Autowired
Expand Down Expand Up @@ -179,8 +185,8 @@ public Obs findMatchingDiagnosis(Collection<Obs> observations, BahmniDiagnosis b
private boolean isDiagnosisNotRevised(Obs obs) {
return !obs.getGroupMembers(false).stream()
.anyMatch(groupMember -> {
return groupMember.getConcept().equals(getBahmniDiagnosisRevisedConcept())
&& groupMember.getValueAsBoolean();});
return groupMember.getConcept().equals(getBahmniDiagnosisRevisedConcept())
&& groupMember.getValueAsBoolean();});
}

private boolean isDiagnosisMatching(Obs obs, EncounterTransaction.Diagnosis diagnosis) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
import org.openmrs.Concept;
import org.openmrs.User;
import org.openmrs.api.ConceptService;
import org.openmrs.api.context.Context;
import org.openmrs.module.bahmniemrapi.disposition.contract.BahmniDisposition;
import org.openmrs.module.emrapi.encounter.domain.EncounterTransaction;
import org.openmrs.util.LocaleUtility;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Set;
import java.util.Locale;

Expand All @@ -32,7 +35,13 @@ public BahmniDisposition map(EncounterTransaction.Disposition disposition, Set<E
bahmniDisposition.setProviders(providers);
bahmniDisposition.setCreatorName(user.getPersonName().toString());
Concept concept = conceptService.getConcept(disposition.getConceptName());
if(concept.getPreferredName(locale) != null) {
if (concept == null && !LocaleUtility.getDefaultLocale().equals(locale)) {
List<Concept> conceptsByName = Context.getConceptService().getConceptsByName(disposition.getConceptName(), LocaleUtility.getDefaultLocale(), false);
if (!conceptsByName.isEmpty()) {
concept = conceptsByName.get(0);
}
}
if(concept != null && concept.getPreferredName(locale) != null) {
bahmniDisposition.setPreferredName(concept.getPreferredName(locale).getName());
}
return bahmniDisposition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
//comment

import java.util.Locale;
@Service
public class VisitDocumentServiceImpl implements VisitDocumentService {

Expand Down Expand Up @@ -87,8 +88,13 @@ private void linkDocumentAndImpressionObs(VisitDocumentRequest visitDocumentRequ
}
}

private Concept getConceptsByNameAndLocale(String name, Locale locale) {
List<Concept> conceptList = conceptService.getConceptsByName(name, locale, false);
return conceptList.isEmpty() ? null : conceptList.get(0);
}

private void updateEncounter(Encounter encounter, Date encounterDateTime, List<Document> documents) {
Concept imageConcept = conceptService.getConceptByName(DOCUMENT_OBS_GROUP_CONCEPT_NAME);
Concept imageConcept = getConceptsByNameAndLocale(DOCUMENT_OBS_GROUP_CONCEPT_NAME, Locale.ENGLISH);

for (Document document : documents) {
Concept testConcept = conceptService.getConceptByUuid(document.getTestUuid());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,39 +30,10 @@ public List<BahmniDrugOrder> mapToResponse(List<DrugOrder> activeDrugOrders,
Map<String, DrugOrder> discontinuedOrderMap,
String locale) throws IOException {

OrderMapper1_12 drugOrderMapper = new OrderMapper1_12();

List<BahmniDrugOrder> bahmniDrugOrders = new ArrayList<>();

for (DrugOrder openMRSDrugOrder : activeDrugOrders) {
BahmniDrugOrder bahmniDrugOrder = new BahmniDrugOrder();

bahmniDrugOrder.setDrugOrder(drugOrderMapper.mapDrugOrder(openMRSDrugOrder));
if(locale != null) {
Locale tempLocale = new Locale(locale);
String localeSpecificName = "";
if (openMRSDrugOrder != null) {
localeSpecificName = openMRSDrugOrder.getDrug().getFullName(tempLocale);
bahmniDrugOrder.getDrugOrder().getDrug().setName(localeSpecificName);
}
}

if((locale != null) && (openMRSDrugOrder.getFrequency().getConcept() != null) && (openMRSDrugOrder.getFrequency().getConcept().getPreferredName(new Locale((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){
bahmniDrugOrder.setRetired(openMRSDrugOrder.getDrug().getRetired());
}
bahmniDrugOrder.setEncounterUuid(openMRSDrugOrder.getEncounter().getUuid());

bahmniDrugOrder.setCreatorName(openMRSDrugOrder.getCreator().getPersonName().toString());
if(discontinuedOrderMap.containsKey(openMRSDrugOrder.getOrderNumber())){
bahmniDrugOrder.setOrderReasonText(discontinuedOrderMap.get(openMRSDrugOrder.getOrderNumber()).getOrderReasonNonCoded());
bahmniDrugOrder.setOrderReasonConcept(conceptMapper.map(discontinuedOrderMap.get(openMRSDrugOrder.getOrderNumber()).getOrderReason()));
}

BahmniDrugOrder bahmniDrugOrder = mapDrugOrderToBahmniDrugOrder(openMRSDrugOrder, locale, discontinuedOrderMap);
bahmniDrugOrders.add(bahmniDrugOrder);
}
if(CollectionUtils.isNotEmpty(orderAttributeObs)){
Expand All @@ -71,9 +42,44 @@ public List<BahmniDrugOrder> mapToResponse(List<DrugOrder> activeDrugOrders,
return bahmniDrugOrders;
}

private BahmniDrugOrder mapDrugOrderToBahmniDrugOrder(DrugOrder openMRSDrugOrder, String locale, Map<String, DrugOrder> discontinuedOrderMap) {
OrderMapper1_12 drugOrderMapper = new OrderMapper1_12();
BahmniDrugOrder bahmniDrugOrder = new BahmniDrugOrder();
bahmniDrugOrder.setDrugOrder(drugOrderMapper.mapDrugOrder(openMRSDrugOrder));
if(locale != null) {
Locale tempLocale = new Locale(locale);
String localeSpecificName = "";
if (openMRSDrugOrder != null) {
localeSpecificName = openMRSDrugOrder.getDrug().getFullName(tempLocale);
bahmniDrugOrder.getDrugOrder().getDrug().setName(localeSpecificName);
}
}

if((locale != null) && (openMRSDrugOrder.getFrequency().getConcept() != null) && (openMRSDrugOrder.getFrequency().getConcept().getPreferredName(new Locale((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){
bahmniDrugOrder.setRetired(openMRSDrugOrder.getDrug().getRetired());
}
bahmniDrugOrder.setEncounterUuid(openMRSDrugOrder.getEncounter().getUuid());

bahmniDrugOrder.setCreatorName(openMRSDrugOrder.getCreator().getPersonName().toString());
if(discontinuedOrderMap.containsKey(openMRSDrugOrder.getOrderNumber())){
bahmniDrugOrder.setOrderReasonText(discontinuedOrderMap.get(openMRSDrugOrder.getOrderNumber()).getOrderReasonNonCoded());
bahmniDrugOrder.setOrderReasonConcept(conceptMapper.map(discontinuedOrderMap.get(openMRSDrugOrder.getOrderNumber()).getOrderReason()));
}
return bahmniDrugOrder;
}

public void setMappers(BahmniProviderMapper bahmniProviderMapper, OrderAttributesMapper orderAttributesMapper, ConceptMapper conceptMapper){
providerMapper = bahmniProviderMapper;
this.orderAttributesMapper = orderAttributesMapper;
this.conceptMapper = conceptMapper;
}

public BahmniDrugOrder mapToResponse(DrugOrder drugOrder, Map<String, DrugOrder> discontinuedDrugOrderMap) {
return mapDrugOrderToBahmniDrugOrder(drugOrder, null, discontinuedDrugOrderMap);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class BahmniObservation implements Comparable<BahmniObservation>{
private String interpretation;
private String status;
private String encounterTypeName;
private String conceptFSN;

@JsonIgnore
private Serializable complexData;
Expand Down Expand Up @@ -431,4 +432,12 @@ public String getEncounterTypeName() {
public void setEncounterTypeName(String encounterTypeName) {
this.encounterTypeName = encounterTypeName;
}

public void setConceptFSN(String conceptFSN) {
this.conceptFSN = conceptFSN;
}

public String getConceptFSN() {
return this.conceptFSN;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,25 @@

import org.apache.commons.collections.CollectionUtils;
import org.openmrs.Concept;
import org.openmrs.ConceptName;
import org.openmrs.EncounterProvider;
import org.openmrs.Obs;
import org.openmrs.api.ConceptNameType;
import org.openmrs.module.bahmniemrapi.drugorder.mapper.BahmniProviderMapper;
import org.openmrs.module.bahmniemrapi.encountertransaction.contract.BahmniObservation;
import org.openmrs.module.bahmniemrapi.encountertransaction.mapper.parameters.AdditionalBahmniObservationFields;
import org.openmrs.module.emrapi.encounter.ObservationMapper;
import org.openmrs.module.emrapi.encounter.matcher.ObservationTypeMatcher;
import org.openmrs.module.emrapi.utils.HibernateLazyLoader;
import org.openmrs.util.LocaleUtility;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Locale;

@Component(value = "omrsObsToBahmniObsMapper")
public class OMRSObsToBahmniObsMapper {
Expand All @@ -33,9 +38,10 @@ public OMRSObsToBahmniObsMapper(ETObsToBahmniObsMapper etObsToBahmniObsMapper, O

public Collection<BahmniObservation> map(List<Obs> obsList, Collection<Concept> rootConcepts) {
Collection<BahmniObservation> bahmniObservations = new ArrayList<>();
Locale implementationLocale = LocaleUtility.getDefaultLocale();
for (Obs obs : obsList) {
if(observationTypeMatcher.getObservationType(obs).equals(ObservationTypeMatcher.ObservationType.OBSERVATION)){
BahmniObservation bahmniObservation =map(obs);
BahmniObservation bahmniObservation = map(obs, implementationLocale);
if(CollectionUtils.isNotEmpty(rootConcepts )){
bahmniObservation.setConceptSortWeight(ConceptSortWeightUtil.getSortWeightFor(bahmniObservation.getConcept().getName(), rootConcepts));
}
Expand All @@ -45,7 +51,7 @@ public Collection<BahmniObservation> map(List<Obs> obsList, Collection<Concept>
return bahmniObservations;
}

public BahmniObservation map(Obs obs) {
public BahmniObservation map(Obs obs, Locale implementationLocale) {
if(obs == null)
return null;
String obsGroupUuid = obs.getObsGroup() == null? null : obs.getObsGroup().getUuid();
Expand All @@ -61,6 +67,28 @@ public BahmniObservation map(Obs obs) {
for (EncounterProvider encounterProvider : obs.getEncounter().getEncounterProviders()) {
additionalBahmniObservationFields.addProvider(bahmniProviderMapper.map(encounterProvider.getProvider()));
}
return etObsToBahmniObsMapper.map(observationMapper.map(obs), additionalBahmniObservationFields, Collections.singletonList(obs.getConcept()), true);
BahmniObservation bahmniObservation = etObsToBahmniObsMapper.map(observationMapper.map(obs), additionalBahmniObservationFields, Collections.singletonList(obs.getConcept()), true);
bahmniObservation.setConceptFSN(getConceptFSNInDefaultLocale(obs, implementationLocale));
return bahmniObservation;
}

private String getConceptFSNInDefaultLocale(Obs obs, Locale implementationLocale) {
if (obs.getConcept() == null) {
return null;
}
Concept concept = new HibernateLazyLoader().load(obs.getConcept());
if (implementationLocale == null) {
return concept.getName().getName();
}
ConceptName fsn = concept.getName(implementationLocale, ConceptNameType.FULLY_SPECIFIED, null);
if (fsn == null) {
fsn = concept.getNames().stream().filter(name -> !name.getVoided() && name.getLocale().equals(implementationLocale)
&& name.getConceptNameType().equals(ConceptNameType.FULLY_SPECIFIED)).findFirst().orElse(null);
}
if (fsn != null) {
return fsn.getName();
} else {
return concept.getName().getName();
}
}
}
Loading

0 comments on commit 9254963

Please sign in to comment.