|
24 | 24 | import org.hl7.fhir.r4.model.Enumerations; |
25 | 25 | import org.hl7.fhir.r4.model.Annotation; |
26 | 26 | import org.hl7.fhir.r4.model.MarkdownType; |
| 27 | +import org.hl7.fhir.r4.model.StringType; |
27 | 28 |
|
28 | 29 | import org.openmrs.DrugOrder; |
29 | 30 | import org.openmrs.EncounterProvider; |
@@ -230,12 +231,10 @@ public Condition mapToCondition(OpenMrsCondition openMrsCondition, Patient patie |
230 | 231 | public Observation mapToObs(Obs obs) { |
231 | 232 | Concept concept = initializeEntityAndUnproxy(obs.getConcept()); |
232 | 233 | obs.setConcept(concept); |
| 234 | + Observation observation = observationTranslator.toFhirResource(obs); |
233 | 235 | if (obs.getGroupMembers().size() > 0 && Config.CONCEPT_DETAILS_CONCEPT_CLASS.getValue().equals(obs.getConcept().getConceptClass().getName()) && obs.getFormFieldNamespace() != null) { |
234 | | - Obs[] groupMembersArray = new Obs[obs.getGroupMembers().size()]; |
235 | | - groupMembersArray = obs.getGroupMembers().toArray(groupMembersArray); |
236 | | - obs.setValueText(groupMembersArray[0].getValueCoded().getDisplayString() + " " + "since" + " " + groupMembersArray[2].getValueNumeric() + " " + groupMembersArray[1].getValueCoded().getDisplayString()); |
| 236 | + observation.setValue(new StringType(getCustomDisplayStringForChiefComplaint(obs.getGroupMembers()))); |
237 | 237 | } |
238 | | - Observation observation = observationTranslator.toFhirResource(obs); |
239 | 238 | observation.addNote(new Annotation(new MarkdownType(obs.getComment()))); |
240 | 239 | return observation; |
241 | 240 | } |
@@ -298,4 +297,17 @@ public static <T> T initializeEntityAndUnproxy(T entity) { |
298 | 297 | } |
299 | 298 | return entity; |
300 | 299 | } |
| 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 | + } |
301 | 313 | } |
0 commit comments