public Patient CreateFHIRPatientProfile() { Patient pt; try { /* * * _patientFHIRProfile.NoIDHubPassword = password; * _patientFHIRProfile.NoIDHubName = patientHub; * _patientFHIRProfile.GenderChangeFlag = genderChangeFlag; * */ pt = new Patient(); BiometricsCaptured = GetBiometricsCaptured(); // Add message status New, Return or Update Meta meta = new Meta(); meta.Extension.Add(FHIRUtilities.MessageTypeExtension(NoIDStatus, NoIDType, CheckinDateTime)); meta.Extension.Add(FHIRUtilities.ClinicLocationExtension(ClinicArea, DevicePhysicalLocation)); if (FingerPrintMinutiasList.Count > 0) { meta.Extension.Add(FHIRUtilities.CaptureSummaryExtension(BiometricsCaptured, FingerPrintMinutiasList[0].DeviceName, FingerPrintMinutiasList[0].OriginalDpi, FingerPrintMinutiasList[0].OriginalHeight, FingerPrintMinutiasList[0].OriginalWidth) ); } meta.Extension.Add(FHIRUtilities.NoIDHubInfo(NoIDHubName, NoIDHubPassword)); if (GenderChangeFlag.ToLower().Contains("yes") == true || MultipleBirth.ToLower().Contains("no") == false) { meta.Extension.Add(FHIRUtilities.GenderAndTwinInfo(GenderChangeFlag, MultipleBirth)); } pt.Meta = meta; //TODO: Move fingerprint minutias to Identifier.Extension Identifier idSession = new Identifier(); idSession.System = ServerName + "/fhir/SessionID"; if (SessionID == null || SessionID.Length == 0) { NewSession(); } idSession.Value = SessionID; pt.Identifier.Add(idSession); if (BiometricExceptionMissingReason.Length > 0) { if (SecretQuestion1.Length > 0 && SecretAnswer1.Length > 0 && SecretQuestion2.Length > 0 && SecretAnswer2.Length > 0) { Identifier idBiometricException = new Identifier(); idBiometricException.System = ServerName + "/fhir/BiometricException"; idBiometricException.Value = "Biometric Exception Pathway"; Extension extBiometricException; extBiometricException = FHIRUtilities.BiometricException( BiometricExceptionMissingReason, SecretQuestion1, SecretAnswer1, SecretQuestion2, SecretAnswer2 ); idBiometricException.Extension.Add(extBiometricException); pt.Identifier.Add(idBiometricException); } { //throw an error back to the page. } } ResourceReference managingOrganization = new ResourceReference(OrganizationName, DomainName); pt.ManagingOrganization = managingOrganization; // Add patient demographics pt.Language = Language; pt.BirthDate = BirthDate; if (Gender.ToLower() == "f") { pt.Gender = AdministrativeGender.Female; } else if (Gender.ToLower() == "m") { pt.Gender = AdministrativeGender.Male; } else { pt.Gender = AdministrativeGender.Unknown; } if (!(MultipleBirth == null) && MultipleBirth.Length > 0) { if (MultipleBirth.ToLower().Substring(0, 2) == "no") { pt.MultipleBirth = new FhirString("No"); } else if (MultipleBirth.ToLower() == "yes") { pt.MultipleBirth = new FhirString("Yes"); } } // Add patient name HumanName ptName = new HumanName(); ptName.Given = new string[] { FirstName, MiddleName }; ptName.Family = LastName; pt.Name = new List <HumanName> { ptName }; if (StreetAddress.Length > 0 || City.Length > 0 || State.Length > 0 || PostalCode.Length > 0) { Address address = new Address(); // Add patient address address.Line = new string[] { StreetAddress, StreetAddress2 }; address.City = City; address.State = State; address.Country = Country; address.PostalCode = PostalCode; pt.Address.Add(address); } // Add patient contact information (phone numbers and email) // TODO: make sure email and phone are valid. // Validate phone with UI. Patient.ContactComponent contact = new Patient.ContactComponent(); bool addContact = false; if ((EmailAddress != null) && EmailAddress.Length > 0) { ContactPoint emailAddress = new ContactPoint(ContactPoint.ContactPointSystem.Email, ContactPoint.ContactPointUse.Home, EmailAddress); contact.Telecom.Add(emailAddress); addContact = true; } if ((PhoneHome != null) && PhoneHome.Length > 0) { ContactPoint phoneHome = new ContactPoint(ContactPoint.ContactPointSystem.Phone, ContactPoint.ContactPointUse.Home, PhoneHome); contact.Telecom.Add(phoneHome); addContact = true; } if ((PhoneCell != null) && PhoneCell.Length > 0) { ContactPoint phoneCell = new ContactPoint(ContactPoint.ContactPointSystem.Phone, ContactPoint.ContactPointUse.Mobile, PhoneCell); contact.Telecom.Add(phoneCell); addContact = true; } if ((PhoneWork != null) && PhoneWork.Length > 0) { ContactPoint phoneWork = new ContactPoint(ContactPoint.ContactPointSystem.Phone, ContactPoint.ContactPointUse.Work, PhoneWork); contact.Telecom.Add(phoneWork); addContact = true; } if (addContact) { pt.Contact.Add(contact); } //TODO: Change location of minutias in Patient FHIR profile from attached Photo.Extension to Identity.Extension foreach (FingerPrintMinutias minutias in FingerPrintMinutiasList) { Attachment attach = new Attachment(); Media fingerprintMedia = FingerPrintFHIRMedia(minutias, minutias.DeviceName, minutias.OriginalDpi, minutias.OriginalHeight, minutias.OriginalWidth); byte[] mediaBytes = FhirSerializer.SerializeToJsonBytes(fingerprintMedia, summary: SummaryType.Data); attach.Data = mediaBytes; pt.Photo.Add(attach); } } catch (Exception ex) { BaseException = new Exception("Error in PatientProfile::CreateFHIRProfile(). Failed to create a new FHIR profile: " + ex.Message); return(null); } return(pt); }