Search in sources :

Example 1 with TelecomDetails

use of uk.gov.hscic.model.telecom.TelecomDetails in project gpconnect-demonstrator by nhsconnect.

the class PatientDetailsToEntityTransformer method populateTelecoms.

/**
 * details to entity
 * there must be a better way ..
 * @param patientDetails
 * @param patientEntity
 */
private void populateTelecoms(PatientDetails patientDetails, PatientEntity patientEntity) {
    ArrayList<TelecomEntity> al = new ArrayList<>();
    if (patientDetails.getTelecoms() != null) {
        for (TelecomDetails telecomDetails : patientDetails.getTelecoms()) {
            TelecomEntity telecomEntity = new TelecomEntity();
            // this has to be populated even though its wrong and get ovewritten with the correct value later
            telecomEntity.setPatientId(1L);
            telecomEntity.setSystem(telecomDetails.getSystem());
            telecomEntity.setUseType(telecomDetails.getUseType());
            telecomEntity.setValue(telecomDetails.getValue());
            al.add(telecomEntity);
        }
    }
    patientEntity.setTelecoms(al);
}
Also used : TelecomDetails(uk.gov.hscic.model.telecom.TelecomDetails) TelecomEntity(uk.gov.hscic.telecom.TelecomEntity) ArrayList(java.util.ArrayList)

Example 2 with TelecomDetails

use of uk.gov.hscic.model.telecom.TelecomDetails in project gpconnect-demonstrator by nhsconnect.

the class PatientResourceProvider method updateAddressAndTelecom.

private void updateAddressAndTelecom(Patient unregisteredPatient, PatientDetails patientDetails) {
    ArrayList<TelecomDetails> al = new ArrayList<>();
    if (unregisteredPatient.getTelecom().size() > 0) {
        for (ContactPoint contactPoint : unregisteredPatient.getTelecom()) {
            TelecomDetails telecomDetails = new TelecomDetails();
            telecomDetails.setSystem(contactPoint.getSystem().toString());
            telecomDetails.setUseType(contactPoint.getUse().toString());
            telecomDetails.setValue(contactPoint.getValue());
            al.add(telecomDetails);
        }
    }
    patientDetails.setTelecoms(al);
    // actually a list of addresses not a single one
    if (unregisteredPatient.getAddress().size() > 0) {
        // get the first one off the block
        Address address = unregisteredPatient.getAddress().get(0);
        String[] addressLines = new String[ADDRESS_DISTRICT_INDEX + 1];
        List<StringType> addressLineList = address.getLine();
        for (int i = 0; i < ADDRESS_CITY_INDEX; i++) {
            if (i < addressLineList.size()) {
                addressLines[i] = addressLineList.get(i).asStringValue();
            } else {
                addressLines[i] = null;
            }
        }
        addressLines[ADDRESS_CITY_INDEX] = address.getCity();
        addressLines[ADDRESS_DISTRICT_INDEX] = address.getDistrict();
        patientDetails.setAddress(addressLines);
        patientDetails.setPostcode(address.getPostalCode());
    }
}
Also used : TelecomDetails(uk.gov.hscic.model.telecom.TelecomDetails)

Example 3 with TelecomDetails

use of uk.gov.hscic.model.telecom.TelecomDetails in project gpconnect-demonstrator by nhsconnect.

the class PatientResourceProvider method patientDetailsToPatientResourceConverter.

private Patient patientDetailsToPatientResourceConverter(PatientDetails patientDetails) throws FHIRException {
    Patient patient = patientDetailsToMinimalPatient(patientDetails);
    HumanName name = getPatientNameFromPatientDetails(patientDetails);
    patient.addName(name);
    // now returns structured address (not using text element) at 1.2.2
    ArrayList<StringType> addressLines = new ArrayList<>();
    for (int i = 0; i < min(ADDRESS_CITY_INDEX, patientDetails.getAddress().length); i++) {
        addressLines.add(new StringType(patientDetails.getAddress()[i]));
    }
    patient.addAddress().setUse(AddressUse.HOME).setType(AddressType.PHYSICAL).setLine(addressLines).setCity(patientDetails.getAddress().length > ADDRESS_CITY_INDEX ? patientDetails.getAddress()[ADDRESS_CITY_INDEX] : "").setDistrict(patientDetails.getAddress().length > ADDRESS_DISTRICT_INDEX ? patientDetails.getAddress()[ADDRESS_DISTRICT_INDEX] : "").setPostalCode(patientDetails.getPostcode());
    Long gpId = patientDetails.getGpId();
    if (gpId != null) {
        Practitioner prac = practitionerResourceProvider.getPractitionerById(new IdType(gpId));
        // HumanName practitionerName = prac.getNameFirstRep();
        Reference practitionerReference = new Reference("Practitioner/" + gpId);
        // #243 remove display from reference elements
        // .setDisplay(practitionerName.getPrefix().get(0) + " " + practitionerName.getGivenAsSingleString() + " "
        // + practitionerName.getFamily());
        List<Reference> ref = new ArrayList<>();
        ref.add(practitionerReference);
        patient.setGeneralPractitioner(ref);
    }
    String telephoneNumber = patientDetails.getTelephone();
    ArrayList<ContactPoint> al = new ArrayList<>();
    // defaults to home, this is from the slot in the patients table
    if (telephoneNumber != null) {
        ContactPoint telephone = new ContactPoint().setSystem(ContactPointSystem.PHONE).setValue(telephoneNumber).setUse(ContactPointUse.HOME);
        al.add(telephone);
    }
    // tack on any from the telecoms table 1.2.2 structured
    if (patientDetails.getTelecoms() != null) {
        for (TelecomDetails telecomDetails : patientDetails.getTelecoms()) {
            al.add(populateTelecom(telecomDetails));
        }
    }
    patient.setTelecom(al);
    String managingOrganization = patientDetails.getManagingOrganization();
    if (managingOrganization != null) {
        patient.setManagingOrganization(new Reference("Organization/" + managingOrganization));
    }
    // # 163 add patient language etc
    setStaticCommunicationData(patient);
    return patient;
}
Also used : TelecomDetails(uk.gov.hscic.model.telecom.TelecomDetails)

Example 4 with TelecomDetails

use of uk.gov.hscic.model.telecom.TelecomDetails in project gpconnect-demonstrator by nhsconnect.

the class PatientEntityToDetailsTransformer method populateTelecoms.

/**
 * entity to details
 * there must be a better way ..
 * @param patientDetails
 * @param patientEntity
 */
private void populateTelecoms(PatientDetails patientDetails, PatientEntity patientEntity) {
    ArrayList<TelecomDetails> al = new ArrayList<>();
    if (patientEntity.getTelecoms() != null) {
        for (TelecomEntity telecomEntity : patientEntity.getTelecoms()) {
            TelecomDetails telecomDetails = new TelecomDetails();
            telecomDetails.setSystem(telecomEntity.getSystem());
            telecomDetails.setUseType(telecomEntity.getUseType());
            telecomDetails.setValue(telecomEntity.getValue());
            al.add(telecomDetails);
        }
    }
    patientDetails.setTelecoms(al);
}
Also used : TelecomDetails(uk.gov.hscic.model.telecom.TelecomDetails) TelecomEntity(uk.gov.hscic.telecom.TelecomEntity) ArrayList(java.util.ArrayList)

Aggregations

TelecomDetails (uk.gov.hscic.model.telecom.TelecomDetails)4 ArrayList (java.util.ArrayList)2 TelecomEntity (uk.gov.hscic.telecom.TelecomEntity)2