Beispiel #1
0
        private void FillValues(TerminologyOperation termOp, string version, string code, string filter, string vsIdentifier, int offsetNo, int countNo)
        {
            this.GetVsProperties(vsIdentifier);

            this.valueSet   = new ValueSet();
            this.codeSystem = new CodeSystem();

            this.valueSet.Id   = this.vsId;
            this.codeSystem.Id = "NZMT";

            this.codeSystem.CaseSensitive = false;
            this.codeSystem.Content       = CodeSystem.CodeSystemContentMode.NotPresent;
            this.codeSystem.Experimental  = false;
            this.codeSystem.Compositional = false;
            this.codeSystem.VersionNeeded = false;

            // Code System properties
            this.codeSystem.Property.Add(new CodeSystem.PropertyComponent {
                Code = "substance", Description = "The Generic Substance (Medicinal Product) & ingredient data relating to this Code.", Type = CodeSystem.PropertyType.Code
            });

            // there is no Value Set that contains the whole of NZMT
            //this.codeSystem.ValueSet = "http://nzmt.org.nz/vs";

            this.valueSet.Url   = this.vsURL;
            this.codeSystem.Url = NzMt.URI;

            this.valueSet.Title   = this.vsTitle;
            this.codeSystem.Title = NzMt.TITLE;

            this.valueSet.Name   = this.valueSet.Id;
            this.codeSystem.Name = this.codeSystem.Id;

            this.valueSet.Description   = new Markdown(this.vsDescription);
            this.codeSystem.Description = new Markdown(NzMt.DESCRIPTION);

            this.valueSet.Version   = NzMt.CURRENT_VERSION;
            this.codeSystem.Version = NzMt.CURRENT_VERSION;

            this.valueSet.Experimental = true;

            this.valueSet.Status   = PublicationStatus.Active;
            this.codeSystem.Status = PublicationStatus.Active;

            this.valueSet.Date   = Hl7.Fhir.Model.Date.Today().Value;
            this.codeSystem.Date = Hl7.Fhir.Model.Date.Today().Value;

            this.valueSet.Publisher   = "Patients First Ltd";
            this.codeSystem.Publisher = "nzulm.org.nz";

            this.valueSet.Copyright   = new Markdown("© 2010+ New Zealand Crown Copyright");
            this.codeSystem.Copyright = new Markdown("© 2010+ New Zealand Crown Copyright");

            ContactPoint cp = new ContactPoint {
                System = ContactPoint.ContactPointSystem.Email, Value = "*****@*****.**"
            };
            ContactDetail cd = new ContactDetail();

            cd.Telecom.Add(cp);
            this.valueSet.Contact.Add(cd);
            this.codeSystem.Contact.Add(cd);

            ValueSet.ConceptSetComponent cs = new ValueSet.ConceptSetComponent();
            ValueSet.ExpansionComponent  es = new ValueSet.ExpansionComponent();

            cs.System  = this.codeSystem.Url;
            cs.Version = this.codeSystem.Version;

            if (!string.IsNullOrEmpty(vsIdentifier))
            {
                cs.Filter.Add(new ValueSet.FilterComponent {
                    Property = "TermType", Op = FilterOperator.Equal, Value = vsIdentifier
                });
            }

            string codeCode       = string.Empty;
            string codeDisplay    = string.Empty;
            string codeDefinition = string.Empty;

            if ((string.IsNullOrEmpty(version) || version == cs.Version) && termOp != TerminologyOperation.define_cs)
            {
                if (termOp != TerminologyOperation.define_vs)
                {
                    List <Coding> codeVals = new List <Coding>();

                    if (termOp == TerminologyOperation.lookup || termOp == TerminologyOperation.validate_code)
                    {
                        codeVals = NzUlmSearch.GetNzmtCombinedByCode(code);
                        if (codeVals.Count > 0 || termOp == TerminologyOperation.validate_code)
                        {
                            // create filter as need to subsequently check that it belongs in the passed Value Set
                            filter = codeVals[0].Display;
                        }
                    }

                    if (termOp == TerminologyOperation.expand || termOp == TerminologyOperation.validate_code)
                    {
                        if (vsId.StartsWith("NZULM-PT-"))
                        {
                            codeVals = NzUlmSearch.GetNZULMPrescribingTerms(filter, vsId.Replace("NZULM-PT-", "").ToLower());
                        }
                        else if (vsId == "NZULM-CTPP")
                        {
                            codeVals = NzUlmSearch.GetContaineredTradeProductPackByTerm(filter);
                        }
                        else if (vsId == "NZULM-MP")
                        {
                            codeVals = NzUlmSearch.GetMedicinalProductByTerm(filter);
                        }
                        else if (vsId == "NZULM-MPP")
                        {
                            codeVals = NzUlmSearch.GetMedicinalProductPackByTerm(filter);
                        }
                        else if (vsId == "NZULM-MPUU")
                        {
                            codeVals = NzUlmSearch.GetMedicinalProductUnitOfUseByTerm(filter);
                        }
                        else if (vsId == "NZULM-TP")
                        {
                            codeVals = NzUlmSearch.GetTradeProductByTerm(filter);
                        }
                        else if (vsId == "NZULM-TPP")
                        {
                            codeVals = NzUlmSearch.GetTradeProductPackByTerm(filter);
                        }
                        else if (vsId == "NZULM-TPUU")
                        {
                            codeVals = NzUlmSearch.GetTradeProductUnitOfUseByTerm(filter);
                        }
                        else
                        {
                            throw new Exception(TerminologyValueSet.UNFOUND_VALUESET);
                        }
                    }

                    // filtering performed at DB Layer, so add all returned concepts
                    foreach (Coding codeVal in codeVals)
                    {
                        ValueSet.DesignationComponent desig = new ValueSet.DesignationComponent {
                            ElementId = "NZULM", Value = codeVal.Version
                        };
                        cs.Concept.Add(new ValueSet.ConceptReferenceComponent {
                            Code = codeVal.Code, Display = codeVal.Display
                        });
                        es.Contains.Add(new ValueSet.ContainsComponent {
                            Code = codeVal.Code, Display = codeVal.Display, System = cs.System
                        });
                        this.codeSystem.Concept.Add(new CodeSystem.ConceptDefinitionComponent {
                            Code = codeVal.Code, Display = codeVal.Display, Definition = codeVal.Version, ElementId = codeVal.ElementId
                        });
                    }

                    if (termOp == TerminologyOperation.expand || termOp == TerminologyOperation.validate_code)
                    {
                        this.valueSet = TerminologyValueSet.AddExpansion(this.valueSet, es, offsetNo, countNo);
                    }
                    else if (termOp == TerminologyOperation.define_vs)
                    {
                        this.valueSet.Compose = new ValueSet.ComposeComponent();
                        this.valueSet.Compose.Include.Add(cs);
                    }
                }
                else
                {
                    this.valueSet.Compose = new ValueSet.ComposeComponent();
                    this.valueSet.Compose.Include.Add(cs);
                }
            }
        }
Beispiel #2
0
        private void FillValues(TerminologyOperation termOp, string version, string code, string filter, string vsIdentifier, int offsetNo, int countNo)
        {
            this.valueSet   = new ValueSet();
            this.codeSystem = new CodeSystem();

            string idSuffix = filter.Replace(" ", "_");

            this.valueSet.Id   = "fhir_rxnorm_vs_" + idSuffix;
            this.codeSystem.Id = "RXNORM";

            this.codeSystem.CaseSensitive = false;
            this.codeSystem.Content       = CodeSystem.CodeSystemContentMode.NotPresent;
            this.codeSystem.Experimental  = false;
            this.codeSystem.Compositional = false;
            this.codeSystem.VersionNeeded = false;

            // Code System properties
            //this.codeSystem.Property.Add(new CodeSystem.PropertyComponent { Code = "substance", Description = "The Generic Substance (Medicinal Product) & ingredient data relating to this Code.", Type = CodeSystem.PropertyType.Code });

            // Value Set that contains all RxNorm CUIs
            this.codeSystem.ValueSet = "http://www.nlm.nih.gov/research/umls/rxnorm/vs";

            this.valueSet.Url   = ServerCapability.TERMINZ_CANONICAL + "/ValueSet/rxnorm/" + idSuffix;
            this.codeSystem.Url = FhirRxNorm.URI;

            this.valueSet.Title   = FhirRxNorm.TITLE;
            this.codeSystem.Title = FhirRxNorm.TITLE;

            this.valueSet.Name   = this.valueSet.Id;
            this.codeSystem.Name = this.codeSystem.Id;

            this.valueSet.Description   = new Markdown(FhirRxNorm.DESCRIPTION);
            this.codeSystem.Description = new Markdown(FhirRxNorm.DESCRIPTION);

            this.valueSet.Version   = FhirRxNorm.CURRENT_VERSION;
            this.codeSystem.Version = FhirRxNorm.CURRENT_VERSION;

            this.valueSet.Experimental = true;

            this.valueSet.Status   = PublicationStatus.Active;
            this.codeSystem.Status = PublicationStatus.Active;

            this.valueSet.Date   = Hl7.Fhir.Model.Date.Today().Value;
            this.codeSystem.Date = Hl7.Fhir.Model.Date.Today().Value;

            this.valueSet.Publisher   = "Patients First Ltd";
            this.codeSystem.Publisher = "http://www.nlm.nih.gov/";

            this.valueSet.Copyright   = new Markdown("Unified Medical Language System® (UMLS®)");
            this.codeSystem.Copyright = new Markdown("Unified Medical Language System® (UMLS®)");

            ContactPoint cp = new ContactPoint {
                System = ContactPoint.ContactPointSystem.Email, Value = "*****@*****.**"
            };
            ContactDetail cd = new ContactDetail();

            cd.Telecom.Add(cp);
            this.valueSet.Contact.Add(cd);
            this.codeSystem.Contact.Add(cd);

            ValueSet.ConceptSetComponent cs = new ValueSet.ConceptSetComponent();
            ValueSet.ExpansionComponent  es = new ValueSet.ExpansionComponent();

            cs.System  = this.codeSystem.Url;
            cs.Version = this.codeSystem.Version;

            //if (!string.IsNullOrEmpty(vsIdentifier))
            //{
            //    cs.Filter.Add(new ValueSet.FilterComponent { Property = "TTY", Op = FilterOperator.Equal, Value = vsIdentifier });
            //}

            string codeCode       = string.Empty;
            string codeDisplay    = string.Empty;
            string codeDefinition = string.Empty;

            if ((string.IsNullOrEmpty(version) || version == cs.Version) && termOp != TerminologyOperation.define_cs)
            {
                if (termOp != TerminologyOperation.define_vs)
                {
                    List <Coding> codeVals = new List <Coding>();

                    if (termOp == TerminologyOperation.lookup || termOp == TerminologyOperation.validate_code)
                    {
                        codeVals = RxNormSearch.GetConceptByCode(code);
                        if (codeVals.Count > 0 || termOp == TerminologyOperation.validate_code)
                        {
                            // create filter as need to subsequently check that it belongs in the passed Value Set
                            filter = codeVals[0].Display;
                        }
                    }

                    if (termOp == TerminologyOperation.expand || termOp == TerminologyOperation.validate_code)
                    {
                        codeVals = RxNormSearch.GetConceptsByTerm(filter);
                    }

                    // filtering performed at DB Layer, so add all returned concepts
                    foreach (Coding codeVal in codeVals)
                    {
                        ValueSet.DesignationComponent desig = new ValueSet.DesignationComponent {
                            ElementId = "RXNORM", Value = codeVal.Version
                        };
                        cs.Concept.Add(new ValueSet.ConceptReferenceComponent {
                            Code = codeVal.Code, Display = codeVal.Display
                        });
                        es.Contains.Add(new ValueSet.ContainsComponent {
                            Code = codeVal.Code, Display = codeVal.Display, System = cs.System
                        });
                        this.codeSystem.Concept.Add(new CodeSystem.ConceptDefinitionComponent {
                            Code = codeVal.Code, Display = codeVal.Display, Definition = codeVal.Version, ElementId = codeVal.ElementId
                        });
                    }

                    if (termOp == TerminologyOperation.expand || termOp == TerminologyOperation.validate_code)
                    {
                        this.valueSet = TerminologyValueSet.AddExpansion(this.valueSet, es, offsetNo, countNo);
                    }
                    else if (termOp == TerminologyOperation.define_vs)
                    {
                        this.valueSet.Compose = new ValueSet.ComposeComponent();
                        this.valueSet.Compose.Include.Add(cs);
                    }
                }
                else
                {
                    this.valueSet.Compose = new ValueSet.ComposeComponent();
                    this.valueSet.Compose.Include.Add(cs);
                }
            }
        }