use of se.inera.intyg.common.support.modules.support.api.CertificateHolder in project webcert by sklintyg.
the class GetMedicalCertificateResponderStub method getMedicalCertificate.
@Override
@StubLatencyAware
@StubModeAware
public GetMedicalCertificateResponseType getMedicalCertificate(String logicalAddress, GetMedicalCertificateRequestType request) {
GetMedicalCertificateResponseType response = new GetMedicalCertificateResponseType();
CertificateHolder intygResponse = intygStore.getIntygForCertificateId(request.getCertificateId());
if (intygResponse != null) {
response.setMeta(ModelConverter.toCertificateMetaType(intygResponse));
attachCertificateDocument(intygResponse, response);
if (intygResponse.isRevoked()) {
response.setResult(ResultTypeUtil.errorResult(ErrorIdType.REVOKED, String.format("Certificate '%s' has been revoked", intygResponse.getId())));
} else {
response.setResult(ResultTypeUtil.okResult());
}
} else {
response.setResult(ResultTypeUtil.errorResult(ErrorIdType.VALIDATION_ERROR, "Intyg not found in stub"));
}
return response;
}
use of se.inera.intyg.common.support.modules.support.api.CertificateHolder in project webcert by sklintyg.
the class ListCertificatesForCareResponderStub method listCertificatesForCare.
@Override
@StubLatencyAware
@StubModeAware
public ListCertificatesForCareResponseType listCertificatesForCare(String logicalAddress, ListCertificatesForCareType parameters) {
ListCertificatesForCareResponseType response = new ListCertificatesForCareResponseType();
response.setIntygsLista(new ListaType());
response.getIntygsLista().getIntyg();
List<CertificateHolder> intygForEnhetAndPersonnummer = intygStore.getIntygForEnhetAndPersonnummer(parameters.getEnhetsId().stream().map(HsaId::getExtension).collect(Collectors.toList()), parameters.getPersonId().getExtension());
for (CertificateHolder cert : intygForEnhetAndPersonnummer) {
Intyg intyg = getIntyg(cert);
intyg.getStatus().addAll(CertificateStateHolderConverter.toIntygsStatusType(cert.getCertificateStates()));
response.getIntygsLista().getIntyg().add(intyg);
}
return response;
}
use of se.inera.intyg.common.support.modules.support.api.CertificateHolder in project webcert by sklintyg.
the class RegisterTSDiabetesResponderStub method buildStubInternalCertificate.
private CertificateHolder buildStubInternalCertificate(RegisterTSDiabetesType parameters) {
CertificateHolder certificate = new CertificateHolder();
certificate.setId(parameters.getIntyg().getIntygsId());
certificate.setType(parameters.getIntyg().getIntygsTyp());
certificate.setCivicRegistrationNumber(Personnummer.createPersonnummer(parameters.getIntyg().getGrundData().getPatient().getPersonId().getExtension()).orElse(null));
certificate.setSignedDate(LocalDateTime.parse(parameters.getIntyg().getGrundData().getSigneringsTidstampel(), DateTimeFormatter.ISO_LOCAL_DATE_TIME));
certificate.setCareUnitId(parameters.getIntyg().getGrundData().getSkapadAv().getVardenhet().getEnhetsId().getExtension());
certificate.setCareUnitName(parameters.getIntyg().getGrundData().getSkapadAv().getVardenhet().getEnhetsnamn());
certificate.setSigningDoctorName(parameters.getIntyg().getGrundData().getSkapadAv().getFullstandigtNamn());
certificate.setAdditionalInfo(parameters.getIntyg().getOvrigKommentar());
certificate.setCareGiverId(parameters.getIntyg().getGrundData().getSkapadAv().getVardenhet().getVardgivare().getVardgivarid().getExtension());
return certificate;
}
use of se.inera.intyg.common.support.modules.support.api.CertificateHolder in project webcert by sklintyg.
the class SendCertificateToRecipientResponderStub method sendCertificateToRecipient.
@Override
@StubLatencyAware
@StubModeAware
public SendCertificateToRecipientResponseType sendCertificateToRecipient(String logicalAddress, SendCertificateToRecipientType parameters) {
CertificateHolder fromStore = intygStore.getIntygForCertificateId(parameters.getIntygsId().getExtension());
SendCertificateToRecipientResponseType responseType = new SendCertificateToRecipientResponseType();
if (fromStore == null) {
ResultType resultOfCall = new ResultType();
resultOfCall.setResultCode(ResultCodeType.ERROR);
resultOfCall.setErrorId(ErrorIdType.APPLICATION_ERROR);
responseType.setResult(resultOfCall);
return responseType;
}
intygStore.addStatus(parameters.getIntygsId().getExtension(), new CertificateStateHolder("FKASSA", CertificateState.SENT, LocalDateTime.now()));
ResultType resultType = new ResultType();
resultType.setResultCode(ResultCodeType.OK);
responseType.setResult(resultType);
return responseType;
}
use of se.inera.intyg.common.support.modules.support.api.CertificateHolder in project webcert by sklintyg.
the class BootstrapBean method addIntyg.
private void addIntyg(Resource res) throws JAXBException, IOException {
CertificateHolder response = objectMapper.readValue(res.getInputStream(), CertificateHolder.class);
intygStore.addIntyg(response);
}
Aggregations