use of org.hl7.fhir.r4.model.AllergyIntolerance in project gpconnect-demonstrator by nhsconnect.
the class StructuredAllergyIntoleranceBuilder method createNoKnownAllergy.
/**
* This relates to the positively asserted this patient has no know
* allergies as opposed to the the negatively asserted no allergies recorded
* patient 5 example 2 from the spec
*
* @param allergyIntoleranceEntity object from the db
* @return the allergy intolerance resource
*/
private AllergyIntolerance createNoKnownAllergy(StructuredAllergyIntoleranceEntity allergyIntoleranceEntity) {
AllergyIntolerance allergyIntolerance = new AllergyIntolerance();
allergyIntolerance.setId(allergyIntoleranceEntity.getGuid());
allergyIntolerance.setAssertedDate(allergyIntoleranceEntity.getAssertedDate());
// db has clinical status of "no known" which is not a valid value
allergyIntolerance.setClinicalStatus(AllergyIntoleranceClinicalStatus.ACTIVE);
allergyIntolerance.setVerificationStatus(AllergyIntoleranceVerificationStatus.valueOf(allergyIntoleranceEntity.getVerificationStatus().toUpperCase()));
allergyIntolerance.setType(AllergyIntoleranceType.ALLERGY);
CodeableConcept codeableConcept = new CodeableConcept();
Coding coding = new Coding();
coding.setDisplay(allergyIntoleranceEntity.getConceptDisplay());
// That's as in db under concept code 716186003
coding.setCode(allergyIntoleranceEntity.getConceptCode());
coding.setSystem(SystemConstants.SNOMED_URL);
Extension extension = new Extension(SystemURL.SD_EXT_SCT_DESC_ID);
// 3305010017
extension.addExtension("descriptionId", new StringType(allergyIntoleranceEntity.getDescCode()));
// NKA - No known allergy
extension.addExtension("descriptionDisplay", new StringType(allergyIntoleranceEntity.getDescDisplay()));
coding.addExtension(extension);
codeableConcept.addCoding(coding);
allergyIntolerance.setCode(codeableConcept);
return allergyIntolerance;
}
use of org.hl7.fhir.r4.model.AllergyIntolerance in project synthea by synthetichealth.
the class FhirR4 method allergy.
/**
* Map the Condition into a FHIR AllergyIntolerance resource, and add it to the given Bundle.
*
* @param rand Source of randomness to use when generating ids etc
* @param personEntry The Entry for the Person
* @param bundle The Bundle to add to
* @param encounterEntry The current Encounter entry
* @param allergy The Allergy Entry
* @return The added Entry
*/
private static BundleEntryComponent allergy(RandomNumberGenerator rand, BundleEntryComponent personEntry, Bundle bundle, BundleEntryComponent encounterEntry, HealthRecord.Allergy allergy) {
AllergyIntolerance allergyResource = new AllergyIntolerance();
allergyResource.setRecordedDate(new Date(allergy.start));
CodeableConcept status = new CodeableConcept();
status.getCodingFirstRep().setSystem("http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical");
allergyResource.setClinicalStatus(status);
if (allergy.stop == 0) {
status.getCodingFirstRep().setCode("active");
} else {
status.getCodingFirstRep().setCode("inactive");
}
if (allergy.allergyType == null || allergy.allergyType.equalsIgnoreCase("allergy")) {
allergyResource.setType(AllergyIntoleranceType.ALLERGY);
} else {
allergyResource.setType(AllergyIntoleranceType.INTOLERANCE);
}
AllergyIntoleranceCategory category = null;
if (allergy.category != null) {
switch(allergy.category) {
case "food":
category = AllergyIntoleranceCategory.FOOD;
break;
case "medication":
category = AllergyIntoleranceCategory.MEDICATION;
break;
case "environment":
category = AllergyIntoleranceCategory.ENVIRONMENT;
break;
case "biologic":
category = AllergyIntoleranceCategory.BIOLOGIC;
break;
default:
category = AllergyIntoleranceCategory.MEDICATION;
}
}
allergyResource.addCategory(category);
allergyResource.setCriticality(AllergyIntoleranceCriticality.LOW);
CodeableConcept verification = new CodeableConcept();
verification.getCodingFirstRep().setSystem("http://terminology.hl7.org/CodeSystem/allergyintolerance-verification").setCode("confirmed");
allergyResource.setVerificationStatus(verification);
allergyResource.setPatient(new Reference(personEntry.getFullUrl()));
Code code = allergy.codes.get(0);
allergyResource.setCode(mapCodeToCodeableConcept(code, SNOMED_URI));
if (allergy.reactions != null) {
allergy.reactions.keySet().stream().forEach(manifestation -> {
AllergyIntolerance.AllergyIntoleranceReactionComponent reactionComponent = new AllergyIntolerance.AllergyIntoleranceReactionComponent();
reactionComponent.addManifestation(mapCodeToCodeableConcept(manifestation, SNOMED_URI));
HealthRecord.ReactionSeverity severity = allergy.reactions.get(manifestation);
switch(severity) {
case MILD:
reactionComponent.setSeverity(AllergyIntolerance.AllergyIntoleranceSeverity.MILD);
break;
case MODERATE:
reactionComponent.setSeverity(AllergyIntolerance.AllergyIntoleranceSeverity.MODERATE);
break;
case SEVERE:
reactionComponent.setSeverity(AllergyIntolerance.AllergyIntoleranceSeverity.SEVERE);
break;
default:
}
allergyResource.addReaction(reactionComponent);
});
}
if (USE_US_CORE_IG) {
Meta meta = new Meta();
meta.addProfile("http://hl7.org/fhir/us/core/StructureDefinition/us-core-allergyintolerance");
allergyResource.setMeta(meta);
}
BundleEntryComponent allergyEntry = newEntry(rand, bundle, allergyResource);
allergy.fullUrl = allergyEntry.getFullUrl();
return allergyEntry;
}
use of org.hl7.fhir.r4.model.AllergyIntolerance in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7AllergyFHIRConversionTest method test_allergy_onset.
@Test
/**
* Verifies AL1-6 is put into AllergyIntolerance.onsetDateTime; AllergyIntolerance.reaction.onset is not set.
*/
void test_allergy_onset() {
String hl7message = "MSH|^~\\&|SE050|050|PACS|050|20120912011230||ADT^A01|102|T|2.6|||AL|NE\r" + "PID|0010||PID1234||DOE^JANE|||F\r" + "AL1|1|DA|00000741^OXYCODONE||HYPOTENSION|20210101\r";
AllergyIntolerance allergy = ResourceUtils.getAllergyResource(ftv, hl7message);
assertThat(allergy.getCategory().get(0).getCode()).isEqualTo("medication");
assertThat(allergy.getReaction().get(0).getManifestation()).extracting(m -> m.getText()).containsExactly("HYPOTENSION");
Date onsetReaction = allergy.getReaction().get(0).getOnset();
Assertions.assertNull(onsetReaction);
DateTimeType onsetAllergy = allergy.getOnsetDateTimeType();
assertThat(onsetAllergy.getValueAsString()).isEqualTo("2021-01-01");
}
use of org.hl7.fhir.r4.model.AllergyIntolerance in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7IdentifierFHIRConversionTest method allergyIdentifierTest.
@Test
void allergyIdentifierTest() {
// This identifier uses the logic from BUILD_IDENTIFIER_FROM_CWE (AL1.3) the three different messages test the three different outcomes
// AL1-3.1 and AL1-3.3, concatenate together with a dash
String Field1andField3 = "MSH|^~\\&|SE050|050|PACS|050|20120912011230||ADT^A01|102|T|2.6|||AL|NE\r" + "PID|||1234||DOE^JANE^|||F||||||||||||||||||||||\r" + "AL1|1|DA|00000741^OXYCODONE^LN||HYPOTENSION\r";
AllergyIntolerance allergy = ResourceUtils.getAllergyResource(ftv, Field1andField3);
// Expect a single identifier
assertThat(allergy.hasIdentifier()).isTrue();
assertThat(allergy.getIdentifier()).hasSize(1);
// Identifier 1: extRef from AL1.3
Identifier identifier = allergy.getIdentifier().get(0);
String value = identifier.getValue();
String system = identifier.getSystem();
assertThat(value).isEqualTo("00000741-LN");
assertThat(system).isEqualTo("urn:id:extID");
// AL1-3.1 and AL1-3.2, use AL1-3.1
String Field1andField2 = "MSH|^~\\&|SE050|050|PACS|050|20120912011230||ADT^A01|102|T|2.6|||AL|NE\r" + "PID|||1234||DOE^JANE^|||F||||||||||||||||||||||\r" + "AL1|1|DA|00000741^OXYCODONE||HYPOTENSION\r";
allergy = ResourceUtils.getAllergyResource(ftv, Field1andField2);
// Expect a single identifier
assertThat(allergy.hasIdentifier()).isTrue();
assertThat(allergy.getIdentifier()).hasSize(1);
// Identifier 1: extRef from AL1.3
identifier = allergy.getIdentifier().get(0);
value = identifier.getValue();
system = identifier.getSystem();
assertThat(value).isEqualTo("00000741");
assertThat(system).isEqualTo("urn:id:extID");
// AL1-3.2 only
String justField2 = "MSH|^~\\&|SE050|050|PACS|050|20120912011230||ADT^A01|102|T|2.6|||AL|NE\r" + "PID|||1234||DOE^JANE^|||F||||||||||||||||||||||\r" + "AL1|1|DA|^OXYCODONE||HYPOTENSION\r";
allergy = ResourceUtils.getAllergyResource(ftv, justField2);
// Expect a single identifier
assertThat(allergy.hasIdentifier()).isTrue();
assertThat(allergy.getIdentifier()).hasSize(1);
// Identifier 1: extRef from AL1.3
identifier = allergy.getIdentifier().get(0);
value = identifier.getValue();
system = identifier.getSystem();
assertThat(value).isEqualTo("OXYCODONE");
assertThat(system).isEqualTo("urn:id:extID");
}
use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceSearchQueryTest method searchForAllergies_shouldSearchForAllergiesBySeveritySevere.
@Test
public void searchForAllergies_shouldSearchForAllergiesBySeveritySevere() {
TokenAndListParam severity = new TokenAndListParam();
severity.addAnd(new TokenOrListParam().addOr(new TokenParam().setValue(SEVERITY_SEVERE)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.SEVERITY_SEARCH_HANDLER, severity);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(((AllergyIntolerance) resultList.iterator().next()).getReactionFirstRep().getSeverity(), equalTo(AllergyIntolerance.AllergyIntoleranceSeverity.SEVERE));
}
Aggregations