use of org.hl7.fhir.dstu3.model.Encounter.EncounterParticipantComponent in project elexis-server by elexis.
the class ServiceRequestTest method createServiceRequest.
@Test
public void createServiceRequest() {
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.of(2016, Month.DECEMBER, 1).atStartOfDay())).setEnd(AllTests.getDate(LocalDate.of(2016, Month.DECEMBER, 1).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 encounterOutcome = client.create().resource(encounter).execute();
assertNotNull(encounterOutcome);
assertTrue(encounterOutcome.getCreated());
assertNotNull(encounterOutcome.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(), encounterOutcome.getId().getIdPart())));
MethodOutcome subjectiveOutcome = client.create().resource(subjective).execute();
assertTrue(subjectiveOutcome.getCreated());
// add procedure request to encounter
ServiceRequest serviceRequest = new ServiceRequest();
narrative = new Narrative();
divEncodedText = "Procedure\nTest".replaceAll("(\r\n|\r|\n)", "<br />");
narrative.setDivAsString(divEncodedText);
serviceRequest.setText(narrative);
serviceRequest.setSubject(new Reference("Patient/" + AllTests.getTestDatabaseInitializer().getPatient().getId()));
serviceRequest.setEncounter(new Reference(new IdType(encounter.getResourceType().name(), encounterOutcome.getId().getIdPart())));
MethodOutcome outcome = client.create().resource(serviceRequest).execute();
assertNotNull(outcome);
assertTrue(outcome.getCreated());
assertNotNull(outcome.getId());
ServiceRequest readServiceRequest = client.read().resource(ServiceRequest.class).withId(outcome.getId()).execute();
assertNotNull(readServiceRequest);
assertEquals(outcome.getId().getIdPart(), readServiceRequest.getIdElement().getIdPart());
assertEquals(serviceRequest.getSubject().getReferenceElement().getIdPart(), readServiceRequest.getSubject().getReferenceElement().getIdPart());
assertEquals(serviceRequest.getEncounter().getReferenceElement().getIdPart(), readServiceRequest.getEncounter().getReferenceElement().getIdPart());
assertTrue(readServiceRequest.getText().getDivAsString().contains("Test"));
// check if the consultation text has been updated
// search by patient and date
Bundle results = client.search().forResource(Encounter.class).where(Encounter.PATIENT.hasId(AllTests.getTestDatabaseInitializer().getPatient().getId())).and(Encounter.DATE.exactly().day(AllTests.getDate(LocalDate.of(2016, Month.DECEMBER, 1).atStartOfDay()))).returnBundle(Bundle.class).execute();
assertNotNull(results);
List<BundleEntryComponent> entries = results.getEntry();
assertFalse(entries.isEmpty());
Encounter readEncounter = (Encounter) entries.get(0).getResource();
assertNotNull(readEncounter);
assertEquals(readEncounter.getIdElement().getIdPart(), encounterOutcome.getId().getIdPart());
List<Identifier> identifier = readEncounter.getIdentifier();
String consultationId = null;
for (Identifier id : identifier) {
if (id.getSystem().equals(IdentifierSystem.ELEXIS_CONSID.getSystem())) {
consultationId = id.getValue();
}
}
assertNotNull(consultationId);
Optional<IEncounter> behandlung = AllTests.getModelService().load(consultationId, IEncounter.class);
assertTrue(behandlung.isPresent());
assertTrue(behandlung.get().getVersionedEntry().getHead().contains("Procedure"));
}
use of org.hl7.fhir.dstu3.model.Encounter.EncounterParticipantComponent in project integration-adaptor-111 by nhsconnect.
the class EncounterMapper method getEncounterParticipantComponents.
private List<EncounterParticipantComponent> getEncounterParticipantComponents(POCDMT000002UK01ClinicalDocument1 clinicalDocument, List<PractitionerRole> authorPractitionerRoles, Optional<PractitionerRole> responsibleParty, Encounter encounter) {
List<EncounterParticipantComponent> encounterParticipantComponents = stream(clinicalDocument.getParticipantArray()).filter(it -> !PARTCIPANT_TYPE_CODE_REFT.equals(it.getTypeCode())).map(participantMapper::mapEncounterParticipant).collect(Collectors.toList());
if (authorPractitionerRoles.size() > 0) {
authorPractitionerRoles.stream().map(it -> buildParticipantComponent(it, AUTHOR_PARTICIPANT_CODE, AUTHOR_PARTICIPANT_DISPLAY)).forEach(encounterParticipantComponents::add);
}
if (clinicalDocument.sizeOfInformantArray() > 0) {
stream(clinicalDocument.getInformantArray()).map(informantMapper::mapInformantIntoParticipantComponent).filter(Optional::isPresent).map(Optional::get).forEach(encounterParticipantComponents::add);
for (POCDMT000002UK01Informant12 informant : clinicalDocument.getInformantArray()) {
EncounterParticipantComponent encounterParticipantComponent = participantMapper.mapEncounterRelatedPerson(informant, encounter);
encounterParticipantComponents.add(encounterParticipantComponent);
}
}
if (clinicalDocument.isSetDataEnterer()) {
encounterParticipantComponents.add(dataEntererMapper.mapDataEntererIntoParticipantComponent(clinicalDocument.getDataEnterer()));
}
responsibleParty.ifPresent(it -> encounterParticipantComponents.add(buildParticipantComponent(it, RESPONSIBLE_PARTY_PARTICIPANT_CODE, RESPONSIBLE_PARTY_PARTICIPANT_DISPLAY)));
return encounterParticipantComponents;
}
use of org.hl7.fhir.dstu3.model.Encounter.EncounterParticipantComponent in project eCRNow by drajer-health.
the class CdaFhirUtilities method getPractitionersForType.
public static List<Practitioner> getPractitionersForType(R4FhirData data, V3ParticipationType type) {
List<Practitioner> practs = new ArrayList<>();
if (data != null && data.getEncounter() != null) {
List<EncounterParticipantComponent> participants = data.getEncounter().getParticipant();
if (participants != null && !participants.isEmpty()) {
for (EncounterParticipantComponent part : participants) {
if (part.getIndividual() != null && part.getIndividual().getReference() != null) {
logger.debug("Individual is present");
List<CodeableConcept> types = part.getType();
if (types != null && !types.isEmpty()) {
logger.debug("Codeable Concepts present for individuals");
for (CodeableConcept conc : types) {
logger.debug("Get Coding information for codeable concept");
List<Coding> typeCodes = conc.getCoding();
if (typeCodes != null && !typeCodes.isEmpty()) {
for (Coding cd : typeCodes) {
if (cd.getSystem() != null && (cd.getSystem().contentEquals(CdaGeneratorConstants.FHIR_PARTICIPANT_TYPE) || cd.getSystem().contentEquals(CdaGeneratorConstants.FHIR_PARTICIPANT_TYPE_V3))) {
logger.debug("Found Practitioner for Participation code system");
if (cd.getCode() != null && cd.getCode().contentEquals(type.toString())) {
logger.debug("Found Practitioner for Code and CodeSystem");
logger.debug("part.getIndividual = {}", part.getIndividual().getDisplay());
if (part.getIndividual().getReferenceElement() != null)
logger.debug("part.getIndividual = {}", part.getIndividual().getReferenceElement());
if (part.getIndividual().getReferenceElement() != null && part.getIndividual().getReferenceElement().getIdPart() != null) {
Practitioner pr = data.getPractitionerById(part.getIndividual().getReferenceElement().getIdPart());
if (pr != null) {
logger.info("Found Practitioner for Type {}", type);
practs.add(pr);
}
// Found Practitioenr
} else // Valid Reference
{
logger.debug("Individual Ref Id is null");
}
} else // Found Type that we need
{
logger.debug("Did not find the code for type {}", type);
}
} else // Found participants that use standard code systems
{
logger.debug("Did not find participants using standard code system ");
}
}
// For all Codings
}
// Codings present
}
// For all Codeable Concepts
}
// Codeable Concept present
}
// PArticipant is an individual
}
// For all EncounteR ParticipantComponents
}
// Participants not empty
}
return practs;
}
use of org.hl7.fhir.dstu3.model.Encounter.EncounterParticipantComponent in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7EncounterFHIRConversionTest method testEncounterParticipantMissing.
/**
* Test Encounter correctly creates and references Practitioners as Participants.
* Sparse data test. Only one participant is created.
*/
@Test
void testEncounterParticipantMissing() {
String hl7message = "MSH|^~\\&|WHI_LOAD_GENERATOR||||20210330144208||ADT^A01|MSGID_4e1c575f-6c6d-47b2-ab9f-829f20c96db2|T|2.3\n" + "EVN||20210330144208||||\n" + "PID|1||ABC12345^^^MRN||DOE^JANE|||||||||||||||\n" + // Key field is PV1.17; note that PV1.7, PV1.8, PV1.9 are purposely empty. See companion test testEncounterParticipantList
"PV1||I|||||||||||||||59367^Doctor^Admitting|||||||||||||||||||||||||||\n";
String json = ftv.convert(hl7message, OPTIONS);
assertThat(json).isNotBlank();
IBaseResource bundleResource = context.getParser().parseResource(json);
assertThat(bundleResource).isNotNull();
Bundle b = (Bundle) bundleResource;
List<BundleEntryComponent> e = b.getEntry();
List<Resource> patientResource = ResourceUtils.getResourceList(e, ResourceType.Patient);
assertThat(patientResource).hasSize(1);
List<Resource> encounterResource = ResourceUtils.getResourceList(e, ResourceType.Encounter);
assertThat(encounterResource).hasSize(1);
Encounter encounter = ResourceUtils.getResourceEncounter(encounterResource.get(0), context);
List<EncounterParticipantComponent> encParticipantList = encounter.getParticipant();
assertThat(encParticipantList).hasSize(1);
EncounterParticipantComponent participantComponent = encParticipantList.get(0);
List<Resource> practioners = ResourceUtils.getResourceList(e, ResourceType.Practitioner);
assertThat(practioners).hasSize(1);
Practitioner practitioner = ResourceUtils.getResourcePractitioner(practioners.get(0), context);
// With one practitioner and one participant, confirm the ID's match, the code and name are expected.
assertThat(participantComponent.getIndividual().getReference()).isEqualTo(practitioner.getId());
assertThat(participantComponent.getType().get(0).getCoding().get(0).getCode()).isEqualTo("ADM");
assertThat(participantComponent.getIndividual().getDisplay()).isEqualTo("Admitting Doctor");
}
use of org.hl7.fhir.dstu3.model.Encounter.EncounterParticipantComponent in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7EncounterFHIRConversionTest method testEncounterParticipantList.
@Test
void testEncounterParticipantList() {
String hl7message = "MSH|^~\\&|WHI_LOAD_GENERATOR||||20210330144208||ADT^A01|MSGID_4e1c575f-6c6d-47b2-ab9f-829f20c96db2|T|2.3\n" + "EVN||20210330144208||||\n" + "PID|1||ABC12345^^^MRN||DOE^JANE|||||||||||||||\n" + // These fields each have multiple XCNs to test they work with repeating values
"PV1||I|||||2905^DoctorA^Attending^M^IV^^MD~2905-2^DoctorA2^Attending2^M2|5755^DoctorB^Referring^^Sr~5755-2^DoctorB2^Referring2^^Sr2|770542^DoctorC^Consulting^^Jr~770542-2^DoctorC2^Consulting2^^Sr||||||||59367^DoctorD^Admitting~59367-2^DoctorD2^Admitting2|||||||||||||||||||||||||||\n";
String json = ftv.convert(hl7message, OPTIONS);
assertThat(json).isNotBlank();
IBaseResource bundleResource = context.getParser().parseResource(json);
assertThat(bundleResource).isNotNull();
Bundle b = (Bundle) bundleResource;
List<BundleEntryComponent> e = b.getEntry();
List<Resource> patientResource = ResourceUtils.getResourceList(e, ResourceType.Patient);
assertThat(patientResource).hasSize(1);
List<Resource> encounterResource = ResourceUtils.getResourceList(e, ResourceType.Encounter);
assertThat(encounterResource).hasSize(1);
Encounter encounter = ResourceUtils.getResourceEncounter(encounterResource.get(0), context);
List<EncounterParticipantComponent> encParticipantList = encounter.getParticipant();
assertThat(encParticipantList).hasSize(8);
List<Resource> practioners = ResourceUtils.getResourceList(e, ResourceType.Practitioner);
assertThat(practioners).hasSize(8);
HashMap<String, List<String>> practionerMap = new HashMap<String, List<String>>();
// Make sure that practitioners found are matching the HL7 by using known ID as check
List<String> practionerIds = Arrays.asList("2905", "2905-2", "5755", "5755-2", "770542", "770542-2", "59367", "59367-2");
for (Resource r : practioners) {
Practitioner p = ResourceUtils.getResourcePractitioner(r, context);
assertThat(p.getIdentifier()).hasSize(1);
String value = p.getIdentifier().get(0).getValue();
assertThat(practionerIds).contains(value);
// Make a map where key is the Participant ID <GUID>, first value is Participant name, second is Participant Code
List<String> values = new ArrayList<String>();
switch(value) {
case "2905":
values.add("Attending M DoctorA IV");
values.add("ATND");
break;
case "2905-2":
values.add("Attending2 M2 DoctorA2");
values.add("ATND");
break;
case "5755":
values.add("Referring DoctorB Sr");
values.add("REF");
break;
case "5755-2":
values.add("Referring2 DoctorB2 Sr2");
values.add("REF");
break;
case "770542":
values.add("Consulting DoctorC Jr");
values.add("CON");
break;
case "770542-2":
values.add("Consulting2 DoctorC2 Sr");
values.add("CON");
break;
case "59367":
values.add("Admitting DoctorD");
values.add("ADM");
break;
case "59367-2":
values.add("Admitting2 DoctorD2");
values.add("ADM");
break;
}
practionerMap.put(p.getId(), values);
}
// Make sure that each practitioner is correctly mapped within the Encounter
for (EncounterParticipantComponent participantComponent : encParticipantList) {
String id = participantComponent.getIndividual().getReference();
// Use the Id to look up the expected Participant name and Participant code
// In map, first value is Participant name , second is Participant code
assertEquals(practionerMap.get(id).get(0), participantComponent.getIndividual().getDisplay());
assertEquals(practionerMap.get(id).get(1), participantComponent.getType().get(0).getCoding().get(0).getCode());
}
}
Aggregations