use of org.hl7.fhir.dstu2.model.Period 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.dstu2.model.Period 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.dstu2.model.Period 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.dstu2.model.Period in project summary-care-record-api by NHSDigital.
the class ObservationMapper method mapFinding.
private static Finding mapFinding(Observation observation, Bundle bundle) {
var finding = new Finding();
finding.setIdRoot(observation.getIdentifierFirstRep().getValue());
finding.setCodeCode(observation.getCode().getCodingFirstRep().getCode());
finding.setCodeDisplayName(observation.getCode().getCodingFirstRep().getDisplay());
finding.setStatusCodeCode(mapStatus(observation.getStatus()));
if (observation.getEffective() instanceof DateTimeType) {
finding.setEffectiveTimeCenter(formatDateToHl7(observation.getEffectiveDateTimeType()));
} else if (observation.getEffective() instanceof Period) {
var period = observation.getEffectivePeriod();
if (period.hasStart()) {
finding.setEffectiveTimeLow(formatDateToHl7(period.getStartElement()));
}
if (period.hasEnd()) {
finding.setEffectiveTimeHigh(formatDateToHl7(period.getEndElement()));
}
} else {
throw new FhirValidationException("Observation.effective must be of type DateTimeType or Period");
}
var encounterReference = observation.getEncounter().getReference();
if (StringUtils.isNotBlank(encounterReference)) {
var encounter = getResourceByReference(bundle, encounterReference, Encounter.class).orElseThrow(() -> new FhirValidationException(String.format("Bundle is Missing Encounter %s that is linked to Condition %s", observation.getEncounter().getReference(), observation.getId())));
for (var encounterParticipant : encounter.getParticipant()) {
Coding coding = encounterParticipant.getTypeFirstRep().getCodingFirstRep();
if (!PARTICIPATION_TYPE_SYSTEM.equals(coding.getSystem())) {
throw new FhirValidationException("Unsupported encounter participant system: " + coding.getSystem());
}
var code = coding.getCode();
if ("AUT".equals(code)) {
var author = mapAuthor1(bundle, encounterParticipant);
finding.setAuthor(author);
} else if ("INF".equals(code)) {
var informant = mapInformant(bundle, encounterParticipant);
finding.setInformant(informant);
} else if ("PRF".equals(code)) {
var performer = mapPerformer(bundle, encounterParticipant);
finding.setPerformer(performer);
} else {
throw new FhirValidationException(String.format("Invalid encounter %s participant code %s", encounter.getId(), code));
}
}
}
return finding;
}
use of org.hl7.fhir.dstu2.model.Period in project openmrs-module-fhir2 by openmrs.
the class GroupComponentTranslatorImplTest method shouldTranslatePeriodToOpenmrsType.
@Test
public void shouldTranslatePeriodToOpenmrsType() {
Period period = mock(Period.class);
component.setPeriod(period);
when(period.getStart()).thenReturn(new Date());
when(period.getEnd()).thenReturn(new Date());
assertThat(translator.toOpenmrsType(component).getPeriod().getStart(), sameDay(new Date()));
assertThat(translator.toOpenmrsType(component).getPeriod().getEnd(), sameDay(new Date()));
}
Aggregations