private static CDSOutput getResponse(CDSInput cdsInput) { OpenCdsService service = new OpenCdsService(endPoint); CDSOutput response = service.evaluate(cdsInput, scopingEntityId, businessId, version); return(response); }
public CDSOutput evaluate(CDSInput cdsInput, string scopingEntityId, string businessId, string version) { CDSOutput cdsOutput = null; MemoryStream ms = new MemoryStream(); XmlWriterSettings settings = new XmlWriterSettings(); settings.Encoding = Encoding.UTF8; settings.Indent = true; settings.IndentChars = " "; settings.ConformanceLevel = ConformanceLevel.Document; XmlWriter writer = XmlTextWriter.Create(ms, settings); XmlSerializer serializer = new XmlSerializer(typeof(CDSInput)); serializer.Serialize(ms, cdsInput); string cdsInputString = Encoding.UTF8.GetString(ms.ToArray()); ms.Close(); string response = evaluate(cdsInputString, scopingEntityId, businessId, version); serializer = new XmlSerializer(typeof(CDSOutput)); StringReader sr = new StringReader(response); cdsOutput = (CDSOutput)serializer.Deserialize(sr); sr.Close(); return(cdsOutput); }
private static void callServiceWithXmlFile() { StreamReader sr = new StreamReader(sampleFilename); XmlSerializer serializer = new XmlSerializer(typeof(CDSInput)); CDSInput cdsInput = (CDSInput)serializer.Deserialize(sr); sr.Close(); CDSOutput response = getResponse(cdsInput); processResponse(response); }
private CDSActionGroupResponse GetSampleResponsePayload(CDSInput payload) { return (new CDSActionGroupResponse { patientId = payload.vmrInput.patient.id, actionGroup = new ActionGroup { subElements = new ActionGroupSubElements { Items = new List <object> { new CreateAction { actionId = new II { extension = Guid.NewGuid().ToString("N") }, actionSentence = new ComplexLiteral { value = new SubstanceAdministrationProposal { id = new II { extension = Guid.NewGuid().ToString("N") }, substanceAdministrationGeneralPurpose = new CD { code = "ASPIRIN", codeSystem = "org.hl7.example", codeSystemName = "org.hl7.example", displayName = new ST { value = "Aspirin" } }, proposedAdministrationTimeInterval = new IVL_TS { low = new TS { value = "20130729" } } } } } } } } }); }
/// <summary> /// Base-64 encodes a vMR request payload. /// </summary> /// <param name="request">The vMR request to be encoded.</param> /// <returns>A base-64 string containing the request document.</returns> public static string EncodeRequestPayload(CDSInput request) { var sb = new StringBuilder(); using (var writer = new StringWriter(sb)) { requestSerializer.Serialize(writer, request); } var bytes = Encoding.UTF8.GetBytes(sb.ToString()); return(Convert.ToBase64String(bytes)); }
public CDSOutput evaluate(CDSInput cdsInput, string scopingEntityId, string businessId, string version) { CDSOutput cdsOutput = null; MemoryStream ms = new MemoryStream(); XmlWriterSettings settings = new XmlWriterSettings(); settings.Encoding = Encoding.UTF8; settings.Indent = true; settings.IndentChars = " "; settings.ConformanceLevel = ConformanceLevel.Document; XmlWriter writer = XmlTextWriter.Create(ms, settings); XmlSerializer serializer = new XmlSerializer(typeof(CDSInput)); serializer.Serialize(ms, cdsInput); string cdsInputString = Encoding.UTF8.GetString(ms.ToArray()); ms.Close(); string response = evaluate(cdsInputString, scopingEntityId, businessId, version); serializer = new XmlSerializer(typeof(CDSOutput)); StringReader sr = new StringReader(response); cdsOutput = (CDSOutput)serializer.Deserialize(sr); sr.Close(); return cdsOutput; }
private EngineResponse GetSampleEngineResponse(CDSInput payload) { var responsePayload = GetSampleResponsePayload(payload); var messages = new List <CDSExecutionMessage>(); // Uncomment this statement to demonstrate exception handling //throw // new CDSExecutionMessageWrapper // ( // new CDSExecutionMessage // { // message = new ST { value = "Error" }, // level = new CDSExecutionMessageLevel1 { valueSpecified = true, value = CDSExecutionMessageLevel.Error }, // reason = new CDSExecutionMessageReason1 { valueSpecified = true, value = CDSExecutionMessageReason.DataIsMissing }, // sourceComponentType = new CDSExecutionMessageSourceComponentType { valueSpecified = true, value = DSSComponentType.System } // } // ); return(new EngineResponse { Response = responsePayload, Messages = messages }); }
private CDSActionGroupResponse GetSampleResponsePayload(CDSInput payload) { return (new CDSActionGroupResponse { patientId = payload.vmrInput.patient.id, actionGroup = new ActionGroup { subElements = new ActionGroupSubElements { Items = new List <ActionBase> { new CreateAction { actionId = new II { extension = Guid.NewGuid().ToString("N") }, actionSentence = new elm.Instance { classType = new XmlQualifiedName("SubstanceAdministrationProposal"), element = new List <elm.InstanceElement> { new elm.InstanceElement { name = "id", value = new elm.Instance { classType = new XmlQualifiedName("II"), element = new List <elm.InstanceElement> { new elm.InstanceElement { name = "extension", value = new elm.Literal { value = Guid.NewGuid().ToString("N"), valueType = new XmlQualifiedName("t:String") } } } } }, new elm.InstanceElement { name = "susbtanceAdministrationGeneralPurpose", value = new elm.Code { code = "ASPIRIN", display = "Aspirin", system = new elm.CodeSystemRef { name = "org.hl7.example" } } }, new elm.InstanceElement { name = "proposedAdministrationTimeInterval", value = new elm.Interval { low = new elm.Literal { value = "2013-07-29", valueType = new XmlQualifiedName("t:DateTime") } } } } //value = // new SubstanceAdministrationProposal // { // id = new II { extension = Guid.NewGuid().ToString("N") }, // substanceAdministrationGeneralPurpose = // new CD // { // code = "ASPIRIN", // codeSystem = "org.hl7.example", // codeSystemName = "org.hl7.example", // displayName = new ST { value = "Aspirin" } // }, // proposedAdministrationTimeInterval = new IVL_TS { low = new TS { value = "20130729" } } // } } } } } } }); }
private static void callServiceWithObject() { string clientSystemPatientId = "1234567890"; CDSInput cdsInput = new CDSInput(); II templateId = new II(); templateId.root = "2.16.840.1.113883.3.795.11.1.1"; cdsInput.templateId = new II[] { templateId }; CDSContext cdsContext = new CDSContext(); CD preferredLanguage = new CD(); preferredLanguage.code = "en"; preferredLanguage.codeSystem = "1.2.3"; preferredLanguage.displayName = "English"; cdsContext.cdsInformationRecipientPreferredLanguage = preferredLanguage; cdsInput.cdsContext = cdsContext; VMR vmr = new VMR(); cdsInput.vmrInput = vmr; II vmrTemplateId = new II(); vmrTemplateId.root = "2.16.840.1.113883.3.795.11.1.1"; vmr.templateId = new II[] { vmrTemplateId }; EvaluatedPerson patient = new EvaluatedPerson(); II personTemplateId = new II(); personTemplateId.root = "2.16.840.1.113883.3.795.11.2.1.1"; patient.templateId = new II[] { personTemplateId }; II id = new II(); id.root = "2.16.840.1.113883.3.795.12.100.11"; id.extension = clientSystemPatientId; patient.id = id; EvaluatedPersonDemographics demographics = new EvaluatedPersonDemographics(); TS birthTime = new TS(); birthTime.value = "20110401"; demographics.birthTime = birthTime; CD gender = new CD(); gender.code = "F"; gender.codeSystem = "2.16.840.1.113883.5.1"; demographics.gender = gender; patient.demographics = demographics; vmr.patient = patient; EvaluatedPersonClinicalStatements statements = new EvaluatedPersonClinicalStatements(); patient.clinicalStatements = statements; SubstanceAdministrationEvent statement1 = getSubstanceAdministrationEvent("185", "20110430"); SubstanceAdministrationEvent statement2 = getSubstanceAdministrationEvent("184", "20110523"); SubstanceAdministrationEvent statement3 = getSubstanceAdministrationEvent("183", "20110721"); SubstanceAdministrationEvent statement4 = getSubstanceAdministrationEvent("182", "20110911"); SubstanceAdministrationEvent statement5 = getSubstanceAdministrationEvent("181", "20110912"); statements.substanceAdministrationEvents = new SubstanceAdministrationEvent[] { statement1, statement2, statement3, statement4, statement5 }; CDSOutput response = getResponse(cdsInput); processResponse(response); }
private static CDSOutput getResponse(CDSInput cdsInput) { OpenCdsService service = new OpenCdsService(endPoint); CDSOutput response = service.evaluate(cdsInput, scopingEntityId, businessId, version); return response; }
private static void callServiceWithObject() { string clientSystemPatientId = "1234567890"; CDSInput cdsInput = new CDSInput(); II templateId = new II(); templateId.root = "2.16.840.1.113883.3.795.11.1.1"; cdsInput.templateId = new II[] { templateId }; CDSContext cdsContext = new CDSContext(); CD preferredLanguage = new CD(); preferredLanguage.code = "en"; preferredLanguage.codeSystem = "1.2.3"; preferredLanguage.displayName = "English"; cdsContext.cdsInformationRecipientPreferredLanguage = preferredLanguage; cdsInput.cdsContext = cdsContext; VMR vmr = new VMR(); cdsInput.vmrInput = vmr; II vmrTemplateId = new II(); vmrTemplateId.root = "2.16.840.1.113883.3.795.11.1.1"; vmr.templateId = new II[] { vmrTemplateId }; EvaluatedPerson patient = new EvaluatedPerson(); II personTemplateId = new II(); personTemplateId.root = "2.16.840.1.113883.3.795.11.2.1.1"; patient.templateId = new II[] { personTemplateId }; II id = new II(); id.root = "2.16.840.1.113883.3.795.12.100.11"; id.extension = clientSystemPatientId; patient.id = id; EvaluatedPersonDemographics demographics = new EvaluatedPersonDemographics(); TS birthTime = new TS(); birthTime.value = "20110401"; demographics.birthTime = birthTime; CD gender = new CD(); gender.code = "F"; gender.codeSystem = "2.16.840.1.113883.5.1"; demographics.gender = gender; patient.demographics = demographics; vmr.patient = patient; EvaluatedPersonClinicalStatements statements = new EvaluatedPersonClinicalStatements(); patient.clinicalStatements = statements; SubstanceAdministrationEvent statement1 = getSubstanceAdministrationEvent("185", "20110430"); SubstanceAdministrationEvent statement2 = getSubstanceAdministrationEvent("184", "20110523"); SubstanceAdministrationEvent statement3 = getSubstanceAdministrationEvent("183", "20110721"); SubstanceAdministrationEvent statement4 = getSubstanceAdministrationEvent("182", "20110911"); SubstanceAdministrationEvent statement5 = getSubstanceAdministrationEvent("181", "20110912"); statements.substanceAdministrationEvents = new SubstanceAdministrationEvent[] { statement1, statement2, statement3, statement4, statement5 }; CDSOutput response = getResponse(cdsInput); processResponse(response); }