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);
        }
Exemplo n.º 2
0
        public static Resource GetStatement(bool inBundle)
        {
            TerminologyCapabilities tsCapabilityStatement = new TerminologyCapabilities
            {
                Url          = ServerCapability.TERMINZ_CANONICAL + "/TerminologyCapabilities/Terminz-Example",
                Id           = "Terminz-Example",
                Description  = new Markdown("HL7© FHIR© terminology services for use in New Zealand."),
                Name         = "Patients First Terminology Server (Terminz)",
                Purpose      = new Markdown("Exemplar of terminology services approach for New Zealand."),
                Publisher    = "Patients First Ltd",
                Version      = "4.0.0",
                Status       = PublicationStatus.Draft,
                Date         = "2019-05-08",
                Experimental = true,
                Copyright    = new Markdown("© 2019+ Patients First Ltd"),
                LockedDate   = false
            };

            ContactDetail cd = new ContactDetail {
                Name = "Peter Jordan"
            };
            ContactPoint cp = new ContactPoint {
                System = ContactPoint.ContactPointSystem.Email, Value = "*****@*****.**"
            };

            cd.Telecom.Add(cp);
            tsCapabilityStatement.Contact.Add(cd);

            CodeableConcept cc = new CodeableConcept("http://hl7.org/fhir/ValueSet/jurisdiction", "NZL", "New Zealand", "New Zealand");

            tsCapabilityStatement.Jurisdiction.Add(cc);

            tsCapabilityStatement.CodeSystem.Add(FhirSnomed.GetCapabilities());
            tsCapabilityStatement.CodeSystem.Add(FhirLoinc.GetCapabilities());
            tsCapabilityStatement.CodeSystem.Add(NzMt.GetCapabilities());
            tsCapabilityStatement.CodeSystem.Add(FhirRxNorm.GetCapabilities());

            tsCapabilityStatement.Expansion = new TerminologyCapabilities.ExpansionComponent
            {
                Hierarchical = false,
                Paging       = true,
                Incomplete   = false,
                TextFilter   = new Markdown("Results include synonyms, not just preferred terms.")
            };

            tsCapabilityStatement.CodeSearch = TerminologyCapabilities.CodeSearchSupport.All;

            tsCapabilityStatement.ValidateCode = new TerminologyCapabilities.ValidateCodeComponent()
            {
                Translations = false
            };

            tsCapabilityStatement.Translation = new TerminologyCapabilities.TranslationComponent()
            {
                NeedsMap = true
            };

            tsCapabilityStatement.Closure = new TerminologyCapabilities.ClosureComponent()
            {
                Translation = false
            };

            // text element

            XNamespace ns = "http://www.w3.org/1999/xhtml";

            var summary = new XElement(ns + "div",
                                       new XElement(ns + "h2", tsCapabilityStatement.Name),
                                       new XElement(ns + "p", tsCapabilityStatement.Description),
                                       new XElement(ns + "table",
                                                    new XElement(ns + "tr",
                                                                 new XElement(ns + "td", "Purpose"),
                                                                 new XElement(ns + "td", tsCapabilityStatement.Purpose.ToString())
                                                                 ),
                                                    new XElement(ns + "tr",
                                                                 new XElement(ns + "td", "Publisher"),
                                                                 new XElement(ns + "td", tsCapabilityStatement.Publisher)
                                                                 ),
                                                    new XElement(ns + "tr",
                                                                 new XElement(ns + "td", "Version"),
                                                                 new XElement(ns + "td", tsCapabilityStatement.Version)
                                                                 ),
                                                    new XElement(ns + "tr",
                                                                 new XElement(ns + "td", "Date"),
                                                                 new XElement(ns + "td", tsCapabilityStatement.Date)
                                                                 )
                                                    ),
                                       new XElement(ns + "table",
                                                    new XElement(ns + "tr",
                                                                 new XElement(ns + "th", "Code System"),
                                                                 new XElement(ns + "th", "Description"),
                                                                 new XElement(ns + "th", "URI"),
                                                                 new XElement(ns + "th", "Version")
                                                                 ),
                                                    new XElement(ns + "tr",
                                                                 new XElement(ns + "td", FhirSnomed.TITLE),
                                                                 new XElement(ns + "td", FhirSnomed.DESCRIPTION),
                                                                 new XElement(ns + "td", FhirSnomed.URI),
                                                                 new XElement(ns + "td", FhirSnomed.CURRENT_VERSION)
                                                                 ),
                                                    new XElement(ns + "tr",
                                                                 new XElement(ns + "td", FhirLoinc.TITLE),
                                                                 new XElement(ns + "td", FhirLoinc.DESCRIPTION),
                                                                 new XElement(ns + "td", FhirLoinc.URI),
                                                                 new XElement(ns + "td", FhirLoinc.CURRENT_VERSION)
                                                                 ),
                                                    new XElement(ns + "tr",
                                                                 new XElement(ns + "td", NzMt.TITLE),
                                                                 new XElement(ns + "td", NzMt.DESCRIPTION),
                                                                 new XElement(ns + "td", NzMt.URI),
                                                                 new XElement(ns + "td", NzMt.CURRENT_VERSION)
                                                                 ),
                                                    new XElement(ns + "tr",
                                                                 new XElement(ns + "td", FhirRxNorm.TITLE),
                                                                 new XElement(ns + "td", FhirRxNorm.DESCRIPTION),
                                                                 new XElement(ns + "td", FhirRxNorm.URI),
                                                                 new XElement(ns + "td", FhirRxNorm.CURRENT_VERSION)
                                                                 )
                                                    )
                                       );

            tsCapabilityStatement.Text = new Narrative
            {
                Status = Narrative.NarrativeStatus.Generated,
                Div    = summary.ToString()
            };

            // place in a bundle

            if (inBundle)
            {
                Bundle tcsBundle = new Bundle
                {
                    Id   = Guid.NewGuid().ToString(),
                    Type = Bundle.BundleType.Searchset
                };

                tcsBundle.Link.Add(new Bundle.LinkComponent {
                    Url = ServerCapability.TERMINZ_CANONICAL + "/TerminologyCapabilities", Relation = "self"
                });
                tcsBundle.AddResourceEntry(tsCapabilityStatement, tsCapabilityStatement.Url);
                tcsBundle.Total = tcsBundle.Entry.Count;

                return(tcsBundle);
            }

            return(tsCapabilityStatement);
        }
        private static CodeSystem GetCodeSystem(TerminologyOperation termOp, string systemURL, NameValueCollection queryParam)
        {
            CodeSystem codeSys = new CodeSystem();

            string codeVal     = Utilities.GetQueryValue("code", queryParam);
            string versionVal  = Utilities.GetQueryValue("version", queryParam);
            string languageVal = Utilities.GetQueryValue("displayLanguage", queryParam);

            // NB: these won't be passed in a GET request & the POST processing places the atomic elements in the queryParam collection
            //string codingVal = Utilities.GetQueryValue("coding", queryParam);
            //string codeableConceptVal = Utilities.GetQueryValue("codeableConcept", queryParam)

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

            if (systemURL == NzRegion.URI)
            {
                NzRegion nzr = new NzRegion(termOp, versionVal, codeVal, string.Empty, -1, -1);
                codeSys = nzr.codeSystem;
            }
            else if (systemURL == NzEthnicityL1.URI)
            {
                NzEthnicityL1 nzEth1 = new NzEthnicityL1(termOp, versionVal, codeVal, string.Empty, -1, -1);
                codeSys = nzEth1.codeSystem;
            }
            else if (systemURL == NzEthnicityL2.URI)
            {
                NzEthnicityL2 nzEth2 = new NzEthnicityL2(termOp, versionVal, codeVal, string.Empty, -1, -1);
                codeSys = nzEth2.codeSystem;
            }
            else if (systemURL == NzEthnicityL3.URI)
            {
                NzEthnicityL3 nzEth3 = new NzEthnicityL3(termOp, versionVal, codeVal, string.Empty, -1, -1);
                codeSys = nzEth3.codeSystem;
            }
            else if (systemURL == NzEthnicityL4.URI)
            {
                NzEthnicityL4 nzEth4 = new NzEthnicityL4(termOp, versionVal, codeVal, string.Empty, -1, -1);
                codeSys = nzEth4.codeSystem;
            }
            else if (systemURL == NzMt.URI)
            {
                NzMt nzmt = new NzMt(termOp, versionVal, codeVal, string.Empty, string.Empty, -1, -1);
                codeSys = nzmt.codeSystem;
            }
            else if (systemURL == FhirLoinc.URI)
            {
                FhirLoinc loinc = new FhirLoinc(termOp, versionVal, codeVal, string.Empty, string.Empty, -1, -1, string.Empty);
                codeSys = loinc.codeSystem;
            }
            else if (systemURL == FhirRxNorm.URI)
            {
                FhirRxNorm rxnorm = new FhirRxNorm(termOp, versionVal, codeVal, string.Empty, string.Empty, -1, -1);
                codeSys = rxnorm.codeSystem;
            }
            else if (FhirSnomed.IsValidURI(systemURL))
            {
                FhirSnomed snomed = new FhirSnomed(termOp, versionVal, codeVal, string.Empty, string.Empty, -1, -1, string.Empty, string.Empty);
                codeSys = snomed.codeSystem;
            }
            else
            {
                throw new Exception(UNSUPPORTED_CODESYSTEM);
            }

            return(codeSys);
        }
        private static Resource LookupOperation(string systemURL, NameValueCollection queryParam)
        {
            CodeSystem codeSys = GetCodeSystem(TerminologyOperation.lookup, systemURL, queryParam);

            if (codeSys.Concept.Count < 1)
            {
                throw new Exception(INVALID_CODE);
            }

            string codeVal = Utilities.GetQueryValue("code", queryParam);
            //string versionVal = Utilities.GetQueryValue("version", queryParam);
            string propertyVal = Utilities.GetQueryValue("property", queryParam);
            string languageVal = Utilities.GetQueryValue("displayLanguage", queryParam);

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

            bool displayCode                = false;
            bool displaySystem              = false;
            bool displayVersion             = true;
            bool displayDisplay             = true;
            bool displayDefinition          = false;
            bool displayDesignation         = false;
            bool displayParents             = false;
            bool displayChildren            = false;
            bool displaySubstance           = false;
            bool displayInactive            = false;
            bool displayModuleId            = false;
            bool displaySufficientlyDefined = false;
            bool displayNf              = false;
            bool displayNfTerse         = false;
            bool displayAllAttributes   = false;
            bool displaySingleAttribute = false;
            bool displayTermType        = false;

            // standard properties...defined for all Code Systems

            /*
             * // The following properties are defined for all code systems:
             * // system, version, display, definition, designation, parent, child, and lang.X where X is a language code in a designation
             * // SCT properties
             * // inactive	boolean	Whether the code is active or not (defaults to false). This is derived from the active column in the Concept file of the RF2 Distribution (by inverting the value)
             * // sufficientlyDefined	boolean	True if the description logic definition of the concept includes sufficient conditions (i.e., if the concept is not primitive).
             * // moduleId	code	The SNOMED CT concept id of the module that the concept belongs to.
             * // normalForm	string	Generated Normal form expression for the provided code or expression, with terms
             * // normalFormTerse	string	Generated Normal form expression for the provided code or expression, conceptIds only
             * // In addition, any SNOMED CT relationships where the relationship type is subsumed by Attribute (246061005) automatically become properties. For example, laterality:
             * // Laterality	code	In this case, the URI (See the code system definition) is http://snomed.info/id/272741003, which can be used to unambiguously map to the underlying concept
             */

            if (!string.IsNullOrEmpty(propertyVal))
            {
                string pvl = propertyVal.ToLower();
                displayCode   = (pvl.Contains("code"));
                displaySystem = (pvl.Contains("system"));
                //displayVersion = (pvl.Contains("version")); // always return code system version
                //displayDisplay = true;  // default true - don't see much point in looking up the code and not displaying its description! (otherwise use validate-code)
                displayDefinition          = (pvl.Contains("definition"));
                displayDesignation         = (pvl.Contains("designation"));
                displayParents             = (pvl.Contains("parent"));
                displayChildren            = (pvl.Contains("child"));
                displaySubstance           = (pvl.Contains("substance"));
                displayTermType            = (pvl.Contains("termtype"));
                displayInactive            = (pvl.Contains("inactive"));
                displaySufficientlyDefined = (pvl.Contains("sufficientlydefined"));
                displayModuleId            = (pvl.Contains("moduleid"));
                displayNfTerse             = (pvl.Contains("normalformterse"));
                displayNf            = (pvl.Contains("normalform") && !displayNfTerse);
                displayAllAttributes = (pvl.Contains(FhirSnomed.SCT_ATTRIBUTE_CONCEPT));
                if (!displayAllAttributes)
                {
                    displaySingleAttribute = (pvl.Count(x => Char.IsDigit(x)) > 7);
                }
            }

            List <Coding> loincPropertyVals         = new List <Coding>();
            List <Coding> substanceCodeVals         = new List <Coding>();
            List <Coding> designationCodeVals       = new List <Coding>();
            List <Coding> childCodeVals             = new List <Coding>();
            List <Coding> parentCodeVals            = new List <Coding>();
            List <Coding> propertyCodeVals          = new List <Coding>();
            List <Coding> attributeCodeVals         = new List <Coding>();
            List <Coding> termTypeVals              = new List <Coding>();
            List <Coding> proximalPrimitiveCodeVals = new List <Coding>();

            // CodeSystem-specific actions

            if (systemURL == NzMt.URI)
            {
                string nzulmType = codeSys.Concept[0].Definition;
                string mp_id     = codeSys.Concept[0].ElementId;
                if (displaySubstance)
                {
                    substanceCodeVals = NzUlmSearch.GetConceptSubstanceDataByCode(mp_id, nzulmType);
                }
            }

            if (systemURL == FhirLoinc.URI)
            {
                if (!string.IsNullOrEmpty(propertyVal))
                {
                    loincPropertyVals = LoincSearch.GetPropertiesByCode(codeVal, propertyVal.ToUpper());
                }
            }

            if (systemURL == FhirRxNorm.URI)
            {
                if (displayTermType)
                {
                    termTypeVals = RxNormSearch.GetPropertiesByCode(codeVal);
                }
            }

            if (systemURL == FhirSnomed.URI)
            {
                displaySystem      = true;
                displayDesignation = true;
                displayInactive    = true;

                if (codeSys.Concept.Count > 0)
                {
                    if (displayDesignation)
                    {
                        designationCodeVals = SnomedCtSearch.GetConceptDesignationsByCode(codeVal);
                    }

                    if (displayInactive || displayModuleId || displaySufficientlyDefined)
                    {
                        propertyCodeVals = SnomedCtSearch.GetConceptPropertiesByCode(codeVal);
                    }

                    if (displayChildren)
                    {
                        childCodeVals = SnomedCtSearch.GetChildCodes(codeVal);
                    }

                    if (displayParents)
                    {
                        parentCodeVals = SnomedCtSearch.GetParentCodes(codeVal);
                    }

                    if (displayAllAttributes || displaySingleAttribute)
                    {
                        List <Coding> acv = SnomedCtSearch.GetAttributes(codeVal);
                        if (displayAllAttributes)
                        {
                            attributeCodeVals = acv;
                        }
                        else
                        {
                            foreach (Coding cv in acv)
                            {
                                if (propertyVal.Contains(cv.Code))
                                {
                                    attributeCodeVals.Add(cv);
                                }
                            }
                        }
                    }
                }
            }

            // build return parameters resource using default & requested properties
            Parameters param = new Parameters();

            if (codeSys.Concept != null)
            {
                param.Add("name", codeSys.NameElement);

                foreach (CodeSystem.ConceptDefinitionComponent comp in codeSys.Concept)
                {
                    if (displaySystem)
                    {
                        param.Add("system", codeSys.UrlElement);
                    }
                    if (displayVersion)
                    {
                        param.Add("version", codeSys.VersionElement);
                    }
                    if (displayCode)
                    {
                        param.Add("code", comp.CodeElement);
                    }
                    if (displayDisplay)
                    {
                        param.Add("display", comp.DisplayElement);
                    }
                }

                foreach (Coding prop in loincPropertyVals)
                {
                    // return all of them
                    List <Tuple <string, Base> > tuples = new List <Tuple <string, Base> >
                    {
                        new Tuple <string, Base>("code", new FhirString(prop.Code)),
                        new Tuple <string, Base>("value", new FhirString(prop.Display))
                    };
                    param.Add("property", tuples);
                }

                foreach (Coding tty in termTypeVals)
                {
                    List <Tuple <string, Base> > tuples = new List <Tuple <string, Base> >
                    {
                        //new Tuple<string, Base>("code", new FhirString(tty.Version)),
                        //new Tuple<string, Base>("value", new FhirString(FhirRxNorm.GetTermType(tty.Version))),
                        //new Tuple<string, Base>("description", new FhirString(tty.Display))
                        new Tuple <string, Base>("use", new Coding {
                            Display = FhirRxNorm.GetTermType(tty.Version), System = FhirRxNorm.URI, Code = tty.Version
                        }),
                        new Tuple <string, Base>("value", new FhirString(tty.Display))
                    };
                    param.Add("termType", tuples);
                }

                foreach (Coding desig in designationCodeVals)
                {
                    List <Tuple <string, Base> > tuples = new List <Tuple <string, Base> >
                    {
                        new Tuple <string, Base>("use", new Coding {
                            Display = desig.System, System = FhirSnomed.URI, Code = FhirSnomed.GetDesignationTypeId(desig.System)
                        }),
                        new Tuple <string, Base>("value", new FhirString(desig.Display))
                    };
                    param.Add("designation", tuples);
                }

                foreach (Coding prop in propertyCodeVals)
                {
                    if ((prop.Code == "inactive" && displayInactive) ||
                        (prop.Code == "sufficientlyDefined" && displaySufficientlyDefined) ||
                        (prop.Code == "moduleId" && displayModuleId))
                    {
                        List <Tuple <string, Base> > tuples = new List <Tuple <string, Base> >
                        {
                            new Tuple <string, Base>("code", new FhirString(prop.Code)),
                            new Tuple <string, Base>("value", new FhirString(prop.Display))
                        };
                        param.Add("property", tuples);
                    }
                }

                if (displayNf || displayNfTerse)
                {
                    string nf = FhirSnomed.GetNormalFormDisplay(codeVal, displayNf);
                    List <Tuple <string, Base> > tuples = new List <Tuple <string, Base> >
                    {
                        new Tuple <string, Base>("code", new FhirString(displayNf ? "normalForm" : "normalFormTerse")),
                        new Tuple <string, Base>("value", new FhirString(nf))
                    };
                    param.Add("property", tuples);
                }

                foreach (Coding subst in substanceCodeVals)
                {
                    List <Tuple <string, Base> > tuples = new List <Tuple <string, Base> >
                    {
                        new Tuple <string, Base>("use", new Coding {
                            Display = subst.System
                        })
                    };
                    if (!string.IsNullOrEmpty(subst.Code))
                    {
                        tuples.Add(new Tuple <string, Base>("code", new FhirString(subst.Code)));
                    }
                    tuples.Add(new Tuple <string, Base>("value", new FhirString(subst.Display)));
                    param.Add("substance", tuples);
                }

                foreach (Coding parent in parentCodeVals)
                {
                    List <Tuple <string, Base> > tuples = new List <Tuple <string, Base> >
                    {
                        new Tuple <string, Base>("code", new FhirString("Parent")),
                        new Tuple <string, Base>("value", new FhirString(parent.Code)),
                        new Tuple <string, Base>("description", new FhirString(parent.Display))
                    };
                    param.Add("property", tuples);
                }

                foreach (Coding child in childCodeVals)
                {
                    List <Tuple <string, Base> > tuples = new List <Tuple <string, Base> >
                    {
                        new Tuple <string, Base>("code", new FhirString("Child")),
                        new Tuple <string, Base>("value", new FhirString(child.Code)),
                        new Tuple <string, Base>("description", new FhirString(child.Display))
                    };
                    param.Add("property", tuples);
                }

                foreach (Coding attrib in attributeCodeVals)
                {
                    List <Tuple <string, Base> > tuples = new List <Tuple <string, Base> >
                    {
                        new Tuple <string, Base>("code", new Code {
                            Value = attrib.Code
                        }),
                        new Tuple <string, Base>("valueCode", new Code {
                            Value = attrib.Display
                        })
                    };
                    param.Add("property", tuples);
                }
            }

            return(param);
        }
        private static Resource GetRequest(string identifier, string systemURL, NameValueCollection queryParam)
        {
            if (string.IsNullOrEmpty(identifier) && string.IsNullOrEmpty(systemURL))
            {
                throw new Exception(MISSING_CODESYSTEM);
            }

            string resourceFilePath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath) + @"\Test Files\";

            CodeSystem codeSys = new CodeSystem();

            string codeVal    = Utilities.GetQueryValue("code", queryParam);
            string versionVal = Utilities.GetQueryValue("version", queryParam);

            if (identifier == "NzRegion" || systemURL == NzRegion.URI)
            {
                NzRegion nzr = new NzRegion(TerminologyOperation.define_cs, versionVal, codeVal, string.Empty, -1, -1);
                codeSys = nzr.codeSystem;
            }
            else if (identifier == "NzEthnicityL1" || systemURL == NzEthnicityL1.URI)
            {
                NzEthnicityL1 nzEth1 = new NzEthnicityL1(TerminologyOperation.define_cs, versionVal, codeVal, string.Empty, -1, -1);
                codeSys = nzEth1.codeSystem;
            }
            else if (identifier == "NzEthnicityL2" || systemURL == NzEthnicityL2.URI)
            {
                NzEthnicityL2 nzEth2 = new NzEthnicityL2(TerminologyOperation.define_cs, versionVal, codeVal, string.Empty, -1, -1);
                codeSys = nzEth2.codeSystem;
            }
            else if (identifier == "NzEthnicityL3" || systemURL == NzEthnicityL3.URI)
            {
                NzEthnicityL3 nzEth3 = new NzEthnicityL3(TerminologyOperation.define_cs, versionVal, codeVal, string.Empty, -1, -1);
                codeSys = nzEth3.codeSystem;
            }
            else if (identifier == "NzEthnicityL4" || systemURL == NzEthnicityL4.URI)
            {
                NzEthnicityL4 nzEth4 = new NzEthnicityL4(TerminologyOperation.define_cs, versionVal, codeVal, string.Empty, -1, -1);
                codeSys = nzEth4.codeSystem;
            }
            else if (identifier == "LOINC" || systemURL == FhirLoinc.URI)
            {
                FhirLoinc loinc = new FhirLoinc(TerminologyOperation.define_cs, versionVal, codeVal, string.Empty, string.Empty, -1, -1, string.Empty);
                codeSys = loinc.codeSystem;
            }
            else if (identifier == "SNOMEDCT" || systemURL == FhirSnomed.URI)
            {
                FhirSnomed snomed = new FhirSnomed(TerminologyOperation.define_cs, versionVal, codeVal, string.Empty, string.Empty, -1, -1, string.Empty, string.Empty);
                codeSys = snomed.codeSystem;
            }
            else if (identifier == "NZMT" || systemURL == NzMt.URI)
            {
                NzMt nzmt = new NzMt(TerminologyOperation.define_cs, versionVal, codeVal, string.Empty, string.Empty, -1, -1);
                codeSys = nzmt.codeSystem;
            }
            else if (identifier == "RXNORM" || systemURL == FhirRxNorm.URI)
            {
                FhirRxNorm rxnorm = new FhirRxNorm(TerminologyOperation.define_cs, versionVal, codeVal, string.Empty, string.Empty, -1, -1);
                codeSys = rxnorm.codeSystem;
            }
            else if (identifier == "bundle-type" || systemURL == "http://hl7.org/fhir/bundle-type")
            {
                FhirJsonParser jsp = new FhirJsonParser();
                codeSys = jsp.Parse <CodeSystem>(File.ReadAllText(resourceFilePath + "BundleType.json"));
            }
            else if (identifier == "bundle-type-german" || systemURL == "http://hl7.org/fhir/bundle-type-de")
            {
                FhirJsonParser jsp = new FhirJsonParser();
                codeSys = jsp.Parse <CodeSystem>(File.ReadAllText(resourceFilePath + "BundleTypeGerman.json"));
            }
            else
            {
                throw new Exception(UNSUPPORTED_CODESYSTEM);
            }

            AddNarrative(codeSys);

            return(codeSys);
        }