Esempio n. 1
0
        public JsonResult AddFamilyHX(PatientFamilyHX_Custom _objFHX)
        {
            try
            {
                ApiResultModel         apiresult = new ApiResultModel();
                PatientFamilyHX_Custom objHX     = new PatientFamilyHX_Custom();
                objHX.name      = _objFHX.name;
                objHX.patientID = _objFHX.patientID;
                if (_objFHX.relationship != null)
                {
                    objHX.relationship = Regex.Replace(_objFHX.relationship, @"^\s*$\n", string.Empty, RegexOptions.Multiline).Trim();
                }
                else
                {
                    objHX.relationship = null;
                }

                apiresult = oMyHealthRepository.AddFamilyHX(objHX);
                return(Json(new { Success = true, ApiResultModel = apiresult }));
            }
            catch (System.Web.Http.HttpResponseException ex)
            {
                return(Json(new { Message = ex.Response }));
            }
        }
Esempio n. 2
0
        public async Task <HttpResponseMessage> addPatientFamilyHX(PatientFamilyHX_Custom model)
        {
            PatientFamilyHX phx = new PatientFamilyHX();

            try
            {
                if (model.name == null || model.name == "")
                {
                    response = Request.CreateResponse(HttpStatusCode.BadRequest, new ApiResultModel {
                        ID = 0, message = "Invalid familyHX."
                    });
                    return(response);
                }
                if (model.patientID == null || model.patientID == 0)
                {
                    response = Request.CreateResponse(HttpStatusCode.BadRequest, new ApiResultModel {
                        ID = 0, message = "Invalid patient id."
                    });
                    return(response);
                }

                phx = db.PatientFamilyHXes.Where(p => p.name.Trim() == model.name.Trim() && p.patientID == model.patientID).FirstOrDefault();
                if (phx != null)
                {
                    phx.relationship    = model.relationship;
                    phx.md              = System.DateTime.Now;
                    phx.mb              = phx.patientID.ToString();
                    phx.active          = true;
                    db.Entry(phx).State = EntityState.Modified;
                    await db.SaveChangesAsync();

                    response = Request.CreateResponse(HttpStatusCode.OK, new ApiResultModel {
                        ID = phx.fhxid, message = ""
                    });
                    return(response);
                }
                if (phx == null)
                {
                    phx              = new PatientFamilyHX();
                    phx.active       = true;
                    phx.name         = model.name;
                    phx.relationship = model.relationship;
                    phx.patientID    = model.patientID;
                    phx.cd           = System.DateTime.Now;
                    phx.cb           = model.patientID.ToString();
                    db.PatientFamilyHXes.Add(phx);
                    await db.SaveChangesAsync();
                }
            }
            catch (Exception ex)
            {
                return(ThrowError(ex, "AddPatientFamilyHX in PatientFamilyHXController."));
            }

            response = Request.CreateResponse(HttpStatusCode.OK, new ApiResultModel {
                ID = phx.fhxid, message = ""
            });
            return(response);
        }
Esempio n. 3
0
 public ApiResultModel AddFamilyHX(PatientFamilyHX_Custom model)
 {
     try
     {
         var strContent = JsonConvert.SerializeObject(model);
         var response   = ApiConsumerHelper.PostData("api/addPatientFamilyHX", strContent);
         var result     = JsonConvert.DeserializeObject <ApiResultModel>(response);
         return(result);
     }
     catch (HttpResponseException ex)
     {
         throw ex;
     }
 }