public override IDeepCopyable CopyTo(IDeepCopyable other)
            {
                var dest = other as ContextComponent;

                if (dest != null)
                {
                    base.CopyTo(dest);
                    if (Encounter != null)
                    {
                        dest.Encounter = (Hl7.Fhir.Model.ResourceReference)Encounter.DeepCopy();
                    }
                    if (Event != null)
                    {
                        dest.Event = new List <Hl7.Fhir.Model.CodeableConcept>(Event.DeepCopy());
                    }
                    if (Period != null)
                    {
                        dest.Period = (Hl7.Fhir.Model.Period)Period.DeepCopy();
                    }
                    if (FacilityType != null)
                    {
                        dest.FacilityType = (Hl7.Fhir.Model.CodeableConcept)FacilityType.DeepCopy();
                    }
                    if (PracticeSetting != null)
                    {
                        dest.PracticeSetting = (Hl7.Fhir.Model.CodeableConcept)PracticeSetting.DeepCopy();
                    }
                    if (SourcePatientInfo != null)
                    {
                        dest.SourcePatientInfo = (Hl7.Fhir.Model.ResourceReference)SourcePatientInfo.DeepCopy();
                    }
                    if (Related != null)
                    {
                        dest.Related = new List <Hl7.Fhir.Model.DocumentReference.RelatedComponent>(Related.DeepCopy());
                    }
                    return(dest);
                }
                else
                {
                    throw new ArgumentException("Can only copy to an object of the same type", "other");
                }
            }
示例#2
0
        public override ExtrinsicObject ToRegistryObject()
        {
            var document = new ExtrinsicObject
            {
                Id          = EntryUuid,
                Home        = HomeCommunityId,
                Status      = AvailabilityStatus,
                Description = XmlUtil.LocalString(Comments),
                Name        = XmlUtil.LocalString(Title),
                MimeType    = MimeType,
                ObjectType  = DocumentEntryType
            };

            document.Classifications.Add(new Classification
            {
                ClassificationScheme = XdsClassification.Document,
                ClassifiedObject     = EntryUuid,
            });

            if (Author != null)
            {
                var authorAttribute = Author.ToClassification(XdsClassification.DocumentAuthor, EntryUuid);
                document.Classifications.Add(authorAttribute);
            }
            if (Class != null && !string.IsNullOrEmpty(Class.Value))
            {
                document.Classifications.Add(Class.ToClassification(EntryUuid));
            }

            if (Confidentiality != null && Confidentiality.Any(c => !string.IsNullOrEmpty(c.Value)))
            {
                document.Classifications.AddRange(
                    Confidentiality.Select(c => c.ToClassification(EntryUuid)));
            }
            if (CreationTime != null)
            {
                document.Slots.Add(XmlUtil.SingleSlot("creationTime", _hl7CreationTime.Encode()));
            }

            if (EventCodes != null && EventCodes.Any(fc => !string.IsNullOrEmpty(fc.Value)))
            {
                document.Classifications.AddRange(EventCodes.Select(fc => fc.ToClassification(EntryUuid)));
            }

            if (Format != null && !string.IsNullOrEmpty(Format.Value))
            {
                document.Classifications.Add(Format.ToClassification(EntryUuid));
            }

            if (!string.IsNullOrEmpty(Hash))
            {
                document.Slots.Add(XmlUtil.SingleSlot("hash", Hash));
            }

            if (HealthCareFacilityType != null && !string.IsNullOrEmpty(HealthCareFacilityType.Value))
            {
                document.Classifications.Add(HealthCareFacilityType.ToClassification(EntryUuid));
            }

            if (!string.IsNullOrEmpty(LanguageCode))
            {
                document.Slots.Add(XmlUtil.SingleSlot("languageCode", LanguageCode));
            }

            if (LegalAuthenticator != null)
            {
                document.Slots.Add(XmlUtil.SingleSlot("legalAuthenticator", LegalAuthenticator.Hl7Person.Encode()));
            }

            string patientId = PatientId != null?PatientId.ToString() : "";

            if (!string.IsNullOrEmpty(patientId))
            {
                document.ExternalIdentifiers.Add(new ExternalIdentifier
                {
                    IdentificationScheme = XdsIdentification.DocumentPatientId,
                    RegistryObject       = EntryUuid,
                    Name  = XmlUtil.LocalString("XDSFolder.patientId"),
                    Value = patientId
                });
            }

            if (PracticeSetting != null && !string.IsNullOrEmpty(PracticeSetting.Value))
            {
                document.Classifications.Add(PracticeSetting.ToClassification(EntryUuid));
            }

            if (!string.IsNullOrEmpty(RepositoryUniqueId))
            {
                document.Slots.Add(XmlUtil.SingleSlot("repositoryUniqueId", RepositoryUniqueId));
            }

            if (ServiceStartTime != null)
            {
                document.Slots.Add(XmlUtil.SingleSlot("serviceStartTime", _hl7ServiceStartTime.Encode()));
            }

            if (ServiceStopTime != null)
            {
                document.Slots.Add(XmlUtil.SingleSlot("serviceStopTime", _hl7ServiceStopTime.Encode()));
            }

            if (Size != null)
            {
                document.Slots.Add(XmlUtil.SingleSlot("size", Size.Value.ToString()));
            }

            if (SourcePatientId != null)
            {
                document.Slots.Add(XmlUtil.SingleSlot("sourcePatientId", SourcePatientId.Hl7Identifier.Encode()));
            }

            if (SourcePatientInfo != null && SourcePatientInfo.Any())
            {
                document.Slots.Add(new Slot
                {
                    Name   = "sourcePatientInfo",
                    Values = SourcePatientInfo
                });
            }

            if (Type != null)
            {
                document.Classifications.Add(Type.ToClassification(EntryUuid));
            }

            if (!string.IsNullOrEmpty(Uri))
            {
                document.Slots.Add(XmlUtil.SingleSlot("URI", Uri));
            }

            if (!string.IsNullOrEmpty(UniqueId))
            {
                document.ExternalIdentifiers.Add(new ExternalIdentifier
                {
                    IdentificationScheme = XdsIdentification.DocumentUniqueId,
                    RegistryObject       = EntryUuid,
                    Name  = XmlUtil.LocalString("XDSFolder.uniqueId"),
                    Value = UniqueId
                });
            }
            if (ReferenceIds != null && ReferenceIds.Any())
            {
                document.Slots.Add(new Slot
                {
                    Name   = "urn:ihe:iti:xds:2013:referenceIdList",
                    Values = ReferenceIds.Select(id => id.Hl7Identifier.Encode()).ToList()
                });
            }
            if (LimitedMetadata)
            {
                document.Classifications.Add(new Classification
                {
                    ClassificationScheme = XdsClassification.DocumentLimitedMetadata,
                    ClassifiedObject     = EntryUuid
                });
            }

            return(document);
        }