Search in sources :

Example 6 with PractitionerRole

use of org.hl7.fhir.r4.model.PractitionerRole in project summary-care-record-api by NHSDigital.

the class FindingMapper method mapPerformer.

private void mapPerformer(List<Resource> resources, Encounter encounter, Node performer) {
    DateTimeType time = parseDate(xmlUtils.getValueByXPath(performer, FINDING_PARTICIPANT_TIME_XPATH), DateTimeType.class);
    participantMapper.map(performer).stream().peek(it -> resources.add(it)).filter(it -> it instanceof PractitionerRole).map(Reference::new).forEach(it -> {
        EncounterParticipantComponent participant = new EncounterParticipantComponent();
        String modeCode = xmlUtils.getValueByXPath(performer, FINDING_PERFORMER_MODE_CODE_XPATH);
        participant.addExtension(PERFORMER_EXTENSION_URL, new CodeableConcept(new Coding().setSystem(ENCOUNTER_PARTICIPATION_MODE_SYSTEM).setCode(modeCode).setDisplay(getParticipationModeDisplay(modeCode))));
        encounter.addParticipant(participant.setPeriod(new Period().setStartElement(time)).addType(getParticipationType("PRF", "performer")).setIndividual(it));
    });
}
Also used : SneakyThrows(lombok.SneakyThrows) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) RequiredArgsConstructor(lombok.RequiredArgsConstructor) Identifier(org.hl7.fhir.r4.model.Identifier) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Autowired(org.springframework.beans.factory.annotation.Autowired) Reference(org.hl7.fhir.r4.model.Reference) ArrayList(java.util.ArrayList) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) FINAL(org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL) Encounter(org.hl7.fhir.r4.model.Encounter) ENTEREDINERROR(org.hl7.fhir.r4.model.Observation.ObservationStatus.ENTEREDINERROR) Node(org.w3c.dom.Node) CodedEntryMapper(uk.nhs.adaptors.scr.mappings.from.hl7.common.CodedEntryMapper) Meta(org.hl7.fhir.r4.model.Meta) Observation(org.hl7.fhir.r4.model.Observation) NodeList(org.w3c.dom.NodeList) Period(org.hl7.fhir.r4.model.Period) Resource(org.hl7.fhir.r4.model.Resource) FINISHED(org.hl7.fhir.r4.model.Encounter.EncounterStatus.FINISHED) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole) EncounterParticipantComponent(org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent) Component(org.springframework.stereotype.Component) List(java.util.List) XmlToFhirMapper.parseDate(uk.nhs.adaptors.scr.mappings.from.hl7.XmlToFhirMapper.parseDate) Coding(org.hl7.fhir.r4.model.Coding) PerformerParticipationMode.getParticipationModeDisplay(uk.nhs.adaptors.scr.mappings.from.hl7.PerformerParticipationMode.getParticipationModeDisplay) FhirHelper.randomUUID(uk.nhs.adaptors.scr.utils.FhirHelper.randomUUID) Optional(java.util.Optional) XmlUtils(uk.nhs.adaptors.scr.utils.XmlUtils) CodedEntry(uk.nhs.adaptors.scr.mappings.from.hl7.common.CodedEntry) EncounterParticipantComponent(org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Coding(org.hl7.fhir.r4.model.Coding) Period(org.hl7.fhir.r4.model.Period) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 7 with PractitionerRole

use of org.hl7.fhir.r4.model.PractitionerRole in project summary-care-record-api by NHSDigital.

the class FindingMapper method mapAuthor.

private void mapAuthor(List<Resource> resources, Encounter encounter, Node author) {
    DateTimeType time = parseDate(xmlUtils.getValueByXPath(author, FINDING_PARTICIPANT_TIME_XPATH), DateTimeType.class);
    participantMapper.map(author).stream().peek(it -> resources.add(it)).filter(it -> it instanceof PractitionerRole).map(Reference::new).forEach(it -> encounter.addParticipant(new EncounterParticipantComponent().setPeriod(new Period().setStartElement(time)).addType(getParticipationType("AUT", "author")).setIndividual(it)));
}
Also used : SneakyThrows(lombok.SneakyThrows) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) RequiredArgsConstructor(lombok.RequiredArgsConstructor) Identifier(org.hl7.fhir.r4.model.Identifier) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Autowired(org.springframework.beans.factory.annotation.Autowired) Reference(org.hl7.fhir.r4.model.Reference) ArrayList(java.util.ArrayList) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) FINAL(org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL) Encounter(org.hl7.fhir.r4.model.Encounter) ENTEREDINERROR(org.hl7.fhir.r4.model.Observation.ObservationStatus.ENTEREDINERROR) Node(org.w3c.dom.Node) CodedEntryMapper(uk.nhs.adaptors.scr.mappings.from.hl7.common.CodedEntryMapper) Meta(org.hl7.fhir.r4.model.Meta) Observation(org.hl7.fhir.r4.model.Observation) NodeList(org.w3c.dom.NodeList) Period(org.hl7.fhir.r4.model.Period) Resource(org.hl7.fhir.r4.model.Resource) FINISHED(org.hl7.fhir.r4.model.Encounter.EncounterStatus.FINISHED) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole) EncounterParticipantComponent(org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent) Component(org.springframework.stereotype.Component) List(java.util.List) XmlToFhirMapper.parseDate(uk.nhs.adaptors.scr.mappings.from.hl7.XmlToFhirMapper.parseDate) Coding(org.hl7.fhir.r4.model.Coding) PerformerParticipationMode.getParticipationModeDisplay(uk.nhs.adaptors.scr.mappings.from.hl7.PerformerParticipationMode.getParticipationModeDisplay) FhirHelper.randomUUID(uk.nhs.adaptors.scr.utils.FhirHelper.randomUUID) Optional(java.util.Optional) XmlUtils(uk.nhs.adaptors.scr.utils.XmlUtils) CodedEntry(uk.nhs.adaptors.scr.mappings.from.hl7.common.CodedEntry) EncounterParticipantComponent(org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Period(org.hl7.fhir.r4.model.Period) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole)

Example 8 with PractitionerRole

use of org.hl7.fhir.r4.model.PractitionerRole 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());
}
Also used : Address(org.hl7.fhir.r4.model.Address) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole) Date(java.util.Date) LocalDate(java.time.LocalDate) Practitioner(org.hl7.fhir.r4.model.Practitioner) HumanName(org.hl7.fhir.r4.model.HumanName) ContactPoint(org.hl7.fhir.r4.model.ContactPoint) Identifier(org.hl7.fhir.r4.model.Identifier) IUser(ch.elexis.core.model.IUser) Test(org.junit.Test)

Example 9 with PractitionerRole

use of org.hl7.fhir.r4.model.PractitionerRole in project elexis-server by elexis.

the class PractitionerRoleTest method getPractitionerRole.

@Test
public void getPractitionerRole() {
    // search by role
    Bundle results = client.search().forResource(PractitionerRole.class).where(PractitionerRole.ROLE.exactly().systemAndCode(org.hl7.fhir.r4.model.codesystems.PractitionerRole.DOCTOR.getSystem(), org.hl7.fhir.r4.model.codesystems.PractitionerRole.DOCTOR.toCode())).returnBundle(Bundle.class).execute();
    assertNotNull(results);
    List<BundleEntryComponent> entries = results.getEntry();
    assertFalse(entries.isEmpty());
    PractitionerRole practitionerRole = (PractitionerRole) entries.get(0).getResource();
    List<CodeableConcept> roles = practitionerRole.getCode();
    boolean doctorRoleFound = false;
    for (CodeableConcept role : roles) {
        List<Coding> codings = role.getCoding();
        for (Coding coding : codings) {
            if (coding.getSystem().equals(org.hl7.fhir.r4.model.codesystems.PractitionerRole.DOCTOR.getSystem()) && coding.getCode().equals(org.hl7.fhir.r4.model.codesystems.PractitionerRole.DOCTOR.toCode())) {
                doctorRoleFound = true;
            }
        }
    }
    assertTrue(doctorRoleFound);
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Coding(org.hl7.fhir.r4.model.Coding) Bundle(org.hl7.fhir.r4.model.Bundle) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.Test)

Example 10 with PractitionerRole

use of org.hl7.fhir.r4.model.PractitionerRole in project openmrs-module-fhir2 by openmrs.

the class PractitionerRoleNarrativeTest method shouldGeneratePractitionerRoleNarrative.

/**
 * Check that the expected narrative is generated for some example PractitionerRole resource
 *
 * @throws IOException
 */
@Test
public void shouldGeneratePractitionerRoleNarrative() throws IOException {
    PractitionerRole given = parser.parseResource(PractitionerRole.class, getClass().getClassLoader().getResourceAsStream(EXAMPLE_RESOURCE_PATH));
    PractitionerRole result = parser.parseResource(PractitionerRole.class, parser.encodeResourceToString(given));
    assertThat(result, notNullValue());
    assertThat(result.getText(), notNullValue());
    assertThat(result.getText().getStatusAsString(), equalTo("generated"));
    assertThat(result.getText().getDivAsString(), equalTo(readNarrativeFile(EXPECTED_NARRATIVE_PATH)));
}
Also used : PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole) Test(org.junit.Test)

Aggregations

PractitionerRole (org.hl7.fhir.r4.model.PractitionerRole)26 Reference (org.hl7.fhir.r4.model.Reference)19 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)16 Coding (org.hl7.fhir.r4.model.Coding)15 Identifier (org.hl7.fhir.r4.model.Identifier)13 ArrayList (java.util.ArrayList)12 Practitioner (org.hl7.fhir.r4.model.Practitioner)12 Resource (org.hl7.fhir.r4.model.Resource)12 List (java.util.List)11 PractitionerRole (org.hl7.fhir.dstu3.model.PractitionerRole)11 RelatedPerson (org.hl7.fhir.r4.model.RelatedPerson)10 Optional (java.util.Optional)9 DateTimeType (org.hl7.fhir.r4.model.DateTimeType)7 EncounterParticipantComponent (org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent)7 Period (org.hl7.fhir.r4.model.Period)7 Test (org.junit.jupiter.api.Test)7 Identifiable (org.openehealth.ipf.commons.ihe.xds.core.metadata.Identifiable)7 Component (org.springframework.stereotype.Component)7 ContactPoint (org.hl7.fhir.r4.model.ContactPoint)6 RequiredArgsConstructor (lombok.RequiredArgsConstructor)5