use of org.hl7.fhir.r4.model.CodeType in project cqf-ruler by DBCG.
the class MultitenantServerR4IT method testCreateAndReadInTenantA.
@Test
public void testCreateAndReadInTenantA() {
// Create tenant A
ourClientTenantInterceptor.setTenantId("DEFAULT");
ourClient.operation().onServer().named(ProviderConstants.PARTITION_MANAGEMENT_CREATE_PARTITION).withParameter(Parameters.class, ProviderConstants.PARTITION_MANAGEMENT_PARTITION_ID, new IntegerType(1)).andParameter(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_NAME, new CodeType("TENANT-A")).execute();
ourClientTenantInterceptor.setTenantId("TENANT-A");
Patient pt = new Patient();
pt.addName().setFamily("Family A");
ourClient.create().resource(pt).execute().getId();
Bundle searchResult = ourClient.search().forResource(Patient.class).returnBundle(Bundle.class).cacheControl(new CacheControlDirective().setNoCache(true)).execute();
assertEquals(1, searchResult.getEntry().size());
Patient pt2 = (Patient) searchResult.getEntry().get(0).getResource();
assertEquals("Family A", pt2.getName().get(0).getFamily());
}
use of org.hl7.fhir.r4.model.CodeType in project cqf-ruler by DBCG.
the class MultitenantServerR4IT method testCreateAndReadInTenantB.
@Test
public void testCreateAndReadInTenantB() {
// Create tenant A
ourClientTenantInterceptor.setTenantId("DEFAULT");
ourClient.operation().onServer().named(ProviderConstants.PARTITION_MANAGEMENT_CREATE_PARTITION).withParameter(Parameters.class, ProviderConstants.PARTITION_MANAGEMENT_PARTITION_ID, new IntegerType(2)).andParameter(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_NAME, new CodeType("TENANT-B")).execute();
ourClientTenantInterceptor.setTenantId("TENANT-B");
Patient pt = new Patient();
pt.addName().setFamily("Family B");
ourClient.create().resource(pt).execute().getId();
Bundle searchResult = ourClient.search().forResource(Patient.class).returnBundle(Bundle.class).cacheControl(new CacheControlDirective().setNoCache(true)).execute();
assertEquals(1, searchResult.getEntry().size());
Patient pt2 = (Patient) searchResult.getEntry().get(0).getResource();
assertEquals("Family B", pt2.getName().get(0).getFamily());
}
use of org.hl7.fhir.r4.model.CodeType in project elexis-server by elexis.
the class ObservationResourceProvider method findObservation.
@Search()
public List<Observation> findObservation(@RequiredParam(name = Observation.SP_SUBJECT) IdType theSubjectId, @OptionalParam(name = Observation.SP_CATEGORY) CodeType categoryCode, @OptionalParam(name = Observation.SP_CODE) CodeType code, @OptionalParam(name = Observation.SP_DATE) DateRangeParam dates, @OptionalParam(name = Observation.SP_ENCOUNTER) IdType contextId) {
if (theSubjectId != null && !theSubjectId.isEmpty()) {
Optional<IPatient> patient = modelService.load(theSubjectId.getIdPart(), IPatient.class);
if (patient.isPresent()) {
if (patient.get().isPatient()) {
List<Observation> ret = new ArrayList<Observation>();
// laboratory
if (categoryCode == null || ObservationCategory.LABORATORY.name().equalsIgnoreCase(CodeTypeUtil.getCode(categoryCode).orElse(""))) {
List<Observation> intermediateRet = new ArrayList<>();
IQuery<ILabResult> resultQuery = modelService.getQuery(ILabResult.class);
resultQuery.and(ModelPackage.Literals.ILAB_RESULT__PATIENT, COMPARATOR.EQUALS, patient.get());
List<ILabResult> result = resultQuery.execute();
result.parallelStream().forEach(r -> getLabTransformer().getFhirObject(r).ifPresent(t -> intermediateRet.add(t)));
ret = sortLaboratory(intermediateRet);
}
// all other observations
List<IObservation> findings = findingsService.getPatientsFindings(theSubjectId.getIdPart(), IObservation.class);
if (findings != null && !findings.isEmpty()) {
for (IObservation iFinding : findings) {
if (categoryCode != null && !isObservationCategory(iFinding, categoryCode)) {
continue;
}
Optional<Observation> fhirObservation = getTransformer().getFhirObject(iFinding);
if (fhirObservation.isPresent()) {
ret.add(fhirObservation.get());
}
}
}
if (dates != null) {
ret = filterDates(ret, dates);
}
if (code != null) {
ret = filterCode(ret, code);
}
if (contextId != null) {
ret = filterContext(ret, contextId);
}
return ret;
}
}
}
return Collections.emptyList();
}
use of org.hl7.fhir.r4.model.CodeType in project elexis-server by elexis.
the class ConditionResourceProvider method findCondition.
@Search()
public List<Condition> findCondition(@RequiredParam(name = Condition.SP_SUBJECT) IdType thePatientId, @OptionalParam(name = Condition.SP_CATEGORY) CodeType categoryCode) {
if (thePatientId != null && !thePatientId.isEmpty()) {
Optional<IPatient> patient = modelService.load(thePatientId.getIdPart(), IPatient.class);
if (patient.isPresent()) {
if (patient.get().isPatient()) {
// migrate diagnose condition first
migratorService.migratePatientsFindings(thePatientId.getIdPart(), ICondition.class, null);
List<ICondition> findings = findingsService.getPatientsFindings(thePatientId.getIdPart(), ICondition.class);
if (findings != null && !findings.isEmpty()) {
List<Condition> ret = new ArrayList<Condition>();
for (ICondition iFinding : findings) {
if (categoryCode != null && !isConditionCategory(iFinding, categoryCode)) {
continue;
}
Optional<Condition> fhirEncounter = getTransformer().getFhirObject(iFinding);
fhirEncounter.ifPresent(fe -> ret.add(fe));
}
return ret;
}
}
}
}
return Collections.emptyList();
}
use of org.hl7.fhir.r4.model.CodeType in project ab2d by CMSgov.
the class CapabilityStatementSTU3 method populateCS.
public static CapabilityStatement populateCS(String server) {
SimpleDateFormat sdfLess = new SimpleDateFormat("MM/dd/yyyy HH:mm");
CapabilityStatement cs = new CapabilityStatement();
cs.setPublisher("Centers for Medicare & Medicaid Services");
cs.setKind(CapabilityStatement.CapabilityStatementKind.INSTANCE);
cs.setStatus(Enumerations.PublicationStatus.ACTIVE);
String dt = sdfLess.format(new Date());
try {
cs.setDate(sdfLess.parse(dt));
} catch (ParseException e) {
cs.setDate(new Date());
}
cs.setAcceptUnknown(CapabilityStatement.UnknownContentCode.EXTENSIONS);
cs.setFhirVersion(FhirVersionEnum.DSTU3.getFhirVersionString());
CodeType codeType = new CodeType();
codeType.setValue(APPLICATION_JSON);
CodeType codeType2 = new CodeType();
codeType2.setValue("application/fhir+json");
cs.setFormat(List.of(codeType, codeType2));
CapabilityStatement.CapabilityStatementSoftwareComponent cssc = new CapabilityStatement.CapabilityStatementSoftwareComponent();
cssc.setName("AB2D");
cssc.setVersion("V1");
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
try {
Date releaseDate = sdf.parse("08/27/2020 00:00:00");
cssc.setReleaseDate(releaseDate);
} catch (Exception ex) {
cssc.setReleaseDate(new Date());
}
cs.setSoftware(cssc);
CapabilityStatement.CapabilityStatementImplementationComponent implementation = new CapabilityStatement.CapabilityStatementImplementationComponent();
implementation.setUrl(server);
cs.setImplementation(implementation);
CapabilityStatement.CapabilityStatementRestComponent rest = new CapabilityStatement.CapabilityStatementRestComponent();
rest.setMode(CapabilityStatement.RestfulCapabilityMode.SERVER);
CapabilityStatement.CapabilityStatementRestSecurityComponent security = new CapabilityStatement.CapabilityStatementRestSecurityComponent();
security.setCors(true);
CodeableConcept codeableConcept = new CodeableConcept();
Coding coding = new Coding();
coding.setSystem("http://hl7.org/fhir/ValueSet/restful-security-service");
coding.setCode("OAuth");
coding.setDisplay("OAuth");
codeableConcept.setCoding(List.of(coding));
codeableConcept.setText("OAuth");
security.setService(List.of(codeableConcept));
rest.setSecurity(security);
List<CapabilityStatement.CapabilityStatementRestOperationComponent> restComponents = new ArrayList<>();
restComponents.add(createOperation("export", server + "/Patient/$export"));
restComponents.add(createOperation("export by contract", server + "/Group/{contractNumber}/$export"));
restComponents.add(createOperation("cancel", server + "/Job/{jobUuid}/$status"));
restComponents.add(createOperation("status", server + "/Job/{jobUuid}/$status"));
restComponents.add(createOperation("download", server + "/Job/{jobUuid}/file/{filename}"));
restComponents.add(createOperation("capability", server + "/metadata"));
rest.setOperation(restComponents);
rest.setInteraction(List.of(new CapabilityStatement.SystemInteractionComponent().setCode(CapabilityStatement.SystemRestfulInteraction.BATCH)));
cs.setRest(List.of(rest));
return cs;
}
Aggregations