/// <summary> /// Create the person portion /// </summary> private MARC.Everest.RMIM.UV.NE2008.PRPA_MT201304UV02.Person CreatePerson(Person patient, List <IResultDetail> details) { var retVal = new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201304UV02.Person(); // Patient names if (patient.Names != null) { retVal.Name = new BAG <PN>(); foreach (var nam in patient.Names) { retVal.Name.Add(CreatePN(nam, details)); } } // Create AsOtherIds retVal.AsOtherIDs = new List <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201303UV02.OtherIDs>(); if (patient.OtherIdentifiers != null) { foreach (var othId in patient.OtherIdentifiers) { var otherIdentifier = new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201303UV02.OtherIDs( SET <II> .CreateSET(CreateII(othId.Value, details)), RoleStatus.Active, null, null); // Any extensions that apply to this? var propertyPath = String.Format("OtherIdentifiers[{0}{1}]", othId.Value.Domain, othId.Value.Identifier); var othAltId = patient.FindAllExtensions(o => o.Name == "AssigningIdOrganizationExtraId" && o.PropertyPath == propertyPath); var extId = patient.FindAllExtensions(o => o.Name == "AssigningIdOrganizationId" && o.PropertyPath == propertyPath); var extName = patient.FindAllExtensions(o => o.Name == "AssigningIdOrganizationName" && o.PropertyPath == propertyPath); var extCode = patient.FindExtension(o => o.Name == "AssigningIdOrganizationCode" && o.PropertyPath == propertyPath); if (othAltId != null) { foreach (var id in othAltId) { otherIdentifier.Id.Add(CreateII(id.Value as DomainIdentifier, details)); } } // Any of the extensions that apply to scoping org applied if (extId != null || extName != null || extCode != null) { // Scoping org otherIdentifier.ScopingOrganization = new MARC.Everest.RMIM.UV.NE2008.COCT_MT150002UV01.Organization( null, extCode != null ? CreateCD <String>(extCode.Value as CodeValue, details) : null, null, null ); // Extended identifiers (scoping id org id) if (extId != null) { otherIdentifier.ScopingOrganization.Id = new SET <II>(); foreach (var ii in extId) { otherIdentifier.ScopingOrganization.Id.Add(CreateII(ii.Value as DomainIdentifier, details)); } } // Extension identifiers for name if (extName != null) { otherIdentifier.ScopingOrganization.Name = new BAG <ON>(); foreach (var on in extName) { otherIdentifier.ScopingOrganization.Name.Add(new ON(EntityNameUse.Legal, new ENXP[] { new ENXP(on.Value as String) })); } } } retVal.AsOtherIDs.Add(otherIdentifier); } } return(retVal); }
/// <summary> /// Create the person object /// </summary> private MARC.Everest.RMIM.UV.NE2008.PRPA_MT201303UV02.Person CreatePersonDetail(Person patient, List <IResultDetail> details) { if (patient == null) { return new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201303UV02.Person() { NullFlavor = NullFlavor.NoInformation } } ; var retVal = new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201303UV02.Person(); var relations = patient.FindAllComponents(HealthServiceRecordSiteRoleType.RepresentitiveOf); // Names if (patient.Names != null) { retVal.Name = new BAG <PN>(); foreach (var n in patient.Names) { retVal.Name.Add(CreatePN(n, details)); } } // Telecoms if (patient.TelecomAddresses != null) { retVal.Telecom = new BAG <TEL>(); foreach (var t in patient.TelecomAddresses) { var tel = CreateTEL(t, details); var use = patient.FindExtension(o => o.Name == "UsablePeriod" && o.PropertyPath == String.Format("TelecomAddresses[{0}]", t.Value)); if (use != null) { tel.UseablePeriod = new GTS() { Hull = use.Value as ISetComponent <TS> } } ; retVal.Telecom.Add(tel); } } // Gender if (!String.IsNullOrEmpty(patient.GenderCode)) { retVal.AdministrativeGenderCode = Util.Convert <AdministrativeGender>(patient.GenderCode); } // Birth if (patient.BirthTime != null) { retVal.BirthTime = CreateTS(patient.BirthTime, details); } // Deceased if (patient.DeceasedTime != null) { retVal.DeceasedInd = true; retVal.DeceasedTime = CreateTS(patient.DeceasedTime, details); } // Multiple birth if (patient.BirthOrder.HasValue) { retVal.MultipleBirthInd = true; if (patient.BirthOrder >= 0) { retVal.MultipleBirthOrderNumber = patient.BirthOrder.Value; } } // Addresses if (patient.Addresses != null) { retVal.Addr = new BAG <AD>(); foreach (var adr in patient.Addresses) { retVal.Addr.Add(CreateAD(adr, details)); } } // Marital status code if (patient.MaritalStatus != null) { retVal.MaritalStatusCode = CreateCD <String>(patient.MaritalStatus, details); } // Religious affiliation if (patient.ReligionCode != null) { retVal.ReligiousAffiliationCode = CreateCD <String>(patient.ReligionCode, details); } // Ethnicity if (patient.EthnicGroup != null) { foreach (var e in patient.EthnicGroup) { retVal.EthnicGroupCode.Add(CreateCD <String>(e, details)); } } if (patient.BirthPlace != null) { retVal.BirthPlace = new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201303UV02.BirthPlace( this.CreateAD(patient.BirthPlace.Address, details), new MARC.Everest.RMIM.UV.NE2008.COCT_MT710007UV.Place( this.CreateIISet(patient.BirthPlace.AlternateIdentifiers, details), this.CreateCD <String>(patient.BirthPlace.LocationType, details), BAG <EN> .CreateBAG(new EN(null, new ENXP[] { new ENXP(patient.BirthPlace.Name) })), null, this.CreateAD(patient.BirthPlace.Address, details), null, null, new MARC.Everest.RMIM.UV.NE2008.COCT_MT710007UV.LocatedEntity() ), null ); } // Other identifiers if (patient.OtherIdentifiers != null) { retVal.AsOtherIDs = new List <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201303UV02.OtherIDs>(); foreach (var id in patient.OtherIdentifiers) { // Other identifiers var othId = new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201303UV02.OtherIDs( new SET <II>(CreateII(id.Value, details)), null, null, new MARC.Everest.RMIM.UV.NE2008.COCT_MT150002UV01.Organization()); // Create Other identifiers var extAddlId = patient.FindAllExtensions(o => o.Name == "AssigningIdOrganizationExtraId" && o.PropertyPath == String.Format("OtherIdentifiers[{0}{1}]", id.Value.Domain, id.Value.Identifier)); if (extAddlId != null) { foreach (var extId in extAddlId) { othId.Id.Add(CreateII(extId.Value as DomainIdentifier, details)); } } // Scoping and other extendsion var extScopingOrgs = patient.FindAllExtensions(o => o.Name == "AssigningIdOrganizationId" && o.PropertyPath == String.Format("OtherIdentifiers[{0}{1}]", id.Value.Domain, id.Value.Identifier)); var extScopingNames = patient.FindAllExtensions(o => o.Name == "AssigningIdOrganizationName" && o.PropertyPath == String.Format("OtherIdentifiers[{0}{1}]", id.Value.Domain, id.Value.Identifier)); var extScopingCode = patient.FindExtension(o => o.Name == "AssigningIdOrganizationCode" && o.PropertyPath == String.Format("OtherIdentifiers[{0}{1}]", id.Value.Domain, id.Value.Identifier)); if (extScopingOrgs != null) { othId.ScopingOrganization.Id = new SET <II>(); foreach (var scpId in extScopingOrgs) { othId.ScopingOrganization.Id.Add(CreateII(scpId.Value as DomainIdentifier, details)); } } if (extScopingNames != null) { othId.ScopingOrganization.Name = new BAG <ON>(); foreach (var scpName in extScopingNames) { othId.ScopingOrganization.Name.Add(new ON(EntityNameUse.Legal, new ENXP[] { new ENXP(scpName.Value.ToString()) })); } } if (extScopingCode != null) { othId.ScopingOrganization.Code = CreateCD <String>(extScopingCode.Value as CodeValue, details); } retVal.AsOtherIDs.Add(othId); } } // Personal relationships if (relations != null) { foreach (var rel in relations) { retVal.PersonalRelationship.Add(CreatePersonalRelationship(rel as PersonalRelationship, details)); } } // Citizenships if (patient.Citizenship != null) { foreach (var cit in patient.Citizenship) { var citizenRole = new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201303UV02.Citizen( null, cit.EffectiveTime != null ? CreateIVL(cit.EffectiveTime, details) : null, new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201303UV02.Nation( new CD <string>(cit.CountryCode, this.m_configService.OidRegistrar.GetOid("ISO3166-1").Oid), cit.CountryName != null ? new ON(EntityNameUse.Legal, new ENXP[] { new ENXP(cit.CountryName) }) : null ) ); // Citizenship identifiers var extCitId = patient.FindExtension(o => o.Name == "CitizenshipIds" && o.PropertyPath == String.Format("Citizenship[{0}]", cit.CountryCode)); if (extCitId != null) { citizenRole.Id = CreateIISet(extCitId.Value as List <DomainIdentifier>, details); } } } // Employment if (patient.Employment != null) { foreach (var emp in patient.Employment) { var employmentRole = new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201303UV02.Employee(); if (emp.Occupation != null) { employmentRole.OccupationCode = CreateCD <String>(emp.Occupation, details); } if (emp.EffectiveTime != null) { employmentRole.EffectiveTime = CreateIVL(emp.EffectiveTime, details); } employmentRole.StatusCode = ConvertStatusRole(emp.Status); retVal.AsEmployee.Add(employmentRole); } } // Lanugage of communication if (patient.Language != null) { foreach (var lang in patient.Language) { var langRole = new MARC.Everest.RMIM.UV.NE2008.COCT_MT030000UV04.LanguageCommunication(); if (!String.IsNullOrEmpty(lang.Language)) { langRole.LanguageCode = new CE <string>(lang.Language, this.m_configService.OidRegistrar.GetOid("ISO639-1").Oid); } else { langRole.LanguageCode = new CE <string>() { NullFlavor = NullFlavor.NoInformation } }; langRole.PreferenceInd = (lang.Type & LanguageType.Preferred) != 0; if ((lang.Type & LanguageType.Fluency) != 0) { langRole.ProficiencyLevelCode = new CE <LanguageAbilityProficiency>(LanguageAbilityProficiency.Excellent); } if ((lang.Type & LanguageType.WrittenAndSpoken) != 0) { ; // No combination here :( } else if ((lang.Type & LanguageType.Written) != 0) // written only { langRole.ModeCode = new CE <LanguageAbilityMode>(LanguageAbilityMode.ExpressedWritten); } else if ((lang.Type & LanguageType.Spoken) != 0) // spoken only { langRole.ModeCode = new CE <LanguageAbilityMode>(LanguageAbilityMode.ExpressedSpoken); } retVal.LanguageCommunication.Add(langRole); } } return(retVal); }