Converting a practice from MedMan to PA.
In order to convert a practice from MedMan to PA two .csv files are required: patients conversion map and claims conversion map.
Conversion:
create table [practice acronym]_acc_map
(
MM_Account VARCHAR(20),
EBM_Account VARCHAR(20)
)
create table [practice acronym]_claim_map
(
MM_Account varchar(20),
item_unique int,
claim_id varchar(50),
claim_detail_id int
)
BULK INSERT [practice acronym]_acc_map
FROM '<patients conversion map file path>'
with (FIELDTERMINATOR=',',ROWTERMINATOR='\n')
BULK INSERT [practice acronym]_claim_map
FROM '<claims conversion map file path>'
with (FIELDTERMINATOR=',',ROWTERMINATOR='\n')
select distinct tmp.EBM_account
from Patients p with (nolock)
inner join Practices pr with (nolock) on p.PracticeID = pr.PracticeID
inner join Conversion.dbo.[practice acronym]_acc_map tmp on p.ACC = tmp.MM_account collate Cyrillic_General_CI_AS
where pr.Acronym = '5wsc'
group by tmp.EBM_account
having COUNT(distinct p.Acc) > 1
If the script returned rows then there are conflicts. Please contact developers.
If there are no conflicts (the script didn't return rows) then proceed to the next step.
declare @readonly int = 1
declare @Acronym varchar(20)
set @Acronym = '5wsc'
declare @practice_id uniqueidentifier
set @practice_id =(select PracticeID from Practices with (nolock) where Acronym = @Acronym)
select
c.ClaimNumber as OldClaimNumber,
c.ItemUnique as OldItemUnique,
t.claim_id as NewClaimNumber,
t.claim_detail_id as NewItemUnique
from Claims c with(nolock)
inner join Patients p with(nolock) on c.PatientID = p.PatientID
inner join Conversion.dbo.[practice acronym]_claim_mapt with(nolock)on
ltrim(rtrim(p.Acc)) = ltrim(rtrim(t.[MM_Account])) collate cyrillic_general_ci_as
and ltrim(rtrim(c.ItemUnique)) = ltrim(rtrim(t.[Item_Unique])) collate cyrillic_general_ci_as
where c.PracticeID = @practice_id
select p.ACC as OldPatACC, t.EBM_Account as NewPatACC
from Patients p
inner join Conversion.dbo.[practice acronym]_acc_map t on ltrim(rtrim(p.Acc)) = ltrim(rtrim(t.[MM_Account])) collate cyrillic_general_ci_as
where p.PracticeID = @practice_id
if (@readonly != 1)
begin
print 'Convert claims'
update Claims set
ClaimNumber = ltrim(rtrim(t.[claim_id])),
ItemUnique = ltrim(rtrim(t.[claim_detail_id]))
from Claims c
inner join Patients p
on c.PatientID = p.PatientID
inner join Conversion.dbo. [practice acronym]_claim_map t
on ltrim(rtrim(p.Acc)) = ltrim(rtrim(t.[MM_Account])) collate cyrillic_general_ci_as
and ltrim(rtrim(c.ItemUnique)) = ltrim(rtrim(t.[Item_Unique])) collate cyrillic_general_ci_as
where c.PracticeID = @practice_id
print 'Convert patients'
update Patients set Acc = ltrim(rtrim(t.[EBM_Account]))
from Patients p
inner join Conversion.dbo.[practice acronym]_acc_map t on ltrim(rtrim(p.Acc)) = ltrim(rtrim(t.[MM_Account])) collate cyrillic_general_ci_as
where p.PracticeID = @practice_id
end