Update customer location

Dear Forum Members,

When my data was ported from the previous PMS customer location was not set. As a result some of the sales reports that split out by customer location don't show the data very well for my one site clinic as they believe most clients have no location and any new ones created in openVPMS do.

In order to remedy this I have concocted the following:

insert into entity_links (version, linkId,arch_short_name, arch_version, `name`, description, sequence, source_id, target_id)
select 0,'randomLinkId','entityLink.customerLocation',1.0,'Customer Location', 'Customer Location', 0, entity_id as source_id, 158
from entities left join entity_links on entity_id=source_id where entities.arch_short_name='party.customerperson' and
target_id is null;

Before I unleash this into the production database I would like to ask someone who knows more than I (just about anyone) what the implications are for the linkId. I have no idea what these do, how they are handled, how they are generated and indeed what they will break if not present.

Constructive criticism appreciated.

Chris

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: Update customer location

Hi Chris,

insert into entity_links (version, linkId, arch_short_name, arch_version, name, description, 

                          sequence, source_id, target_id)

select

    0,

    UUID(),

    "entityLink.customerLocation",

    "1.0",

    "Customer Location",

    "Customer Location",

    0,

    e.entity_id,

    158

from entities e

left join entity_links l on l.source_id = e.entity_id and l.arch_short_name = "entityLink.customerLocation"

where e.arch_short_name = "party.customerperson" and l.source_id is null;

 

Given 158 is your location id. 

Cheers
Tony

Re: Update customer location

Thanks Tony, that's brilliant. I now at least understand the linkId is a UUID. Can I ask what they are used for internally? Between the various id fields and archetype names there are other ways of deriving uniqueness. Are these used in the java layers before the *_id fields are assigned by the database?

Chris

Re: Update customer location

The linkId is used to link objects until they can be stored in the database, and to provide support for object equality.

Syndicate content