/// <summary> /// Read a patint resource /// </summary> public SVC.Messaging.FHIR.FhirOperationResult Read(string id, string versionId) { FhirOperationResult result = new FhirOperationResult(); result.Details = new List <IResultDetail>(); result.Results = new List <ResourceBase>(); // Data persistence service IDataPersistenceService dataPersistence = ApplicationContext.CurrentContext.GetService(typeof(IDataPersistenceService)) as IDataPersistenceService; var container = dataPersistence.GetContainer(new VersionedDomainIdentifier() { Domain = this.DataDomain, Identifier = id, Version = String.IsNullOrEmpty(versionId) ? null : versionId }, String.IsNullOrEmpty(versionId)); // Container was not found if (container == null) { result.Outcome = ResultCode.NotAvailable; } else { var processor = FhirMessageProcessorUtil.GetComponentProcessor(container.GetType()); // Was there a history? if (versionId == null) { result.Results.Add(processor.ProcessComponent(container as IComponent, result.Details)); } else if (versionId == String.Empty) // Get all versions { while (container != null) { var hsrc = container as HealthServiceRecordContainer; var resource = processor.ProcessComponent(container as IComponent, result.Details); if (hsrc.IsMasked) // record is masked so add a detected issue { result.Issues.Add(new SVC.Core.Issues.DetectedIssue() { MitigatedBy = ManagementType.OtherActionTaken, Severity = IssueSeverityType.Moderate, Text = String.Format("{0}/_history/{1} will not be returned as it has been masked", resource.Id, resource.VersionId), Type = IssueType.DetectedIssue }); } else { result.Results.Add(resource); } container = hsrc.FindComponent(HealthServiceRecordSiteRoleType.OlderVersionOf) as IContainer; } } else // Some version { while (container != null) { var hsrc = container as HealthServiceRecordContainer; var resource = processor.ProcessComponent(container as IComponent, result.Details); container = hsrc.FindComponent(HealthServiceRecordSiteRoleType.ReplacementOf) as IContainer; if (resource != null && resource.VersionId.ToString() != versionId) { continue; } if (hsrc.IsMasked) // record is masked so add a detected issue { result.Issues.Add(new SVC.Core.Issues.DetectedIssue() { MitigatedBy = ManagementType.OtherActionTaken, Severity = IssueSeverityType.Moderate, Text = String.Format("{0}/_history/{1} will not be returned as it has been masked", resource.Id, resource.VersionId), Type = IssueType.DetectedIssue }); } else { result.Results.Add(resource); } } } result.Outcome = ResultCode.Accepted; } result.Results.RemoveAll(o => o == null); return(result); }
public override SVC.Messaging.FHIR.Resources.ResourceBase ProcessComponent(System.ComponentModel.IComponent component, List <Everest.Connectors.IResultDetail> dtls) { // Create a component HealthcareParticipant ptcpt = component as HealthcareParticipant; if (ptcpt.Classifier != HealthcareParticipant.HealthcareParticipantType.Organization) { ; // Not an organization pass off } // Organization Organization retVal = new Organization(); retVal.Id = ptcpt.Id.ToString(); retVal.VersionId = ptcpt.Id.ToString(); // Other identifiers foreach (var id in ptcpt.AlternateIdentifiers) { retVal.Extension.Add(ExtensionUtil.CreateIdentificationExtension(id)); } if (ptcpt.Type != null) { retVal.Type = base.ConvertCode(ptcpt.Type); } retVal.Name = ptcpt.LegalName.Parts[0].Value; retVal.Active = true; // Address if (ptcpt.PrimaryAddress != null) { retVal.Address = base.ConvertAddressSet(ptcpt.PrimaryAddress); } // Telecoms if (ptcpt.TelecomAddresses != null) { foreach (var tel in ptcpt.TelecomAddresses) { retVal.Telecom.AddRange(base.ConvertTelecom(tel)); } } var contacts = ptcpt.FindAllComponents(SVC.Core.ComponentModel.HealthServiceRecordSiteRoleType.RepresentitiveOf); foreach (HealthcareParticipant contact in contacts) { ContactEntity ce = new ContactEntity(); // Link var processor = FhirMessageProcessorUtil.GetComponentProcessor(contact.GetType()); var processResult = processor.ProcessComponent(contact, dtls); if (processResult is Practictioner) { var prac = processResult as Practictioner; ce.Name = prac.Name[0]; ce.Address = prac.Address[0]; ce.Gender = prac.Gender; ce.Telecom = prac.Telecom; } if (ce.Name != null) { ce.Name = base.ConvertNameSet(contact.LegalName); } if (contact.TelecomAddresses != null) { foreach (var t in contact.TelecomAddresses) { ce.Telecom.AddRange(base.ConvertTelecom(t)); } } if (contact.PrimaryAddress != null) { ce.Address = base.ConvertAddressSet(contact.PrimaryAddress)[0]; } retVal.ContactEntity.Add(ce); } return(retVal); }