use of org.hl7.fhir.r5.model.Coding in project bunsen by cerner.
the class FhirEncodersTest method coding.
@Test
public void coding() {
Coding expectedCoding = condition.getSeverity().getCodingFirstRep();
Coding actualCoding = decodedCondition.getSeverity().getCodingFirstRep();
// Codings are a nested array, so we explode them into a table of the coding
// fields so we can easily select and compare individual fields.
Dataset<Row> severityCodings = conditionsDataset.select(functions.explode(conditionsDataset.col("severity.coding")).alias("coding")).select(// Pull all fields in the coding to the top level.
"coding.*").cache();
Assert.assertEquals(expectedCoding.getCode(), severityCodings.select("code").head().get(0));
Assert.assertEquals(expectedCoding.getCode(), actualCoding.getCode());
Assert.assertEquals(expectedCoding.getSystem(), severityCodings.select("system").head().get(0));
Assert.assertEquals(expectedCoding.getSystem(), actualCoding.getSystem());
Assert.assertEquals(expectedCoding.getUserSelected(), severityCodings.select("userSelected").head().get(0));
Assert.assertEquals(expectedCoding.getUserSelected(), actualCoding.getUserSelected());
Assert.assertEquals(expectedCoding.getDisplay(), severityCodings.select("display").head().get(0));
Assert.assertEquals(expectedCoding.getDisplay(), actualCoding.getDisplay());
}
use of org.hl7.fhir.r5.model.Coding in project gpconnect-demonstrator by nhsconnect.
the class AppointmentResourceProvider method appointmentDetailToAppointmentResourceConverter.
/**
* AppointmentDetail to fhir resource Appointment
*
* @param appointmentDetail
* @return Appointment Resource
*/
private Appointment appointmentDetailToAppointmentResourceConverter(AppointmentDetail appointmentDetail) {
Appointment appointment = new Appointment();
String appointmentId = String.valueOf(appointmentDetail.getId());
String versionId = String.valueOf(appointmentDetail.getLastUpdated().getTime());
String resourceType = appointment.getResourceType().toString();
IdType id = new IdType(resourceType, appointmentId, versionId);
appointment.setId(id);
appointment.getMeta().setVersionId(versionId);
appointment.getMeta().setLastUpdated(appointmentDetail.getLastUpdated());
appointment.getMeta().addProfile(SystemURL.SD_GPC_APPOINTMENT);
Extension extension = new Extension(SystemURL.SD_EXTENSION_GPC_APPOINTMENT_CANCELLATION_REASON, new StringType(appointmentDetail.getCancellationReason()));
appointment.addExtension(extension);
// #157 derive delivery channel from slot
List<Long> sids = appointmentDetail.getSlotIds();
ScheduleDetail scheduleDetail = null;
if (sids.size() > 0) {
// get the first slot but it should not matter because for multi slot appts the deliveryChannel is always the same
SlotDetail slotDetail = slotSearch.findSlotByID(sids.get(0));
String deliveryChannel = slotDetail.getDeliveryChannelCode();
if (deliveryChannel != null && !deliveryChannel.trim().isEmpty()) {
Extension deliveryChannelExtension = new Extension(SystemURL.SD_EXTENSION_GPC_DELIVERY_CHANNEL, new CodeType(deliveryChannel));
appointment.addExtension(deliveryChannelExtension);
}
scheduleDetail = scheduleSearch.findScheduleByID(slotDetail.getScheduleReference());
}
// practitioner role extension here
// lookup the practitioner
Long practitionerID = appointmentDetail.getPractitionerId();
if (practitionerID != null) {
// #195 we need to get this detail from the schedule not the practitioner table
if (scheduleDetail != null) {
Coding roleCoding = new Coding(SystemURL.VS_GPC_PRACTITIONER_ROLE, scheduleDetail.getPractitionerRoleCode(), scheduleDetail.getPractitionerRoleDisplay());
Extension practitionerRoleExtension = new Extension(SystemURL.SD_EXTENSION_GPC_PRACTITIONER_ROLE, new CodeableConcept().addCoding(roleCoding));
appointment.addExtension(practitionerRoleExtension);
}
}
switch(appointmentDetail.getStatus().toLowerCase(Locale.UK)) {
case "pending":
appointment.setStatus(AppointmentStatus.PENDING);
break;
case "booked":
appointment.setStatus(AppointmentStatus.BOOKED);
break;
case "arrived":
appointment.setStatus(AppointmentStatus.ARRIVED);
break;
case "fulfilled":
appointment.setStatus(AppointmentStatus.FULFILLED);
break;
case "cancelled":
appointment.setStatus(AppointmentStatus.CANCELLED);
break;
case "noshow":
appointment.setStatus(AppointmentStatus.NOSHOW);
break;
default:
appointment.setStatus(AppointmentStatus.PENDING);
break;
}
appointment.setStart(appointmentDetail.getStartDateTime());
appointment.setEnd(appointmentDetail.getEndDateTime());
// #218 Date time formats
appointment.getStartElement().setPrecision(TemporalPrecisionEnum.SECOND);
appointment.getEndElement().setPrecision(TemporalPrecisionEnum.SECOND);
List<Reference> slotResources = new ArrayList<>();
for (Long slotId : appointmentDetail.getSlotIds()) {
slotResources.add(new Reference("Slot/" + slotId));
}
appointment.setSlot(slotResources);
if (appointmentDetail.getPriority() != null) {
appointment.setPriority(appointmentDetail.getPriority());
}
appointment.setComment(appointmentDetail.getComment());
appointment.setDescription(appointmentDetail.getDescription());
appointment.addParticipant().setActor(new Reference("Patient/" + appointmentDetail.getPatientId())).setStatus(ParticipationStatus.ACCEPTED);
appointment.addParticipant().setActor(new Reference("Location/" + appointmentDetail.getLocationId())).setStatus(ParticipationStatus.ACCEPTED);
if (null != appointmentDetail.getPractitionerId()) {
appointment.addParticipant().setActor(new Reference("Practitioner/" + appointmentDetail.getPractitionerId())).setStatus(ParticipationStatus.ACCEPTED);
}
if (null != appointmentDetail.getCreated()) {
appointment.setCreated(appointmentDetail.getCreated());
}
if (null != appointmentDetail.getBookingOrganization()) {
// add extension with reference to contained item
String reference = "#1";
Reference orgRef = new Reference(reference);
Extension bookingOrgExt = new Extension(SystemURL.SD_CC_APPOINTMENT_BOOKINGORG, orgRef);
appointment.addExtension(bookingOrgExt);
BookingOrgDetail bookingOrgDetail = appointmentDetail.getBookingOrganization();
Organization bookingOrg = new Organization();
bookingOrg.setId(reference);
bookingOrg.getNameElement().setValue(bookingOrgDetail.getName());
// #198 org phone now persists usetype and system
ContactPoint orgTelecom = bookingOrg.getTelecomFirstRep();
orgTelecom.setValue(bookingOrgDetail.getTelephone());
try {
orgTelecom.setSystem(ContactPointSystem.fromCode(bookingOrgDetail.getSystem().toLowerCase()));
if (bookingOrgDetail.getUsetype() != null && !bookingOrgDetail.getUsetype().trim().isEmpty()) {
orgTelecom.setUse(ContactPointUse.fromCode(bookingOrgDetail.getUsetype().toLowerCase()));
}
} catch (FHIRException ex) {
// Logger.getLogger(AppointmentResourceProvider.class.getName()).log(Level.SEVERE, null, ex);
}
bookingOrg.getMeta().addProfile(SystemURL.SD_GPC_ORGANIZATION);
if (null != bookingOrgDetail.getOrgCode()) {
bookingOrg.getIdentifierFirstRep().setSystem(SystemURL.ID_ODS_ORGANIZATION_CODE).setValue(bookingOrgDetail.getOrgCode());
}
// add contained booking organization resource
appointment.getContained().add(bookingOrg);
}
// if bookingOrganization
appointment.setMinutesDuration(appointmentDetail.getMinutesDuration());
// 1.2.7 set service category from schedule type description
appointment.setServiceCategory(new CodeableConcept().setText(scheduleDetail.getTypeDescription()));
// 1.2.7 set service type from slot type description
appointment.addServiceType(new CodeableConcept().setText(slotSearch.findSlotByID(sids.get(0)).getTypeDisply()));
return appointment;
}
use of org.hl7.fhir.r5.model.Coding in project gpconnect-demonstrator by nhsconnect.
the class ScheduleResourceProvider method scheduleDetailToScheduleResourceConverter.
private Schedule scheduleDetailToScheduleResourceConverter(ScheduleDetail scheduleDetail) {
Schedule schedule = new Schedule();
String resourceId = String.valueOf(scheduleDetail.getId());
String versionId = String.valueOf(scheduleDetail.getLastUpdated().getTime());
String resourceType = schedule.getResourceType().toString();
IdType id = new IdType(resourceType, resourceId, versionId);
schedule.setId(id);
schedule.getMeta().setVersionId(versionId);
schedule.getMeta().setLastUpdated(scheduleDetail.getLastUpdated());
if (scheduleDetail.getPractitionerId() != null) {
schedule.addActor(new Reference("Practitioner/" + scheduleDetail.getPractitionerId()));
}
if (scheduleDetail.getPractitionerRoleCode() != null) {
Coding roleCoding = new Coding(SystemURL.VS_GPC_PRACTITIONER_ROLE, scheduleDetail.getPractitionerRoleCode(), scheduleDetail.getPractitionerRoleDisplay());
Extension practitionerRoleExtension = new Extension(SystemURL.SD_EXTENSION_GPC_PRACTITIONER_ROLE, new CodeableConcept().addCoding(roleCoding));
schedule.addExtension(practitionerRoleExtension);
}
// # 194
// Identifier identifier = new Identifier();
// identifier.setSystem(SystemURL.ID_GPC_SCHEDULE_IDENTIFIER);
// identifier.setValue(scheduleDetail.getIdentifier());
// schedule.addIdentifier(identifier);
Coding coding = new Coding().setSystem(SystemURL.HL7_VS_C80_PRACTICE_CODES).setCode(scheduleDetail.getTypeCode()).setDisplay(scheduleDetail.getTypeDescription());
CodeableConcept codableConcept = new CodeableConcept().addCoding(coding);
codableConcept.setText(scheduleDetail.getTypeDescription());
schedule.addActor(new Reference("Location/" + scheduleDetail.getLocationId()));
Period period = new Period();
period.setStart(scheduleDetail.getStartDateTime());
period.setEnd(scheduleDetail.getEndDateTime());
schedule.setPlanningHorizon(period);
// 1.2.7 remove comment
// schedule.setComment(scheduleDetail.getComment());
// 1.2.7 add schedule type description as service category
schedule.setServiceCategory(new CodeableConcept().setText(scheduleDetail.getTypeDescription()));
return schedule;
}
use of org.hl7.fhir.r5.model.Coding in project gpconnect-demonstrator by nhsconnect.
the class OrganizationResourceProvider method getValidContact.
private ContactDetail getValidContact() {
HumanName orgCtName = new HumanName();
orgCtName.setUse(NameUse.USUAL);
orgCtName.setFamily("FamilyName");
Coding coding = new Coding().setSystem(SystemURL.VS_CC_ORG_CT_ENTITYTYPE).setDisplay("ADMIN");
CodeableConcept orgCtPurpose = new CodeableConcept().addCoding(coding);
ContactDetail orgContact = new ContactDetail();
orgContact.setNameElement(orgCtName.getFamilyElement());
orgContact.addTelecom(getValidTelecom());
return orgContact;
}
use of org.hl7.fhir.r5.model.Coding in project gpconnect-demonstrator by nhsconnect.
the class ValueSetValidator method validateCode.
public Boolean validateCode(Coding code) {
String systemUrl = code.getSystem();
ValueSet valSet = loadValueSet(systemUrl);
// Check Code System
@SuppressWarnings("unused") ValueSetComposeComponent codeSys = valSet.getCompose();
@SuppressWarnings("unused") List<ValueSet.ConceptReferenceComponent> concepts;
return true;
}
Aggregations