Beispiel #1
0
        private void CreateCodedValue(VocabularyDomain vocabularyDomain,
                                      String oid, String code, String parentCode, IList <String> childCodes)
        {
            CodeSystem codeSystem_0   = this.factory.CreateCodeSystem(oid);
            CodedValue codeCodedValue = CreateCodedValue(vocabularyDomain,
                                                         codeSystem_0, code);
            CodedValue parentCodeCodedValue = null;

            if (parentCode != null)
            {
                parentCodeCodedValue = CreateCodedValue(vocabularyDomain,
                                                        codeSystem_0, parentCode);
            }
            IList <CodedValue> childCodesCodedValues = new List <CodedValue>();

            if (childCodes != null)
            {
                /* foreach */
                foreach (String childCode  in  childCodes)
                {
                    CodedValue childCodedValue = CreateCodedValue(vocabularyDomain,
                                                                  codeSystem_0, childCode);
                    ILOG.J2CsMapping.Collections.Generics.Collections.Add(childCodesCodedValues, childCodedValue);
                }
            }
            this.factory.CreateCodedValue(codeCodedValue, parentCodeCodedValue,
                                          childCodesCodedValues);
        }
        public void Setup()
        {
            this.tdb = new MockObjectRepository();

            MemoryStream           docStream = new MemoryStream();
            WordprocessingDocument document  = WordprocessingDocument.Create(docStream, WordprocessingDocumentType.Document);

            this.body              = new Body();
            this.mainPart          = document.AddMainDocumentPart();
            this.mainPart.Document = new Document(this.body);

            // Dummy Data
            CodeSystem snomed = this.tdb.FindOrCreateCodeSystem("SNOMED-CT", "1.2.3.4");

            this.vs1 = this.tdb.FindOrCreateValueSet("ValueSet 1", "1.2.3");
            this.tdb.FindOrCreateValueSetMember(this.vs1, snomed, "1", "One");
            this.tdb.FindOrCreateValueSetMember(this.vs1, snomed, "2", "Two");
            this.tdb.FindOrCreateValueSetMember(this.vs1, snomed, "3", "Three");

            this.vs2 = this.tdb.FindOrCreateValueSet("ValueSet 2", "1.2.3.4");
            this.tdb.FindOrCreateValueSetMember(this.vs2, snomed, "1", "One");
            this.tdb.FindOrCreateValueSetMember(this.vs2, snomed, "2", "Two");

            this.vs3 = this.tdb.FindOrCreateValueSet("ValueSet 3", "1.2.3.4.5");
            this.vs3.IsIncomplete = true;
            this.vs3.Source       = "http://www.lantanagroup.com";
        }
Beispiel #3
0
        private void UpdateConstraintCodeSystem(TemplateConstraint constraint, ImportConstraint importConstraint)
        {
            if (importConstraint.CodeSystem != null && !string.IsNullOrEmpty(importConstraint.CodeSystem.identifier))
            {
                ImportCodeSystem importCs        = importConstraint.CodeSystem;
                CodeSystem       foundCodeSystem = this.tdb.CodeSystems.FirstOrDefault(y => y.Oid.ToLower() == importCs.identifier.ToLower());

                if (foundCodeSystem == null)
                {
                    if (string.IsNullOrEmpty(importCs.name))
                    {
                        this.errors.Add(string.Format(
                                            "Code System with oid \"{0}\" could not be found for constraint with number \"{1}\" in template with identifier \"{2}\"",
                                            importCs.identifier,
                                            importConstraint.number,
                                            constraint.Template.Oid));
                        throw new Exception("Constraint has an error.");
                    }

                    foundCodeSystem = new CodeSystem()
                    {
                        Name        = importCs.name,
                        Oid         = importCs.identifier,
                        Description = "Automatically generated by template import"
                    };
                    this.tdb.CodeSystems.Add(foundCodeSystem);
                }

                constraint.CodeSystem = foundCodeSystem;
            }
        }
Beispiel #4
0
        private void ExcelImportConcept(ValueSet valueSet, ImportValueSetChange.ConceptChange checkConcept)
        {
            ValueSetMember member = null;

            if (checkConcept.ChangeType == ImportValueSetChange.ChangeTypes.None)
            {
                return;
            }

            if (checkConcept.ChangeType == ImportValueSetChange.ChangeTypes.Update)
            {
                member = this.tdb.ValueSetMembers.Single(y => y.Id == checkConcept.Id);

                if (member.DisplayName != checkConcept.DisplayName)
                {
                    member.DisplayName = checkConcept.DisplayName;
                }
            }
            else // Add
            {
                CodeSystem codeSystem = this.tdb.CodeSystems.Single(y => y.Oid == checkConcept.CodeSystemOid);

                member = new ValueSetMember()
                {
                    ValueSet    = valueSet,
                    Code        = checkConcept.Code,
                    DisplayName = checkConcept.DisplayName,
                    CodeSystem  = codeSystem,
                    Status      = checkConcept.Status,
                    StatusDate  = checkConcept.StatusDate
                };
                this.tdb.ValueSetMembers.Add(member);
            }
        }
        private Trifolia.DB.CodeSystem FindOrAddCodeSystem(IObjectRepository tdb, string codeSystemOid, string codeSystemName)
        {
            Trifolia.DB.CodeSystem foundCodeSystem = addedCodeSystems.SingleOrDefault(y => y.Oid == codeSystemOid);

            // If we haven't added the code system as part of this save, search the database for the code system
            if (foundCodeSystem == null)
            {
                foundCodeSystem = tdb.CodeSystems.FirstOrDefault(y => y.Oid == codeSystemOid);
            }

            // If no code system was found that we added recently, and it was not found in the database, create a new one
            if (foundCodeSystem == null)
            {
                foundCodeSystem = new CodeSystem()
                {
                    Oid        = codeSystemOid,
                    Name       = codeSystemName,
                    LastUpdate = DateTime.Now
                };

                tdb.CodeSystems.Add(foundCodeSystem);
                addedCodeSystems.Add(foundCodeSystem);
            }

            return(foundCodeSystem);
        }
        public void TestSetup()
        {
            this.tdb = new MockObjectRepository();
            this.tdb.InitializeCDARepository();

            CodeSystem cs = tdb.FindOrCreateCodeSystem("LOINC", "1.2.3.4.5");

            this.vs1 = tdb.FindOrCreateValueSet("Test Valueset 1", "1.2.3.4");
            this.tdb.FindOrCreateValueSetMember(this.vs1, cs, "1", "One", "active", "1/1/2000");
            this.tdb.FindOrCreateValueSetMember(this.vs1, cs, "2", "Two", "active", "1/1/2000");
            this.tdb.FindOrCreateValueSetMember(this.vs1, cs, "1", "One", "inactive", "1/1/2001");
            this.tdb.FindOrCreateValueSetMember(this.vs1, cs, "3", "Three", "active", "1/1/2001");
            this.tdb.FindOrCreateValueSetMember(this.vs1, cs, "1", "One", "active", "1/1/2002");

            this.vs2 = tdb.FindOrCreateValueSet("Test Valueset 2", "4.3.2.1");
            this.tdb.FindOrCreateValueSetMember(this.vs2, cs, "1", "One");
            this.tdb.FindOrCreateValueSetMember(this.vs2, cs, "2", "Two");
            this.tdb.FindOrCreateValueSetMember(this.vs2, cs, "3", "Three", "inactive", "1/1/2000");
            this.tdb.FindOrCreateValueSetMember(this.vs2, cs, "4", "Four", "active", "1/1/2000");

            this.vs3 = tdb.FindOrCreateValueSet("Test Valueset 3", "1.4.2.3");
            this.tdb.FindOrCreateValueSetMember(this.vs3, cs, "1", "One");
            this.tdb.FindOrCreateValueSetMember(this.vs3, cs, "2", "Two");
            this.tdb.FindOrCreateValueSetMember(this.vs3, cs, "3", "Three", valueSetStatus: "inactive", dateOfValueSetStatus: "08/05/2013");
            this.tdb.FindOrCreateValueSetMember(this.vs3, cs, "4", "Four", valueSetStatus: "active");
            this.tdb.FindOrCreateValueSetMember(this.vs3, cs, "5", "Five");

            this.ig = this.tdb.FindOrCreateImplementationGuide(Constants.IGTypeNames.CDA, "Test IG");
        }
Beispiel #7
0
        private void SaveConceptProperties(IObjectRepository tdb, ValueSetMember member, ConceptItem concept)
        {
            if (member.Code != concept.Code)
            {
                member.Code = concept.Code;
            }

            if (member.DisplayName != concept.DisplayName)
            {
                member.DisplayName = concept.DisplayName;
            }

            CodeSystem foundCodeSystem = tdb.CodeSystems.Single(y => y.Id == concept.CodeSystemId);

            if (member.CodeSystem != foundCodeSystem)
            {
                member.CodeSystem = foundCodeSystem;
            }

            if (member.Status != concept.Status)
            {
                member.Status = concept.Status;
            }

            if (member.StatusDate != concept.StatusDate)
            {
                member.StatusDate = concept.StatusDate;
            }
        }
Beispiel #8
0
        public static CodeSystem GetCodeSystem()
        {
            var CodeSys = new CodeSystem();

            CodeSys.Id           = "pyroserver";
            CodeSys.Url          = PyroServerCodeSystem.System;
            CodeSys.Version      = "1.00";
            CodeSys.Name         = "PyroServerCodeSystem";
            CodeSys.Title        = "The Pyro Server CodeSystem";
            CodeSys.Status       = PublicationStatus.Active;
            CodeSys.Experimental = false;
            //When the CodeSystem was last editied
            CodeSys.DateElement = new FhirDateTime(new DateTimeOffset(2018, 05, 01, 10, 00, 00, new TimeSpan(8, 0, 0)));
            CodeSys.Publisher   = "Pyrohealth.net";
            var AngusContactDetail = Common.PyroHealthInformation.PyroHealthContactDetailAngusMillar.GetContactDetail();

            CodeSys.Contact = new List <ContactDetail>()
            {
                AngusContactDetail
            };
            CodeSys.Description   = new Markdown("List of codes used throughout the Pyro FHIR Server to identity concepts key to the operation of the server.");
            CodeSys.CaseSensitive = true;
            CodeSys.Compositional = false;
            CodeSys.Count         = CodeSys.Concept.Count;
            CodeSys.Content       = CodeSystem.CodeSystemContentMode.Complete;
            CodeSys.Concept       = new List <CodeSystem.ConceptDefinitionComponent>()
            {
                new CodeSystem.ConceptDefinitionComponent()
                {
                    Code       = Codes.ActiveCompartment.GetPyroLiteral(),
                    Display    = "Active Compartment",
                    Definition = "Used to indicate that a CompartmentDefinition Resource is used as an active Compartment in the FHIR server.",
                },
                new CodeSystem.ConceptDefinitionComponent()
                {
                    Code       = Codes.CompartmentDefinition.GetPyroLiteral(),
                    Display    = "CompartmentDefinition",
                    Definition = "A FHIR CompartmentDefinition resource definied for use in a Pyro FHIR server",
                },
                new CodeSystem.ConceptDefinitionComponent()
                {
                    Code       = Codes.HiServiceCallAudit.GetPyroLiteral(),
                    Display    = "HI Service Call Audit",
                    Definition = "An Audit event in response to a web service call made to the Australian Healthcare Identifer Service (HI Service) by a Pyro FHIR server",
                },
                new CodeSystem.ConceptDefinitionComponent()
                {
                    Code       = Codes.ServerInstance.GetPyroLiteral(),
                    Display    = "Server Instance",
                    Definition = "An instance of a Pyro FHIR server",
                },
                new CodeSystem.ConceptDefinitionComponent()
                {
                    Code       = Codes.Protected.GetPyroLiteral(),
                    Display    = "Protected",
                    Definition = "Protected entities and resource can not be updated or deleted",
                },
            };
            return(CodeSys);
        }
        private static Resource ValidateCodeOperation(string systemURL, NameValueCollection queryParam)
        {
            string codeVal     = Utilities.GetQueryValue("code", queryParam);
            string displayVal  = Utilities.GetQueryValue("display", queryParam);
            string languageVal = Utilities.GetQueryValue("displayLanguage", queryParam);

            if (!string.IsNullOrEmpty(languageVal) && languageVal != "en-NZ")
            {
                throw new Exception(UNSUPPORTED_DISPLAY_LANGUAGE);
            }

            FhirBoolean validCode    = new FhirBoolean(false);
            FhirString  validDisplay = new FhirString();

            if (FhirSnomed.IsValidURI(systemURL))
            {
                validCode    = new FhirBoolean(FhirSnomed.ValidateCode(codeVal, displayVal, out string prefTerm));
                validDisplay = new FhirString(prefTerm);
            }
            else
            {
                CodeSystem codeSys = GetCodeSystem(TerminologyOperation.validate_code, systemURL, queryParam);

                foreach (CodeSystem.ConceptDefinitionComponent cc in codeSys.Concept)
                {
                    if (string.IsNullOrEmpty(displayVal))
                    {
                        validCode    = new FhirBoolean(true);
                        validDisplay = new FhirString(cc.Display);
                    }
                    else if (displayVal.Trim().ToLower() == cc.Display.Trim().ToLower())
                    {
                        validCode    = new FhirBoolean(true);
                        validDisplay = new FhirString(cc.Display);
                    }
                    else
                    {
                        validDisplay = new FhirString(cc.Display);
                    }
                }
            }

            // build return parameters resource from search result

            Parameters param = new Parameters();

            param.Add("result", validCode);

            if (validCode.Value == false)
            {
                param.Add("message", new FhirString("The code/display value " + codeVal + " / " + displayVal + " passed is incorrect"));
            }

            if (!string.IsNullOrEmpty(validDisplay.Value))
            {
                param.Add("display", validDisplay);
            }

            return(param);
        }
Beispiel #10
0
        public static bool CanOverride(this CodeSystem codeSystem, IObjectRepository tdb)
        {
            if (codeSystem == null)
            {
                return(true);
            }

            if (!CheckPoint.Instance.HasSecurables(SecurableNames.TERMINOLOGY_OVERRIDE))
            {
                return(false);
            }

            if (CheckPoint.Instance.IsDataAdmin)
            {
                return(true);
            }

            var publishedImplementationGuides = (from tc in codeSystem.Constraints  // Published constraints that directly reference the CS
                                                 join t in tdb.Templates on tc.TemplateId equals t.Id
                                                 where t.OwningImplementationGuide.IsPublished()
                                                 select t.OwningImplementationGuideId)
                                                .Union(         // Valuesets that are bound to a published constraint that use the CS
                from vsm in codeSystem.Members
                join tc in tdb.TemplateConstraints on vsm.ValueSetId equals tc.ValueSetId
                join t in tdb.Templates on tc.TemplateId equals t.Id
                where t.OwningImplementationGuide.IsPublished()
                select t.OwningImplementationGuideId).AsEnumerable();

            var uneditablePublishedImplementationGuides = (from igid in publishedImplementationGuides
                                                           where !CheckPoint.Instance.GrantEditImplementationGuide(igid)
                                                           select igid);

            return(uneditablePublishedImplementationGuides.Count() == 0);
        }
Beispiel #11
0
        ///<summary>Inserts one CodeSystem into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(CodeSystem codeSystem, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                codeSystem.CodeSystemNum = ReplicationServers.GetKey("codesystem", "CodeSystemNum");
            }
            string command = "INSERT INTO codesystem (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "CodeSystemNum,";
            }
            command += "CodeSystemName,VersionCur,VersionAvail,HL7OID,Note) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(codeSystem.CodeSystemNum) + ",";
            }
            command +=
                "'" + POut.String(codeSystem.CodeSystemName) + "',"
                + "'" + POut.String(codeSystem.VersionCur) + "',"
                + "'" + POut.String(codeSystem.VersionAvail) + "',"
                + "'" + POut.String(codeSystem.HL7OID) + "',"
                + "'" + POut.String(codeSystem.Note) + "')";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                codeSystem.CodeSystemNum = Db.NonQ(command, true, "CodeSystemNum", "codeSystem");
            }
            return(codeSystem.CodeSystemNum);
        }
Beispiel #12
0
    // Update is called once per frame
    void Interact()
    {
        GameObject ui = GameObject.Find("UI").transform.GetChild(0).gameObject; // epic

        ui.SetActive(!ui.activeSelf);

        GameObject   edo    = ui.transform.GetChild(0).GetChild(0).GetChild(0).gameObject;
        ScriptEditor editor = edo.GetComponent <ScriptEditor>();

        editor.calback = this;

        CodeSystem d = GetComponentInChildren <CodeSystem>();

        editor.editable = !d.DoNotEdit;

        if (!ui.activeSelf)
        {
            d.CurrentScript = editor.stringToEdit;
        }
        else
        {
            editor.stringToEdit = d.CurrentScript;
        }


        Debug.Log("Interact/UI");
    }
        public static IFormattedConstraint NewFormattedConstraint(
            IObjectRepository tdb,
            IGSettingsManager igSettings,
            IIGTypePlugin igTypePlugin,
            IConstraint constraint,
            List <ConstraintReference> references,
            string templateLinkBase      = null,
            string valueSetLinkBase      = null,
            bool linkContainedTemplate   = false,
            bool linkIsBookmark          = false,
            bool createLinksForValueSets = false,
            bool includeCategory         = true,
            ValueSet valueSet            = null,
            CodeSystem codeSystem        = null)
        {
            Type selectedType = null;

            if (igSettings == null || !igSettings.IsPublished)
            {
                var latestVersion = versions.Keys.OrderByDescending(y => y).First();
                selectedType = versions[latestVersion];
            }
            else
            {
                foreach (var versionDate in versions.Keys.OrderByDescending(y => y))
                {
                    if (igSettings.PublishDate > versionDate)
                    {
                        selectedType = versions[versionDate];
                        break;
                    }
                }

                if (selectedType == null)
                {
                    var latestVersion = versions.Keys.OrderByDescending(y => y).Last();
                    selectedType = versions[latestVersion];
                }
            }

            IFormattedConstraint formattedConstraint = (IFormattedConstraint)Activator.CreateInstance(selectedType);

            formattedConstraint.Tdb                    = tdb;
            formattedConstraint.IgSettings             = igSettings;
            formattedConstraint.IncludeCategory        = includeCategory;
            formattedConstraint.TemplateLinkBase       = templateLinkBase;
            formattedConstraint.ValueSetLinkBase       = valueSetLinkBase;
            formattedConstraint.LinkContainedTemplate  = linkContainedTemplate;
            formattedConstraint.LinkIsBookmark         = linkIsBookmark;
            formattedConstraint.CreateLinkForValueSets = createLinksForValueSets;
            formattedConstraint.ConstraintReferences   = references;

            // Set the properties in the FormattedConstraint based on the IConstraint
            formattedConstraint.ParseConstraint(igTypePlugin, constraint, valueSet, codeSystem);

            // Pre-process the constraint so that calls to GetHtml(), GetPlainText(), etc. returns something
            formattedConstraint.ParseFormattedConstraint();

            return(formattedConstraint);
        }
Beispiel #14
0
 ///<summary>Inserts one CodeSystem into the database.  Returns the new priKey.</summary>
 public static long Insert(CodeSystem codeSystem)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         codeSystem.CodeSystemNum = DbHelper.GetNextOracleKey("codesystem", "CodeSystemNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(codeSystem, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     codeSystem.CodeSystemNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(codeSystem, false));
     }
 }
Beispiel #15
0
        ///<summary>Inserts one CodeSystem into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(CodeSystem codeSystem, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO codesystem (";

            if (!useExistingPK && isRandomKeys)
            {
                codeSystem.CodeSystemNum = ReplicationServers.GetKeyNoCache("codesystem", "CodeSystemNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "CodeSystemNum,";
            }
            command += "CodeSystemName,VersionCur,VersionAvail,HL7OID,Note) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(codeSystem.CodeSystemNum) + ",";
            }
            command +=
                "'" + POut.String(codeSystem.CodeSystemName) + "',"
                + "'" + POut.String(codeSystem.VersionCur) + "',"
                + "'" + POut.String(codeSystem.VersionAvail) + "',"
                + "'" + POut.String(codeSystem.HL7OID) + "',"
                + "'" + POut.String(codeSystem.Note) + "')";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                codeSystem.CodeSystemNum = Db.NonQ(command, true, "CodeSystemNum", "codeSystem");
            }
            return(codeSystem.CodeSystemNum);
        }
Beispiel #16
0
 public CSInfo(CodeSystem cs)
 {
     this.CodeSystem = cs;
     this.ClassCode  = new CodeEditor();
     this.ClassCode.TryAddUserMacro("ClassName", CSMisc.CodeSystemName(this));
     this.ClassCode.Load(Path.Combine("Templates", "CodeSystem.txt"));
 }
Beispiel #17
0
        private CodeSystem CreateCodeSystem()
        {
            CodeSystem result = new CodeSystem();

            result.Oid = CODE_SYSTEM_OID;
            return(result);
        }
Beispiel #18
0
        private CodedValue CreateCodedValue(VocabularyDomain vocabularyDomain,
                                            CodeSystem codeSystem_0, String code)
        {
            CodedValue codedValue = this.factory.CreateCodedValue(codeSystem_0, code);

            this.factory.CreateValueSet(codedValue, vocabularyDomain);
            return(codedValue);
        }
Beispiel #19
0
        private CodedValue CreateCodedValue(VocabularyDomain vocabularyDomain,
                                            String oid, String code, String version)
        {
            CodeSystem codeSystem_0 = this.factory.CreateCodeSystem(oid);
            CodedValue codedValue   = this.factory.CreateCodedValue(codeSystem_0, code);

            this.factory.CreateValueSet(codedValue, version, vocabularyDomain);
            return(codedValue);
        }
Beispiel #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CodeSystemViewModel"/> class.
 /// </summary>
 /// <param name="codeSystem">The code system.</param>
 public CodeSystemViewModel(CodeSystem codeSystem) : this(codeSystem.Key.Value)
 {
     this.Description = codeSystem.Description;
     this.Domain      = codeSystem.Authority;
     this.Name        = codeSystem.Name ?? Constants.NotApplicable;
     this.Oid         = codeSystem.Oid;
     this.Url         = codeSystem.Url;
     this.Version     = codeSystem.VersionText;
 }
Beispiel #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EditCodeSystemModel"/> class.
 /// </summary>
 /// <param name="codeSystem">The code system.</param>
 public EditCodeSystemModel(CodeSystem codeSystem) : base(codeSystem.Key.Value)
 {
     this.Description = codeSystem.Description;
     this.Domain      = codeSystem.Authority;
     this.Name        = codeSystem.Name;
     this.Oid         = codeSystem.Oid;
     this.Url         = codeSystem.Url;
     this.Version     = codeSystem.VersionText;
 }
Beispiel #22
0
        public CodeSystem CreateCodeSystem(String oid)
        {
            CodeSystem result = new CodeSystem();

            result.Oid = oid;
            Save(result);

            return(result);
        }
Beispiel #23
0
        /// <summary>Gets the coded concept.</summary>
        /// <param name="propertyInfo">The property information.</param>
        /// <param name="defaultCodeSystem">The default code system.</param>
        /// <returns>A <see cref="CodedConcept" />.</returns>
        protected static CodedConcept GetCodedConcept(PropertyInfo propertyInfo, CodeSystem defaultCodeSystem)
        {
            var codeSystemAttribute = propertyInfo.GetCustomAttribute <CodeSystemAttribute>();
            var codedConcept        = new CodedConcept(
                codeSystemAttribute == null ? defaultCodeSystem : codeSystemAttribute.CodeSystem,
                propertyInfo.GetCustomAttribute <CodeAttribute>().Value,
                propertyInfo.Name);

            return(codedConcept);
        }
Beispiel #24
0
        private string GetCodeSystemDisplay(IConstraint constraint)
        {
            if (constraint.ValueCodeSystemId != null)
            {
                CodeSystem codeSystem = this.tdb.CodeSystems.Single(y => y.Id == constraint.ValueCodeSystemId);
                return(string.Format("{0} ({1})", codeSystem.Name, codeSystem.Oid));
            }

            return(string.Empty);
        }
        /// <summary>
        /// Creates the code system.
        /// </summary>
        /// <param name="codeSystem">The code system.</param>
        /// <returns>Returns the created code system.</returns>
        /// <exception cref="System.InvalidOperationException">Unable to locate persistence service</exception>
        public CodeSystem CreateCodeSystem(CodeSystem codeSystem)
        {
            var persistenceService = ApplicationContext.Current.GetService <IDataPersistenceService <CodeSystem> >();

            if (persistenceService == null)
            {
                throw new InvalidOperationException($"Unable to locate persistence service: {nameof(IDataPersistenceService<CodeSystem>)}");
            }

            return(persistenceService.Insert(codeSystem, AuthenticationContext.Current.Principal, TransactionMode.Commit));
        }
Beispiel #26
0
        public void TestSelectCodeSystem()
        {
            this.factory.CreateCodeSystem(OID);
            this.factory.CreateCodeSystem(OID + ".1");
            this.factory.CreateCodeSystem(OID + "01");

            CodeSystem codeSystem_0 = this.dao.FindCodeSystem(OID);

            NUnit.Framework.Assert.IsNotNull(codeSystem_0, "code system");
            NUnit.Framework.Assert.AreEqual(OID, codeSystem_0.Oid, "oid");
        }
Beispiel #27
0
        /// <summary>
        /// Create a value set of all the codes in the passed code system.
        /// </summary>
        ValueSet CreateValueSet(String name,
                                String title,
                                String mapName,
                                String description,
                                String groupPath,
                                CodeSystem cs = null)
        {
            ValueSet vs = new ValueSet
            {
                Id          = name,
                Url         = $"http://hl7.org/fhir/us/breast-radiology/ValueSet/{name}",
                Name        = name,
                Title       = title,
                Description = new Markdown(description)
            };

            vs.AddFragRef(this.HeaderFragment);

            // store groupPath as an extension. This is an unregistered extension that will be removed before
            // processing is complete.
            vs.Extension.Add(new Extension
            {
                Url   = Global.GroupExtensionUrl,
                Value = new FhirString(groupPath)
            });

            this.resources.Add(Path.Combine(this.resourceDir, $"ValueSet-{name}.json"), vs);
            Debug.Assert(mapName.Contains("Tumor Satellite") == false);
            vs.AddExtension(Global.ResourceMapNameUrl, new FhirString(mapName));

            if (cs == null)
            {
                return(vs);
            }

            ValueSet.ConceptSetComponent vsComp = new ValueSet.ConceptSetComponent
            {
                System = cs.Url
            };

            vs.Compose = new ValueSet.ComposeComponent();
            vs.Compose.Include.Add(vsComp);

            foreach (var code in cs.Concept)
            {
                vsComp.Concept.Add(new ValueSet.ConceptReferenceComponent
                {
                    Code    = code.Code,
                    Display = code.Display
                });
            }

            return(vs);
        }
Beispiel #28
0
        /// <summary>
        /// Converts a <see cref="CreateCodeSystemModel"/> instance to a <see cref="CodeSystem"/> instance.
        /// </summary>
        /// <returns>Returns the converted code system.</returns>
        public CodeSystem ToCodeSystem(CodeSystem codeSystem)
        {
            codeSystem.Description = this.Description;
            codeSystem.Name        = this.Name;
            codeSystem.Authority   = this.Domain;
            codeSystem.Oid         = this.Oid;
            codeSystem.Url         = this.Url;
            codeSystem.VersionText = this.Version;

            return(codeSystem);
        }
Beispiel #29
0
        /// <summary>
        /// Creates the code system.
        /// </summary>
        /// <param name="codeSystem">The code system.</param>
        /// <returns>Returns the created code system.</returns>
        /// <exception cref="System.InvalidOperationException">IMetadataRepositoryService</exception>
        public CodeSystem CreateCodeSystem(CodeSystem codeSystem)
        {
            var metadataService = ApplicationContext.Current.GetService <IMetadataRepositoryService>();

            if (metadataService == null)
            {
                throw new InvalidOperationException($"Unable to locate service: {nameof(IMetadataRepositoryService)}");
            }

            return(metadataService.CreateCodeSystem(codeSystem));
        }
Beispiel #30
0
        ///<summary>Updates one CodeSystem in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
        public static bool Update(CodeSystem codeSystem, CodeSystem oldCodeSystem)
        {
            string command = "";

            if (codeSystem.CodeSystemName != oldCodeSystem.CodeSystemName)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CodeSystemName = '" + POut.String(codeSystem.CodeSystemName) + "'";
            }
            if (codeSystem.VersionCur != oldCodeSystem.VersionCur)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "VersionCur = '" + POut.String(codeSystem.VersionCur) + "'";
            }
            if (codeSystem.VersionAvail != oldCodeSystem.VersionAvail)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "VersionAvail = '" + POut.String(codeSystem.VersionAvail) + "'";
            }
            if (codeSystem.HL7OID != oldCodeSystem.HL7OID)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "HL7OID = '" + POut.String(codeSystem.HL7OID) + "'";
            }
            if (codeSystem.Note != oldCodeSystem.Note)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Note = '" + POut.String(codeSystem.Note) + "'";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE codesystem SET " + command
                      + " WHERE CodeSystemNum = " + POut.Long(codeSystem.CodeSystemNum);
            Db.NonQ(command);
            return(true);
        }
Beispiel #31
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<CodeSystem> TableToList(DataTable table){
			List<CodeSystem> retVal=new List<CodeSystem>();
			CodeSystem codeSystem;
			for(int i=0;i<table.Rows.Count;i++) {
				codeSystem=new CodeSystem();
				codeSystem.CodeSystemNum = PIn.Long  (table.Rows[i]["CodeSystemNum"].ToString());
				codeSystem.CodeSystemName= PIn.String(table.Rows[i]["CodeSystemName"].ToString());
				codeSystem.VersionCur    = PIn.String(table.Rows[i]["VersionCur"].ToString());
				codeSystem.VersionAvail  = PIn.String(table.Rows[i]["VersionAvail"].ToString());
				codeSystem.HL7OID        = PIn.String(table.Rows[i]["HL7OID"].ToString());
				codeSystem.Note          = PIn.String(table.Rows[i]["Note"].ToString());
				retVal.Add(codeSystem);
			}
			return retVal;
		}
Beispiel #32
0
		///<summary>Inserts one CodeSystem into the database.  Returns the new priKey.</summary>
		public static long Insert(CodeSystem codeSystem){
			if(DataConnection.DBtype==DatabaseType.Oracle) {
				codeSystem.CodeSystemNum=DbHelper.GetNextOracleKey("codesystem","CodeSystemNum");
				int loopcount=0;
				while(loopcount<100){
					try {
						return Insert(codeSystem,true);
					}
					catch(Oracle.DataAccess.Client.OracleException ex){
						if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
							codeSystem.CodeSystemNum++;
							loopcount++;
						}
						else{
							throw ex;
						}
					}
				}
				throw new ApplicationException("Insert failed.  Could not generate primary key.");
			}
			else {
				return Insert(codeSystem,false);
			}
		}
Beispiel #33
0
		///<summary>Inserts one CodeSystem into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(CodeSystem codeSystem,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				codeSystem.CodeSystemNum=ReplicationServers.GetKey("codesystem","CodeSystemNum");
			}
			string command="INSERT INTO codesystem (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="CodeSystemNum,";
			}
			command+="CodeSystemName,VersionCur,VersionAvail,HL7OID,Note) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(codeSystem.CodeSystemNum)+",";
			}
			command+=
				 "'"+POut.String(codeSystem.CodeSystemName)+"',"
				+"'"+POut.String(codeSystem.VersionCur)+"',"
				+"'"+POut.String(codeSystem.VersionAvail)+"',"
				+"'"+POut.String(codeSystem.HL7OID)+"',"
				+"'"+POut.String(codeSystem.Note)+"')";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				codeSystem.CodeSystemNum=Db.NonQ(command,true);
			}
			return codeSystem.CodeSystemNum;
		}
Beispiel #34
0
		///<summary>Updates one CodeSystem in the database.</summary>
		public static void Update(CodeSystem codeSystem){
			string command="UPDATE codesystem SET "
				+"CodeSystemName= '"+POut.String(codeSystem.CodeSystemName)+"', "
				+"VersionCur    = '"+POut.String(codeSystem.VersionCur)+"', "
				+"VersionAvail  = '"+POut.String(codeSystem.VersionAvail)+"', "
				+"HL7OID        = '"+POut.String(codeSystem.HL7OID)+"', "
				+"Note          = '"+POut.String(codeSystem.Note)+"' "
				+"WHERE CodeSystemNum = "+POut.Long(codeSystem.CodeSystemNum);
			Db.NonQ(command);
		}
Beispiel #35
0
		///<summary>Updates one CodeSystem in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
		public static bool Update(CodeSystem codeSystem,CodeSystem oldCodeSystem){
			string command="";
			if(codeSystem.CodeSystemName != oldCodeSystem.CodeSystemName) {
				if(command!=""){ command+=",";}
				command+="CodeSystemName = '"+POut.String(codeSystem.CodeSystemName)+"'";
			}
			if(codeSystem.VersionCur != oldCodeSystem.VersionCur) {
				if(command!=""){ command+=",";}
				command+="VersionCur = '"+POut.String(codeSystem.VersionCur)+"'";
			}
			if(codeSystem.VersionAvail != oldCodeSystem.VersionAvail) {
				if(command!=""){ command+=",";}
				command+="VersionAvail = '"+POut.String(codeSystem.VersionAvail)+"'";
			}
			if(codeSystem.HL7OID != oldCodeSystem.HL7OID) {
				if(command!=""){ command+=",";}
				command+="HL7OID = '"+POut.String(codeSystem.HL7OID)+"'";
			}
			if(codeSystem.Note != oldCodeSystem.Note) {
				if(command!=""){ command+=",";}
				command+="Note = '"+POut.String(codeSystem.Note)+"'";
			}
			if(command==""){
				return false;
			}
			command="UPDATE codesystem SET "+command
				+" WHERE CodeSystemNum = "+POut.Long(codeSystem.CodeSystemNum);
			Db.NonQ(command);
			return true;
		}