private void PreparePatientDetailsFromFormC() { var identifier_asm = GetAttributeValueFromObject(1, "asmNumber"); List <CustomAttributeParameter> parameters = new List <CustomAttributeParameter>(); parameters.Add(new CustomAttributeParameter() { AttributeKey = "Medical Record Number", AttributeValue = identifier_asm }); var patientFromRepo = _patientService.GetPatientUsingAttributes(parameters); if (patientFromRepo == null) { throw new Exception($"Unable to locate patient record for {identifier_asm}"); } IExtendable patientExtended = patientFromRepo; _patientDetailForUpdate = new PatientDetailForUpdate(); _patientDetailForUpdate.CustomAttributes = _modelExtensionBuilder.BuildModelExtension(patientExtended); // Attachments _patientDetailForUpdate.Attachments.Add(new AttachmentDetail() { Description = _formForCreation.FormIdentifier, ImageSource = _formForCreation.Attachment }); if (_formForCreation.HasSecondAttachment) { _patientDetailForUpdate.Attachments.Add(new AttachmentDetail() { Description = _formForCreation.FormIdentifier, ImageSource = _formForCreation.Attachment_2 }); } // Encounter _patientDetailForUpdate.EncounterTypeId = 3; _patientDetailForUpdate.EncounterDate = String.IsNullOrWhiteSpace(GetAttributeValueFromObject(4, "currentDate")) ? DateTime.Today : Convert.ToDateTime(GetAttributeValueFromObject(4, "currentDate")); _patientDetailForUpdate.PriorityId = 1; if (!_patientDetailForUpdate.IsValid()) { _patientDetailForUpdate.InvalidAttributes.ForEach(element => _validationErrors.Add(element)); } }
private void PreparePatientDetailsFromFormB() { var identifier_asm = GetAttributeValueFromObject(1, "asmNumber"); List <CustomAttributeParameter> parameters = new List <CustomAttributeParameter>(); parameters.Add(new CustomAttributeParameter() { AttributeKey = "Medical Record Number", AttributeValue = identifier_asm }); var patientFromRepo = _patientService.GetPatientUsingAttributes(parameters); if (patientFromRepo == null) { throw new Exception($"Unable to locate patient record for {identifier_asm}"); } IExtendable patientExtended = patientFromRepo; _patientDetailForUpdate = new PatientDetailForUpdate(); _patientDetailForUpdate.CustomAttributes = _modelExtensionBuilder.BuildModelExtension(patientExtended); // Prepare patient first class _patientDetailForUpdate.FirstName = GetAttributeValueFromObject(1, "patientFirstName"); _patientDetailForUpdate.Surname = GetAttributeValueFromObject(1, "patientLastName"); _patientDetailForUpdate.DateOfBirth = String.IsNullOrWhiteSpace(GetAttributeValueFromObject(1, "birthDate")) ? (DateTime?)null : Convert.ToDateTime(GetAttributeValueFromObject(1, "birthDate")); // Prepare patient attributes _patientDetailForUpdate.SetAttributeValue("Medical Record Number", GetAttributeValueFromObject(1, "asmNumber")); if (!String.IsNullOrWhiteSpace(GetAttributeValueFromObject(1, "patientIdentityNumber"))) { _patientDetailForUpdate.SetAttributeValue("Patient Identity Number", GetAttributeValueFromObject(1, "patientIdentityNumber")); } if (!String.IsNullOrWhiteSpace(GetAttributeValueFromObject(1, "patientIdentityNumber"))) { _patientDetailForUpdate.SetAttributeValue("Patient Identity Number", GetAttributeValueFromObject(1, "patientIdentityNumber")); } if (TransformToGender(GetAttributeValueFromObject(1, "gender")) != "0") { _patientDetailForUpdate.SetAttributeValue("Gender", TransformToGender(GetAttributeValueFromObject(1, "gender"))); } // Clinical _patientDetailForUpdate.LabTests.AddRange(PrepareLabTestDetail(3)); _patientDetailForUpdate.ClinicalEvents.AddRange(PrepareClinicalEventDetail(1)); // Attachments _patientDetailForUpdate.Attachments.Add(new AttachmentDetail() { Description = _formForCreation.FormIdentifier, ImageSource = _formForCreation.Attachment }); if (_formForCreation.HasSecondAttachment) { _patientDetailForUpdate.Attachments.Add(new AttachmentDetail() { Description = _formForCreation.FormIdentifier, ImageSource = _formForCreation.Attachment_2 }); } // Encounter _patientDetailForUpdate.EncounterTypeId = 2; _patientDetailForUpdate.EncounterDate = String.IsNullOrWhiteSpace(GetAttributeValueFromObject(6, "currentDate")) ? DateTime.Today : Convert.ToDateTime(GetAttributeValueFromObject(6, "currentDate")); _patientDetailForUpdate.PriorityId = 1; if (!_patientDetailForUpdate.IsValid()) { _patientDetailForUpdate.InvalidAttributes.ForEach(element => _validationErrors.Add(element)); } }