use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceFhirResourceProviderIntegrationTest method shouldReturnNotFoundWhenDeletingNonExistentAllergyAsJson.
@Test
public void shouldReturnNotFoundWhenDeletingNonExistentAllergyAsJson() throws Exception {
MockHttpServletResponse response = delete("/AllergyIntolerance/" + UNKNOWN_ALLERGY_UUID).accept(FhirMediaTypes.JSON).go();
assertThat(response, isNotFound());
assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
assertThat(response.getContentAsString(), notNullValue());
OperationOutcome operationOutcome = readOperationOutcome(response);
assertThat(operationOutcome, notNullValue());
assertThat(operationOutcome.hasIssue(), is(true));
}
use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceFhirResourceProviderIntegrationTest method shouldUpdateExistingAllergyAsXML.
@Test
public void shouldUpdateExistingAllergyAsXML() throws Exception {
// get the existing record
MockHttpServletResponse response = get("/AllergyIntolerance/" + ALLERGY_UUID).accept(FhirMediaTypes.XML).go();
AllergyIntolerance allergy = readResponse(response);
// update the existing record
Enumeration<AllergyIntolerance.AllergyIntoleranceCategory> category = new Enumeration<>(new AllergyIntolerance.AllergyIntoleranceCategoryEnumFactory());
category.setValue(AllergyIntolerance.AllergyIntoleranceCategory.ENVIRONMENT);
allergy.getCategory().set(0, category);
// send the update to the server
response = put("/AllergyIntolerance/" + ALLERGY_UUID).xmlContent(toXML(allergy)).accept(FhirMediaTypes.XML).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
assertThat(response.getContentAsString(), notNullValue());
// read the updated record
AllergyIntolerance updatedAllergy = readResponse(response);
assertThat(updatedAllergy, notNullValue());
assertThat(updatedAllergy.getIdElement().getIdPart(), equalTo(ALLERGY_UUID));
assertThat(updatedAllergy.getCategory().get(0).getValue().toCode(), equalTo("environment"));
assertThat(updatedAllergy, validResource());
// double-check the record returned via get
response = get("/AllergyIntolerance/" + ALLERGY_UUID).accept(FhirMediaTypes.XML).go();
AllergyIntolerance reReadAllergy = readResponse(response);
assertThat(reReadAllergy.getCategory().get(0).getValue().toCode(), equalTo("environment"));
}
use of org.hl7.fhir.r4.model.AllergyIntolerance in project openmrs-module-fhir2 by openmrs.
the class AllergyIntoleranceFhirResourceProviderIntegrationTest method shouldSearchForExistingAllergyAsXML.
@Test
public void shouldSearchForExistingAllergyAsXML() throws Exception {
MockHttpServletResponse response = get("/AllergyIntolerance").accept(FhirMediaTypes.XML).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
assertThat(response.getContentAsString(), notNullValue());
Bundle results = readBundleResponse(response);
assertThat(results, notNullValue());
assertThat(results.getType(), equalTo(Bundle.BundleType.SEARCHSET));
assertThat(results.hasEntry(), is(true));
List<Bundle.BundleEntryComponent> entries = results.getEntry();
assertThat(entries, everyItem(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R3/AllergyIntolerance/"))));
assertThat(entries, everyItem(hasResource(instanceOf(AllergyIntolerance.class))));
assertThat(entries, everyItem(hasResource(validResource())));
response = get("/AllergyIntolerance?patient.identifier=M4001-1&_sort=severity").accept(FhirMediaTypes.XML).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
assertThat(response.getContentAsString(), notNullValue());
results = readBundleResponse(response);
assertThat(results, notNullValue());
assertThat(results.getType(), equalTo(Bundle.BundleType.SEARCHSET));
assertThat(results.hasEntry(), is(true));
entries = results.getEntry();
assertThat(entries, everyItem(hasResource(hasProperty("patient", hasProperty("referenceElement", hasProperty("idPart", equalTo("8d703ff2-c3e2-4070-9737-73e713d5a50d")))))));
assertThat(entries, containsInRelativeOrder(hasResource(hasProperty("criticality", hasProperty("display", equalTo("Low Risk")))), // mild
hasResource(hasProperty("criticality", hasProperty("display", equalTo("Unable to Assess Risk")))), // severe
hasResource(hasProperty("criticality", hasProperty("display", equalTo("High Risk")))), // null
hasResource(hasProperty("criticality", equalTo(null)))));
assertThat(entries, everyItem(hasResource(validResource())));
}
use of org.hl7.fhir.r4.model.AllergyIntolerance in project org.hl7.fhir.core by hapifhir.
the class CCDAConverter method processAllergyProblemAct.
protected void processAllergyProblemAct(ListResource list, Element concern) throws Exception {
cda.checkTemplateId(concern, "2.16.840.1.113883.10.20.22.4.30");
// Allergy Problem Act - this is a concern - we treat the concern as information about it's place in the list
checkNoNegationOrNullFlavor(concern, "Allergy Problem Act");
checkNoSubject(concern, "Allergy Problem Act");
// SHALL contain exactly one [1..1] Allergy - intolerance Observation
for (Element entry : cda.getChildren(concern, "entryRelationship")) {
Element obs = cda.getChild(entry, "observation");
cda.checkTemplateId(obs, "2.16.840.1.113883.10.20.22.4.7");
checkNoNegationOrNullFlavor(obs, "Allergy - intolerance Observation");
checkNoSubject(obs, "Allergy Problem Act");
AllergyIntolerance ai = new AllergyIntolerance();
ListEntryComponent item = addItemToList(list, ai);
// SHALL contain at least one [1..*] id (CONF:7472).
for (Element e : cda.getChildren(concern, "id")) ai.getIdentifier().add(convert.makeIdentifierFromII(e));
// SHALL contain exactly one [1..1] statusCode, which SHALL be selected from ValueSet 2.16.840.1.113883.3.88.12.80.68 HITSPProblemStatus DYNAMIC (CONF:7485)
// the status code is about the concern (e.g. the entry in the list)
// possible values: active, suspended, aborted, completed, with an effective time
String s = cda.getStatus(concern);
item.setFlag(Factory.newCodeableConcept(s, "http://hl7.org/fhir/v3/ActStatus", s));
if (// only on this condition?
s.equals("aborted"))
item.setDeleted(true);
// SHALL contain exactly one [1..1] effectiveTime (CONF:7498)
Period p = convert.makePeriodFromIVL(cda.getChild(concern, "effectiveTime"));
item.getExtension().add(Factory.newExtension("http://www.healthintersections.com.au/fhir/extensions/list-period", p, false));
if (p.getEnd() != null)
item.setDate(p.getEnd());
else
item.setDate(p.getStart());
// SHALL contain at least one [1..*] id (CONF:7382)
for (Element e : cda.getChildren(obs, "id")) ai.getIdentifier().add(convert.makeIdentifierFromII(e));
// SHALL contain exactly one [1..1] effectiveTime (CONF:7387)
ai.getExtension().add(Factory.newExtension("http://www.healthintersections.com.au/fhir/extensions/allergyintolerance-period", convert.makePeriodFromIVL(cda.getChild(obs, "effectiveTime")), false));
// SHALL contain exactly one [1..1] value with @xsi:type="CD" (CONF:7390)
CodeableConcept type = convert.makeCodeableConceptFromCD(cda.getChild(obs, "value"));
// This value SHALL contain @code, which SHALL be selected from ValueSet 2.16.840.1.113883.3.88.12.3221.6.2 Allergy/Adverse Event Type
String ss = type.getCoding().get(0).getCode();
if (ss.equals("416098002") || ss.equals("414285001"))
ai.setType(AllergyIntoleranceType.ALLERGY);
else if (ss.equals("59037007") || ss.equals("235719002"))
ai.setType(AllergyIntoleranceType.INTOLERANCE);
ai.getExtension().add(Factory.newExtension("http://www.healthintersections.com.au/fhir/extensions/allergy-category", type, false));
// SHOULD contain zero or one [0..1] participant (CONF:7402) such that it
// ......This playingEntity SHALL contain exactly one [1..1] code
ai.setCode(convert.makeCodeableConceptFromCD(cda.getDescendent(obs, "participant/participantRole/playingEntity/code")));
// SHOULD contain zero or more [0..*] entryRelationship (CONF:7447) such that it SHALL contain exactly one [1..1] Reaction Observation (templateId:2.16.840.1.113883.10.20.22.4.9) (CONF:7450).
for (Element e : cda.getChildren(obs, "entryRelationship")) {
Element child = cda.getChild(e, "observation");
if (cda.hasTemplateId(child, "2.16.840.1.113883.10.20.22.4.28") && ai.getClinicalStatus() == null) {
// SHALL contain exactly one [1..1] value with @xsi:type="CE", where the @code SHALL be selected from ValueSet Problem Status Value Set 2.16.840.1.113883.3.88.12.80.68 DYNAMIC (CONF:7322).
// 55561003 SNOMED CT Active
// 73425007 SNOMED CT Inactive
// 413322009 SNOMED CT Resolved
String sc = cda.getChild(child, "value").getAttribute("code");
if (sc.equals("55561003")) {
ai.setClinicalStatus(AllergyIntoleranceClinicalStatus.ACTIVE);
ai.setVerificationStatus(AllergyIntoleranceVerificationStatus.CONFIRMED);
} else
ai.setClinicalStatus(AllergyIntoleranceClinicalStatus.RESOLVED);
} else if (cda.hasTemplateId(child, "2.16.840.1.113883.10.20.22.4.9")) {
ai.getReaction().add(processAdverseReactionObservation(child));
}
}
// SHOULD contain zero or one [0..1] entryRelationship (CONF:9961) such that it SHALL contain exactly one [1..1] Severity Observation (templateId:2.16.840.1.113883.10.20.22.4.8) (CONF:9963).
ai.setCriticality(readCriticality(cda.getSeverity(obs)));
}
}
use of org.hl7.fhir.r4.model.AllergyIntolerance in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeAllergyIntoleranceAllergyIntoleranceReactionComponent.
protected void composeAllergyIntoleranceAllergyIntoleranceReactionComponent(Complex parent, String parentType, String name, AllergyIntolerance.AllergyIntoleranceReactionComponent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeBackboneElement(t, "reaction", name, element, index);
if (element.hasSubstance())
composeCodeableConcept(t, "AllergyIntolerance", "substance", element.getSubstance(), -1);
for (int i = 0; i < element.getManifestation().size(); i++) composeCodeableConcept(t, "AllergyIntolerance", "manifestation", element.getManifestation().get(i), i);
if (element.hasDescriptionElement())
composeString(t, "AllergyIntolerance", "description", element.getDescriptionElement(), -1);
if (element.hasOnsetElement())
composeDateTime(t, "AllergyIntolerance", "onset", element.getOnsetElement(), -1);
if (element.hasSeverityElement())
composeEnum(t, "AllergyIntolerance", "severity", element.getSeverityElement(), -1);
if (element.hasExposureRoute())
composeCodeableConcept(t, "AllergyIntolerance", "exposureRoute", element.getExposureRoute(), -1);
for (int i = 0; i < element.getNote().size(); i++) composeAnnotation(t, "AllergyIntolerance", "note", element.getNote().get(i), i);
}
Aggregations