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); }