public PersonRelationType[] ToSpouses(CivilStatusKodeType existingStatusCode, CivilStatusKodeType[] terminatedStatusCodes, bool sameGenderSpouseForDead, Func<string, Guid> cpr2uuidFunc) { if (cpr2uuidFunc != null) { if (this.SpousePNR > 0) { var status = Converters.ToCivilStatusKodeType(this.MaritalStatus); if (status == CivilStatusKodeType.Ugift // Dead && this.Spouse != null && sameGenderSpouseForDead == (this.Gender == this.Spouse.Gender) ) { return PersonRelationType.CreateList(cpr2uuidFunc(this.ToSpousePNR()), null, this.ToMaritalStatusDate()); } else if (status == existingStatusCode) // Married or registered partner { return PersonRelationType.CreateList(cpr2uuidFunc(this.ToSpousePNR()), this.ToMaritalStatusDate(), null); } else if (terminatedStatusCodes.Contains(status)) // Terminated relationship (divorced, widow...) { return PersonRelationType.CreateList(cpr2uuidFunc(this.ToSpousePNR()), null, this.ToMaritalStatusDate()); } } return new PersonRelationType[0]; } else { throw new ArgumentNullException("cpr2uuidFunc"); } }
public void AddRelatedPerson(int personId, Person relatedPerson, PersonRelationType relationType) { var personRelation = new PersonRelation { PersonId = personId, RelatedPerson = relatedPerson, RelationType = relationType }; context.PersonRelations.Add(personRelation); context.SaveChanges(); }
RelationListeType CreateRelationListeType(DateTime date) { return(new RelationListeType() { Aegtefaelle = new PersonRelationType[] { PersonRelationType.Create(Guid.NewGuid(), date, null), PersonRelationType.Create(Guid.NewGuid(), date, null) } }); }
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); }
public static PersonRelationType[] ToFatherOrMother(Func <string, Guid> cpr2uuidFunc, string parentPnr, DateTime?parentDate) { if (!string.IsNullOrEmpty(parentPnr)) { return(PersonRelationType.CreateList( cpr2uuidFunc(parentPnr), parentDate, null )); } return(new PersonRelationType[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]); } }
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); }
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" ); } } }
public PersonRelationType[] ToMother(Func<string, Guid> cpr2uuidFunc) { if (this.MotherPNR > 0) { if (Converters.IsValidCprNumber(this.MotherPNR)) { if (cpr2uuidFunc != null) { return PersonRelationType.CreateList(cpr2uuidFunc(Converters.ToCprNumber(this.MotherPNR))); } else { throw new ArgumentNullException("cpr2uuidFunc"); } } else { throw new ArgumentException("Invalid MotherPNR", "citizen.MotherPNR"); } } return new PersonRelationType[0]; }