use of se.inera.intyg.schemas.contract.Personnummer in project webcert by sklintyg.
the class NotificationPatientEnricher method buildPatientFromPersonSvar.
private se.riv.clinicalprocess.healthcond.certificate.v3.Patient buildPatientFromPersonSvar(Person person) {
se.riv.clinicalprocess.healthcond.certificate.v3.Patient patient = new se.riv.clinicalprocess.healthcond.certificate.v3.Patient();
Optional<Personnummer> personnummer = Optional.ofNullable(person.getPersonnummer());
PersonId personId = new PersonId();
personId.setRoot(SamordningsnummerValidator.isSamordningsNummer(personnummer) ? Constants.SAMORDNING_ID_OID : Constants.PERSON_ID_OID);
personId.setExtension(personnummer.get().getPersonnummer());
patient.setPersonId(personId);
patient.setFornamn(nullSafe(person.getFornamn()));
if (person.getMellannamn() != null) {
patient.setMellannamn(person.getMellannamn());
}
patient.setEfternamn(nullSafe(person.getEfternamn()));
patient.setPostadress(nullSafe(person.getPostadress()));
patient.setPostnummer(nullSafe(person.getPostnummer()));
patient.setPostort(nullSafe(person.getPostort()));
return patient;
}
use of se.inera.intyg.schemas.contract.Personnummer in project webcert by sklintyg.
the class ValidatePrivatePractitionerResponderStub method validatePrivatePractitioner.
@Override
public ValidatePrivatePractitionerResponseType validatePrivatePractitioner(String logicalAddress, ValidatePrivatePractitionerType parameters) {
// Do validation of parameters object
validate(parameters);
String id = parameters.getPersonalIdentityNumber();
Personnummer personnummer = Personnummer.createPersonnummer(id).orElse(null);
ValidatePrivatePractitionerResponseType response = new ValidatePrivatePractitionerResponseType();
HoSPersonType person = personStub.get(id);
if (person == null) {
response.setResultCode(ResultCodeEnum.ERROR);
response.setResultText("No private practitioner with personal identity number: " + Personnummer.getPersonnummerHashSafe(personnummer) + " exists.");
} else if (person.isGodkandAnvandare()) {
response.setResultCode(ResultCodeEnum.OK);
} else {
response.setResultCode(ResultCodeEnum.ERROR);
response.setResultText("Private practitioner with personal identity number: " + Personnummer.getPersonnummerHashSafe(personnummer) + " is not authorized to use webcert.");
}
return response;
}
use of se.inera.intyg.schemas.contract.Personnummer in project webcert by sklintyg.
the class CopyUtkastServiceImpl method refreshPatientDetailsFromPUService.
private Person refreshPatientDetailsFromPUService(AbstractCreateCopyRequest copyRequest) {
Personnummer personnummer;
if (copyRequest.containsNyttPatientPersonnummer()) {
LOG.debug("Request contained a new personnummer to use for the copy");
personnummer = copyRequest.getNyttPatientPersonnummer();
} else {
personnummer = copyRequest.getPatient().getPersonId();
}
LOG.debug("Refreshing person data to use for the copy");
PersonSvar personSvar = getPersonSvar(personnummer);
if (PersonSvar.Status.ERROR.equals(personSvar.getStatus())) {
LOG.error("An error occured when using '{}' to lookup person data", personnummer.getPersonnummerHash());
return null;
} else if (PersonSvar.Status.NOT_FOUND.equals(personSvar.getStatus())) {
LOG.error("No person data was found using '{}' to lookup person data", personnummer.getPersonnummerHash());
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.DATA_NOT_FOUND, "No person data found using '" + personnummer.getPersonnummerHash() + "'");
}
return personSvar.getPerson();
}
use of se.inera.intyg.schemas.contract.Personnummer in project webcert by sklintyg.
the class UtkastServiceImpl method updatePatientOnDraft.
@Override
public void updatePatientOnDraft(UpdatePatientOnDraftRequest request) {
// diff draftPatient and request patient: if no changes, do nothing
String draftId = request.getDraftId();
LOG.debug("Checking that Patient is up-to-date on Utkast '{}'", draftId);
Utkast utkast = utkastRepository.findOne(draftId);
if (utkast == null) {
LOG.warn("Utkast '{}' was not found", draftId);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.DATA_NOT_FOUND, "The utkast could not be found");
}
if (webCertUserService.getUser().getIdsOfAllVardenheter().stream().noneMatch(enhet -> enhet.equalsIgnoreCase(utkast.getEnhetsId()))) {
LOG.error("User did not have any medarbetaruppdrag for enhet '{}'", utkast.getEnhetsId());
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.AUTHORIZATION_PROBLEM, "User did not have any medarbetaruppdrag for enhet " + utkast.getEnhetsId());
}
// check that the draft hasn't been modified concurrently
if (utkast.getVersion() != request.getVersion()) {
LOG.debug("Utkast '{}' was concurrently modified", draftId);
throw new OptimisticLockException(utkast.getSenastSparadAv().getNamn());
}
// check that the draft is still a draft
if (!isTheDraftStillADraft(utkast.getStatus())) {
LOG.error("Utkast '{}' can not be updated since it is no longer in draft mode", draftId);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, "This utkast can not be updated since it is no longer in draft mode");
}
final ModuleApi moduleApi = getModuleApi(utkast.getIntygsTyp());
// INTYG-4086
Patient draftPatient = getPatientFromCurrentDraft(moduleApi, utkast.getModel());
Optional<Personnummer> optionalPnr = Optional.ofNullable(request.getPersonnummer());
Optional<Personnummer> optionalDraftPnr = Optional.ofNullable(draftPatient.getPersonId());
if (optionalDraftPnr.isPresent()) {
// Spara undan det gamla personnummret temporärt
String oldPersonId = optionalDraftPnr.get().getPersonnummer();
webCertUserService.getUser().getParameters().setBeforeAlternateSsn(oldPersonId);
}
if ((optionalPnr.isPresent() || SamordningsnummerValidator.isSamordningsNummer(optionalPnr)) && !isHashEqual(optionalPnr, optionalDraftPnr)) {
// INTYG-4086: Ta reda på om man skall kunna uppdatera annat än personnumret? Och om man uppdaterar
// personnumret -
// vilka regler gäller då för namn och adress? Samma regler som i PatientDetailsResolverImpl?
draftPatient.setPersonId(optionalPnr.get());
try {
String updatedModel = moduleApi.updateBeforeSave(utkast.getModel(), draftPatient);
updateUtkastModel(utkast, updatedModel);
saveDraft(utkast);
monitoringService.logUtkastPatientDetailsUpdated(utkast.getIntygsId(), utkast.getIntygsTyp());
sendNotification(utkast, Event.CHANGED);
} catch (ModuleException e) {
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.MODULE_PROBLEM, "Patient details on Utkast " + draftId + " could not be updated", e);
}
} else {
LOG.debug("Utkast '{}' patient details were already up-to-date: no update needed", draftId);
}
}
use of se.inera.intyg.schemas.contract.Personnummer in project webcert by sklintyg.
the class ModuleApiController method getModulesMap.
/**
* Serving module configuration populating selectors based on user.
*
* @return a JSON object
*/
@GET
@Path("/map/{patientId}")
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public Response getModulesMap(@PathParam("patientId") String patientId) {
try {
Personnummer personnummer = createPnr(patientId);
SekretessStatus sekretessmarkering = patientDetailsResolver.getSekretessStatus(personnummer);
List<IntygModule> intygModules = moduleRegistry.listAllModules();
// If patient has sekretessmarkering or PU-service didn't respond, filter out ts-intyg using privilege.
if (sekretessmarkering == SekretessStatus.TRUE || sekretessmarkering == SekretessStatus.UNDEFINED) {
// INTYG-4086
intygModules = intygModules.stream().filter(module -> authoritiesValidator.given(getWebCertUserService().getUser(), module.getId()).privilege(AuthoritiesConstants.PRIVILEGE_HANTERA_SEKRETESSMARKERAD_PATIENT).isVerified()).collect(Collectors.toList());
}
if (patientDetailsResolver.isAvliden(personnummer)) {
intygModules = intygModules.stream().filter(module -> authoritiesValidator.given(getWebCertUserService().getUser(), module.getId()).features(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST_AVLIDEN).isVerified()).collect(Collectors.toList());
}
return Response.ok(intygModules).build();
} catch (InvalidPersonNummerException e) {
LOG.error(e.getMessage());
return Response.status(Response.Status.BAD_REQUEST).build();
}
}
Aggregations