public override ErrorList Validate()
        {
            var result = new ErrorList();

            result.AddRange(base.Validate());

            if (Identifier != null)
            {
                result.AddRange(Identifier.Validate());
            }
            if (NameElement != null)
            {
                result.AddRange(NameElement.Validate());
            }
            if (Type != null)
            {
                result.AddRange(Type.Validate());
            }
            if (DescriptionElement != null)
            {
                result.AddRange(DescriptionElement.Validate());
            }
            if (Status != null)
            {
                result.AddRange(Status.Validate());
            }
            if (EffectiveTime != null)
            {
                result.AddRange(EffectiveTime.Validate());
            }
            if (Quantity != null)
            {
                result.AddRange(Quantity.Validate());
            }
            if (Ingredient != null)
            {
                Ingredient.ForEach(elem => result.AddRange(elem.Validate()));
            }
            if (QuantityMode != null)
            {
                result.AddRange(QuantityMode.Validate());
            }

            return(result);
        }
 public TokenEntity(TokenIdentityEntity onBehalfOf, TokenIdentityEntity initiator, TokenIdentityEntity[] consumedBy)
 {
     if (onBehalfOf != null)
     {
         this.OnBehalfOf = onBehalfOf;
     }
     if (initiator != null)
     {
         this.Initiator = initiator;
     }
     if (consumedBy != null)
     {
         this.ConsumedBy = consumedBy;
     }
     ModelVersion          = "1.0";
     ExpirationIntervalSec = int.MaxValue;
     // default Initiation and EffectiveTime to now
     InitiationTime  = DateTime.Now;
     EffectiveTime   = InitiationTime;
     ExpirationTime  = EffectiveTime.AddSeconds(ExpirationIntervalSec);
     CurrentUseCount = 0;
     MaxUseCount     = int.MaxValue;
 }
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as MedicationAdministration;

            if (dest != null)
            {
                base.CopyTo(dest);
                if (Identifier != null)
                {
                    dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
                }
                if (StatusElement != null)
                {
                    dest.StatusElement = (Code <Hl7.Fhir.Model.MedicationAdministrationStatus>)StatusElement.DeepCopy();
                }
                if (Patient != null)
                {
                    dest.Patient = (Hl7.Fhir.Model.ResourceReference)Patient.DeepCopy();
                }
                if (Practitioner != null)
                {
                    dest.Practitioner = (Hl7.Fhir.Model.ResourceReference)Practitioner.DeepCopy();
                }
                if (Encounter != null)
                {
                    dest.Encounter = (Hl7.Fhir.Model.ResourceReference)Encounter.DeepCopy();
                }
                if (Prescription != null)
                {
                    dest.Prescription = (Hl7.Fhir.Model.ResourceReference)Prescription.DeepCopy();
                }
                if (WasNotGivenElement != null)
                {
                    dest.WasNotGivenElement = (Hl7.Fhir.Model.FhirBoolean)WasNotGivenElement.DeepCopy();
                }
                if (ReasonNotGiven != null)
                {
                    dest.ReasonNotGiven = new List <Hl7.Fhir.Model.CodeableConcept>(ReasonNotGiven.DeepCopy());
                }
                if (ReasonGiven != null)
                {
                    dest.ReasonGiven = new List <Hl7.Fhir.Model.CodeableConcept>(ReasonGiven.DeepCopy());
                }
                if (EffectiveTime != null)
                {
                    dest.EffectiveTime = (Hl7.Fhir.Model.Element)EffectiveTime.DeepCopy();
                }
                if (Medication != null)
                {
                    dest.Medication = (Hl7.Fhir.Model.Element)Medication.DeepCopy();
                }
                if (Device != null)
                {
                    dest.Device = new List <Hl7.Fhir.Model.ResourceReference>(Device.DeepCopy());
                }
                if (NoteElement != null)
                {
                    dest.NoteElement = (Hl7.Fhir.Model.FhirString)NoteElement.DeepCopy();
                }
                if (Dosage != null)
                {
                    dest.Dosage = (Hl7.Fhir.Model.MedicationAdministration.DosageComponent)Dosage.DeepCopy();
                }
                return(dest);
            }
            else
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }
        }
Exemple #4
0
        public string BindHeader(string title, ClinicalDocument clinicalDoc, Factory hl7factory, ICS realmCode)
        {
            string docheader = String.Empty;

            header                     = new CCDAHeader();
            realmCode_code             = new RealmCode();
            typeId                     = new TypeId();
            templateId                 = new TemplateId();
            id                         = new Id();
            code                       = new Code();
            effectiveTime              = new EffectiveTime();
            confidentialityCode        = new ConfidentialityCode();
            languageCode               = new LanguageCode();
            setId                      = new SetId();
            versionNumber              = new VersionNumber();
            header.Id                  = id;
            header.languageCode        = languageCode;
            header.realmCode           = realmCode_code;
            header.code                = code;
            header.effectiveTime       = effectiveTime;
            header.confidentialityCode = confidentialityCode;
            header.setId               = setId;
            header.versionNumber       = versionNumber;
            header.TemplateId          = templateId;
            header.typeId              = typeId;
            header.title               = title;
            realmCode                  = hl7factory.CreateCS();
            realmCode                  = hl7factory.CreateCS();
            realmCode.Code             = header.realmCode.code;
            clinicalDoc.RealmCode.Add(realmCode);
            // Manage Clinical Report Header
            //Manage TypeId
            clinicalDoc.TypeId.Root      = header.typeId.root;
            clinicalDoc.TypeId.Extension = header.typeId.extension;
            //END
            //Manage template Id
            clinicalDoc.TemplateId.Append().Root = header.TemplateId.root;
            //END
            //Manage Header Id
            clinicalDoc.Id.Init(header.Id.root, header.Id.extension);
            //END
            //Manage Header Code
            clinicalDoc.Code.Code           = header.code.code;
            clinicalDoc.Code.CodeSystemName = header.code.codeSystemName;
            clinicalDoc.Code.DisplayName    = header.code.displayName;
            clinicalDoc.Code.CodeSystem     = header.code.codeSystem;
            //END
            //Manage Header Title
            clinicalDoc.Title.Text = header.title;
            //END
            //Manage Header Effective Date
            clinicalDoc.EffectiveTime.AsDateTime = Convert.ToDateTime(header.effectiveTime.value);
            //END
            //Manage Header Confidencial Code
            clinicalDoc.ConfidentialityCode.Code       = header.confidentialityCode.code;
            clinicalDoc.ConfidentialityCode.CodeSystem = header.confidentialityCode.codeSystem;
            //END
            //Manage Header Language Code
            clinicalDoc.LanguageCode.Code = header.languageCode.code;
            //END
            //Manage Header SetId
            clinicalDoc.SetId.Root      = header.setId.root;
            clinicalDoc.SetId.Extension = header.setId.extension;
            //END
            //Manage Header Version
            clinicalDoc.VersionNumber.Value = header.versionNumber.value;
            //END
            //END
            //docheader = "<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet type='text/xsl' href='CDA.xsl'?>"+clinicalDoc.Xml;
            docheader = clinicalDoc.Xml;

            return(docheader.ToString());
        }
Exemple #5
0
        public XElement CreateCDA()
        {
            ensureValueProvided(IdRoot, nameof(IdRoot));
            ensureValueProvided(IdExtension, nameof(IdExtension));
            ensureValueProvided(EffectiveTime == DateTime.MinValue ? null : "", nameof(EffectiveTime));
            ensureValueProvided(PatientIdRoot, nameof(PatientIdRoot));
            ensureValueProvided(PatientIdExtension, nameof(PatientIdExtension));
            ensureValueProvided(AuthorIdRoot, nameof(AuthorIdRoot));
            ensureValueProvided(AuthorIdExtension, nameof(AuthorIdExtension));
            ensureValueProvided(OrganizationRoot, nameof(OrganizationRoot));
            ensureValueProvided(OrganizationExtension, nameof(OrganizationExtension));

            XElement patient = null;

            if (PatientGivenName != null || PatientFamilyName != null)
            {
                patient = new XElement(hl7 + "patient", nameElement(PatientGivenName, PatientFamilyName));
            }

            XElement assignedPerson = null;

            if (AuthorGivenName != null || AuthorFamilyName != null)
            {
                assignedPerson = new XElement(hl7 + "assignedPerson", nameElement(AuthorGivenName, AuthorFamilyName));
            }

            return(new XElement(hl7 + "ClinicalDocument",
                                new XElement(hl7 + "typeId", new XAttribute("root", "2.16.840.1.113883.1.3"), new XAttribute("extension", "POCD_HD000040")),
                                idElement(IdRoot, IdExtension),
                                new XElement(hl7 + "code"),
                                new XElement(hl7 + "effectiveTime", new XAttribute("value", EffectiveTime.ToString("yyyyMMddHHmmss"))),
                                new XElement(hl7 + "confidentialityCode"),
                                new XElement(hl7 + "recordTarget",
                                             new XElement(hl7 + "patientRole",
                                                          idElement(PatientIdRoot, PatientIdExtension),
                                                          patient
                                                          )
                                             ),
                                new XElement(hl7 + "author",
                                             new XElement(hl7 + "time", new XAttribute("value", EffectiveTime.ToString("yyyyMMddHHmmss"))),
                                             new XElement(hl7 + "assignedAuthor",
                                                          idElement(AuthorIdRoot, AuthorIdExtension),
                                                          assignedPerson
                                                          )
                                             ),
                                new XElement(hl7 + "custodian",
                                             new XElement(hl7 + "assignedCustodian",
                                                          new XElement(hl7 + "representedCustodianOrganization",
                                                                       idElement(OrganizationRoot, OrganizationExtension)
                                                                       )
                                                          )
                                             ),
                                new XElement(hl7 + "component",
                                             new XElement(hl7 + "nonXMLBody",
                                                          new XElement(hl7 + "text", new XAttribute("mediaType", _mimeType), new XAttribute("representation", "B64"), Convert.ToBase64String(_contents))
                                                          )
                                             )
                                ));
        }