I just went through the OpenMRS-Core code repository. While referring the code, I couldn’t understand the reason for multiple address variable declaration in the Location Class. I thought, it might be a mistake or issue. So I would like to get some idea about this one.
Location class have address1 to address15 (altogether 15 variables) for the address assignment and it have 15 get methods and 15 set methods itself. I wonder why this class does not use a string array for this reason. If we use a string array, then we can simply manage multiple address though the index.
Example :
String[] address = new address[15]
public void setAddress (int index, string address) {
this.address[index] = address;
}
I believe, there might be a valid technical reason for this implementation. Could some one explain me the actual idea behind this one?
Very good point that I also came across and did not know why exactly. I assume it might be that we didnt want to create a separate table, so we could avoid the join. Since the majority of people might not have many addresses it would be “easier/quicker” to just take the data out of the same table.
But am not sure and would also be interested in the why
These are not for storing multiple address, but rather for storing multiple configurable structured fields for a single address. E.g. addresses look different in the US, Germany, India, and Kenya.
There are also some fields with more explicit meaning (e.g. city_village) but we have a bunch of general-purpose fields to provide “more than enough” configurability.