Skip to content

Commit

Permalink
Merge pull request #52 from vedfordev/master
Browse files Browse the repository at this point in the history
Added location properties method same as observation
  • Loading branch information
vinayvenu authored Apr 11, 2024
2 parents 1316682 + da28081 commit a5f7a92
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/AddressLevel.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,27 @@ class AddressLevel extends BaseEntity {
getLineage() {
return appendLineage(this, []);
}

findObservation(conceptNameOrUuid, parentConceptNameOrUuid) {
const observations = _.isNil(parentConceptNameOrUuid) ? this.locationProperties : this.findGroupedObservation(parentConceptNameOrUuid);
return _.find(observations, (observation) => {
return (observation.concept.name === conceptNameOrUuid) || (observation.concept.uuid === conceptNameOrUuid);
});
}

findGroupedObservation(parentConceptNameOrUuid) {
const groupedObservations = _.find(this.locationProperties, (observation) =>
(observation.concept.name === parentConceptNameOrUuid) || (observation.concept.uuid === parentConceptNameOrUuid));
return _.isEmpty(groupedObservations) ? [] : groupedObservations.getValue();
}

getObservationReadableValue(conceptNameOrUuid, parentConceptNameOrUuid) {
const observationForConcept = this.findObservation(conceptNameOrUuid, parentConceptNameOrUuid);
return _.isEmpty(observationForConcept)
? observationForConcept
: observationForConcept.getReadableValue();
}

}

export default AddressLevel;

0 comments on commit a5f7a92

Please sign in to comment.