Search in sources :

Example 1 with Patient

use of se.inera.intyg.common.support.model.common.internal.Patient in project webcert by sklintyg.

the class IntygResource method createDraft.

@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createDraft(CreateNewDraftRequest request) {
    Utkast utkast = new Utkast();
    Patient patient = request.getPatient();
    utkast.setPatientPersonnummer(patient.getPersonId());
    utkast.setPatientFornamn(patient.getFornamn());
    utkast.setPatientMellannamn(patient.getMellannamn());
    utkast.setPatientEfternamn(patient.getEfternamn());
    utkast.setIntygsId(request.getIntygId());
    utkast.setIntygsTyp(request.getIntygType());
    utkast.setStatus(UtkastStatus.DRAFT_INCOMPLETE);
    Vardenhet vardenhet = request.getHosPerson().getVardenhet();
    utkast.setEnhetsId(vardenhet.getEnhetsid());
    utkast.setEnhetsNamn(vardenhet.getEnhetsnamn());
    Vardgivare vardgivare = vardenhet.getVardgivare();
    utkast.setVardgivarId(vardgivare.getVardgivarid());
    utkast.setVardgivarNamn(vardgivare.getVardgivarnamn());
    VardpersonReferens vardPerson = new VardpersonReferens();
    vardPerson.setNamn(request.getHosPerson().getFullstandigtNamn());
    vardPerson.setHsaId(request.getHosPerson().getPersonId());
    utkast.setSenastSparadAv(vardPerson);
    utkast.setSkapadAv(vardPerson);
    utkastRepository.save(utkast);
    return Response.ok().build();
}
Also used : Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) Patient(se.inera.intyg.common.support.model.common.internal.Patient) Vardenhet(se.inera.intyg.common.support.model.common.internal.Vardenhet) Vardgivare(se.inera.intyg.common.support.model.common.internal.Vardgivare) VardpersonReferens(se.inera.intyg.webcert.persistence.utkast.model.VardpersonReferens) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 2 with Patient

use of se.inera.intyg.common.support.model.common.internal.Patient in project webcert by sklintyg.

the class IntygModuleApiController method createRenewalCopyRequest.

private CreateRenewalCopyRequest createRenewalCopyRequest(String orgIntygsId, String intygsTyp, CopyIntygRequest request) {
    HoSPersonal hosPerson = createHoSPersonFromUser();
    Patient patient = createPatientFromCopyIntygRequest(request);
    CreateRenewalCopyRequest req = new CreateRenewalCopyRequest(orgIntygsId, intygsTyp, patient, hosPerson);
    // Add new personnummer to request
    addPersonnummerToRequest(req, userService.getUser().getParameters());
    // Set djupintegrerad flag on request to true if origin is DJUPINTEGRATION
    setDeepIntegrationFlagOnRequest(req);
    return req;
}
Also used : HoSPersonal(se.inera.intyg.common.support.model.common.internal.HoSPersonal) Patient(se.inera.intyg.common.support.model.common.internal.Patient)

Example 3 with Patient

use of se.inera.intyg.common.support.model.common.internal.Patient in project webcert by sklintyg.

the class IntygModuleApiController method createReplacementCopyRequest.

private CreateReplacementCopyRequest createReplacementCopyRequest(String orgIntygsId, String intygsTyp, CopyIntygRequest request) {
    HoSPersonal hosPerson = createHoSPersonFromUser();
    Patient patient = createPatientFromCopyIntygRequest(request);
    final WebCertUser user = userService.getUser();
    IntegrationParameters parameters = user.getParameters();
    boolean coherentJournaling = parameters != null && parameters.isSjf();
    CreateReplacementCopyRequest req = new CreateReplacementCopyRequest(orgIntygsId, intygsTyp, patient, hosPerson, coherentJournaling);
    // Add new personnummer to request
    addPersonnummerToRequest(req, parameters);
    // Set djupintegrerad flag on request to true if origin is DJUPINTEGRATION
    setDeepIntegrationFlagOnRequest(req);
    return req;
}
Also used : HoSPersonal(se.inera.intyg.common.support.model.common.internal.HoSPersonal) IntegrationParameters(se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters) Patient(se.inera.intyg.common.support.model.common.internal.Patient) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 4 with Patient

use of se.inera.intyg.common.support.model.common.internal.Patient in project webcert by sklintyg.

the class UtkastApiController method createServiceRequest.

private CreateNewDraftRequest createServiceRequest(CreateUtkastRequest req) {
    Patient pat = patientDetailsResolver.resolvePatient(req.getPatientPersonnummer(), req.getIntygType());
    // CreateUtkastRequest is the manual entry.
    if (pat == null) {
        pat = new Patient();
        pat.setPersonId(req.getPatientPersonnummer());
        pat.setFornamn(req.getPatientFornamn());
        pat.setMellannamn(req.getPatientMellannamn());
        pat.setEfternamn(req.getPatientEfternamn());
        pat.setFullstandigtNamn(IntygConverterUtil.concatPatientName(pat.getFornamn(), pat.getMellannamn(), pat.getEfternamn()));
        pat.setPostadress(req.getPatientPostadress());
        pat.setPostnummer(req.getPatientPostnummer());
        pat.setPostort(req.getPatientPostort());
    }
    return new CreateNewDraftRequest(null, req.getIntygType(), null, createHoSPersonFromUser(), pat);
}
Also used : CreateNewDraftRequest(se.inera.intyg.webcert.web.service.utkast.dto.CreateNewDraftRequest) Patient(se.inera.intyg.common.support.model.common.internal.Patient)

Example 5 with Patient

use of se.inera.intyg.common.support.model.common.internal.Patient in project webcert by sklintyg.

the class AbstractUtkastBuilder method populateCopyUtkastFromSignedIntyg.

/*
     * (non-Javadoc)
     *
     * @see
     * se.inera.intyg.webcert.web.service.utkast.CopyUtkastBuilder#populateCopyUtkastFromSignedIntyg(se.inera.intyg.
     * webcert.web.service.utkast.dto.CreateNewDraftCopyRequest, se.inera.intyg.webcert.integration.pu.model.Person)
     */
@Override
public CopyUtkastBuilderResponse populateCopyUtkastFromSignedIntyg(T copyRequest, Person patientDetails, boolean addRelation, boolean coherentJournaling, boolean enforceEnhet) throws ModuleNotFoundException, ModuleException {
    String orignalIntygsId = copyRequest.getOriginalIntygId();
    String originalIntygsTyp = copyRequest.getOriginalIntygTyp();
    String intygsTyp = copyRequest.getTyp();
    IntygContentHolder signedIntygHolder = intygService.fetchIntygData(orignalIntygsId, originalIntygsTyp, coherentJournaling);
    ModuleApi orgModuleApi = moduleRegistry.getModuleApi(originalIntygsTyp);
    Utlatande orgUtlatande;
    try {
        orgUtlatande = orgModuleApi.getUtlatandeFromJson(signedIntygHolder.getContents());
    } catch (IOException e) {
        throw new ModuleException("Could not convert orignal certificate to Utlatande", e);
    }
    GrundData grundData = signedIntygHolder.getUtlatande().getGrundData();
    se.inera.intyg.common.support.model.common.internal.Vardenhet vardenhet = grundData.getSkapadAv().getVardenhet();
    if (coherentJournaling && enforceEnhet) {
        verifyEnhetsAuth(vardenhet.getVardgivare().getVardgivarid(), vardenhet.getEnhetsid(), true);
    }
    LOG.debug("Populating copy with details from signed Intyg '{}'", orignalIntygsId);
    CopyUtkastBuilderResponse builderResponse = new CopyUtkastBuilderResponse();
    builderResponse.setOrginalEnhetsId(vardenhet.getEnhetsid());
    builderResponse.setOrginalEnhetsNamn(vardenhet.getEnhetsnamn());
    builderResponse.setOrginalVardgivarId(vardenhet.getVardgivare().getVardgivarid());
    builderResponse.setOrginalVardgivarNamn(vardenhet.getVardgivare().getVardgivarnamn());
    ModuleApi moduleApi = moduleRegistry.getModuleApi(intygsTyp);
    // Set relation to null if not applicable
    Relation relation = createRelation(copyRequest);
    String newDraftCopyId = intygsIdStrategy.createId();
    String draftCopyJson = getInternalModel(orgUtlatande, moduleApi, copyRequest, patientDetails, relation, newDraftCopyId);
    UtkastStatus utkastStatus = validateDraft(moduleApi, draftCopyJson);
    Utkast utkast = buildUtkastCopy(copyRequest, newDraftCopyId, intygsTyp, addRelation, relation, draftCopyJson, utkastStatus);
    if (patientDetails != null) {
        populatePatientDetailsFromPerson(utkast, patientDetails);
    } else {
        se.inera.intyg.common.support.model.common.internal.Patient patient = signedIntygHolder.getUtlatande().getGrundData().getPatient();
        populatePatientDetailsFromPatient(utkast, patient);
    }
    replacePatientPersonnummerWithNew(utkast, copyRequest);
    builderResponse.setUtkastCopy(utkast);
    return builderResponse;
}
Also used : ModuleApi(se.inera.intyg.common.support.modules.support.api.ModuleApi) UtkastStatus(se.inera.intyg.webcert.common.model.UtkastStatus) CopyUtkastBuilderResponse(se.inera.intyg.webcert.web.service.utkast.dto.CopyUtkastBuilderResponse) Vardenhet(se.inera.intyg.common.support.model.common.internal.Vardenhet) IOException(java.io.IOException) Relation(se.inera.intyg.common.support.model.common.internal.Relation) IntygContentHolder(se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder) Utlatande(se.inera.intyg.common.support.model.common.internal.Utlatande) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) GrundData(se.inera.intyg.common.support.model.common.internal.GrundData) ModuleException(se.inera.intyg.common.support.modules.support.api.exception.ModuleException) Patient(se.inera.intyg.common.support.model.common.internal.Patient)

Aggregations

Patient (se.inera.intyg.common.support.model.common.internal.Patient)62 Test (org.junit.Test)28 Personnummer (se.inera.intyg.schemas.contract.Personnummer)28 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)12 HoSPersonal (se.inera.intyg.common.support.model.common.internal.HoSPersonal)11 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 Utlatande (se.inera.intyg.common.support.model.common.internal.Utlatande)7 Vardenhet (se.inera.intyg.common.support.model.common.internal.Vardenhet)6 ModuleApi (se.inera.intyg.common.support.modules.support.api.ModuleApi)6 ArrayList (java.util.ArrayList)5 Before (org.junit.Before)5 Vardgivare (se.inera.intyg.common.support.model.common.internal.Vardgivare)5 Vardgivare (se.inera.intyg.infra.integration.hsa.model.Vardgivare)5 IntygContentHolder (se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder)5 Relations (se.inera.intyg.webcert.web.web.controller.api.dto.Relations)5 IOException (java.io.IOException)4 GrundData (se.inera.intyg.common.support.model.common.internal.GrundData)4 ModuleNotFoundException (se.inera.intyg.common.support.modules.registry.ModuleNotFoundException)4 ModuleException (se.inera.intyg.common.support.modules.support.api.exception.ModuleException)4 PersonSvar (se.inera.intyg.infra.integration.pu.model.PersonSvar)4