<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CprBroker.Schemas.Part;

namespace CprBroker.Providers.CPRDirect
{
    public partial class CurrentCivilStatusType
    {
        public CivilStatusType ToCivilStatusType(CurrentSeparationType currentSeparation)
        {
            if (currentSeparation != null)
            {
                return currentSeparation.ToCivilStatusType();
            }
            else
            {
                return new CivilStatusType()
                {
                    CivilStatusKode = new CivilStatusLookupMap().Map(this.CivilStatus),
                    TilstandVirkning = TilstandVirkningType.Create(this.ToCivilStatusDate()),
                };
            }
        }

        public PersonRelationType[] ToSpouses(Func<string, Guid> cpr2uuidFunc)
        {
            return this.ToSpouses('G', new char[] { 'F', 'E' }, 'D', false, cpr2uuidFunc);
        }

        public PersonRelationType[] ToRegisteredPartners(Func<string, Guid> cpr2uuidFunc)
        {
            return this.ToSpouses('P', new char[] { 'O', 'L' }, 'D', true, cpr2uuidFunc);
        }

        public PersonRelationType[] ToSpouses(char marriedStatus, char[] terminatedStates, char deadStatus, bool sameGenderForDead, Func<string, Guid> cpr2uuidFunc)
        {
            // TODO: Make sure that it is correct to return an empty array if SpousePNR is empty
            if (this.ToSpousePnr() != null)
            {
                if (this.CivilStatus == marriedStatus)
                {
                    return PersonRelationType.CreateList(cpr2uuidFunc(this.SpousePNR), this.ToCivilStatusDate(), null);
                }
                else if (terminatedStates.Contains(this.CivilStatus))
                {
                    return PersonRelationType.CreateList(cpr2uuidFunc(this.SpousePNR), null, this.ToCivilStatusDate());
                }
                else if (this.CivilStatus == deadStatus)
                {
                    // TODO: Will there be a spouse PNR in this case?
                    if (
                        (Utilities.Strings.PersonNumberToGender(this.PNR) == Utilities.Strings.PersonNumberToGender(this.ToSpousePnr()))
                        ==
                        sameGenderForDead
                        )
                    {
                        return PersonRelationType.CreateList(cpr2uuidFunc(this.SpousePNR), null, this.ToCivilStatusDate());
                    }
                }<commit_msg>Namespace organization<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CprBroker.Schemas.Util;
using CprBroker.Schemas.Part;

namespace CprBroker.Providers.CPRDirect
{
    public partial class CurrentCivilStatusType
    {
        public CivilStatusType ToCivilStatusType(CurrentSeparationType currentSeparation)
        {
            if (currentSeparation != null)
            {
                return currentSeparation.ToCivilStatusType();
            }
            else
            {
                return new CivilStatusType()
                {
                    CivilStatusKode = new CivilStatusLookupMap().Map(this.CivilStatus),
                    TilstandVirkning = TilstandVirkningType.Create(this.ToCivilStatusDate()),
                };
            }
        }

        public PersonRelationType[] ToSpouses(Func<string, Guid> cpr2uuidFunc)
        {
            return this.ToSpouses('G', new char[] { 'F', 'E' }, 'D', false, cpr2uuidFunc);
        }

        public PersonRelationType[] ToRegisteredPartners(Func<string, Guid> cpr2uuidFunc)
        {
            return this.ToSpouses('P', new char[] { 'O', 'L' }, 'D', true, cpr2uuidFunc);
        }

        public PersonRelationType[] ToSpouses(char marriedStatus, char[] terminatedStates, char deadStatus, bool sameGenderForDead, Func<string, Guid> cpr2uuidFunc)
        {
            // TODO: Make sure that it is correct to return an empty array if SpousePNR is empty
            if (this.ToSpousePnr() != null)
            {
                if (this.CivilStatus == marriedStatus)
                {
                    return PersonRelationType.CreateList(cpr2uuidFunc(this.SpousePNR), this.ToCivilStatusDate(), null);
                }
                else if (terminatedStates.Contains(this.CivilStatus))
                {
                    return PersonRelationType.CreateList(cpr2uuidFunc(this.SpousePNR), null, this.ToCivilStatusDate());
                }
                else if (this.CivilStatus == deadStatus)
                {
                    // TODO: Will there be a spouse PNR in this case?
                    if (
                        (Enums.PersonNumberToGender(this.PNR) == Enums.PersonNumberToGender(this.ToSpousePnr()))
                        ==
                        sameGenderForDead
                        )
                    {
                        return PersonRelationType.CreateList(cpr2uuidFunc(this.SpousePNR), null, this.ToCivilStatusDate());
                    }
                }
{'fraction_non_alphanumeric': 0.08851815505397448, 'fraction_numerical': 0.003140333660451423, 'mean_word_length': 1.739784946236559, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '674507', 'n_tokens_mistral': 1391, 'n_tokens_neox': 1296, 'n_words': 263}