Exemple #1
0
        private ClientIdentifier GenerateClientIdentifier(Guid clientId)
        {
            if (null == ClientEnrollment)
            {
                return(null);
            }
            //ClientIdentifier

            //string identifierTypeId, string identifier, DateTime registrationDate,bool preferred, Guid clientId

            var clientIdentifier = ClientIdentifier.Create(ClientEnrollment.IdentifierTypeId, ClientEnrollment.Identifier, ClientEnrollment.RegistrationDate, true, clientId);

            if (!string.IsNullOrWhiteSpace(ClientEnrollment.Id))
            {
                clientIdentifier.Id = new Guid(ClientEnrollment.Id);
            }

            return(clientIdentifier);
        }
Exemple #2
0
        public Client GetClient(Guid practiceId, Guid userId)
        {
            var smartClient = SmartClientDTO.Create(this);
            var smartPerson = Person.Create(smartClient.FirstName, smartClient.MiddleName, smartClient.LastName,
                                            smartClient.Sex, smartClient.BirthDate, smartClient.BirthDateEstimated, string.Empty,
                                            smartClient.Landmark, smartClient.Phone, string.Empty, null, null, null);

            var client = Client.Create(smartClient.MaritalStatus, smartClient.KeyPop, smartClient.OtherKeyPop,
                                       practiceId, smartPerson, userId, Guid.Empty, Guid.Empty, Guid.Empty);

            client.PersonId = smartPerson.Id;

            var clientIdentifier =
                ClientIdentifier.Create("Serial", smartClient.HtsNumber, DateTime.Today, true, client.Id);

            client.AddIdentifier(clientIdentifier);
            client.SmartCardSerial = smartClient.SmartCardSerial;

            return(client);
        }
Exemple #3
0
        public void SmartSync(ClientInfo client)
        {
            // IDS
            var clientIdentifiers = ClientIdentifier.Create(client.Identifiers);

            client.Identifiers = new List <IdentifierInfo>();

            // RELATIONSHIPS
            var clientRelationships = ClientRelationship.Create(client.Relationships);

            client.Relationships = new List <RelationshipInfo>();

            //STATES
            var states = client.ClientStates;

            client.ClientStates = new List <ClientStateInfo>();

            // PERSON
            var personInfo     = client.Person;
            var exisitngPerson = _personRepository.GetDemographics(personInfo.Id);

            try
            {
                if (null == exisitngPerson)
                {
                    var person = Person.CreateClient(personInfo);
                    _personRepository.Insert(person);
                    _personRepository.Save();

                    //client
                    var cient = Client.Create(client, client.PracticeId.Value, person.Id);


                    _clientRepository.Insert(cient);
                    _clientRepository.Save();
                }
                else
                {
                    exisitngPerson.UpdateClient(personInfo);
                    _personRepository.Update(exisitngPerson);
                    _personRepository.Save();

                    var existingClient = _clientRepository.GetClient(client.Id, false);

                    if (null != existingClient)
                    {
                        existingClient.Update(client);
                        _clientRepository.Update(existingClient);
                        _clientRepository.Save();
                    }
                    else
                    {
                        var cient = Client.Create(client, client.PracticeId.Value, exisitngPerson.Id);

                        _clientRepository.Insert(cient);
                        _clientRepository.Save();
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error(e, "Error saving Client");
                Preserve(client);
                return;
            }


            //STATES
            var allstates = Mapper.Map <List <ClientState> >(states);

            _clientRepository.UpdateClientState(client.Id, allstates);

            //IDS
            if (clientIdentifiers.Any())
            {
                _clientRepository.UpdateIds(clientIdentifiers);
                // _clientRepository.Save();
            }

            // RELATIONSHIPS
            if (clientRelationships.Any())
            {
                _clientRepository.UpdateTempRelations(clientRelationships);
                _clientRepository.UpdateRelationships();
            }
        }