use of org.hl7.fhir.dstu3.model.Coding in project gpconnect-demonstrator by nhsconnect.
the class MedicationDispenseResourceProvider method getMedicationDispensesForPatientId.
@Search
public List<MedicationDispense> getMedicationDispensesForPatientId(@RequiredParam(name = "patient") String patientId) {
ArrayList<MedicationDispense> medicationDispenses = new ArrayList<>();
List<MedicationDispenseDetail> medicationDispenseDetailList = medicationDispenseSearch.findMedicationDispenseForPatient(Long.parseLong(patientId));
if (medicationDispenseDetailList != null && !medicationDispenseDetailList.isEmpty()) {
for (MedicationDispenseDetail medicationDispenseDetail : medicationDispenseDetailList) {
MedicationDispense medicationDispense = new MedicationDispense();
medicationDispense.setId(String.valueOf(medicationDispenseDetail.getId()));
medicationDispense.getMeta().setLastUpdated(medicationDispenseDetail.getLastUpdated());
medicationDispense.getMeta().setVersionId(String.valueOf(medicationDispenseDetail.getLastUpdated().getTime()));
switch(medicationDispenseDetail.getStatus().toLowerCase(Locale.UK)) {
case "completed":
medicationDispense.setStatus(MedicationDispenseStatus.COMPLETED);
break;
case "entered_in_error":
medicationDispense.setStatus(MedicationDispenseStatus.ENTEREDINERROR);
break;
case "in_progress":
medicationDispense.setStatus(MedicationDispenseStatus.INPROGRESS);
break;
case "on_hold":
medicationDispense.setStatus(MedicationDispenseStatus.ONHOLD);
break;
case "stopped":
medicationDispense.setStatus(MedicationDispenseStatus.STOPPED);
break;
}
medicationDispense.setSubject(new Reference("Patient/" + patientId));
medicationDispense.setAuthorizingPrescription(Collections.singletonList(new Reference("MedicationOrder/" + medicationDispenseDetail.getMedicationOrderId())));
Medication medication = new Medication();
Coding coding = new Coding();
coding.setCode(String.valueOf(medicationDispenseDetail.getMedicationId()));
coding.setDisplay(medicationDispenseDetail.getMedicationName());
CodeableConcept codeableConcept = new CodeableConcept();
codeableConcept.setCoding(Collections.singletonList(coding));
medication.setCode(codeableConcept);
medicationDispense.addDosageInstruction().setText(medicationDispenseDetail.getDosageText());
medicationDispenses.add(medicationDispense);
}
}
return medicationDispenses;
}
use of org.hl7.fhir.dstu3.model.Coding in project gpconnect-demonstrator by nhsconnect.
the class OrganizationResourceProvider method addAdditionalProperties.
// Adding in additional properties manually for now so we can test in the
// Test Suite
private Organization addAdditionalProperties(Organization organization) {
Coding orgTypeCode = new Coding();
orgTypeCode.setCode("dept");
orgTypeCode.setDisplay("Hospital Department");
orgTypeCode.setSystem(SystemURL.VS_CC_ORGANISATION_TYPE);
organization.addTelecom(getValidTelecom());
organization.addAddress(getValidAddress());
// organization.addContact(getValidContact());
CodeableConcept orgType = new CodeableConcept();
orgType.addCoding(orgTypeCode);
organization.addType(orgType);
organization.addExtension().setUrl(SystemURL.SD_EXTENSION_CC_MAIN_LOCATION);
return organization;
}
use of org.hl7.fhir.dstu3.model.Coding in project gpconnect-demonstrator by nhsconnect.
the class PatientResourceProvider method patientDetailsToMinimalPatient.
private Patient patientDetailsToMinimalPatient(PatientDetails patientDetails) throws FHIRException {
Patient patient = new Patient();
Date lastUpdated = patientDetails.getLastUpdated() == null ? new Date() : patientDetails.getLastUpdated();
String resourceId = String.valueOf(patientDetails.getId());
String versionId = String.valueOf(lastUpdated.getTime());
String resourceType = patient.getResourceType().toString();
IdType id = new IdType(resourceType, resourceId, versionId);
patient.setId(id);
patient.getMeta().setVersionId(versionId);
patient.getMeta().setLastUpdated(lastUpdated);
patient.getMeta().addProfile(SystemURL.SD_GPC_PATIENT);
Identifier patientNhsNumber = new Identifier().setSystem(SystemURL.ID_NHS_NUMBER).setValue(patientDetails.getNhsNumber());
Extension extension = createCodingExtension("01", "Number present and verified", SystemURL.CS_CC_NHS_NUMBER_VERIF, SystemURL.SD_CC_EXT_NHS_NUMBER_VERIF);
patientNhsNumber.addExtension(extension);
patient.addIdentifier(patientNhsNumber);
patient.setBirthDate(patientDetails.getDateOfBirth());
String gender = patientDetails.getGender();
if (gender != null) {
patient.setGender(AdministrativeGender.fromCode(gender.toLowerCase(Locale.UK)));
}
Date registrationEndDateTime = patientDetails.getRegistrationEndDateTime();
Date registrationStartDateTime = patientDetails.getRegistrationStartDateTime();
Extension regDetailsExtension = new Extension(SystemURL.SD_EXTENSION_CC_REG_DETAILS);
Period registrationPeriod = new Period().setStart(registrationStartDateTime).setEnd(registrationEndDateTime);
Extension regPeriodExt = new Extension(SystemURL.SD_CC_EXT_REGISTRATION_PERIOD, registrationPeriod);
regDetailsExtension.addExtension(regPeriodExt);
String registrationStatusValue = patientDetails.getRegistrationStatus();
patient.setActive(ACTIVE_REGISTRATION_STATUS.equals(registrationStatusValue) || null == registrationStatusValue);
String registrationTypeValue = patientDetails.getRegistrationType();
if (registrationTypeValue != null) {
Coding regTypeCode = new Coding();
regTypeCode.setCode(registrationTypeValue);
// Should always be Temporary
regTypeCode.setDisplay("Temporary");
regTypeCode.setSystem(SystemURL.CS_REGISTRATION_TYPE);
CodeableConcept regTypeConcept = new CodeableConcept();
regTypeConcept.addCoding(regTypeCode);
Extension regTypeExt = new Extension(SystemURL.SD_CC_EXT_REGISTRATION_TYPE, regTypeConcept);
regDetailsExtension.addExtension(regTypeExt);
}
patient.addExtension(regDetailsExtension);
String maritalStatus = patientDetails.getMaritalStatus();
if (maritalStatus != null) {
CodeableConcept marital = new CodeableConcept();
Coding maritalCoding = new Coding();
maritalCoding.setSystem(SystemURL.VS_CC_MARITAL_STATUS);
maritalCoding.setCode(patientDetails.getMaritalStatus());
maritalCoding.setDisplay("Married");
marital.addCoding(maritalCoding);
patient.setMaritalStatus(marital);
}
patient.setMultipleBirth(patientDetails.isMultipleBirth());
if (patientDetails.isDeceased()) {
DateTimeType decesed = new DateTimeType(patientDetails.getDeceased());
patient.setDeceased(decesed);
}
return patient;
}
use of org.hl7.fhir.dstu3.model.Coding in project loinc2hpo by monarch-initiative.
the class ObservationDtu3 method getOutcome.
@Override
public Optional<Outcome> getOutcome() {
if (observation.hasInterpretation()) {
List<String> codes = this.observation.getInterpretation().getCoding().stream().map(Coding::getCode).distinct().collect(Collectors.toList());
if (codes.size() > 1) {
LOGGER.error("Multiple interpretation codes returned");
return Optional.empty();
}
ShortCode code = ShortCode.fromShortCode(codes.get(0));
Outcome outcome = getOutcome(code, observation);
return Optional.of(outcome);
} else if (observation.hasValueCodeableConcept()) {
return getOutcomeFromCodedValue();
} else if (observation.hasValueQuantity()) {
return getOutcomeFromValueQuantity();
} else {
LOGGER.error("Unable to handle observation {}", observation);
return Optional.empty();
}
}
use of org.hl7.fhir.dstu3.model.Coding in project loinc2hpo by monarch-initiative.
the class ObservationDtu3 method getOutcomeFromCodedValue.
Optional<Outcome> getOutcomeFromCodedValue() {
CodeableConcept codeableConcept = this.observation.getValueCodeableConcept();
if (codeableConcept == null) {
// should never happen
LOGGER.error("Codable concept null in getOutcomeFromCodedValue");
}
List<Coding> codings = codeableConcept != null ? codeableConcept.getCoding() : List.of();
for (Coding coding : codings) {
String code = coding.getCode();
String system = coding.getSystem();
String display = coding.getDisplay();
String outcomeString = code + ":" + system + ":" + display;
Outcome outcome = Outcome.nominal(outcomeString);
return Optional.of(outcome);
}
return Optional.empty();
}
Aggregations