use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.
the class UserSearchQueryTest method searchForUsers_shouldReturnUsersByCity.
@Test
public void searchForUsers_shouldReturnUsersByCity() {
StringAndListParam city = new StringAndListParam().addAnd(new StringParam(CITY));
SearchParameterMap theParams = new SearchParameterMap().addParameter(ADDRESS_SEARCH_HANDLER, CITY_PROPERTY, city);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), greaterThanOrEqualTo(1));
List<Practitioner> resultList = get(results);
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(resultList.get(0).getAddressFirstRep().getCity(), equalTo(CITY));
}
use of org.hl7.fhir.r4.model.Practitioner in project elexis-server by elexis.
the class PractitionerResourceProvider method search.
@Search
public List<Practitioner> search(@OptionalParam(name = Practitioner.SP_NAME) StringParam name, @OptionalParam(name = ca.uhn.fhir.rest.api.Constants.PARAM_FILTER) StringAndListParam theFtFilter) {
IQuery<IMandator> query = coreModelService.getQuery(IMandator.class);
if (name != null) {
QueryUtil.andContactNameCriterion(query, name);
}
if (theFtFilter != null) {
new IContactSearchFilterQueryAdapter().adapt(query, theFtFilter);
}
List<IMandator> practitioners = query.execute();
List<Practitioner> _practitioners = practitioners.parallelStream().map(org -> getTransformer().getFhirObject(org)).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
return _practitioners;
}
use of org.hl7.fhir.r4.model.Practitioner in project elexis-server by elexis.
the class EncounterTest method createEncounter.
@Test
public void createEncounter() {
Condition problem = new Condition();
problem.setCode(new CodeableConcept().addCoding(new Coding("http://hl7.org/fhir/sid/icpc-2", "A04", "Müdigkeit")));
problem.setSubject(new Reference("Patient/" + AllTests.getTestDatabaseInitializer().getPatient().getId()));
problem.addCategory().addCoding(new Coding(ConditionCategory.PROBLEMLISTITEM.getSystem(), ConditionCategory.PROBLEMLISTITEM.toCode(), ConditionCategory.PROBLEMLISTITEM.getDisplay()));
MethodOutcome problemOutcome = client.create().resource(problem).execute();
Encounter encounter = new Encounter();
EncounterParticipantComponent participant = new EncounterParticipantComponent();
participant.setIndividual(new Reference("Practitioner/" + TestDatabaseInitializer.getMandant().getId()));
encounter.addParticipant(participant);
encounter.setPeriod(new Period().setStart(AllTests.getDate(LocalDate.now().atStartOfDay())).setEnd(AllTests.getDate(LocalDate.now().atTime(23, 59, 59))));
encounter.setSubject(new Reference("Patient/" + AllTests.getTestDatabaseInitializer().getPatient().getId()));
encounter.addDiagnosis().setCondition(new Reference(new IdType(problem.getResourceType().name(), problemOutcome.getId().getIdPart())));
encounter.addType(new CodeableConcept().addCoding(new Coding("www.elexis.info/encounter/type", "struct", "structured enconter")));
MethodOutcome outcome = client.create().resource(encounter).execute();
assertNotNull(outcome);
assertTrue(outcome.getCreated());
assertNotNull(outcome.getId());
// add subjective to the encounter
Observation subjective = new Observation();
Narrative narrative = new Narrative();
String divEncodedText = "Subjective\nTest".replaceAll("(\r\n|\r|\n)", "<br />");
narrative.setDivAsString(divEncodedText);
subjective.setText(narrative);
subjective.setSubject(new Reference("Patient/" + AllTests.getTestDatabaseInitializer().getPatient().getId()));
subjective.addCategory().addCoding(new Coding(IdentifierSystem.ELEXIS_SOAP.getSystem(), ObservationCategory.SOAP_SUBJECTIVE.getCode(), ObservationCategory.SOAP_SUBJECTIVE.getLocalized()));
subjective.setEncounter(new Reference(new IdType(encounter.getResourceType().name(), encounter.getId())));
MethodOutcome subjectiveOutcome = client.create().resource(subjective).execute();
assertTrue(subjectiveOutcome.getCreated());
Encounter readEncounter = client.read().resource(Encounter.class).withId(outcome.getId()).execute();
assertNotNull(readEncounter);
assertEquals(outcome.getId().getIdPart(), readEncounter.getIdElement().getIdPart());
assertEquals(encounter.getPeriod().getStart(), readEncounter.getPeriod().getStart());
}
use of org.hl7.fhir.r4.model.Practitioner in project elexis-server by elexis.
the class PractitionerRoleTest method getPractitionerProperties.
/**
* Test all properties set by {@link TestDatabaseInitializer#initializeMandant()}.
*/
@Test
public void getPractitionerProperties() {
List<IUser> user = UserServiceHolder.get().getUsersByAssociatedContact(TestDatabaseInitializer.getMandant());
assertFalse(user.isEmpty());
PractitionerRole readPractitionerRole = client.read().resource(PractitionerRole.class).withId(user.get(0).getId()).execute();
assertNotNull(readPractitionerRole);
assertNotNull(readPractitionerRole.getPractitioner());
Practitioner readPractitioner = client.read().resource(Practitioner.class).withId(readPractitionerRole.getPractitioner().getReferenceElement().getIdPart()).execute();
assertNotNull(readPractitioner);
List<HumanName> names = readPractitioner.getName();
assertNotNull(names);
assertFalse(names.isEmpty());
assertEquals(2, names.size());
HumanName name = names.get(0);
assertNotNull(name);
assertEquals(NameUse.OFFICIAL, name.getUse());
assertEquals("Mandant", name.getFamily());
assertEquals("Test", name.getGivenAsSingleString());
HumanName sysName = names.get(1);
assertNotNull(sysName);
assertEquals(NameUse.ANONYMOUS, sysName.getUse());
assertEquals("tst", sysName.getText());
Date dob = readPractitioner.getBirthDate();
assertNotNull(dob);
assertEquals(LocalDate.of(1970, Month.JANUARY, 1), AllTests.getLocalDateTime(dob).toLocalDate());
assertEquals(AdministrativeGender.MALE, readPractitioner.getGender());
List<ContactPoint> telcoms = readPractitioner.getTelecom();
assertNotNull(telcoms);
assertEquals(2, telcoms.size());
assertEquals(1, telcoms.get(0).getRank());
assertEquals("+01555234", telcoms.get(0).getValue());
assertEquals(ContactPointUse.MOBILE, telcoms.get(1).getUse());
assertEquals("+01444234", telcoms.get(1).getValue());
List<Address> addresses = readPractitioner.getAddress();
assertNotNull(addresses);
assertEquals(1, addresses.size());
assertEquals("City", addresses.get(0).getCity());
assertEquals("123", addresses.get(0).getPostalCode());
assertEquals("Street 100", addresses.get(0).getLine().get(0).asStringValue());
List<Identifier> identifiers = readPractitioner.getIdentifier();
boolean eanFound = false;
boolean kskFound = false;
for (Identifier identifier : identifiers) {
if (identifier.getSystem().equals(XidConstants.DOMAIN_EAN)) {
assertEquals("2000000000002", identifier.getValue());
eanFound = true;
}
if (identifier.getSystem().equals("www.xid.ch/id/ksk")) {
assertEquals("C000002", identifier.getValue());
kskFound = true;
}
}
assertTrue(eanFound);
assertTrue(kskFound);
assertTrue(readPractitioner.getActive());
}
use of org.hl7.fhir.r4.model.Practitioner in project elexis-server by elexis.
the class AppointmentTest method testDirectLoadAppointmentInContactAssignedArea.
@Test
public void testDirectLoadAppointmentInContactAssignedArea() {
Appointment appointment = client.read().resource(Appointment.class).withId("Af322a333db4daf37093177").execute();
assertNotNull(appointment);
assertEquals(1484116200000l, appointment.getStart().getTime());
assertEquals(1484121600000l, appointment.getEnd().getTime());
assertEquals(90, appointment.getMinutesDuration());
List<AppointmentParticipantComponent> participants = appointment.getParticipant();
assertEquals(1, participants.size());
assertEquals(ParticipantRequired.REQUIRED, participants.get(0).getRequired());
Practitioner practitioner = client.read().resource(Practitioner.class).withId(participants.get(0).getActor().getReferenceElement()).execute();
assertNotNull(practitioner);
assertEquals("Nachname", practitioner.getName().get(0).getFamily());
List<Reference> slotReference = appointment.getSlot();
assertNotNull(slotReference);
Slot slot = client.read().resource(Slot.class).withId(slotReference.get(0).getReferenceElement()).execute();
assertNotNull(slot);
assertEquals(SlotStatus.BUSY, slot.getStatus());
Schedule schedule = client.read().resource(Schedule.class).withId(slot.getSchedule().getReferenceElement()).execute();
assertNotNull(schedule);
// practitioner = client.read().resource(Practitioner.class)
// .withId(schedule.getActor().get(0).getReferenceElement()).execute();
// assertEquals("Nachname", practitioner.getName().get(0).getFamily());
}
Aggregations