use of org.hl7.fhir.r4.model.StringType 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.r4.model.StringType in project gpconnect-demonstrator by nhsconnect.
the class LocationResourceProvider method createAddress.
/**
* Some of the assignments look rather odd but they are deliberate.
* They result from a change to spec to remove the state attribute from the address
* See the commit cd26528 by James Cox 6/3/18 see also OrganizationResourceProvider.getValidAddress
* @param locationDetails
* @return Address Resource
*/
private Address createAddress(LocationDetails locationDetails) {
Address address = new Address();
List<StringType> list = new LinkedList<>();
list.add(new StringType(locationDetails.getAddressLine()));
list.add(new StringType(locationDetails.getAddressCity()));
address.setLine(list);
address.setCity(locationDetails.getAddressDistrict());
address.setDistrict(locationDetails.getAddressState());
address.setPostalCode(locationDetails.getAddressPostalCode());
address.setCountry(locationDetails.getAddressCountry());
return address;
}
use of org.hl7.fhir.r4.model.StringType in project gpconnect-demonstrator by nhsconnect.
the class PatientResourceProvider method createContact.
// patientDetailsToMinimalPatient
/**
* add a set of contact details into the patient record NB these are
* Contacts (related people etc) not contactpoints (telecoms)
*
* @param patient fhirResource object
*/
private void createContact(Patient patient) {
// relationships
Patient.ContactComponent contact = new ContactComponent();
for (String relationship : new String[] { "Emergency contact", "Next of kin", "Daughter" }) {
CodeableConcept crelationship = new CodeableConcept();
crelationship.setText(relationship);
contact.addRelationship(crelationship);
}
// contact address
Address address = new Address();
address.addLine("Trevelyan Square");
address.addLine("Boar Ln");
address.setPostalCode("LS1 6AE");
address.setType(AddressType.PHYSICAL);
address.setUse(AddressUse.HOME);
contact.setAddress(address);
// gender
contact.setGender(AdministrativeGender.FEMALE);
// telecom
ContactPoint telecom = new ContactPoint();
telecom.setSystem(ContactPointSystem.PHONE);
telecom.setUse(ContactPointUse.MOBILE);
telecom.setValue("07777123123");
contact.addTelecom(telecom);
// Name
HumanName name = new HumanName();
name.addGiven("Jane");
name.setFamily("Jackson");
List<StringType> prefixList = new ArrayList<>();
prefixList.add(new StringType("Miss"));
name.setPrefix(prefixList);
name.setText("JACKSON Jane (Miss)");
name.setUse(NameUse.OFFICIAL);
contact.setName(name);
patient.addContact(contact);
}
use of org.hl7.fhir.r4.model.StringType in project beneficiary-fhir-data by CMSgov.
the class AbstractTransformerV2 method createHumanNameFrom.
protected static List<HumanName> createHumanNameFrom(PatientInfo patientInfo) {
List<HumanName> names;
// If no names, don't set anything
if (patientInfo.getFirstName() != null || patientInfo.getLastName() != null || patientInfo.getMiddleName() != null) {
names = new ArrayList<>();
List<StringType> givens;
// If no givens, don't set any
if (patientInfo.getFirstName() != null || patientInfo.getLastName() != null) {
givens = new ArrayList<>();
if (patientInfo.getFirstName() != null) {
givens.add(new StringType(patientInfo.getFirstName()));
}
if (patientInfo.getMiddleName() != null) {
givens.add(new StringType(patientInfo.getMiddleName()));
}
} else {
givens = null;
}
names.add(new HumanName().setFamily(patientInfo.getLastName()).setGiven(givens));
} else {
names = null;
}
return names;
}
use of org.hl7.fhir.r4.model.StringType in project beneficiary-fhir-data by CMSgov.
the class BeneficiaryTransformerV2Test method shouldMatchAddressWithAddrHeader.
/**
* Verifies that {@link gov.cms.bfd.server.war.r4.providers.BeneficiaryTransformerV2} works
* correctly when passed a {@link Beneficiary} with includeAddressFields header values.
*/
@Test
public void shouldMatchAddressWithAddrHeader() {
RequestHeaders reqHdr = getRHwithIncldAddrFldHdr("true");
createPatient(reqHdr);
assertNotNull(patient);
List<Address> addrList = patient.getAddress();
assertEquals(1, addrList.size());
assertEquals(6, addrList.get(0).getLine().size());
Address compare = new Address();
compare.setPostalCode("12345");
compare.setState("MO");
compare.setCity("PODUNK");
ArrayList<StringType> lineList = new ArrayList<>(Arrays.asList(new StringType("204 SOUTH ST"), new StringType("7560 123TH ST"), new StringType("SURREY"), new StringType("DAEJEON SI 34867"), new StringType("COLOMBIA"), new StringType("SURREY")));
compare.setLine(lineList);
assertTrue(compare.equalsDeep(addrList.get(0)));
}
Aggregations