Ejemplo n.º 1
0
        // Let's request the conformance statement from the SMART on FHIR API server and
        // find out the endpoint URLs for the authorization server



        //public ActionResult FraminghamCalculator(CernerFullConnectionInformationViewModel cfcivm) //Models.ViewModels.Patient viewPatient)
        public FraminghamCalculatorViewModel FraminghamCalculator(CernerFullConnectionInformationViewModel cfcivm) //Models.ViewModels.Patient viewPatient)

        {
            ViewBag.Message = "Framingham Calculator";


            var client = new FhirClient(cfcivm.ServiceUrl)
            {
                PreferredFormat = ResourceFormat.Json
            };;

            client.OnBeforeRequest += (object sender, BeforeRequestEventArgs e) =>
            {
                e.RawRequest.Headers.Add("Authorization", "Bearer " + cfcivm.AccessToken);
            };


            var identity = ResourceIdentity.Build("Patient", cfcivm.PatientId);

            Hl7.Fhir.Model.Patient viewPatient = client.Read <Hl7.Fhir.Model.Patient>(identity);

            //Get those values we don't know how to retrive yet.
            FraminghamCalculatorPatient Fcp = PhillFCM(0);

            Fcp.LastName  = viewPatient.Name[viewPatient.Name.Count - 1].FamilyElement[0].ToString();
            Fcp.FirstName = viewPatient.Name[viewPatient.Name.Count - 1].GivenElement[0].ToString();
            Fcp.Gender    = viewPatient.Gender.ToString();
            Fcp.Age       = Convert.ToDateTime(viewPatient.BirthDate).Age();


            #region Get HDL
            //Now we get some real data like the HDL
            FraminghamCalculator fc = new FraminghamCalculator(Fcp);
            fc.FhirClient = client;

            string loinc_hdl = "2085-9";
            string loinc_ldl = "13457-7";
            string loinc_Cholesterol_Total = "9830-1";
            string loinc_cholesterol       = "2093-3";
            string loinc_Triglycerides     = "2571-8";
            string loinc_SystolicBP        = "8480-6";
            string loinc_DiastolicBP       = "8462-4";

            BloodPressureValue bpv      = fc.GetLatestBloodPressureValue(cfcivm.PatientId, loinc_SystolicBP);
            CholesterolValue   cv_hdl   = fc.GetLatestCholesterolValue(cfcivm.PatientId, loinc_hdl);
            CholesterolValue   cv_total = fc.GetLatestCholesterolValue(cfcivm.PatientId, loinc_cholesterol);

            #endregion Get HDL

            Fcp.SystolicBP       = (int)bpv.Value;
            Fcp.HDL              = (int)cv_hdl.Value;
            Fcp.TotalCholesterol = (int)cv_total.Value;

            FraminghamCalculatorViewModel vm = new FraminghamCalculatorViewModel();

            vm.FraminghamScore = fc.DoCalculation();
            vm.FCM             = Fcp;

            return(vm);
        }
Ejemplo n.º 2
0
        public ActionResult Index(CernerOAuth2ViewModels lvm)
        {
            CernerAuth myCernerAuth = TokenGettingStuff();

            try
            {
                CernerFullConnectionInformationViewModel cfcivm = new CernerFullConnectionInformationViewModel
                {
                    AccessToken  = myCernerAuth.access_token,
                    RefreshToken = myCernerAuth.refresh_token,

                    PatientId = myCernerAuth.patient,

                    ServiceUrl = myCernerHelper.cci.ServiceUrl
                };

                FraminghamCalculatorViewModel fcvm = FraminghamCalculator(cfcivm);

                return(View("FraminghamCalculator", fcvm));
            }
            catch (Exception ex)
            {
                myCernerHelper.cci.ErrorCorrelationId = myCernerAuth.CorrelationId;

                return(View("CernerHelper", myCernerHelper.cci));
            }
        }