Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        private static CDSOutput getResponse(CDSInput cdsInput)
        {
            OpenCdsService service  = new OpenCdsService(endPoint);
            CDSOutput      response = service.evaluate(cdsInput, scopingEntityId, businessId, version);

            return(response);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        private static void processResponse(CDSOutput response)
        {
            XmlSerializer     serializer = new XmlSerializer(typeof(CDSOutput));
            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);

            serializer.Serialize(writer, response);
            Console.WriteLine("Raw Output:");
            Console.WriteLine(Encoding.UTF8.GetString(ms.ToArray()));
            ms.Close();
            VMR vmr = response.vmrOutput;

            if (vmr == null)
            {
                throw new Exception("vmr was null!");
            }
            EvaluatedPerson patient = vmr.patient;

            if (patient == null)
            {
                throw new Exception("patient wasd null!");
            }
            EvaluatedPersonClinicalStatements statements = patient.clinicalStatements;

            if (statements == null)
            {
                throw new Exception("statments was null!");
            }
            SubstanceAdministrationProposal[] proposals = statements.substanceAdministrationProposals;
            if (proposals == null || proposals.Length == 0)
            {
                throw new Exception("proposals was null or empty!");
            }
            for (int i = 0; i < proposals.Length; i++)
            {
                SubstanceAdministrationProposal proposal = proposals[i];
                if (proposal == null)
                {
                    throw new Exception("proposal was null!");
                }
                Console.WriteLine("Substance administration proposal:");
                AdministrableSubstance substance = proposal.substance;
                if (substance == null)
                {
                    throw new Exception("substance was null!");
                }
                CD substanceCode = substance.substanceCode;
                if (substanceCode != null)
                {
                    Console.WriteLine("    proposed substance code: " + substanceCode.code);
                }
                IVL_TS proposedTimeInterval = proposal.proposedAdministrationTimeInterval;
                if (proposedTimeInterval != null)
                {
                    Console.WriteLine("    proposed administration time: " + proposedTimeInterval.low);
                }
                RelatedClinicalStatement[] reasons = proposal.relatedClinicalStatement;

                if (reasons != null)
                {
                    for (int c = 0; c < reasons.Length; c++)
                    {
                        RelatedClinicalStatement reason = reasons[c];
                        ObservationResult        result = (ObservationResult)reason.Item;
                        if (result != null)
                        {
                            Console.WriteLine("    proposed reason - focus: " + result.observationFocus.displayName);
                            Console.WriteLine("    proposed reason - value: " + ((CD)result.observationValue.Item).code);
                            Console.WriteLine("    proposed reason - interpretation: " + result.interpretation[0].code);
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
        private static void processResponse(CDSOutput response)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(CDSOutput));
            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);
            serializer.Serialize(writer, response);
            Console.WriteLine("Raw Output:");
            Console.WriteLine(Encoding.UTF8.GetString(ms.ToArray()));
            ms.Close();
            VMR vmr = response.vmrOutput;
            if (vmr == null)
            {
                throw new Exception("vmr was null!");
            }
            EvaluatedPerson patient = vmr.patient;
            if (patient == null)
            {
                throw new Exception("patient wasd null!");
            }
            EvaluatedPersonClinicalStatements statements = patient.clinicalStatements;
            if (statements == null)
            {
                throw new Exception("statments was null!");
            }
            SubstanceAdministrationProposal[] proposals = statements.substanceAdministrationProposals;
            if (proposals == null || proposals.Length == 0)
            {
                throw new Exception("proposals was null or empty!");
            }
            for (int i = 0; i < proposals.Length; i++)
            {
                SubstanceAdministrationProposal proposal = proposals[i];
                if (proposal == null)
                {
                    throw new Exception("proposal was null!");
                }
                Console.WriteLine("Substance administration proposal:");
                AdministrableSubstance substance = proposal.substance;
                if (substance == null)
                {
                    throw new Exception("substance was null!");
                }
                CD substanceCode = substance.substanceCode;
                if (substanceCode != null)
                {
                    Console.WriteLine("    proposed substance code: " + substanceCode.code);
                }
                IVL_TS proposedTimeInterval = proposal.proposedAdministrationTimeInterval;
                if (proposedTimeInterval != null)
                {
                    Console.WriteLine("    proposed administration time: " + proposedTimeInterval.low);
                }
                RelatedClinicalStatement[] reasons = proposal.relatedClinicalStatement;

                if (reasons != null)
                {
                    for (int c = 0; c < reasons.Length; c++)
                    {
                        RelatedClinicalStatement reason = reasons[c];
                        ObservationResult result = (ObservationResult)reason.Item;
                        if (result != null)
                        {
                            Console.WriteLine("    proposed reason - focus: " + result.observationFocus.displayName);
                            Console.WriteLine("    proposed reason - value: " + ((CD) result.observationValue.Item).code);
                            Console.WriteLine("    proposed reason - interpretation: " + result.interpretation[0].code);
                        }
                    }
                }
            }
        }