public DTOPerson GetPersonByCpf(string cpf)
        {
            var person = _personRepository.GetByCpf(cpf);

            if (person == null)
            {
                return(null);
            }

            var dto = new DTOPerson
            {
                DateOfBirth = person.DateOfBirth,
                Cpf         = person.Cpf,
                Id          = person.Id,
                Name        = person.Name,
                Nickname    = person.Nickname,
                Contact     = new DTOContact
                {
                }
            };

            //Mapper.Map<Person,DTOPerson>(person, dto);

            return(dto);
        }
Exemple #2
0
        public DTOPerson UpsertPerson(DTOPerson person)
        {
            try {
                connection();
                con.Open();
                var parameters = new DynamicParameters();
                parameters.Add("@Id", dbType: DbType.Int32, direction: ParameterDirection.ReturnValue);
                parameters.Add("@firstName", person.firstName);
                parameters.Add("@lastName", person.lastName);
                parameters.Add("@birthDate", person.birthDate);

                con.Execute("uspUpsertPerson", parameters, commandType: CommandType.StoredProcedure);

                int insertedId = parameters.Get <int>("@Id");
                if (insertedId > 0)
                {
                    person.Id = insertedId;
                }

                return(person);
            }
            catch (Exception)
            {
                throw;
            }
        }
 public HttpResponseMessage UpsertPerson(DTOPerson person)
 {
     if (ModelState.IsValid)
     {
         var result = PersonRepository.UpsertPerson(person);
         return(Request.CreateResponse(HttpStatusCode.Created, result));
     }
     return(Request.CreateResponse(HttpStatusCode.BadRequest));
 }
        public static Person ToBllPerson(this DTOPerson dtoPerson)
        {
            var person = new Person(dtoPerson.FirstName, dtoPerson.LastName, dtoPerson.Email);

            foreach (var i in dtoPerson.Accounts)
            {
                person.accounts.Add(i.ToBLLAccount());
            }

            return(person);
        }
Exemple #5
0
 public ActionResult CreatePerson(DTOPerson dto)
 {
     try
     {
         personService.CreatePerson(dto);
         return(Ok());
     }
     catch (Exception ex)
     {
         return(BadRequest());
     }
 }
        public static DTOPerson ToDTOPerson(this Person person)
        {
            var dtoPerson = new DTOPerson
            {
                FirstName = person.FirstName,
                LastName  = person.LastName,
                Email     = person.Email
            };

            foreach (var i in person.Accounts)
            {
                dtoPerson.Accounts.Add(i.ToDTOAccount());
            }

            return(dtoPerson);
        }
        public static Person ToORMPerson(this DTOPerson person)
        {
            var ormPerson = new Person
            {
                FirstName = person.FirstName,
                LastName  = person.LastName,
                Email     = person.Email
            };

            foreach (var i in person.Accounts)
            {
                ormPerson.Accounts.Add(i.ToORMAccount());
            }

            return(ormPerson);
        }
Exemple #8
0
        public bool UpdatePerson(DTOPerson person)
        {
            connection();
            con.Open();
            var sqlString =
                "UPDATE [Tutorial].[dbo].[persons] " +
                "SET firstname = @firstName, " +
                " lastname = @LastName " +
                "WHERE id = @Id";

            con.Execute(sqlString, new
            {
                person.Id,
                person.firstName,
                person.lastName
            });
            //con.Close();
            return(true);
        }
        public void CreatePerson(DTOPerson dto)
        {
            var person = new Person
            {
                Cpf         = dto.Cpf,
                DateOfBirth = dto.DateOfBirth,
                Name        = dto.Name,
                Nickname    = dto.Nickname
            };

            _personRepository.Insert(person);

            if (dto.Contact != null)
            {
                var contact = new Contact
                {
                    PersonId   = person.Id,
                    Email      = dto.Contact.Email,
                    Cellphone1 = dto.Contact.Cellphone1,
                    Cellphone2 = dto.Contact.Cellphone2
                };
                _contactRepository.Insert(contact);
            }
        }
Exemple #10
0
        //todo handle possible null reference exceptions when fetching data from lists
        public Registration PatientRegistrationMapping(PatientRegistrationEntity entity)
        {
            var patient = new DTOPerson()
            {
                FirstName       = entity.PATIENT_IDENTIFICATION.PATIENT_NAME.FIRST_NAME,
                MiddleName      = entity.PATIENT_IDENTIFICATION.PATIENT_NAME.FIRST_NAME,
                LastName        = entity.PATIENT_IDENTIFICATION.PATIENT_NAME.FIRST_NAME,
                DateOfBirth     = entity.PATIENT_IDENTIFICATION.DATE_OF_BIRTH,
                MobileNumber    = entity.PATIENT_IDENTIFICATION.PHONE_NUMBER,
                NationalId      = entity.PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID.FirstOrDefault(n => n.IDENTIFIER_TYPE == "NATIONAL_ID").ID,
                Sex             = entity.PATIENT_IDENTIFICATION.SEX,
                PhysicalAddress = entity.PATIENT_IDENTIFICATION.PATIENT_ADDRESS.POSTAL_ADDRESS,
                //todo update precision once updated in IL
                DobPrecision = false
            };

            var ts = entity.NEXT_OF_KIN.FirstOrDefault(n => n.CONTACT_ROLE == "T");
            var treatmentSupporter = new DTOPerson()
            {
                FirstName       = ts.NOK_NAME.FIRST_NAME,
                MiddleName      = ts.NOK_NAME.MIDDLE_NAME,
                LastName        = ts.NOK_NAME.LAST_NAME,
                PhysicalAddress = ts.ADDRESS,
                Sex             = ts.SEX,
                DateOfBirth     = ts.DATE_OF_BIRTH,
                MobileNumber    = ts.PHONE_NUMBER,
                //todo update precision once updated in IL
                //NationalId = ,
                DobPrecision = false
            };
            var identifiers = new List <DTOIdentifier>();

            foreach (var id in entity.PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID)
            {
                var identifier = new DTOIdentifier()
                {
                    AssigningAuthority = id.ASSIGNING_AUTHORITY,
                    IdentifierType     = id.IDENTIFIER_TYPE,
                    IdentifierValue    = id.ID
                };
                identifiers.Add(identifier);
            }
            var registration = new Registration()
            {
                Patient                    = patient,
                MotherMaidenName           = entity.PATIENT_IDENTIFICATION.MOTHER_MAIDEN_NAME,
                MaritalStatus              = entity.PATIENT_IDENTIFICATION.MARITAL_STATUS,
                County                     = entity.PATIENT_IDENTIFICATION.PATIENT_ADDRESS.PHYSICAL_ADDRESS.COUNTY,
                SubCounty                  = entity.PATIENT_IDENTIFICATION.PATIENT_ADDRESS.PHYSICAL_ADDRESS.SUB_COUNTY,
                Ward                       = entity.PATIENT_IDENTIFICATION.PATIENT_ADDRESS.PHYSICAL_ADDRESS.WARD,
                Village                    = entity.PATIENT_IDENTIFICATION.PATIENT_ADDRESS.PHYSICAL_ADDRESS.VILLAGE,
                DateOfDeath                = null,
                DeathIndicator             = entity.PATIENT_IDENTIFICATION.DEATH_INDICATOR,
                TreatmentSupporter         = treatmentSupporter,
                TSRelationshipType         = ts.RELATIONSHIP,
                InternalPatientIdentifiers = identifiers
                                             //DateOfEnrollment = entity,
            };

            return(registration);
        }