/// <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);
        }
        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" } }
														//	}
                                                    }
                                            }
                                        }
                                }
                        }
                    
                };
        }
Example #4
0
        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 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" } }
                                                            }
                                                    }
                                            }
                                        }
                                }
                        }

                };
        }