use of org.hl7.fhir.utilities.xml.SchematronWriter.Section in project integration-adaptor-111 by nhsconnect.
the class CarePlanMapperTest method setup.
@BeforeEach
public void setup() {
POCDMT000002UK01Component2 component2 = mock(POCDMT000002UK01Component2.class);
POCDMT000002UK01Component3 component3 = mock(POCDMT000002UK01Component3.class);
POCDMT000002UK01StructuredBody structuredBody = mock(POCDMT000002UK01StructuredBody.class);
code = CE.Factory.newInstance();
code.setCodeSystem(SNOMED);
code.setCode(INFORMATION_ADVICE_GIVEN);
when(clinicalDocument.getComponent()).thenReturn(component2);
when(component2.isSetStructuredBody()).thenReturn(true);
when(component2.getStructuredBody()).thenReturn(structuredBody);
when(component3.getSection()).thenReturn(section);
when(component5.getSection()).thenReturn(section);
when(structuredBody.getComponentArray()).thenReturn(new POCDMT000002UK01Component3[] { component3 });
encounter.setPeriod(period);
title.setLanguage(LANG);
cs.setCode(LANG);
Patient subject = mock(Patient.class);
Reference subjectReference = new Reference(subject);
when(encounter.getSubject()).thenReturn(subjectReference);
when(encounter.getSubjectTarget()).thenReturn(subject);
when(encounter.getPeriod()).thenReturn(period);
locationComponentList = new ArrayList<>();
locationComponentList.add(locationComponent);
when(encounter.hasLocation()).thenReturn(true);
when(encounter.getLocation()).thenReturn(locationComponentList);
when(locationComponent.hasLocation()).thenReturn(true);
when(locationComponent.getLocation()).thenReturn(locationref);
when(locationref.getResource()).thenReturn(location);
when(location.hasManagingOrganization()).thenReturn(true);
when(location.getManagingOrganization()).thenReturn(organization);
when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
when(resourceUtil.createReference(encounter)).thenReturn(new Reference(encounter));
when(resourceUtil.createReference(condition)).thenReturn(new Reference(condition));
}
use of org.hl7.fhir.utilities.xml.SchematronWriter.Section in project integration-adaptor-111 by nhsconnect.
the class ConditionMapperTest method setUp.
@BeforeEach
public void setUp() {
POCDMT000002UK01Component3[] component3Array = new POCDMT000002UK01Component3[1];
component3Array[0] = component3;
POCDMT000002UK01Component5[] component5Array = new POCDMT000002UK01Component5[1];
component5Array[0] = component5;
questionnaireResponseList = new ArrayList<>();
questionnaireResponseList.add(questionnaireResponse);
when(encounter.getSubject()).thenReturn(patient);
when(clinicalDocument.getComponent()).thenReturn(component2);
when(component2.isSetStructuredBody()).thenReturn(true);
when(component2.getStructuredBody()).thenReturn(structuredBody);
when(structuredBody.getComponentArray()).thenReturn(component3Array);
when(component3.getSection()).thenReturn(section);
POCDMT000002UK01Entry[] entries = new POCDMT000002UK01Entry[] { entry };
when(section.getEntryArray()).thenReturn(entries);
when(entry.isSetEncounter()).thenReturn(true);
when(entry.getEncounter()).thenReturn(itkEncounter);
when(itkEncounter.isSetEffectiveTime()).thenReturn(true);
when(itkEncounter.getEffectiveTime()).thenReturn(time);
when(time.getValue()).thenReturn(EFFECTIVE_TIME_STRING);
when(itkEncounter.isSetText()).thenReturn(true);
when(itkEncounter.getText()).thenReturn(ed);
when(ed.getDomNode()).thenReturn(node);
when(nodeUtil.getAllText(node)).thenReturn(CONIDITION_TEXT);
when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
when(resourceUtil.createReference(encounter)).thenReturn(new Reference(encounter));
when(resourceUtil.createReference(questionnaireResponse)).thenReturn(new Reference(QUESTIONNAIRE_RESPONSE_ID));
when(section.getComponentArray()).thenReturn(component5Array);
when(component5.getSection()).thenReturn(section);
when(section.isSetLanguageCode()).thenReturn(true);
when(section.getLanguageCode()).thenReturn(cs);
when(cs.isSetCode()).thenReturn(true);
when(cs.getCode()).thenReturn(LANGUAGE_CODE);
when(questionnaireResponse.hasId()).thenReturn(true);
}
use of org.hl7.fhir.utilities.xml.SchematronWriter.Section in project integration-adaptor-111 by nhsconnect.
the class AppointmentMapperTest method shouldMapAppointment.
@Test
public void shouldMapAppointment() {
POCDMT000002UK01Entry entry = mockEntry();
POCDMT000002UK01Section section = mockSection();
Reference patient = mock(Reference.class);
when(locationMapper.mapRoleToLocation(any())).thenReturn(location);
when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
Optional<Appointment> appointment = appointmentMapper.mapAppointment(entry, section, patient);
assertThat(appointment.isPresent());
assertThat(appointment.get().getIdElement().getValue()).isEqualTo(RANDOM_UUID);
assertThat(appointment.get().getStatus()).isEqualTo(BOOKED);
assertThat(appointment.get().getStart()).isNull();
assertThat(appointment.get().getEnd()).isNull();
assertThat(appointment.get().getMinutesDuration()).isEqualTo(0);
assertThat(appointment.get().getDescription()).isEqualTo(TITLE);
assertThat(appointment.get().getComment()).isEqualTo(COMMENT);
assertThat(appointment.get().getParticipantFirstRep().getActor()).isEqualTo(patient);
assertThat(appointment.get().getParticipantFirstRep().getRequired()).isEqualTo(REQUIRED);
assertThat(appointment.get().getParticipantFirstRep().getStatus()).isEqualTo(ACCEPTED);
assertThat(appointment.get().getReasonFirstRep().getText()).isEqualTo(REASON);
}
use of org.hl7.fhir.utilities.xml.SchematronWriter.Section in project kindling by HL7.
the class BreadCrumbManager method parse.
public void parse(String filename) throws Exception {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
Document xdoc = builder.parse(new CSFileInputStream(new CSFile(filename)));
if (xdoc.getDocumentElement().getNodeName().equals("fhir")) {
home = parsePage(XMLUtil.getFirstChild(xdoc.getDocumentElement()));
} else
throw new Exception("File not recognised");
// now we assign section numbers to everything, and index the source files
home.setId("0");
numberChildren(home, null);
}
use of org.hl7.fhir.utilities.xml.SchematronWriter.Section in project kindling by HL7.
the class SchematronGenerator method generate.
public void generate(OutputStream out, ResourceDefn root, Definitions definitions) throws Exception {
SchematronWriter sch = new SchematronWriter(out, SchematronType.RESOURCE, root.getName());
insertGlobalRules(sch);
Section s = sch.section(root.getName());
ArrayList<String> parents = new ArrayList<String>();
generateInvariants(s, null, root.getRoot(), definitions, parents, root.getName());
sch.dump();
sch.close();
}
Aggregations