use of org.hl7.fhir.r5.model.DateTimeType in project openmrs-module-fhir2 by openmrs.
the class PatientTranslatorImpl method toFhirResource.
@Override
public Patient toFhirResource(@Nonnull org.openmrs.Patient openmrsPatient) {
notNull(openmrsPatient, "The Openmrs Patient object should not be null");
Patient patient = new Patient();
patient.setId(openmrsPatient.getUuid());
patient.setActive(!openmrsPatient.getVoided());
for (PatientIdentifier identifier : openmrsPatient.getActiveIdentifiers()) {
patient.addIdentifier(identifierTranslator.toFhirResource(identifier));
}
for (PersonName name : openmrsPatient.getNames()) {
patient.addName(nameTranslator.toFhirResource(name));
}
if (openmrsPatient.getGender() != null) {
patient.setGender(genderTranslator.toFhirResource(openmrsPatient.getGender()));
}
patient.setBirthDateElement(birthDateTranslator.toFhirResource(openmrsPatient));
if (openmrsPatient.getDead()) {
if (openmrsPatient.getDeathDate() != null) {
patient.setDeceased(new DateTimeType(openmrsPatient.getDeathDate()));
} else {
patient.setDeceased(new BooleanType(true));
}
} else {
patient.setDeceased(new BooleanType(false));
}
for (PersonAddress address : openmrsPatient.getAddresses()) {
patient.addAddress(addressTranslator.toFhirResource(address));
}
patient.setTelecom(getPatientContactDetails(openmrsPatient));
patient.getMeta().setLastUpdated(openmrsPatient.getDateChanged());
patient.addContained(provenanceTranslator.getCreateProvenance(openmrsPatient));
patient.addContained(provenanceTranslator.getUpdateProvenance(openmrsPatient));
return patient;
}
use of org.hl7.fhir.r5.model.DateTimeType in project Gravity-SDOH-Exchange-RI by FHIR.
the class ConditionBundleToDtoConverterBase method conditionInfoToDto.
protected T conditionInfoToDto(ConditionInfoBundleExtractor.ConditionInfoHolder conditionInfo) {
T conditionDto = newConditionDtoImpl();
Condition condition = conditionInfo.getCondition();
conditionDto.setId(condition.getIdElement().getIdPart());
conditionDto.setName(codeableConceptToStringConverter.convert(condition.getCode()));
Coding categoryCoding = FhirUtil.findCoding(condition.getCategory(), SDOHMappings.getInstance().getSystem());
// TODO remove this in future. Fow now two different categories might be used before discussed.
if (categoryCoding == null) {
categoryCoding = FhirUtil.findCoding(condition.getCategory(), "http://hl7.org/fhir/us/sdoh-clinicalcare/CodeSystem/SDOHCC-CodeSystemTemporaryCodes");
}
if (categoryCoding == null) {
conditionDto.getErrors().add("SDOH category is not found.");
} else {
conditionDto.setCategory(new CodingDto(categoryCoding.getCode(), categoryCoding.getDisplay()));
}
Optional<Coding> icdCodeCodingOptional = findCode(condition.getCode(), System.ICD_10);
if (icdCodeCodingOptional.isPresent()) {
Coding icdCodeCoding = icdCodeCodingOptional.get();
conditionDto.setIcdCode(new CodingDto(icdCodeCoding.getCode(), icdCodeCoding.getDisplay()));
} else {
conditionDto.getErrors().add("ICD-10 code is not found.");
}
Optional<Coding> snomedCodeCodingOptional = findCode(condition.getCode(), System.SNOMED);
if (snomedCodeCodingOptional.isPresent()) {
Coding snomedCodeCoding = snomedCodeCodingOptional.get();
conditionDto.setSnomedCode(new CodingDto(snomedCodeCoding.getCode(), snomedCodeCoding.getDisplay()));
} else {
conditionDto.getErrors().add("SNOMED-CT code is not found.");
}
QuestionnaireResponse questionnaireResponse = conditionInfo.getQuestionnaireResponse();
if (questionnaireResponse != null) {
conditionDto.setAssessmentDate(FhirUtil.toLocalDateTime(questionnaireResponse.getAuthoredElement()));
Questionnaire questionnaire = conditionInfo.getQuestionnaire();
if (questionnaire != null) {
conditionDto.setBasedOn(new ReferenceDto(questionnaireResponse.getIdElement().getIdPart(), questionnaire.getTitle()));
} else {
conditionDto.setBasedOn(new ReferenceDto(questionnaireResponse.getIdElement().getIdPart(), questionnaireResponse.getQuestionnaire()));
conditionDto.getErrors().add("Based on QuestionnaireResponse doesn't have a matching Questionnaire to get a title from. Using URL " + "instead.");
}
} else {
conditionDto.setBasedOn(new StringTypeDto(condition.getEvidenceFirstRep().getCodeFirstRep().getText()));
Reference recorder = condition.getRecorder();
conditionDto.setAuthoredBy(new ReferenceDto(recorder.getReferenceElement().getIdPart(), recorder.getDisplay()));
}
// abatement must be available for all resolved condition
if (ConditionClinicalStatusCodes.RESOLVED.toCode().equals(condition.getClinicalStatus().getCodingFirstRep().getCode())) {
if (condition.getAbatement() instanceof DateTimeType) {
conditionDto.setResolutionDate(FhirUtil.toLocalDateTime((DateTimeType) condition.getAbatement()));
} else {
conditionDto.getErrors().add("Condition is resolved but an abatement property is missing or not of a DateTimeType type.");
}
}
return conditionDto;
}
use of org.hl7.fhir.r5.model.DateTimeType in project Gravity-SDOH-Exchange-RI by FHIR.
the class ProblemBundleToDtoConverter method conditionInfoToDto.
@Override
protected ProblemDto conditionInfoToDto(ConditionInfoBundleExtractor.ConditionInfoHolder conditionInfo) {
// TODO refactor this. Avoid manual casting. Refactor the design of a base class instead.
Assert.isInstanceOf(ProblemInfoBundleExtractor.ProblemInfoHolder.class, conditionInfo, "conditionInfo must be a ProblemInfoHolder.");
ProblemInfoBundleExtractor.ProblemInfoHolder probleminfo = (ProblemInfoBundleExtractor.ProblemInfoHolder) conditionInfo;
Condition condition = probleminfo.getCondition();
ProblemDto problemDto = super.conditionInfoToDto(probleminfo);
// Onset must be available for the problem list items.
if (condition.getOnset() != null) {
problemDto.setStartDate(FhirUtil.toLocalDateTime((DateTimeType) condition.getOnset()));
} else {
problemDto.getErrors().add("Condition is a problem-list-item but an onset property is missing or not of a DateTimeType " + "type.");
}
problemDto.getTasks().addAll(probleminfo.getTasks().stream().map(t -> new TaskInfoDto(t.getId(), t.getName(), t.getStatus())).collect(Collectors.toList()));
problemDto.getGoals().addAll(probleminfo.getGoals().stream().map(t -> new GoalInfoDto(t.getId(), t.getName(), t.getStatus())).collect(Collectors.toList()));
return problemDto;
}
use of org.hl7.fhir.r5.model.DateTimeType in project integration-adaptor-111 by nhsconnect.
the class DateUtil method parse.
public static DateTimeType parse(String dateToParse) {
DateFormat format = getFormat(dateToParse);
SimpleDateFormat formatter = getFormatter(format);
try {
Date date = formatter.parse(dateToParse);
return new DateTimeType(date, format.getPrecision(), TimeZone.getTimeZone(ZoneOffset.UTC));
} catch (ParseException e) {
throw new IllegalStateException(String.format(ERROR_MESSAGE, dateToParse), e);
}
}
use of org.hl7.fhir.r5.model.DateTimeType in project org.hl7.fhir.core by hapifhir.
the class ICD11Generator method execute.
private void execute(String base, String dest) throws IOException {
CodeSystem cs = makeMMSCodeSystem();
JsonObject version = fetchJson(Utilities.pathURL(base, "/icd/release/11/mms"));
String[] p = version.get("latestRelease").getAsString().split("\\/");
cs.setVersion(p[6]);
JsonObject root = fetchJson(url(base, version.get("latestRelease").getAsString()));
cs.setDateElement(new DateTimeType(root.get("releaseDate").getAsString()));
for (JsonElement child : root.getAsJsonArray("child")) {
processMMSEntity(cs, base, child.getAsString(), cs.addConcept(), dest);
System.out.println();
}
new XmlParser(XmlVersion.V1_1).setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "icd-11-mms.xml")), cs);
makeFullVs(dest, cs);
cs = makeEntityCodeSystem();
root = fetchJson(Utilities.pathURL(base, "/icd/entity"));
cs.setVersion(root.get("releaseId").getAsString());
cs.setDateElement(new DateTimeType(root.get("releaseDate").getAsString()));
cs.setTitle(readString(root, "title"));
Set<String> ids = new HashSet<>();
for (JsonElement child : root.getAsJsonArray("child")) {
processEntity(cs, ids, base, tail(child.getAsString()), dest);
System.out.println();
}
new XmlParser(XmlVersion.V1_1).setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "icd-11-foundation.xml")), cs);
makeFullVs2(dest, cs);
System.out.println("finished");
}
Aggregations