Пример #1
0
        private IenResult SaveDsioObservation(DsioObservation observation)
        {
            IenResult result = new IenResult();

            DsioSaveObservationCommand command = new DsioSaveObservationCommand(this.broker);

            // *** Add entry date if new ***
            if (string.IsNullOrWhiteSpace(observation.Ien))
            {
                observation.ExamDate = DateTime.Now.ToString(VistaDates.VistADateFormatFour);
            }

            command.AddCommandArguments(observation);

            RpcResponse response = command.Execute();

            result.Success = response.Status == RpcResponseStatus.Success;
            result.Message = response.InformationalMessage;

            if (result.Success)
            {
                result.Ien = command.Ien;
            }

            return(result);
        }
Пример #2
0
        public IenResult AddLactationObservation(string patientDfn, bool currentlyLactating)
        {
            // *** Add a lactation observation to the patient ***

            IenResult result;

            // *** Create the observation ***
            DsioObservation obs = new DsioObservation();

            obs.PatientDfn       = patientDfn;
            obs.Ien              = "";
            obs.ExamDate         = DateTime.Now.ToString(VistaDates.VistADateFormatFour);
            obs.PregnancyIen     = "";
            obs.BabyIen          = "";
            obs.Category         = "Postpartum";
            obs.Code.CodeSystem  = DsioObservation.OtherCodeSystem;
            obs.Code.Code        = "Lactating";
            obs.Code.DisplayName = "The patient is currently lactating";
            obs.Value            = currentlyLactating.ToString();

            // *** Save it ***
            result = this.SaveDsioObservation(obs);

            return(result);
        }
Пример #3
0
        public static DsioObservation GetDsioObservation(Observation observation)
        {
            DsioObservation returnVal = new DsioObservation()
            {
                Ien                 = observation.Ien,
                BabyIen             = observation.BabyIen,
                Category            = observation.Category,
                EnteredBy           = observation.EnteredBy,
                PatientDfn          = observation.PatientDfn,
                PregnancyIen        = observation.PregnancyIen,
                Value               = observation.Value,
                Narrative           = observation.Narrative,
                Unit                = observation.Unit,
                ExchangeDocumentIen = observation.ExchangeDocumentIen
            };

            returnVal.Code.Code           = observation.Code;
            returnVal.Code.DisplayName    = observation.Description;
            returnVal.Code.CodeSystemName = CodingSystemUtility.GetDescription(observation.CodeSystem);

            returnVal.ExamDate  = observation.ExamDate.ToString(VistaDates.VistADateFormatFour);
            returnVal.EntryDate = observation.EntryDate.ToString(VistaDates.VistADateFormatFour);

            returnVal.Negation = (observation.Negation) ? "true" : "false";

            return(returnVal);
        }
Пример #4
0
        public static Observation GetObservation(DsioObservation dsioObs)
        {
            Observation returnVal = new Observation()
            {
                Ien                 = dsioObs.Ien,
                BabyIen             = dsioObs.BabyIen,
                BabyNumber          = dsioObs.BabyNum,
                Category            = dsioObs.Category,
                Code                = dsioObs.Code.Code,
                Description         = dsioObs.Code.DisplayName,
                EnteredBy           = dsioObs.EnteredBy,
                PatientDfn          = dsioObs.PatientDfn,
                PregnancyIen        = dsioObs.PregnancyIen,
                Value               = dsioObs.Value,
                Narrative           = dsioObs.Narrative,
                Unit                = dsioObs.Unit,
                ExchangeDocumentIen = dsioObs.ExchangeDocumentIen
            };

            returnVal.CodeSystem = CodingSystemUtility.GetCodingSystemName(dsioObs.Code.CodeSystemName);

            returnVal.EntryDate = VistaDates.FlexParse(dsioObs.EntryDate);
            returnVal.ExamDate  = VistaDates.FlexParse(dsioObs.ExamDate);

            returnVal.Relationship = CdaRoleCode.GetHl7FamilyMember(dsioObs.Relationship);

            returnVal.Negation = dsioObs.Negation.Equals("true", StringComparison.CurrentCultureIgnoreCase);

            return(returnVal);
        }
        //public PregnancyResult GetMostRecentPregnancy(string patientDfn)
        //{
        //    PregnancyResult result = new PregnancyResult();

        //    PregnancyListResult listResult = GetPregnancies(patientDfn, "");


        //    if (listResult.Success)
        //    {
        //        if (listResult.Pregnancies != null)
        //        {
        //            Pregnancy mostRecent;
        //            foreach (Pregnancy preg in listResult.Pregnancies)
        //            {

        //                if (mostRecent == null)
        //                    mostRecent = preg;
        //                else if (preg.RecordType == PregnancyRecordType.Current)
        //                    mostRecent = preg;

        //            }
        //        }
        //    }

        //    return result;
        //}

        private List <DsioObservation> GetObservationsToSave(string patientDfn, PregnancyHistory pregnancyHistory)
        {
            PregnancyHistory origHist = null;

            // *** Get original history ***
            PregnancyHistoryResult histResult = this.GetPregnancyHistory(patientDfn);

            // *** Create a list of items that need to be saved ***
            List <DsioObservation> observationsToSave = new List <DsioObservation>();

            // *** Set original history ***
            if (histResult.Success)
            {
                origHist = histResult.PregnancyHistory;
            }

            // *** Loop through all the observations ***
            foreach (Observation newObservation in pregnancyHistory.Observations.Values)
            {
                if (!string.IsNullOrWhiteSpace(newObservation.Value)) // *** Add if there's something there
                {
                    // *** If we have previous entries ***
                    if (origHist != null)
                    {
                        // *** Compare current with previous and only save if different ***

                        string origVal = origHist.GetValue(newObservation.Code);

                        if (origVal == null)
                        {
                            origVal = "";
                        }

                        if (origVal != newObservation.Value)
                        {
                            DsioObservation dsioObs = ObservationUtility.GetDsioObservation(newObservation);
                            observationsToSave.Add(dsioObs);
                        }
                    }
                    else
                    {
                        DsioObservation dsioObs = ObservationUtility.GetDsioObservation(newObservation);
                        observationsToSave.Add(dsioObs);
                    }
                }
            }

            return(observationsToSave);
        }
Пример #6
0
        public BrokerOperationResult SaveObservations(List <Observation> observationList)
        {
            BrokerOperationResult result = new BrokerOperationResult();

            // *** Create the command ***
            DsioSaveObservationCommand command = new DsioSaveObservationCommand(this.broker);

            // *** Set some loop values ***
            bool okToContinue = true;
            int  i            = 0;

            // *** Loop through the observations ***
            while ((i < observationList.Count) && (okToContinue))
            {
                // *** Get the current ***
                DsioObservation observation = ObservationUtility.GetDsioObservation(observationList[i]);

                // *** Add the command arguments ***
                command.AddCommandArguments(observation);

                // *** Execute the command ***
                RpcResponse response = command.Execute();

                // *** Set the return response ***
                result.Success = (response.Status == RpcResponseStatus.Success);
                result.Message = response.InformationalMessage;

                // *** Continue if successful ***
                okToContinue = result.Success;

                // *** Set index to next ***
                i++;
            }

            return(result);
        }
Пример #7
0
        public IenResult SaveObservation(Observation observation)
        {
            DsioObservation dsioObs = ObservationUtility.GetDsioObservation(observation);

            return(SaveDsioObservation(dsioObs));
        }
        public BrokerOperationResult SavePregnancyHistory(string patientDfn, PregnancyHistory pregnancyHistory)
        {
            // *** Save new pregnancy history observations ***

            BrokerOperationResult result = new BrokerOperationResult();

            List <DsioObservation> observationsToSave = GetObservationsToSave(patientDfn, pregnancyHistory);

            // *** If there's something to save ***
            if (observationsToSave.Count > 0)
            {
                // *** Create the command ***
                DsioSaveObservationCommand command = new DsioSaveObservationCommand(this.broker);

                // *** Set some loop values ***
                bool okToContinue = true;
                int  i            = 0;

                // TODO: Simplify and shorten...

                // *** Loop through the observations ***
                while ((i < observationsToSave.Count) && (okToContinue))
                {
                    // *** Get the current ***
                    DsioObservation observation = observationsToSave[i];

                    // *** Set the patient dfn ***
                    observation.PatientDfn = patientDfn;

                    // *** Set the date/time ***
                    observation.ExamDate = DateTime.Now.ToString(VistaDates.VistADateFormatFour);

                    // *** Add the command arguments ***
                    command.AddCommandArguments(observation);

                    // *** Execute the command ***
                    RpcResponse response = command.Execute();

                    // *** Set the return response ***
                    result.Success = (response.Status == RpcResponseStatus.Success);
                    result.Message = response.InformationalMessage;

                    // *** Continue if successful ***
                    okToContinue = result.Success;

                    // *** Set index to next ***
                    i++;
                }

                if (okToContinue)
                {
                    // *** Save G&P Summary ***
                    DsioObservation observation = new DsioObservation();
                    observation.Code.CodeSystemName = "NONE";
                    observation.Code.Code           = "GravidaParaSummary";
                    observation.Category            = "Pregnancy History";
                    observation.Code.DisplayName    = "Gravida & Para Summary";

                    // *** Set the patient dfn ***
                    observation.PatientDfn = patientDfn;

                    // *** Set the date/time ***
                    observation.ExamDate = DateTime.Now.ToString(VistaDates.VistADateFormatFour);

                    // *** Add the value ***
                    observation.Value = pregnancyHistory.GravidaPara;

                    // *** Add the command arguments ***
                    command.AddCommandArguments(observation);

                    // *** Execute the command ***
                    RpcResponse response = command.Execute();

                    // *** Set the return response ***
                    result.Success = (response.Status == RpcResponseStatus.Success);
                    result.Message = response.InformationalMessage;

                    // *** Continue if successful ***
                    okToContinue = result.Success;
                }
            }
            else
            {
                result.Success = true;
                result.Message = "Nothing to save";
            }

            return(result);
        }