Exemplo n.º 1
0
 RelationListeType CreateRelationListeType(DateTime date)
 {
     return(new RelationListeType()
     {
         Aegtefaelle = new PersonRelationType[] {
             PersonRelationType.Create(Guid.NewGuid(), date, null),
             PersonRelationType.Create(Guid.NewGuid(), date, null)
         }
     });
 }
Exemplo n.º 2
0
        public RelationListeType ToRelationListeType(Func <string, Guid> cpr2uuidConverter, DPRDataContext dataContext)
        {
            Func <decimal, Guid> cpr2uuidFunc = (cpr) => cpr2uuidConverter(cpr.ToPnrDecimalString());

            var ret = new RelationListeType();
            // Now fill the relations
            var fatherPnr = Utilities.ToParentPnr(this.PersonTotal.FatherPersonalOrBirthdate);

            if (fatherPnr.HasValue)
            {
                ret.Fader = new PersonRelationType[]
                {
                    PersonRelationType.Create(
                        cpr2uuidFunc(fatherPnr.Value),
                        null,
                        null
                        )
                };
            }

            var motherPnr = Utilities.ToParentPnr(this.PersonTotal.MotherPersonalOrBirthDate);

            if (motherPnr.HasValue)
            {
                ret.Moder = new PersonRelationType[]
                {
                    PersonRelationType.Create
                        (cpr2uuidFunc(motherPnr.Value),
                        null,
                        null
                        )
                };
            }

            // Fill children (including adults)
            ret.Boern = Child.ToPersonFlerRelationTypeArray(Children, cpr2uuidFunc);

            // TODO : Fill custody children
            ret.Foraeldremyndighedsboern = null;

            // Normal spouse(s)
            ret.Aegtefaelle = CivilStatusWrapper.ToSpouses(null, this.CivilStatesAsInterface, cpr2uuidConverter);

            // Registered partner(s)
            ret.RegistreretPartner = CivilStatusWrapper.ToRegisteredPartners(null, this.CivilStatesAsInterface, cpr2uuidConverter);

            //TODO: Has legal authority on
            ret.RetligHandleevneVaergeForPersonen = null;

            //TODO: People who have legal authority on this person
            ret.Foraeldremyndighedsindehaver = null;

            return(ret);
        }
Exemplo n.º 3
0
        public PersonRelationType[] ToReplacedByRelationType(Func <string, Guid> cpr2UuidFunc)
        {
            var newPnr = Converters.ToPnrStringOrNull(CurrentCprNumber);

            if (!string.IsNullOrEmpty(newPnr))
            {
                return(new PersonRelationType[] { PersonRelationType.Create(cpr2UuidFunc(newPnr), PersonEndDate, null) });
            }
            else
            {
                return(new PersonRelationType[0]);
            }
        }
Exemplo n.º 4
0
        public RelationListeType ToRelationListeType(EnglishAS78207Response details, Func <string, Guid> cpr2uuidFunc)
        {
            var ret = new RelationListeType();

            //Children
            if (details.ChildrenPNRs != null)
            {
                var childPnrs = (from pnr in details.ChildrenPNRs where pnr.Replace("-", "").Length > 0 select pnr.Replace("-", "")).ToArray();
                var uuids     = Array.ConvertAll <string, Guid>(childPnrs, (cpr) => cpr2uuidFunc(cpr));
                ret.Boern = Array.ConvertAll <Guid, PersonFlerRelationType>
                            (
                    uuids,
                    (pId) => PersonFlerRelationType.Create(pId, null, null)
                            );
            }

            //Father
            if (Convert.ToDecimal(details.FatherPNR) > 0)
            {
                ret.Fader = new PersonRelationType[] { PersonRelationType.Create(cpr2uuidFunc(details.FatherPNR), null, null) };
            }
            //Mother
            if (Convert.ToDecimal(details.MotherPNR) > 0)
            {
                ret.Fader = new PersonRelationType[] { PersonRelationType.Create(cpr2uuidFunc(details.MotherPNR), null, null) };
            }

            // Spouse
            if (Convert.ToDecimal(details.SpousePNR) > 0)
            {
                var  maritalStatus     = Utilities.ToPartMaritalStatus(details.MaritallStatusCode[0]);
                var  maritalStatusDate = Utilities.ToDateTime(details.MaritalStatusDate);
                bool isMarried         = maritalStatus == CivilStatusKodeType.Gift || maritalStatus == CivilStatusKodeType.RegistreretPartner;
                var  spouseUuid        = cpr2uuidFunc(details.SpousePNR);
                ret.Aegtefaelle = new PersonRelationType[]
                {
                    PersonRelationType.Create
                    (
                        spouseUuid,
                        isMarried? maritalStatusDate : null,
                        isMarried? null : maritalStatusDate
                    )
                };
            }
            // TODO: Fill other relationships such as custody
            return(ret);
        }
Exemplo n.º 5
0
        public PersonRelationType ToPersonRelationType(ParentsInformationType parents, Func <string, Guid> cpr2uuidFunc)
        {
            // TODO: A few persons have custody with father/mother but there is no father(45)/mother(6) PNR
            // Is it possible to get a UUID from a person name for a person not in CPR?
            var type = (CustodyTypes)(int)this.RelationshipType;

            switch (type)
            {
            case CustodyTypes.Mother:
                return(parents.ToMother(cpr2uuidFunc).FirstOrDefault());

            case CustodyTypes.Father:
                return(parents.ToFather(cpr2uuidFunc).FirstOrDefault());

            default:
                if (type == CustodyTypes.OtherHolder1 || type == CustodyTypes.OtherHolder2)
                {
                    var relPnr = ToCustodyOwnerPnr();
                    if (!string.IsNullOrEmpty(relPnr))
                    {
                        return(PersonRelationType.Create(
                                   cpr2uuidFunc(relPnr),
                                   this.CustodyStartDate,
                                   this.CustodyEndDate));
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    throw new ArgumentException(
                              string.Format("Invalied value <{0}>, must be between 0003 and 0006", this.RelationshipType),
                              "RelationshipType"
                              );
                }
            }
        }