use of org.hl7.fhir.r5.model.Annotation in project bunsen by cerner.
the class FhirEncodersTest method annotation.
@Test
public void annotation() throws FHIRException {
Annotation original = medRequest.getNoteFirstRep();
Annotation decoded = decodedMedRequest.getNoteFirstRep();
Assert.assertEquals(original.getText(), medDataset.select(functions.expr("note[0].text")).head().get(0));
Assert.assertEquals(original.getText(), decoded.getText());
Assert.assertEquals(original.getAuthorReference().getReference(), decoded.getAuthorReference().getReference());
}
use of org.hl7.fhir.r5.model.Annotation in project bunsen by cerner.
the class TestData method newMedRequest.
/**
* Returns a FHIR medication request for testing purposes.
*/
public static MedicationRequest newMedRequest() {
MedicationRequest medReq = new MedicationRequest();
medReq.setId("test-med");
// Medication code
CodeableConcept med = new CodeableConcept();
med.addCoding().setSystem("http://www.nlm.nih.gov/research/umls/rxnorm").setCode("582620").setDisplay("Nizatidine 15 MG/ML Oral Solution [Axid]");
med.setText("Nizatidine 15 MG/ML Oral Solution [Axid]");
medReq.setMedication(med);
Annotation annotation = new Annotation();
annotation.setText("Test medication note.");
annotation.setAuthor(new Reference("Provider/example").setDisplay("Example provider."));
medReq.addNote(annotation);
return medReq;
}
use of org.hl7.fhir.r5.model.Annotation in project bunsen by cerner.
the class TestData method newMedRequest.
/**
* Returns a FHIR medication request for testing purposes.
*/
public static MedicationRequest newMedRequest() {
MedicationRequest medReq = new MedicationRequest();
medReq.setId("test-med");
// Medication code
CodeableConcept med = new CodeableConcept();
med.addCoding().setSystem("http://www.nlm.nih.gov/research/umls/rxnorm").setCode("582620").setDisplay("Nizatidine 15 MG/ML Oral Solution [Axid]");
med.setText("Nizatidine 15 MG/ML Oral Solution [Axid]");
medReq.setMedication(med);
Annotation annotation = new Annotation();
annotation.setText("Test medication note.");
annotation.setAuthor(new Reference("Provider/example").setDisplay("Example provider."));
medReq.addNote(annotation);
return medReq;
}
use of org.hl7.fhir.r5.model.Annotation in project dpc-app by CMSgov.
the class ParamResourceFactoryTest method testNamedResource.
@Test
void testNamedResource() throws IOException {
final Parameters parameters = new Parameters();
final Patient unnamedPatient = new Patient();
final Patient namedPatient = new Patient();
namedPatient.addName().setFamily("Patient").addGiven("Test");
parameters.addParameter().setResource(unnamedPatient);
parameters.addParameter().setResource(namedPatient).setName("named");
final HttpServletRequest mock = Mockito.mock(HttpServletRequest.class);
final ServletInputStream mockStream = Mockito.mock(ServletInputStream.class);
final IParser parser = Mockito.mock(IParser.class);
Mockito.when(parser.parseResource(Mockito.eq(Parameters.class), Mockito.any(InputStream.class))).thenReturn(parameters);
final Injector mockInjector = Mockito.mock(Injector.class);
Mockito.when(mockInjector.getInstance(HttpServletRequest.class)).thenReturn(mock);
Mockito.when(mock.getInputStream()).thenReturn(mockStream);
final Parameter parameter = Mockito.mock(Parameter.class);
final FHIRParameter annotation = Mockito.mock(FHIRParameter.class);
Mockito.when(annotation.name()).thenReturn("named");
Mockito.when(parameter.getAnnotation(FHIRParameter.class)).thenReturn(annotation);
Mockito.when(parameter.getRawType()).thenAnswer(answer -> Patient.class);
final ParamResourceFactory factory = new ParamResourceFactory(mockInjector, parameter, parser);
assertAll(() -> assertTrue(namedPatient.equalsDeep((Patient) factory.provide()), "Should have returned dummy patient"), () -> assertFalse(unnamedPatient.equalsDeep((Patient) factory.provide()), "Should have returned dummy patient"));
}
use of org.hl7.fhir.r5.model.Annotation in project dpc-app by CMSgov.
the class ParamResourceFactoryTest method testMissingResource.
@Test
void testMissingResource() throws IOException {
final Parameters parameters = new Parameters();
final Patient dummyPatient = new Patient();
parameters.addParameter().setResource(dummyPatient);
final HttpServletRequest mock = Mockito.mock(HttpServletRequest.class);
final ServletInputStream mockStream = Mockito.mock(ServletInputStream.class);
final IParser parser = Mockito.mock(IParser.class);
Mockito.when(parser.parseResource(Mockito.eq(Parameters.class), Mockito.any(InputStream.class))).thenReturn(parameters);
final Injector mockInjector = Mockito.mock(Injector.class);
Mockito.when(mockInjector.getInstance(HttpServletRequest.class)).thenReturn(mock);
Mockito.when(mock.getInputStream()).thenReturn(mockStream);
final Parameter parameter = Mockito.mock(Parameter.class);
final FHIRParameter annotation = Mockito.mock(FHIRParameter.class);
Mockito.when(annotation.name()).thenReturn("missing");
Mockito.when(parameter.getAnnotation(FHIRParameter.class)).thenReturn(annotation);
Mockito.when(parameter.getRawType()).thenAnswer(answer -> Patient.class);
final ParamResourceFactory factory = new ParamResourceFactory(mockInjector, parameter, parser);
final WebApplicationException exception = assertThrows(WebApplicationException.class, factory::provide, "Should throw an exception");
assertAll(() -> assertEquals(HttpStatus.BAD_REQUEST_400, exception.getResponse().getStatus(), "Should be a bad request"), () -> assertEquals("Cannot find matching parameter named `missing`", exception.getMessage(), "Should output which parameter is missing"));
}
Aggregations