Search in sources :

Example 1 with EncounterParticipantComponent

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

the class ParticipantAgentMapper method mapInformant.

public static Participant.Informant mapInformant(Bundle bundle, EncounterParticipantComponent encounterParticipant) {
    var informant = new Participant.Informant();
    informant.setTime(formatDateToHl7(encounterParticipant.getPeriod().getStartElement()));
    var participantType = encounterParticipant.getIndividual().getReference().split("/")[0];
    if (PractitionerRole.class.getSimpleName().equals(participantType)) {
        setParticipantAgents(bundle, encounterParticipant.getIndividual(), informant);
    } else if (RelatedPerson.class.getSimpleName().equals(participantType)) {
        var relatedPerson = getResourceByReference(bundle, encounterParticipant.getIndividual().getReference(), RelatedPerson.class).orElseThrow(() -> new FhirValidationException(String.format("Bundle is missing RelatedPerson %s that is linked to Encounter", encounterParticipant.getIndividual().getReference())));
        var participantNonAgentRole = new NonAgentRole("participantNonAgentRole");
        setRelationship(relatedPerson, participantNonAgentRole);
        setRelatedPersonName(relatedPerson, participantNonAgentRole);
        informant.setParticipantNonAgentRole(participantNonAgentRole);
    } else {
        throw new FhirValidationException(String.format("Invalid Encounter participant type %s", participantType));
    }
    return informant;
}
Also used : PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole) NonAgentRole(uk.nhs.adaptors.scr.models.xml.NonAgentRole) FhirValidationException(uk.nhs.adaptors.scr.exceptions.FhirValidationException)

Example 2 with EncounterParticipantComponent

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

the class DiagnosisMapper method mapAuthor.

private void mapAuthor(List<Resource> resources, Encounter encounter, Node author) {
    DateTimeType time = parseDate(xmlUtils.getValueByXPath(author, DIAGNOSIS_PARTICIPANT_TIME_XPATH), DateTimeType.class);
    participantMapper.map(author).stream().peek(it -> resources.add(it)).filter(it -> it instanceof PractitionerRole).forEach(it -> encounter.addParticipant(new EncounterParticipantComponent().setPeriod(new Period().setStartElement(time)).addType(getParticipationType("AUT", "author")).setIndividual(new Reference(it))));
}
Also used : SneakyThrows(lombok.SneakyThrows) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) RequiredArgsConstructor(lombok.RequiredArgsConstructor) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Autowired(org.springframework.beans.factory.annotation.Autowired) Condition(org.hl7.fhir.r4.model.Condition) Reference(org.hl7.fhir.r4.model.Reference) ArrayList(java.util.ArrayList) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) Encounter(org.hl7.fhir.r4.model.Encounter) Node(org.w3c.dom.Node) CodedEntryMapper(uk.nhs.adaptors.scr.mappings.from.hl7.common.CodedEntryMapper) 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) FhirHelper.randomUUID(uk.nhs.adaptors.scr.utils.FhirHelper.randomUUID) Optional(java.util.Optional) XmlUtils(uk.nhs.adaptors.scr.utils.XmlUtils) Annotation(org.hl7.fhir.r4.model.Annotation) 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) Reference(org.hl7.fhir.r4.model.Reference) Period(org.hl7.fhir.r4.model.Period) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole)

Example 3 with EncounterParticipantComponent

use of org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent 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 4 with EncounterParticipantComponent

use of org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent 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 5 with EncounterParticipantComponent

use of org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent 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());
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) EncounterParticipantComponent(org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent) Coding(org.hl7.fhir.r4.model.Coding) Narrative(org.hl7.fhir.r4.model.Narrative) Reference(org.hl7.fhir.r4.model.Reference) Observation(org.hl7.fhir.r4.model.Observation) Encounter(org.hl7.fhir.r4.model.Encounter) Period(org.hl7.fhir.r4.model.Period) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) IdType(org.hl7.fhir.r4.model.IdType) Test(org.junit.Test)

Aggregations

EncounterParticipantComponent (org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent)11 Encounter (org.hl7.fhir.r4.model.Encounter)10 ArrayList (java.util.ArrayList)9 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)8 Coding (org.hl7.fhir.r4.model.Coding)8 Reference (org.hl7.fhir.r4.model.Reference)8 List (java.util.List)7 Observation (org.hl7.fhir.r4.model.Observation)7 Period (org.hl7.fhir.r4.model.Period)7 PractitionerRole (org.hl7.fhir.r4.model.PractitionerRole)7 Resource (org.hl7.fhir.r4.model.Resource)7 Optional (java.util.Optional)6 Component (org.springframework.stereotype.Component)6 RequiredArgsConstructor (lombok.RequiredArgsConstructor)5 SneakyThrows (lombok.SneakyThrows)5 DateTimeType (org.hl7.fhir.r4.model.DateTimeType)5 FINISHED (org.hl7.fhir.r4.model.Encounter.EncounterStatus.FINISHED)5 RelatedPerson (org.hl7.fhir.r4.model.RelatedPerson)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 Node (org.w3c.dom.Node)5