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

Kavitha | Upgrade module and API fixes for default locale #277

Merged
merged 47 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
c7199cf
Incrementing development version to 1.2.0-SNAPSHOT (#220)
sivareddyp Jul 12, 2023
4258998
Siva Reddy | Removing Packaging of lombok dependency (#211)
sivareddyp Jul 12, 2023
0aa4001
BS-91 | Merge snomed-master to product master (#212)
sivareddyp Jul 12, 2023
0336ce0
BAH-3079 | add. medications tagged as inpatient to be fetched in acti…
Arjun-Go Jul 13, 2023
e07f387
BAH-3110 | Upgrade OpenMRS version to 2.5.12 (#222)
sivareddyp Jul 18, 2023
e129f78
BAH-3037 | adding provider attribute for "login locations" (#223)
angshu Jul 20, 2023
201d4f0
[BAH-3180]Exception Handler for OrderEntryException to ensure duplica…
deeptirawat1510 Aug 29, 2023
536c8f9
[Rahul] | BAH-3228 | Add. Bump Bahmni Commons Version
rahu1ramesh Oct 6, 2023
ab8c5d1
BAH-2962 | Added sms sending functionality . (#231)
anubhavBeehyv Oct 20, 2023
62dab0f
BAH-3266 | Siva Reddy | Fetching concepts from default locale if no c…
sivareddyp Nov 24, 2023
45a3bd4
BAH-3181 | Enable locale specific concept search and also return FSN …
angshu Dec 7, 2023
6fa213c
BAH-3336 | Patient Stage dropdown is empty in programs module [Env - …
vijayanandtwks Dec 15, 2023
1d8a3ff
Add. Accession number for lab test performed in OpenElis to orders ta…
riyaTw Dec 18, 2023
759e3df
BAH-3416 | Fix. Add accession number for lab panel test
riyaTw Dec 21, 2023
3c1a9cd
Updated. Bahmni java util version (#241)
SanoferSameera Dec 27, 2023
d0b60bb
BAH-3361 | Updated. emrapi version (#242)
SanoferSameera Jan 3, 2024
21f340a
BAH 3407|Fix of locale issue in the visit search handler (#244)
poojadeshpande01 Jan 10, 2024
09a996c
BAH 3455| Locale issue while sending request with diagnoses (#247)
poojadeshpande01 Jan 12, 2024
18478da
BAH-3473 | Locale Issue while uploading the patient visit document. (…
poojadeshpande01 Jan 22, 2024
9e64174
BAH-3454 | Refactor. search concepts in both user and default locale …
SanoferSameera Jan 23, 2024
7ffa7d5
BAH-3499 | Add. diagnosis search in user locale (#250)
SanoferSameera Jan 30, 2024
414cc29
BAH-3513 | Fix. Disable encounter search when patient does not have v…
mohan-13 Feb 5, 2024
0947dbe
BAH-3606 | Add. panelName property in tabularResult (#254)
parvathy00 Feb 29, 2024
7408af9
Parvathy | BAH-2833 | Add. Size Limit To The Patient Documents (#256)
parvathy00 Mar 26, 2024
450a43b
Parvathy | BAH-3720 | Fix. applicationDataDirectory File Path (#257)
parvathy00 Mar 29, 2024
0b4ce7d
Parvathy | BAH-3720 | Fix. Append applicationDataDirectory File Path …
parvathy00 Mar 29, 2024
3645144
BAH-2833 | Fix. Handle Error Due To Empty Document Size Limit In Bahm…
parvathy00 Apr 4, 2024
8c6391d
Deepthi M|BAH-3706| Updated openmrsAtomfeedVersion to 2.6.3. (#260)
deepthi-mantena Apr 4, 2024
cb42607
BAH-3117 | Ability to add, edit and delete notes in OT module (#261)
kavitha-sundararajan May 7, 2024
1ae59c4
BAH-3745 | Add. Api To Fetch Order By Order Id (#262)
parvathy00 May 15, 2024
8697e05
BAH-3892 | Support atomfeed test events for concepts with class Test …
mohan-13 Jun 4, 2024
925996e
BAH-3893 | Enhancement to raise Radiology atomfeed events on save of …
mohan-13 Jun 4, 2024
82ea8e8
BAH-3973 | optimizing query for patient list from ward (#265)
angshu Jul 1, 2024
1909f38
Fix. Use upgraded runner version.
mohan-13 Jul 1, 2024
1555fbe
Upgraded runner version to macos-14 for Validate PR workflow
mohan-13 Jul 12, 2024
6359f3c
BAH-4026 | Raise Sample event when the concept class is Specimen (#267)
mohan-13 Jul 12, 2024
c53f6f7
BAH-4029 | adding better logs in cases of outside range values or inv…
angshu Jul 19, 2024
ffd25c0
BAH-4029 | Fix. Class Cast exception by using getConceptNumeric (#270)
mohan-13 Jul 22, 2024
2a03cf9
BAH-4045 | Add. Privilege for getting program attribute types (#272)
mohan-13 Jul 25, 2024
a698974
BAH-3971 | Add. contextCookieExpirationTimeInMinutes Global Property …
rahu1ramesh Jul 29, 2024
53fccf7
BAH-4065 | Fix. Get Concept by FSN should return only unretired conce…
mohan-13 Aug 8, 2024
dd48d7d
BAH-4090 | Refactor. Upgrade dependencies for release (#275)
mohan-13 Aug 27, 2024
a50beb1
BAH-4090 | Add. Workflow torelease artifacts on push of a tag (#276)
mohan-13 Aug 27, 2024
cafe093
BAH-4090 | Release of version 1.2.0
mohan-13 Aug 27, 2024
a2a062a
BAH-4090 | Incrementing dev version to 1.3.0-SNAPSHOT
mohan-13 Aug 27, 2024
9254963
Merge master into ipd branch and add disposition locale support
kavitha-sundararajan Oct 8, 2024
b8a6bf3
fix test failures
kavitha-sundararajan Oct 10, 2024
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
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
Loading