Skip to content

Commit 19ef139

Browse files
BAH-2433 | refactor. extracted the message building in separate method
1 parent 8bfe1ad commit 19ef139

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

omod/src/main/java/org/bahmni/module/hip/web/service/FHIRResourceMapper.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -233,16 +233,7 @@ public Observation mapToObs(Obs obs) {
233233
obs.setConcept(concept);
234234
Observation observation = observationTranslator.toFhirResource(obs);
235235
if (obs.getGroupMembers().size() > 0 && Config.CONCEPT_DETAILS_CONCEPT_CLASS.getValue().equals(obs.getConcept().getConceptClass().getName()) && obs.getFormFieldNamespace() != null) {
236-
String chiefComplaintCoded = null, signOrSymptomDuration = null, chiefComplaintDuration = null;
237-
for (Obs childObs : obs.getGroupMembers()) {
238-
if(childObs.getConcept().getName().getName().equals(Config.CHIEF_COMPLAINT_CODED.getValue()))
239-
chiefComplaintCoded = childObs.getValueCoded().getDisplayString();
240-
if(childObs.getConcept().getName().getName().equals(Config.SIGN_SYMPTOM_DURATION.getValue()))
241-
signOrSymptomDuration = childObs.getValueNumeric().toString();
242-
if(childObs.getConcept().getName().getName().equals(Config.CHIEF_COMPLAINT_DURATION.getValue()))
243-
chiefComplaintDuration = childObs.getValueCoded().getDisplayString();
244-
}
245-
observation.setValue(new StringType(chiefComplaintCoded + " " + "since" + " " + signOrSymptomDuration + " " + chiefComplaintDuration));
236+
observation.setValue(new StringType(getCustomDisplayStringForChiefComplaint(obs.getGroupMembers())));
246237
}
247238
observation.addNote(new Annotation(new MarkdownType(obs.getComment())));
248239
return observation;
@@ -306,4 +297,17 @@ public static <T> T initializeEntityAndUnproxy(T entity) {
306297
}
307298
return entity;
308299
}
300+
301+
public String getCustomDisplayStringForChiefComplaint(Set<Obs> groupMembers) {
302+
String chiefComplaintCoded = null, signOrSymptomDuration = null, chiefComplaintDuration = null;
303+
for (Obs childObs : groupMembers) {
304+
if(childObs.getConcept().getName().getName().equals(Config.CHIEF_COMPLAINT_CODED.getValue()))
305+
chiefComplaintCoded = childObs.getValueCoded().getDisplayString();
306+
if(childObs.getConcept().getName().getName().equals(Config.SIGN_SYMPTOM_DURATION.getValue()))
307+
signOrSymptomDuration = childObs.getValueNumeric().toString();
308+
if(childObs.getConcept().getName().getName().equals(Config.CHIEF_COMPLAINT_DURATION.getValue()))
309+
chiefComplaintDuration = childObs.getValueCoded().getDisplayString();
310+
}
311+
return (chiefComplaintCoded + " " + "since" + " " + signOrSymptomDuration + " " + chiefComplaintDuration);
312+
}
309313
}

0 commit comments

Comments
 (0)