use of se.riv.clinicalprocess.healthcond.certificate.v3.Intyg in project webcert by sklintyg.
the class NotificationTransformer method process.
public void process(Message message) throws ModuleException, IOException, ModuleNotFoundException, TemporaryException {
LOG.debug("Receiving message: {}", message.getMessageId());
NotificationMessage notificationMessage = message.getBody(NotificationMessage.class);
message.setHeader(NotificationRouteHeaders.LOGISK_ADRESS, notificationMessage.getLogiskAdress());
message.setHeader(NotificationRouteHeaders.INTYGS_ID, notificationMessage.getIntygsId());
// Note that this header have been set already by the original sender to accommodate header-based routing
// in the aggreagatorRoute. It is 100% safe to overwrite it at this point.
message.setHeader(NotificationRouteHeaders.HANDELSE, notificationMessage.getHandelse().value());
if (notificationMessage.getVersion() != null) {
message.setHeader(NotificationRouteHeaders.VERSION, notificationMessage.getVersion().name());
} else {
message.setHeader(NotificationRouteHeaders.VERSION, SchemaVersion.VERSION_1.name());
}
if (SchemaVersion.VERSION_3.equals(notificationMessage.getVersion())) {
ModuleApi moduleApi = moduleRegistry.getModuleApi(notificationMessage.getIntygsTyp());
Utlatande utlatande = moduleApi.getUtlatandeFromJson(notificationMessage.getUtkast());
Intyg intyg = moduleApi.getIntygFromUtlatande(utlatande);
notificationPatientEnricher.enrichWithPatient(intyg);
message.setBody(NotificationTypeConverter.convert(notificationMessage, intyg));
} else if (Fk7263EntryPoint.MODULE_ID.equals(notificationMessage.getIntygsTyp())) {
message.setBody(fk7263Transform.createCertificateStatusUpdateForCareType(notificationMessage));
} else {
throw new IllegalArgumentException("Unsupported combination of version '" + notificationMessage.getVersion() + "' and type '" + notificationMessage.getIntygsTyp() + "'");
}
}
use of se.riv.clinicalprocess.healthcond.certificate.v3.Intyg in project webcert by sklintyg.
the class CreateNewDraftRequestBuilderTest method createIntyg.
private Intyg createIntyg() {
Intyg intyg = new Intyg();
TypAvIntyg intygTyp = new TypAvIntyg();
intygTyp.setCode(CERT_TYPE);
intyg.setTypAvIntyg(intygTyp);
HosPersonal hosPerson = new HosPersonal();
HsaId userHsaId = new HsaId();
userHsaId.setExtension(USER_HSAID);
userHsaId.setRoot("USERHSAID");
hosPerson.setPersonalId(userHsaId);
hosPerson.setFullstandigtNamn(FULLSTANDIGT_NAMN);
Enhet hosEnhet = new Enhet();
HsaId unitHsaId = new HsaId();
unitHsaId.setExtension(UNIT_HSAID);
unitHsaId.setRoot("UNITHSAID");
hosEnhet.setEnhetsId(unitHsaId);
hosPerson.setEnhet(hosEnhet);
intyg.setSkapadAv(hosPerson);
Patient patType = new Patient();
PersonId personId = new PersonId();
personId.setRoot("PERSNR");
personId.setExtension(PERSONNUMMER);
patType.setPersonId(personId);
patType.setFornamn(FORNAMN);
patType.setMellannamn(MELLANNAMN);
patType.setEfternamn(EFTERNAMN);
patType.setPostadress(PATIENT_POSTADRESS);
patType.setPostnummer(PATIENT_POSTNUMMER);
patType.setPostort(PATIENT_POSTORT);
intyg.setPatient(patType);
return intyg;
}
use of se.riv.clinicalprocess.healthcond.certificate.v3.Intyg in project webcert by sklintyg.
the class IntygServiceImpl method listCertificatesForCareWithQA.
@Override
public List<IntygWithNotificationsResponse> listCertificatesForCareWithQA(IntygWithNotificationsRequest request) {
List<Utkast> utkastList;
if (request.shouldUseEnhetId()) {
utkastList = utkastRepository.findDraftsByPatientAndEnhetAndStatus(DaoUtil.formatPnrForPersistence(request.getPersonnummer()), request.getEnhetId(), Arrays.asList(UtkastStatus.values()), moduleRegistry.listAllModules().stream().map(IntygModule::getId).collect(Collectors.toSet()));
} else {
utkastList = utkastRepository.findDraftsByPatientAndVardgivareAndStatus(DaoUtil.formatPnrForPersistence(request.getPersonnummer()), request.getVardgivarId(), Arrays.asList(UtkastStatus.values()), moduleRegistry.listAllModules().stream().map(IntygModule::getId).collect(Collectors.toSet()));
}
List<IntygWithNotificationsResponse> res = new ArrayList<>();
for (Utkast utkast : utkastList) {
List<Handelse> notifications = notificationService.getNotifications(utkast.getIntygsId());
String ref = referensService.getReferensForIntygsId(utkast.getIntygsId());
notifications = notifications.stream().filter(handelse -> {
if (request.getStartDate() != null && handelse.getTimestamp().isBefore(request.getStartDate())) {
return false;
}
if (request.getEndDate() != null && handelse.getTimestamp().isAfter(request.getEndDate())) {
return false;
}
return true;
}).collect(Collectors.toList());
// this time span
if ((request.getStartDate() != null || request.getEndDate() != null) && notifications.isEmpty()) {
continue;
}
try {
ModuleApi api = moduleRegistry.getModuleApi(utkast.getIntygsTyp());
Intyg intyg = api.getIntygFromUtlatande(api.getUtlatandeFromJson(utkast.getModel()));
Pair<ArendeCount, ArendeCount> arenden = fragorOchSvarCreator.createArenden(utkast.getIntygsId(), utkast.getIntygsTyp());
res.add(new IntygWithNotificationsResponse(intyg, notifications, arenden.getLeft(), arenden.getRight(), ref));
} catch (ModuleNotFoundException | ModuleException | IOException e) {
LOG.error("Could not convert intyg {} to external format", utkast.getIntygsId());
}
}
return res;
}
Aggregations