use of org.hl7.fhir.dstu3.model.ResourceType in project gpconnect-demonstrator by nhsconnect.
the class PractitionerResourceProvider method practitionerDetailsToPractitionerResourceConverter.
private Practitioner practitionerDetailsToPractitionerResourceConverter(PractitionerDetails practitionerDetails) {
Identifier identifier = new Identifier().setSystem(SystemURL.ID_SDS_USER_ID).setValue(practitionerDetails.getUserId());
Practitioner practitioner = new Practitioner().addIdentifier(identifier);
practitionerDetails.getRoleIds().stream().distinct().map(roleId -> new Identifier().setSystem(SystemURL.ID_SDS_ROLE_PROFILE_ID).setValue(roleId)).forEach(practitioner::addIdentifier);
String resourceId = String.valueOf(practitionerDetails.getId());
String versionId = String.valueOf(practitionerDetails.getLastUpdated().getTime());
String resourceType = practitioner.getResourceType().toString();
IdType id = new IdType(resourceType, resourceId, versionId);
practitioner.setId(id);
practitioner.getMeta().setVersionId(versionId);
practitioner.getMeta().setLastUpdated(practitionerDetails.getLastUpdated());
practitioner.getMeta().addProfile(SystemURL.SD_GPC_PRACTITIONER);
HumanName name = new HumanName().setFamily(practitionerDetails.getNameFamily()).addGiven(practitionerDetails.getNameGiven()).addPrefix(practitionerDetails.getNamePrefix()).setUse(NameUse.USUAL);
practitioner.addName(name);
switch(practitionerDetails.getGender().toLowerCase(Locale.UK)) {
case "male":
practitioner.setGender(AdministrativeGender.MALE);
break;
case "female":
practitioner.setGender(AdministrativeGender.FEMALE);
break;
case "other":
practitioner.setGender(AdministrativeGender.OTHER);
break;
default:
practitioner.setGender(AdministrativeGender.UNKNOWN);
break;
}
Coding roleCoding = new Coding(SystemURL.VS_SDS_JOB_ROLE_NAME, practitionerDetails.getRoleCode(), practitionerDetails.getRoleDisplay());
for (int i = 0; i < practitionerDetails.getComCode().size(); i++) {
Coding comCoding = new Coding(SystemURL.VS_HUMAN_LANGUAGE, practitionerDetails.getComCode().get(i), null).setDisplay(practitionerDetails.getComDisplay().get(i));
practitioner.addCommunication().addCoding(comCoding);
}
return practitioner;
}
use of org.hl7.fhir.dstu3.model.ResourceType 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.dstu3.model.ResourceType 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.dstu3.model.ResourceType in project gpconnect-demonstrator by nhsconnect.
the class OrganizationResourceProvider method convertOrganizatonDetailsListToOrganizationList.
private List<Organization> convertOrganizatonDetailsListToOrganizationList(List<OrganizationDetails> organizationDetails) {
Map<Long, Organization> map = new HashMap<>();
for (OrganizationDetails organizationDetail : organizationDetails) {
// Changed key to be logical id rather than ods code since can have > 1 org per ods code
// for 1.2.2
Long mapKey = organizationDetail.getId();
if (map.containsKey(mapKey)) {
continue;
}
Identifier identifier = new Identifier().setSystem(SystemURL.ID_ODS_ORGANIZATION_CODE).setValue(organizationDetail.getOrgCode());
Organization organization = new Organization().setName(organizationDetail.getOrgName()).addIdentifier(identifier);
String resourceId = String.valueOf(organizationDetail.getId());
String versionId = String.valueOf(organizationDetail.getLastUpdated().getTime());
String resourceType = organization.getResourceType().toString();
IdType id = new IdType(resourceType, resourceId, versionId);
organization.setId(id);
organization.getMeta().setVersionId(versionId);
organization.getMeta().setLastUpdated(organizationDetail.getLastUpdated());
organization.getMeta().addProfile(SystemURL.SD_GPC_ORGANIZATION);
organization = addAdditionalProperties(organization);
map.put(mapKey, organization);
}
return new ArrayList<>(map.values());
}
use of org.hl7.fhir.dstu3.model.ResourceType in project dpc-app by CMSgov.
the class DataServiceTest method whenGetJobBatchesReturnsCompletedJobWithResourceType.
@Test
public void whenGetJobBatchesReturnsCompletedJobWithResourceType() {
DPCResourceType resourceType = DPCResourceType.ExplanationOfBenefit;
workJob(false, resourceType);
Resource resource = dataService.retrieveData(orgID, orgNPI, providerNPI, List.of(patientID.toString()), resourceType);
Assertions.assertTrue(resource instanceof Bundle);
}
Aggregations