/// <summary> /// Parse an PN Use extension /// </summary> public static NameSet.NameSetUse ParsePNUseExtension(List <Extension> extension, List <IResultDetail> dtls) { // Now fun part parse try { NameSet.NameSetUse value = 0; foreach (var ext in extension.FindAll(o => o.Url == GetExtensionNameUrl("nameUse"))) { var coding = ext.Value as Coding; if (coding == null) { dtls.Add(new NotSupportedChoiceResultDetail(ResultDetailType.Error, "Name use extension must carry a value of type coding", null)); } else if (coding.System != typeof(EntityNameUse).GetValueSetDefinition()) { dtls.Add(new VocabularyIssueResultDetail(ResultDetailType.Error, String.Format("Name use extension must carry a value drawn from system {0}", typeof(EntityNameUse).GetValueSetDefinition()), null, null)); } else { value |= (NameSet.NameSetUse)Enum.Parse(typeof(NameSet.NameSetUse), MARC.Everest.Connectors.Util.Convert <EntityNameUse>(coding.Code).ToString()); } } return(value); } catch (VocabularyException e) { dtls.Add(new VocabularyIssueResultDetail(ResultDetailType.Error, String.Format(ApplicationContext.LocalizationService.GetString("FHIR007"), GetExtensionNameUrl("personalRelationshipRoleType"), e.Message), e)); return(0); } }
/// <summary> /// Create a name set /// </summary> public NameSet CreateNameSet(EN legalName, List <IResultDetail> dtls) { NameSet retVal = new NameSet(); NameSet.NameSetUse internalNameUse = 0; var lnu = legalName.Use == null || legalName.Use.IsNull || legalName.Use.IsEmpty ? EntityNameUse.Search : (EntityNameUse)legalName.Use[0]; if ((lnu == EntityNameUse.Legal || lnu == EntityNameUse.OfficialRecord) && legalName.Use.Count > 1 && (legalName.Use[1] == EntityNameUse.OfficialRecord | legalName.Use[1] == EntityNameUse.Legal)) { internalNameUse = NameSet.NameSetUse.OfficialRecord; } else if (!m_nameUseMap.TryGetValue(lnu, out internalNameUse)) { return(null); } retVal.Use = internalNameUse; // Create the parts foreach (ENXP namePart in legalName.Part) { retVal.Parts.Add(new NamePart() { Value = namePart.Value, Type = namePart.Type.HasValue ? m_namePartTypeMap[namePart.Type] : NamePart.NamePartType.None }); } return(retVal); }
public static Extension CreatePNUseExtension(NameSet.NameSetUse nameSetUse) { EntityNameUse entityNameUse = EntityNameUse.Alphabetic; if (Enum.TryParse <EntityNameUse>(nameSetUse.ToString(), out entityNameUse)) { return new Extension() { Url = GetExtensionNameUrl("nameUse"), Value = new Coding( typeof(EntityNameUse).GetValueSetDefinition(), MARC.Everest.Connectors.Util.ToWireFormat(entityNameUse) ) } } ; return(null); }