Exemple #1
0
        public string GetPatientEnrollmentDetails()
        {
            try
            {
                EnrollmentDetails enrollmentDetails = new EnrollmentDetails();
                enrollmentDetails.IndentifiersList = new List <Identifier>();
                PersonId = int.Parse(Session["PersonId"].ToString());
                PatientLookupManager     patientLookupManager = new PatientLookupManager();
                PatientEntryPointManager entryPointManager    = new PatientEntryPointManager();
                PatientIdentifierManager identifierManager    = new PatientIdentifierManager();
                IdentifierManager        ideManager           = new IdentifierManager();
                PersonLookUpManager      personLookUp         = new PersonLookUpManager();

                PatientLookup patientList = patientLookupManager.GetPatientByPersonId(PersonId);

                if (patientList != null)
                {
                    enrollmentDetails.DOB          = String.Format("{0:dd-MMM-yyyy}", patientList.DateOfBirth);
                    enrollmentDetails.DobPrecision = patientList.DobPrecision;
                    if (enrollmentDetails.DOB == null)
                    {
                        PersonLookUp person = personLookUp.GetPersonById(PersonId);
                        if (person.DateOfBirth != null)
                        {
                            enrollmentDetails.DOB          = String.Format("{0:dd-MMM-yyyy}", person.DateOfBirth);
                            enrollmentDetails.DobPrecision = person.DobPrecision == null?false:Convert.ToBoolean(person.DobPrecision);
                        }
                    }
                    enrollmentDetails.NationalId     = patientList.NationalId;
                    enrollmentDetails.EnrollmentDate = String.Format("{0:dd-MMM-yyyy}", patientList.EnrollmentDate);

                    var entryPoints   = entryPointManager.GetPatientEntryPoints(patientList.Id);
                    var identifiers   = identifierManager.GetAllPatientEntityIdentifiers(patientList.Id);
                    var dynamicFields = EnrollmentService.ServiceDynamicFields(1);
                    if (entryPoints.Count > 0)
                    {
                        string Name = LookupLogic.GetLookupNameById(entryPoints[0].EntryPointId);
                        if (Name == "Unknown")
                        {
                            enrollmentDetails.EntryPointIdUnknown = true;
                            enrollmentDetails.EntryPointId        = entryPoints[0].EntryPointId;
                        }
                        else
                        {
                            enrollmentDetails.EntryPointIdUnknown = false;
                            enrollmentDetails.EntryPointId        = entryPoints[0].EntryPointId;
                        }
                    }
                    var dynamicObject = new ExpandoObject() as IDictionary <string, Object>;
                    foreach (var field in dynamicFields)
                    {
                        foreach (var itemsEntityIdentifier in identifiers)
                        {
                            if (itemsEntityIdentifier.IdentifierTypeId == field.ID)
                            {
                                var code = field.Code;
                                dynamicObject.Add(code, itemsEntityIdentifier.IdentifierValue);
                            }
                        }
                    }
                    //if (identifiers.Count > 0)
                    //{
                    //    enrollmentDetails.IndentifierId = identifiers[0].IdentifierTypeId;
                    //}

                    foreach (var dynamicItem in dynamicObject)
                    {
                        var key           = dynamicItem.Key;
                        var identifier    = ideManager.GetIdentifierByCode(key);
                        var dynIdentifier = new Identifier();
                        if (identifier.PrefixType != null)
                        {
                            string[] enrollmentParts = dynamicItem.Value.ToString().Split('-');
                            int      parts           = enrollmentParts.Length;
                            if (parts > 1)
                            {
                                dynIdentifier.Code       = key;
                                dynIdentifier.PrefixType = enrollmentParts[0];
                                dynIdentifier.DataType   = enrollmentParts[1];
                                //enrollmentDetails.EnrollmentValue = enrollmentParts[1];
                                //enrollmentDetails.Prefix = enrollmentParts[0];
                                //enrollmentDetails.Suffix = null;
                            }
                            else
                            {
                                dynIdentifier.Code     = key;
                                dynIdentifier.DataType = dynamicItem.Value.ToString();
                                //enrollmentDetails.EnrollmentValue = dynamicItem.Value.ToString();
                            }
                        }
                        else
                        {
                            dynIdentifier.Code     = key;
                            dynIdentifier.DataType = dynamicItem.Value.ToString();
                        }
                        enrollmentDetails.IndentifiersList.Add(dynIdentifier);
                    }

                    //string[] enrollmentParts = patientList[0].EnrollmentNumber.Split('-');
                    //int parts = enrollmentParts.Length;
                    //if (parts > 1)
                    //{
                    //    enrollmentDetails.EnrollmentValue = enrollmentParts[1];
                    //    enrollmentDetails.Prefix = enrollmentParts[0];
                    //    enrollmentDetails.Suffix = null;
                    //}
                    //else
                    //{
                    //    enrollmentDetails.EnrollmentValue = patientList[0].EnrollmentNumber;
                    //}
                }
                else
                {
                    PersonLookUp person = personLookUp.GetPersonById(PersonId);
                    if (person.DateOfBirth != null)
                    {
                        enrollmentDetails.DOB          = String.Format("{0:dd-MMM-yyyy}", person.DateOfBirth);
                        enrollmentDetails.DobPrecision = person.DobPrecision == null ? false : Convert.ToBoolean(person.DobPrecision);
                    }
                }

                return(new JavaScriptSerializer().Serialize(enrollmentDetails));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Exemple #2
0
 public string GetDynamicFields()
 {
     return(new JavaScriptSerializer().Serialize(EnrollmentService.ServiceDynamicFields(1)));
 }
 public string GetServiceAreaIdentifiers()
 {
     return(new JavaScriptSerializer().Serialize(EnrollmentService.ServiceAreaIdentifiers(1)));
 }