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;
}
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))));
}
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));
});
}
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)));
}
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());
}
Aggregations