public void RaceNameToRaceCode_Test(string input, string expected) { Assert.Equal(expected, mortalityData.RaceNameToRaceCode(input)); }
/// <summary>Convert Nightingale style JSON string to FHIR VRDR <c>DeathRecord</c>,</summary> public static DeathRecord FromNightingale(string json) { // Load in Nightingale string and serialize to Dictionary<string, string> Dictionary <string, string> values = JsonConvert.DeserializeObject <Dictionary <string, string> >(json); // Start building the record DeathRecord deathRecord = new DeathRecord(); SetStringValueDeathRecordString(deathRecord, "Identifier", GetValue(values, "certificateNumber")); SetYesNoValueDeathRecordCode(deathRecord, "MilitaryService", GetValue(values, "armedForcesService.armedForcesService")); SetYesNoValueDeathRecordCode(deathRecord, "AutopsyPerformedIndicator", GetValue(values, "autopsyPerformed.autopsyPerformed")); SetYesNoValueDeathRecordCode(deathRecord, "AutopsyResultsAvailable", GetValue(values, "autopsyAvailableToCompleteCauseOfDeath.autopsyAvailableToCompleteCauseOfDeath")); SetYesNoValueDeathRecordCode(deathRecord, "TobaccoUse", GetValue(values, "didTobaccoUseContributeToDeath.didTobaccoUseContributeToDeath")); SetYesNoValueDeathRecordCode(deathRecord, "ExaminerContacted", GetValue(values, "meOrCoronerContacted.meOrCoronerContacted")); if (GetValue(values, "certifierType.certifierType") == "Physician (Certifier)") { SetStringValueDeathRecordDictionary(deathRecord, "CertificationRole", "code", "434641000124105"); SetStringValueDeathRecordDictionary(deathRecord, "CertificationRole", "display", "Physician"); SetStringValueDeathRecordDictionary(deathRecord, "CertificationRole", "system", "http://snomed.info/sct"); } else if (GetValue(values, "certifierType.certifierType") == "Physician (Pronouncer and Certifier)") { SetStringValueDeathRecordDictionary(deathRecord, "CertificationRole", "code", "434651000124107"); SetStringValueDeathRecordDictionary(deathRecord, "CertificationRole", "display", "Physician (Pronouncer and Certifier)"); SetStringValueDeathRecordDictionary(deathRecord, "CertificationRole", "system", "http://snomed.info/sct"); } else if (GetValue(values, "certifierType.certifierType") == "Medical Examiner") { SetStringValueDeathRecordDictionary(deathRecord, "CertificationRole", "code", "440051000124108"); SetStringValueDeathRecordDictionary(deathRecord, "CertificationRole", "display", "Medical Examiner"); SetStringValueDeathRecordDictionary(deathRecord, "CertificationRole", "system", "http://snomed.info/sct"); } SetStringValueDeathRecordString(deathRecord, "COD1A", GetValue(values, "cod.immediate")); SetStringValueDeathRecordString(deathRecord, "INTERVAL1A", GetValue(values, "cod.immediateInt")); SetStringValueDeathRecordString(deathRecord, "COD1B", GetValue(values, "cod.under1")); SetStringValueDeathRecordString(deathRecord, "INTERVAL1B", GetValue(values, "cod.under1Int")); SetStringValueDeathRecordString(deathRecord, "COD1C", GetValue(values, "cod.under2")); SetStringValueDeathRecordString(deathRecord, "INTERVAL1C", GetValue(values, "cod.under2Int")); SetStringValueDeathRecordString(deathRecord, "COD1D", GetValue(values, "cod.under3")); SetStringValueDeathRecordString(deathRecord, "INTERVAL1D", GetValue(values, "cod.under3Int")); SetStringValueDeathRecordString(deathRecord, "ContributingConditions", GetValue(values, "contributingCauses.contributingCauses")); SetStringValueDeathRecordString(deathRecord, "DateOfBirth", GetValue(values, "dateOfBirth.dateOfBirth")); SetStringValueDeathRecordString(deathRecord, "DateOfDeath", GetValue(values, "dateOfDeath.dateOfDeath")); SetStringValueDeathRecordString(deathRecord, "DateOfDeathPronouncement", GetValue(values, "datePronouncedDead.datePronouncedDead")); SetStringValueDeathRecordDictionary(deathRecord, "Residence", "addressLine1", GetValue(values, "decedentAddress.street")); SetStringValueDeathRecordDictionary(deathRecord, "Residence", "addressCity", GetValue(values, "decedentAddress.city")); SetStringValueDeathRecordDictionary(deathRecord, "Residence", "addressState", GetValue(values, "decedentAddress.state")); SetStringValueDeathRecordDictionary(deathRecord, "Residence", "addressZip", GetValue(values, "decedentAddress.zip")); SetStringValueDeathRecordDictionary(deathRecord, "Residence", "addressCountry", "United States"); SetStringValueDeathRecordString(deathRecord, "InjuryLocationName", GetValue(values, "detailsOfInjuryLocation.name")); SetStringValueDeathRecordDictionary(deathRecord, "InjuryLocationAddress", "addressLine1", GetValue(values, "detailsOfInjuryLocation.street")); SetStringValueDeathRecordDictionary(deathRecord, "InjuryLocationAddress", "addressCity", GetValue(values, "detailsOfInjuryLocation.city")); SetStringValueDeathRecordDictionary(deathRecord, "InjuryLocationAddress", "addressState", GetValue(values, "detailsOfInjuryLocation.state")); SetStringValueDeathRecordDictionary(deathRecord, "InjuryLocationAddress", "addressZip", GetValue(values, "detailsOfInjuryLocation.zip")); SetStringValueDeathRecordDictionary(deathRecord, "InjuryLocationAddress", "addressCountry", "United States"); SetStringValueDeathRecordString(deathRecord, "DeathLocationName", GetValue(values, "locationOfDeath.name")); SetStringValueDeathRecordDictionary(deathRecord, "DeathLocationAddress", "addressLine1", GetValue(values, "locationOfDeath.street")); SetStringValueDeathRecordDictionary(deathRecord, "DeathLocationAddress", "addressCity", GetValue(values, "locationOfDeath.city")); SetStringValueDeathRecordDictionary(deathRecord, "DeathLocationAddress", "addressState", GetValue(values, "locationOfDeath.state")); SetStringValueDeathRecordDictionary(deathRecord, "DeathLocationAddress", "addressZip", GetValue(values, "locationOfDeath.zip")); SetStringValueDeathRecordDictionary(deathRecord, "DeathLocationAddress", "addressCountry", "United States"); SetStringValueDeathRecordString(deathRecord, "FuneralHomeName", GetValue(values, "funeralFacility.name")); SetStringValueDeathRecordDictionary(deathRecord, "FuneralHomeAddress", "addressLine1", GetValue(values, "funeralFacility.street")); SetStringValueDeathRecordDictionary(deathRecord, "FuneralHomeAddress", "addressCity", GetValue(values, "funeralFacility.city")); SetStringValueDeathRecordDictionary(deathRecord, "FuneralHomeAddress", "addressState", GetValue(values, "funeralFacility.state")); SetStringValueDeathRecordDictionary(deathRecord, "FuneralHomeAddress", "addressZip", GetValue(values, "funeralFacility.zip")); SetStringValueDeathRecordDictionary(deathRecord, "FuneralHomeAddress", "addressCountry", "United States"); SetStringValueDeathRecordDictionary(deathRecord, "CertifierAddress", "addressLine1", GetValue(values, "personCompletingCauseOfDeathAddress.street")); SetStringValueDeathRecordDictionary(deathRecord, "CertifierAddress", "addressCity", GetValue(values, "personCompletingCauseOfDeathAddress.city")); SetStringValueDeathRecordDictionary(deathRecord, "CertifierAddress", "addressState", GetValue(values, "personCompletingCauseOfDeathAddress.state")); SetStringValueDeathRecordDictionary(deathRecord, "CertifierAddress", "addressZip", GetValue(values, "personCompletingCauseOfDeathAddress.zip")); SetStringValueDeathRecordDictionary(deathRecord, "CertifierAddress", "addressCountry", "United States"); SetStringValueDeathRecordDictionary(deathRecord, "PlaceOfBirth", "addressCity", GetValue(values, "placeOfBirth.city")); SetStringValueDeathRecordDictionary(deathRecord, "PlaceOfBirth", "addressState", GetValue(values, "placeOfBirth.state")); SetStringValueDeathRecordDictionary(deathRecord, "PlaceOfBirth", "addressZip", GetValue(values, "placeOfBirth.zip")); SetStringValueDeathRecordDictionary(deathRecord, "PlaceOfBirth", "addressCountry", "United States"); SetStringValueDeathRecordString(deathRecord, "DispositionLocationName", GetValue(values, "placeOfDisposition.name")); SetStringValueDeathRecordDictionary(deathRecord, "DispositionLocationAddress", "addressCity", GetValue(values, "placeOfDisposition.city")); SetStringValueDeathRecordDictionary(deathRecord, "DispositionLocationAddress", "addressState", GetValue(values, "placeOfDisposition.state")); SetStringValueDeathRecordDictionary(deathRecord, "DispositionLocationAddress", "addressCountry", GetValue(values, "placeOfDisposition.country")); List <string> names = new List <string>(); if (!String.IsNullOrWhiteSpace(GetValue(values, "decedentName.firstName"))) { names.Add(GetValue(values, "decedentName.firstName")); } if (!String.IsNullOrWhiteSpace(GetValue(values, "decedentName.middleName"))) { names.Add(GetValue(values, "decedentName.middleName")); } deathRecord.GivenNames = names.ToArray(); SetStringValueDeathRecordString(deathRecord, "FamilyName", GetValue(values, "decedentName.lastName")); List <string> cnames = new List <string>(); if (!String.IsNullOrWhiteSpace(GetValue(values, "personCompletingCauseOfDeathName.firstName"))) { cnames.Add(GetValue(values, "personCompletingCauseOfDeathName.firstName")); } if (!String.IsNullOrWhiteSpace(GetValue(values, "personCompletingCauseOfDeathName.middleName"))) { cnames.Add(GetValue(values, "personCompletingCauseOfDeathName.middleName")); } deathRecord.CertifierGivenNames = cnames.ToArray(); SetStringValueDeathRecordString(deathRecord, "CertifierFamilyName", GetValue(values, "personCompletingCauseOfDeathName.lastName")); SetStringValueDeathRecordString(deathRecord, "InjuryLocationDescription", GetValue(values, "detailsOfInjury.detailsOfInjury")); switch (GetValue(values, "education.education")) { case "8th grade or less": case "9th through 12th grade; no diploma": Dictionary <string, string> edu = new Dictionary <string, string>(); edu.Add("code", "SEC"); edu.Add("system", "http://terminology.hl7.org/CodeSystem/v3-EducationLevel"); edu.Add("display", "Some secondary or high school education"); deathRecord.EducationLevel = edu; break; case "High School Graduate or GED Completed": edu = new Dictionary <string, string>(); edu.Add("code", "HS"); edu.Add("system", "http://terminology.hl7.org/CodeSystem/v3-EducationLevel"); edu.Add("display", "High School or secondary school degree complete"); deathRecord.EducationLevel = edu; break; case "Some college credit, but no degree": edu = new Dictionary <string, string>(); edu.Add("code", "PB"); edu.Add("system", "http://terminology.hl7.org/CodeSystem/v3-EducationLevel"); edu.Add("display", "Some post-baccalaureate education"); deathRecord.EducationLevel = edu; break; case "Associate Degree": edu = new Dictionary <string, string>(); edu.Add("code", "ASSOC"); edu.Add("system", "http://terminology.hl7.org/CodeSystem/v3-EducationLevel"); edu.Add("display", "Associate's or technical degree complete"); deathRecord.EducationLevel = edu; break; case "Bachelor's Degree": edu = new Dictionary <string, string>(); edu.Add("code", "BD"); edu.Add("system", "http://terminology.hl7.org/CodeSystem/v3-EducationLevel"); edu.Add("display", "College or baccalaureate degree complete"); deathRecord.EducationLevel = edu; break; case "Master's Degree": edu = new Dictionary <string, string>(); edu.Add("code", "GD"); edu.Add("system", "http://terminology.hl7.org/CodeSystem/v3-EducationLevel"); edu.Add("display", "Graduate or professional Degree complete"); deathRecord.EducationLevel = edu; break; case "Doctorate Degree or Professional Degree": edu = new Dictionary <string, string>(); edu.Add("code", "POSTG"); edu.Add("system", "http://terminology.hl7.org/CodeSystem/v3-EducationLevel"); edu.Add("display", "Doctoral or post graduate education"); deathRecord.EducationLevel = edu; break; } SetStringValueDeathRecordString(deathRecord, "MotherMaidenName", GetValue(values, "motherName.lastName")); switch (GetValue(values, "mannerOfDeath.mannerOfDeath")) { case "Natural": Dictionary <string, string> mod = new Dictionary <string, string>(); mod.Add("code", "38605008"); mod.Add("display", "Natural"); deathRecord.MannerOfDeathType = mod; break; case "Accident": mod = new Dictionary <string, string>(); mod.Add("code", "7878000"); mod.Add("display", "Accident"); deathRecord.MannerOfDeathType = mod; break; case "Suicide": mod = new Dictionary <string, string>(); mod.Add("code", "44301001"); mod.Add("display", "Suicide"); deathRecord.MannerOfDeathType = mod; break; case "Homicide": mod = new Dictionary <string, string>(); mod.Add("code", "27935005"); mod.Add("display", "Homicide"); deathRecord.MannerOfDeathType = mod; break; case "Pending Investigation": mod = new Dictionary <string, string>(); mod.Add("code", "185973002"); mod.Add("display", "Pending Investigation"); deathRecord.MannerOfDeathType = mod; break; case "Could not be determined": mod = new Dictionary <string, string>(); mod.Add("code", "65037004"); mod.Add("display", "Could not be determined"); deathRecord.MannerOfDeathType = mod; break; } switch (GetValue(values, "maritalStatus.maritalStatus")) { case "Married": Dictionary <string, string> mar = new Dictionary <string, string>(); mar.Add("code", "M"); mar.Add("system", "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus"); mar.Add("display", "Married"); deathRecord.MaritalStatus = mar; break; case "Legally Separated": mar = new Dictionary <string, string>(); mar.Add("code", "L"); mar.Add("system", "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus"); mar.Add("display", "Legally Separated"); deathRecord.MaritalStatus = mar; break; case "Widowed": mar = new Dictionary <string, string>(); mar.Add("code", "W"); mar.Add("system", "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus"); mar.Add("display", "Widowed"); deathRecord.MaritalStatus = mar; break; case "Divorced": mar = new Dictionary <string, string>(); mar.Add("code", "D"); mar.Add("system", "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus"); mar.Add("display", "Divorced"); deathRecord.MaritalStatus = mar; break; case "Never Married": mar = new Dictionary <string, string>(); mar.Add("code", "S"); mar.Add("system", "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus"); mar.Add("display", "Never Married"); deathRecord.MaritalStatus = mar; break; case "unknown": mar = new Dictionary <string, string>(); mar.Add("code", "UNK"); mar.Add("system", "http://terminology.hl7.org/CodeSystem/v3-NullFlavor"); mar.Add("display", "unknown"); deathRecord.MaritalStatus = mar; break; } if (GetValue(values, "sex.sex") == "Male") { deathRecord.BirthSex = "M"; } else if (GetValue(values, "sex.sex") == "Female") { deathRecord.BirthSex = "F"; } if (GetValue(values, "ssn.ssn1") != null && GetValue(values, "ssn.ssn2") != null && GetValue(values, "ssn.ssn3") != null) { SetStringValueDeathRecordString(deathRecord, "SSN", GetValue(values, "ssn.ssn1") + GetValue(values, "ssn.ssn2") + GetValue(values, "ssn.ssn3")); } if (!String.IsNullOrWhiteSpace(GetValue(values, "race.race.specify"))) { MortalityData mdata = MortalityData.Instance; List <Tuple <string, string> > rtuples = new List <Tuple <string, string> >(); string[] races = JsonConvert.DeserializeObject <string[]>(GetValue(values, "race.race.specify")); foreach (string r in races) { string c = mdata.RaceNameToRaceCode(r); if (!String.IsNullOrWhiteSpace(c)) { rtuples.Add(Tuple.Create(r, c)); } } deathRecord.Race = rtuples.ToArray(); } return(deathRecord); }