Skip to content

Commit af1ec47

Browse files
RA-1945: ParserEncounterIntoSimpleObjects to cast concepts to ConceptNumeric where applicable. (#423)
* RA-1926 Change StringUtils Library * RA-1945 Add new test to ParserEncounterIntoSimpleObjectsTest * RA-1945 Rename variables and test names * RA-1945 Adjust tests * RA-1945 Concept convert to numericConcept * RA-1945 Concept convert to numericConcept * RA-1945 Remove not used ConceptService * RA-1945 Confirm concept is numeric before going to HibernateUtil * RA-1945 Minor Refactor in ParserEncounterIntoSimpleObjects.java * RA-1945 Minor Refactor in ParserEncounterIntoSimpleObjects.java
1 parent be85e7b commit af1ec47

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

omod/src/main/java/org/openmrs/module/coreapps/fragment/controller/visit/ParserEncounterIntoSimpleObjects.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
import org.openmrs.Location;
1818
import org.openmrs.Obs;
1919
import org.openmrs.Order;
20+
import org.openmrs.Concept;
21+
import org.openmrs.ConceptNumeric;
2022
import org.openmrs.api.LocationService;
23+
import org.openmrs.api.db.hibernate.HibernateUtil;
2124
import org.openmrs.module.emrapi.EmrApiProperties;
2225
import org.openmrs.module.emrapi.diagnosis.Diagnosis;
2326
import org.openmrs.module.emrapi.diagnosis.DiagnosisMetadata;
@@ -39,7 +42,7 @@ public class ParserEncounterIntoSimpleObjects {
3942
private Encounter encounter;
4043

4144
private UiUtils uiUtils;
42-
45+
4346
private EmrApiProperties emrApiProperties;
4447

4548
private LocationService locationService;
@@ -125,6 +128,12 @@ public int compare(SimpleObject o1, SimpleObject o2) {
125128
}
126129

127130
private SimpleObject parseObs(Obs obs, Locale locale) {
131+
Concept concept = obs.getConcept();
132+
if (concept != null && concept.isNumeric()) {
133+
//TODO HibernateUtil.getRealObjectFromProxy(obs.getConcept()) should be moved to a better place in the future,
134+
//If we remove it, the concept type will never be an instanceof ConceptNumeric
135+
obs.setConcept(HibernateUtil.getRealObjectFromProxy(concept));
136+
}
128137
if ("org.openmrs.Location".equals(obs.getComment())) {
129138
return (parseObsWithLocationAnswer(obs, locationService.getLocation(Integer.valueOf(obs.getValueText()))));
130139
}

omod/src/main/java/org/openmrs/module/coreapps/fragment/controller/visit/VisitDetailsFragmentController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,4 +248,4 @@ private boolean verifyIfUserHasPermissionToDeleteAnEncounter(Encounter encounter
248248
boolean userParticipatedInEncounter = encounterDomainWrapper.participatedInEncounter(authenticatedUser);
249249
return canDelete || userParticipatedInEncounter;
250250
}
251-
}
251+
}

omod/src/main/webapp/fragments/patientdashboard/encountertemplate/defaultEncounterTemplate.gsp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@
7676
<small>${ ui.message("coreapps.patientDashBoard.order")}</small><span>{{- order.concept }}</span>
7777
</p>
7878
{{ }); }}
79-
</script>
79+
</script>

0 commit comments

Comments
 (0)